geforkt von Mirrors/Paper
edd6b6a2ba
Blow up if a plugin tries to mutate visibleChunks directly and prevent them from doing so. Also provide a safe get call if any plugins directly call get on it so that it uses the special logic to check pending. Also restores ABI for the visibleChunks field back to what it was too. Additionally, remove the stack trace from Timings Stack Corruption for any error thrown on Minecraft Timings, and tell them to get the error ABOVE this instead, so people stop giving us useless error reports. Also fixes a memory leak when the source map down sizes but dest map didn't, which resulted in lingering references to old chunk holders. Fixes #3414
59 Zeilen
2.4 KiB
Diff
59 Zeilen
2.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Tue, 21 Apr 2020 03:51:53 -0400
|
|
Subject: [PATCH] Allow multiple callbacks to schedule for Callback Executor
|
|
|
|
ChunkMapDistance polls multiple entries for pendingChunkUpdates
|
|
|
|
Each of these have the potential to move a chunk in and out of
|
|
"Loaded" state, which will result in multiple callbacks being
|
|
needed within a single tick of ChunkMapDistance
|
|
|
|
Use an ArrayDeque to store this Queue
|
|
|
|
We make sure to also implement a pattern that is recursion safe too.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
|
index 030c980b522c4cada800e5d8ca47f0b8733bf5b6..4d591d620262e8c4ed0508b01e26ef7355e75e88 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
|
@@ -110,24 +110,32 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
|
public final CallbackExecutor callbackExecutor = new CallbackExecutor();
|
|
public static final class CallbackExecutor implements java.util.concurrent.Executor, Runnable {
|
|
|
|
- private Runnable queued;
|
|
+ // Paper start - replace impl with recursive safe multi entry queue
|
|
+ // it's possible to schedule multiple tasks currently, so it's vital we change this impl
|
|
+ // If we recurse into the executor again, we will append to another queue, ensuring task order consistency
|
|
+ private java.util.ArrayDeque<Runnable> queued = new java.util.ArrayDeque<>();
|
|
|
|
@Override
|
|
public void execute(Runnable runnable) {
|
|
- if (queued != null) {
|
|
- throw new IllegalStateException("Already queued");
|
|
+ if (queued == null) {
|
|
+ queued = new java.util.ArrayDeque<>();
|
|
}
|
|
- queued = runnable;
|
|
+ queued.add(runnable);
|
|
}
|
|
|
|
@Override
|
|
public void run() {
|
|
- Runnable task = queued;
|
|
+ if (queued == null) {
|
|
+ return;
|
|
+ }
|
|
+ java.util.ArrayDeque<Runnable> queue = queued;
|
|
queued = null;
|
|
- if (task != null) {
|
|
+ Runnable task;
|
|
+ while ((task = queue.pollFirst()) != null) {
|
|
task.run();
|
|
}
|
|
}
|
|
+ // Paper end
|
|
};
|
|
// CraftBukkit end
|
|
|