aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0135-Optimize-UserCache-Thread-Safe.patch
diff options
context:
space:
mode:
authorZach Brown <[email protected]>2017-04-29 05:27:31 -0500
committerZach Brown <[email protected]>2017-04-29 05:27:31 -0500
commit974b0afca91844fed61c5fda9293bbcd88752c2f (patch)
treed3a7b65e14f34b7cc8928efaf6403f67eaaaf708 /Spigot-Server-Patches/0135-Optimize-UserCache-Thread-Safe.patch
parent8b2122a291e3ea68f0e1516209914ef43a2d55e9 (diff)
downloadPaper-974b0afca91844fed61c5fda9293bbcd88752c2f.tar.gz
Paper-974b0afca91844fed61c5fda9293bbcd88752c2f.zip
Remove last bit of chunk exists region file fix
CraftBukkit removed their implementation that caused this issue, switching to Mojang's implementation which doesn't appear to share it. I already removed the important bit in the last upstream merge, this is just unused and unnecessary now. So we remove it.
Diffstat (limited to 'Spigot-Server-Patches/0135-Optimize-UserCache-Thread-Safe.patch')
-rw-r--r--Spigot-Server-Patches/0135-Optimize-UserCache-Thread-Safe.patch100
1 files changed, 100 insertions, 0 deletions
diff --git a/Spigot-Server-Patches/0135-Optimize-UserCache-Thread-Safe.patch b/Spigot-Server-Patches/0135-Optimize-UserCache-Thread-Safe.patch
new file mode 100644
index 0000000000..9097c497ae
--- /dev/null
+++ b/Spigot-Server-Patches/0135-Optimize-UserCache-Thread-Safe.patch
@@ -0,0 +1,100 @@
+From f8298bd0e0b7b50c1e71d97df928320f537323e6 Mon Sep 17 00:00:00 2001
+From: Aikar <[email protected]>
+Date: Mon, 16 May 2016 20:47:41 -0400
+Subject: [PATCH] Optimize UserCache / Thread Safe
+
+Because Techable keeps complaining about how this isn't thread safe,
+easier to do this than replace the entire thing.
+
+Additionally, move Saving of the User cache to be done async, incase
+the user never changed the default setting for Spigot's save on stop only.
+
+diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
+index 83b62da55..2349c3ade 100644
+--- a/src/main/java/net/minecraft/server/MinecraftServer.java
++++ b/src/main/java/net/minecraft/server/MinecraftServer.java
+@@ -527,7 +527,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
+ // Spigot start
+ if (org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) {
+ LOGGER.info("Saving usercache.json");
+- this.Y.c();
++ this.Y.c(false); // Paper
+ }
+ // Spigot end
+ }
+diff --git a/src/main/java/net/minecraft/server/UserCache.java b/src/main/java/net/minecraft/server/UserCache.java
+index ccfc755d2..989758cdf 100644
+--- a/src/main/java/net/minecraft/server/UserCache.java
++++ b/src/main/java/net/minecraft/server/UserCache.java
+@@ -108,7 +108,7 @@ public class UserCache {
+ this.a(gameprofile, (Date) null);
+ }
+
+- private void a(GameProfile gameprofile, Date date) {
++ private synchronized void a(GameProfile gameprofile, Date date) { // Paper - synchronize
+ UUID uuid = gameprofile.getId();
+
+ if (date == null) {
+@@ -122,8 +122,9 @@ public class UserCache {
+ String s = gameprofile.getName().toLowerCase(Locale.ROOT);
+ UserCache.UserCacheEntry usercache_usercacheentry = new UserCache.UserCacheEntry(gameprofile, date, null);
+
+- if (this.e.containsKey(uuid)) {
++ //if (this.e.containsKey(uuid)) { // Paper
+ UserCache.UserCacheEntry usercache_usercacheentry1 = (UserCache.UserCacheEntry) this.e.get(uuid);
++ if (usercache_usercacheentry1 != null) { // Paper
+
+ this.d.remove(usercache_usercacheentry1.a().getName().toLowerCase(Locale.ROOT));
+ this.f.remove(gameprofile);
+@@ -136,7 +137,7 @@ public class UserCache {
+ }
+
+ @Nullable
+- public GameProfile getProfile(String s) {
++ public synchronized GameProfile getProfile(String s) { // Paper - synchronize
+ String s1 = s.toLowerCase(Locale.ROOT);
+ UserCache.UserCacheEntry usercache_usercacheentry = (UserCache.UserCacheEntry) this.d.get(s1);
+
+@@ -165,7 +166,7 @@ public class UserCache {
+ return usercache_usercacheentry == null ? null : usercache_usercacheentry.a();
+ }
+
+- public String[] a() {
++ public synchronized String[] a() { // Paper - synchronize
+ ArrayList arraylist = Lists.newArrayList(this.d.keySet());
+
+ return (String[]) arraylist.toArray(new String[arraylist.size()]);
+@@ -227,8 +228,15 @@ public class UserCache {
+
+ }
+
++ // Paper start
+ public void c() {
++ c(true);
++ }
++ public void c(boolean asyncSave) {
++ // Paper end
+ String s = this.b.toJson(this.a(org.spigotmc.SpigotConfig.userCacheCap));
++ Runnable save = () -> {
++
+ BufferedWriter bufferedwriter = null;
+
+ try {
+@@ -242,6 +250,14 @@ public class UserCache {
+ } finally {
+ IOUtils.closeQuietly(bufferedwriter);
+ }
++ // Paper start
++ };
++ if (asyncSave) {
++ MCUtil.scheduleAsyncTask(save);
++ } else {
++ save.run();
++ }
++ // Paper end
+
+ }
+
+--
+2.12.2.windows.2
+