Fix bad thread safety in ChunkRegionLoader

This commit is contained in:
md_5 2018-09-09 09:39:23 +10:00
parent 3f5ca5f2a4
commit cd367fa4d8

View File

@ -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 {