mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-27 10:41:27 +01:00
SPIGOT-2385: RegionFileCache synchronization issues
By: md_5 <git@md-5.net>
This commit is contained in:
parent
f5e45ed35f
commit
c93d857872
@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/server/ChunkRegionLoader.java
|
--- a/net/minecraft/server/ChunkRegionLoader.java
|
||||||
+++ b/net/minecraft/server/ChunkRegionLoader.java
|
+++ b/net/minecraft/server/ChunkRegionLoader.java
|
||||||
@@ -29,8 +29,36 @@
|
@@ -29,25 +29,55 @@
|
||||||
this.e = dataconvertermanager;
|
this.e = dataconvertermanager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +37,21 @@
|
|||||||
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i, j);
|
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i, j);
|
||||||
NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.get(chunkcoordintpair);
|
NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.get(chunkcoordintpair);
|
||||||
|
|
||||||
@@ -47,7 +75,7 @@
|
if (nbttagcompound == null) {
|
||||||
|
- DataInputStream datainputstream = RegionFileCache.c(this.d, i, j);
|
||||||
|
+ // CraftBukkit start
|
||||||
|
+ nbttagcompound = RegionFileCache.c(this.d, i, j);
|
||||||
|
|
||||||
|
- if (datainputstream == null) {
|
||||||
|
+ if (nbttagcompound == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
- nbttagcompound = this.e.a((DataConverterType) DataConverterTypes.CHUNK, NBTCompressedStreamTools.a(datainputstream));
|
||||||
|
+ nbttagcompound = this.e.a((DataConverterType) DataConverterTypes.CHUNK, nbttagcompound);
|
||||||
|
+ // CraftBukkit end
|
||||||
|
}
|
||||||
|
|
||||||
return this.a(world, i, j, nbttagcompound);
|
return this.a(world, i, j, nbttagcompound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +60,7 @@
|
|||||||
if (!nbttagcompound.hasKeyOfType("Level", 10)) {
|
if (!nbttagcompound.hasKeyOfType("Level", 10)) {
|
||||||
ChunkRegionLoader.a.error("Chunk file at {},{} is missing level data, skipping", new Object[] { Integer.valueOf(i), Integer.valueOf(j)});
|
ChunkRegionLoader.a.error("Chunk file at {},{} is missing level data, skipping", new Object[] { Integer.valueOf(i), Integer.valueOf(j)});
|
||||||
return null;
|
return null;
|
||||||
@@ -64,10 +92,28 @@
|
@@ -64,10 +94,28 @@
|
||||||
ChunkRegionLoader.a.error("Chunk file at {},{} is in the wrong location; relocating. (Expected {}, {}, got {}, {})", new Object[] { Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(chunk.locX), Integer.valueOf(chunk.locZ)});
|
ChunkRegionLoader.a.error("Chunk file at {},{} is in the wrong location; relocating. (Expected {}, {}, got {}, {})", new Object[] { Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(chunk.locX), Integer.valueOf(chunk.locZ)});
|
||||||
nbttagcompound1.setInt("xPos", i);
|
nbttagcompound1.setInt("xPos", i);
|
||||||
nbttagcompound1.setInt("zPos", j);
|
nbttagcompound1.setInt("zPos", j);
|
||||||
@ -76,7 +90,23 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -326,6 +372,13 @@
|
@@ -131,10 +179,14 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
private void b(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException {
|
||||||
|
- DataOutputStream dataoutputstream = RegionFileCache.d(this.d, chunkcoordintpair.x, chunkcoordintpair.z);
|
||||||
|
+ // CraftBukkit start
|
||||||
|
+ RegionFileCache.d(this.d, chunkcoordintpair.x, chunkcoordintpair.z, nbttagcompound);
|
||||||
|
|
||||||
|
+ /*
|
||||||
|
NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) dataoutputstream);
|
||||||
|
dataoutputstream.close();
|
||||||
|
+ */
|
||||||
|
+ // CraftBukkit end
|
||||||
|
}
|
||||||
|
|
||||||
|
public void b(World world, Chunk chunk) throws IOException {}
|
||||||
|
@@ -326,6 +378,13 @@
|
||||||
chunk.a(nbttagcompound.getByteArray("Biomes"));
|
chunk.a(nbttagcompound.getByteArray("Biomes"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +120,7 @@
|
|||||||
NBTTagList nbttaglist1 = nbttagcompound.getList("Entities", 10);
|
NBTTagList nbttaglist1 = nbttagcompound.getList("Entities", 10);
|
||||||
|
|
||||||
if (nbttaglist1 != null) {
|
if (nbttaglist1 != null) {
|
||||||
@@ -369,7 +422,7 @@
|
@@ -369,7 +428,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +129,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -397,14 +450,20 @@
|
@@ -397,14 +456,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -121,7 +151,7 @@
|
|||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
if (nbttagcompound.hasKeyOfType("Passengers", 9)) {
|
if (nbttagcompound.hasKeyOfType("Passengers", 9)) {
|
||||||
@@ -433,8 +492,14 @@
|
@@ -433,8 +498,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
32
paper-server/nms-patches/RegionFileCache.patch
Normal file
32
paper-server/nms-patches/RegionFileCache.patch
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
--- a/net/minecraft/server/RegionFileCache.java
|
||||||
|
+++ b/net/minecraft/server/RegionFileCache.java
|
||||||
|
@@ -53,15 +53,25 @@
|
||||||
|
RegionFileCache.a.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
- public static DataInputStream c(File file, int i, int j) {
|
||||||
|
+ // CraftBukkit start - call sites hoisted for synchronization
|
||||||
|
+ public static synchronized NBTTagCompound c(File file, int i, int j) throws IOException {
|
||||||
|
RegionFile regionfile = a(file, i, j);
|
||||||
|
|
||||||
|
- return regionfile.a(i & 31, j & 31);
|
||||||
|
+ DataInputStream datainputstream = regionfile.a(i & 31, j & 31);
|
||||||
|
+
|
||||||
|
+ if (datainputstream == null) {
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return NBTCompressedStreamTools.a(datainputstream);
|
||||||
|
}
|
||||||
|
|
||||||
|
- public static DataOutputStream d(File file, int i, int j) {
|
||||||
|
+ public static synchronized void d(File file, int i, int j, NBTTagCompound nbttagcompound) throws IOException {
|
||||||
|
RegionFile regionfile = a(file, i, j);
|
||||||
|
|
||||||
|
- return regionfile.b(i & 31, j & 31);
|
||||||
|
+ DataOutputStream dataoutputstream = regionfile.b(i & 31, j & 31);
|
||||||
|
+ NBTCompressedStreamTools.a(nbttagcompound, (java.io.DataOutput) dataoutputstream);
|
||||||
|
+ dataoutputstream.close();
|
||||||
|
}
|
||||||
|
+ // CraftBukkit end
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user