From 1f42cc66e78eb866aa1581f096300fe94d17bba0 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Wed, 2 Mar 2022 18:08:10 +0000 Subject: [PATCH] Revert chunk postprocessing back to 1.18.1 logic --- ...-Chunk-Post-Processing-deadlock-risk.patch | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/patches/server/Fix-Chunk-Post-Processing-deadlock-risk.patch b/patches/server/Fix-Chunk-Post-Processing-deadlock-risk.patch index 34a8a2c806..974388e893 100644 --- a/patches/server/Fix-Chunk-Post-Processing-deadlock-risk.patch +++ b/patches/server/Fix-Chunk-Post-Processing-deadlock-risk.patch @@ -68,14 +68,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>(); @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - return (LevelChunk) list.get(list.size() / 2); - }); - }, (runnable) -> { + return ChunkStatus.FULL; + }); + CompletableFuture> completablefuture1 = completablefuture.thenApplyAsync((either) -> { +- return either.mapLeft((list) -> { +- return (LevelChunk) list.get(list.size() / 2); +- }); +- }, (runnable) -> { - this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, runnable)); -+ this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, () -> ChunkMap.this.chunkLoadConversionCallbackExecutor.execute(runnable))); // Paper - delay running Chunk post processing until outside of the sorter to prevent a deadlock scenario when post processing causes another chunk request. - }).thenApplyAsync((either) -> { - return either.ifLeft((chunk) -> { +- }).thenApplyAsync((either) -> { +- return either.ifLeft((chunk) -> { ++ // Paper start ++ return either.flatMap((list) -> { ++ LevelChunk chunk = (LevelChunk) list.get(list.size() / 2); chunk.postProcessGeneration(); + this.level.startTickingChunk(chunk); ++ return Either.left(chunk); ++ + }); +- }, this.mainThreadExecutor); ++ }, (runnable) -> { ++ this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, () -> ChunkMap.this.chunkLoadConversionCallbackExecutor.execute(runnable))); // Paper - delay running Chunk post processing until outside of the sorter to prevent a deadlock scenario when post processing causes another chunk request. ++ }); ++ // Paper end + + completablefuture1.thenAcceptAsync((either) -> { + either.ifLeft((chunk) -> { diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java