Skip to content
Success

Changes

Summary

  1. Fix a few chunk saving race conditions (details)
Commit 963b19c5995b14f8980a42f13b1bd693a5b411d1 by md_5
Fix a few chunk saving race conditions
* ChunkRegionLoader.c() picks an entry in the save queue, removes that
entry from the save queue and then actually writes the entry to the
region file. So, between the last two steps, the entry is neither in the
save queue nor is it in the region file; if somebody loads the chunk
again (with ChunkRegionLoader.loadChunk()) in that gap, they'll get old
data. I've delayed the removal until the saving is done.
* ChunkRegionLoader.c() also records the coords of the chunks it's
currently saving in this.c. ChunkRegionLoader.a(ChunkCoordIntPair,
NBTTagCompound), which adds an entry to the save queue, stops the
addition of an entry if its coords are in this.c. Now, I'm guessing that
Mojang's intended purpose for this mechanism was to prevent multiple
parallel writes for the same chunk. The "stops the addition" bit above
should then be something like "block until it's no longer in c"; in
fact, the vanilla implementation is "discard the new state of the
chunk". I've taken the easy route to solving this, by just making
ChunkRegionLoader.c() synchronized (since, in normal use, only the chunk
saving thread is in here).
The file was modifiednms-patches/ChunkRegionLoader.patch