summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2018-09-09 09:39:23 +1000
committermd_5 <git@md-5.net>2018-09-09 09:39:23 +1000
commitcd367fa4d829b3ca386a94b73dfb7b47ae9cf06b (patch)
tree8b8c24030a93fada4f6f2b4f85a58f8bac8f2ecc
parent3f5ca5f2a41a7cdb38255668c73c3776482e6474 (diff)
downloadcraftbukkit-cd367fa4d829b3ca386a94b73dfb7b47ae9cf06b.tar
craftbukkit-cd367fa4d829b3ca386a94b73dfb7b47ae9cf06b.tar.gz
craftbukkit-cd367fa4d829b3ca386a94b73dfb7b47ae9cf06b.tar.lz
craftbukkit-cd367fa4d829b3ca386a94b73dfb7b47ae9cf06b.tar.xz
craftbukkit-cd367fa4d829b3ca386a94b73dfb7b47ae9cf06b.zip
Fix bad thread safety in ChunkRegionLoader
-rw-r--r--nms-patches/ChunkRegionLoader.patch34
1 files changed, 24 insertions, 10 deletions
diff --git a/nms-patches/ChunkRegionLoader.patch b/nms-patches/ChunkRegionLoader.patch
index b455a239..50ae59b6 100644
--- a/nms-patches/ChunkRegionLoader.patch
+++ b/nms-patches/ChunkRegionLoader.patch
@@ -1,6 +1,11 @@
--- a/net/minecraft/server/ChunkRegionLoader.java
+++ b/net/minecraft/server/ChunkRegionLoader.java
-@@ -31,7 +31,7 @@
+@@ -27,11 +27,11 @@
+ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
+
+ private static final Logger a = LogManager.getLogger();
+- private final Map<ChunkCoordIntPair, NBTTagCompound> b = Maps.newHashMap();
++ private final Map<ChunkCoordIntPair, NBTTagCompound> b = java.util.Collections.synchronizedMap(Maps.newHashMap()); // CraftBukkit
private final File c;
private final DataFixer d;
private PersistentStructureLegacy e;
@@ -165,7 +170,7 @@
} else {
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Level");
-@@ -217,10 +289,14 @@
+@@ -217,10 +289,15 @@
}
public boolean a() {
@@ -175,6 +180,7 @@
+ }
+ private boolean processSaveQueueEntry(boolean logCompletion) {
++ synchronized (this.b) { // CraftBukkit
+ Iterator iterator = this.b.entrySet().iterator();
if (!iterator.hasNext()) {
- if (this.f) {
@@ -182,7 +188,7 @@
ChunkRegionLoader.a.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.c.getName());
}
-@@ -236,10 +312,14 @@
+@@ -236,10 +313,14 @@
return true;
} else {
try {
@@ -198,7 +204,15 @@
if (this.e != null) {
this.e.a(chunkcoordintpair.a());
}
-@@ -266,15 +346,16 @@
+@@ -250,6 +331,7 @@
+ return true;
+ }
+ }
++ } // CraftBukkit
+ }
+
+ private ChunkStatus.Type a(@Nullable NBTTagCompound nbttagcompound) {
+@@ -266,15 +348,16 @@
public void b() {
try {
@@ -218,7 +232,7 @@
}
}
-@@ -303,7 +384,7 @@
+@@ -303,7 +386,7 @@
if (abiomebase != null) {
for (int k = 0; k < abiomebase.length; ++k) {
@@ -227,7 +241,7 @@
}
}
-@@ -385,7 +466,7 @@
+@@ -385,7 +468,7 @@
int[] aint = new int[abiomebase.length];
for (int i = 0; i < abiomebase.length; ++i) {
@@ -236,7 +250,7 @@
}
nbttagcompound.setIntArray("Biomes", aint);
-@@ -487,27 +568,27 @@
+@@ -487,27 +570,27 @@
}
ChunkConverter chunkconverter = nbttagcompound.hasKeyOfType("UpgradeData", 10) ? new ChunkConverter(nbttagcompound.getCompound("UpgradeData")) : ChunkConverter.a;
@@ -270,7 +284,7 @@
long i1 = nbttagcompound.getLong("InhabitedTime");
Chunk chunk = new Chunk(generatoraccess.getMinecraftWorld(), i, j, abiomebase, chunkconverter, protochunkticklist, protochunkticklist1, i1);
-@@ -850,17 +931,29 @@
+@@ -850,17 +933,29 @@
}
@Nullable
@@ -302,7 +316,7 @@
});
}
-@@ -874,8 +967,14 @@
+@@ -874,8 +969,14 @@
}
}
@@ -318,7 +332,7 @@
Iterator iterator = entity.bP().iterator();
while (iterator.hasNext()) {
-@@ -891,7 +990,7 @@
+@@ -891,7 +992,7 @@
boolean flag = false;
try {