mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
lock when editing the chunks cache in SingletThreadQueueExtent
- Long2ObjectLinkedOpenHashMap is not thread-safe and should not be used from multiple threads at once - Fixes #851
This commit is contained in:
parent
3034419918
commit
fa69c79160
@ -114,7 +114,9 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
|||||||
for (IChunk chunk : this.chunks.values()) {
|
for (IChunk chunk : this.chunks.values()) {
|
||||||
chunk.recycle();
|
chunk.recycle();
|
||||||
}
|
}
|
||||||
|
getChunkLock.lock();
|
||||||
this.chunks.clear();
|
this.chunks.clear();
|
||||||
|
getChunkLock.unlock();
|
||||||
}
|
}
|
||||||
this.enabledQueue = true;
|
this.enabledQueue = true;
|
||||||
this.lastChunk = null;
|
this.lastChunk = null;
|
||||||
@ -163,7 +165,9 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
|||||||
lastChunk = null;
|
lastChunk = null;
|
||||||
}
|
}
|
||||||
final long index = MathMan.pairInt(chunk.getX(), chunk.getZ());
|
final long index = MathMan.pairInt(chunk.getX(), chunk.getZ());
|
||||||
|
getChunkLock.lock();
|
||||||
chunks.remove(index, chunk);
|
chunks.remove(index, chunk);
|
||||||
|
getChunkLock.unlock();
|
||||||
V future = submitUnchecked(chunk);
|
V future = submitUnchecked(chunk);
|
||||||
submissions.add(future);
|
submissions.add(future);
|
||||||
return future;
|
return future;
|
||||||
@ -374,7 +378,9 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
getChunkLock.lock();
|
||||||
chunks.clear();
|
chunks.clear();
|
||||||
|
getChunkLock.unlock();
|
||||||
}
|
}
|
||||||
pollSubmissions(0, true);
|
pollSubmissions(0, true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user