mirror of
https://github.com/PaperMC/Folia.git
synced 2025-04-23 04:39:19 +08:00
Always synchronise on target for regionized queue mergeInto
While for merging the synchronisation occured, it did not synchronise for splitting. This resolves a possible CME that may occur while splitting regions.
This commit is contained in:
parent
34039e3709
commit
81fe50f26f
@ -4064,7 +4064,7 @@ index 0000000000000000000000000000000000000000..8e31c6ee9ee16aff699e124a9b0554ea
|
|||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/RegionizedTaskQueue.java b/src/main/java/io/papermc/paper/threadedregions/RegionizedTaskQueue.java
|
diff --git a/src/main/java/io/papermc/paper/threadedregions/RegionizedTaskQueue.java b/src/main/java/io/papermc/paper/threadedregions/RegionizedTaskQueue.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..2e4514e5a45db6e625ef7799b63a9285a3bc1030
|
index 0000000000000000000000000000000000000000..98ddb674b63a4777a98152ea960debf48aa2bc35
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/threadedregions/RegionizedTaskQueue.java
|
+++ b/src/main/java/io/papermc/paper/threadedregions/RegionizedTaskQueue.java
|
||||||
@@ -0,0 +1,768 @@
|
@@ -0,0 +1,768 @@
|
||||||
@ -4382,13 +4382,12 @@ index 0000000000000000000000000000000000000000..2e4514e5a45db6e625ef7799b63a9285
|
|||||||
+ public void mergeInto(final PrioritisedQueue target) {
|
+ public void mergeInto(final PrioritisedQueue target) {
|
||||||
+ synchronized (this) {
|
+ synchronized (this) {
|
||||||
+ this.isDestroyed = true;
|
+ this.isDestroyed = true;
|
||||||
+ synchronized (target) {
|
|
||||||
+ mergeInto(target, this.queues);
|
+ mergeInto(target, this.queues);
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ }
|
|
||||||
+
|
+
|
||||||
+ private static void mergeInto(final PrioritisedQueue target, final ArrayDeque<ChunkBasedPriorityTask>[] thisQueues) {
|
+ private static void mergeInto(final PrioritisedQueue target, final ArrayDeque<ChunkBasedPriorityTask>[] thisQueues) {
|
||||||
|
+ synchronized (target) {
|
||||||
+ final ArrayDeque<ChunkBasedPriorityTask>[] otherQueues = target.queues;
|
+ final ArrayDeque<ChunkBasedPriorityTask>[] otherQueues = target.queues;
|
||||||
+ for (int i = 0; i < thisQueues.length; ++i) {
|
+ for (int i = 0; i < thisQueues.length; ++i) {
|
||||||
+ final ArrayDeque<ChunkBasedPriorityTask> fromQ = thisQueues[i];
|
+ final ArrayDeque<ChunkBasedPriorityTask> fromQ = thisQueues[i];
|
||||||
@ -4405,6 +4404,7 @@ index 0000000000000000000000000000000000000000..2e4514e5a45db6e625ef7799b63a9285
|
|||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
|
+ }
|
||||||
+
|
+
|
||||||
+ // into is a map of section coordinate to region
|
+ // into is a map of section coordinate to region
|
||||||
+ public void split(final boolean isChunkData,
|
+ public void split(final boolean isChunkData,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user