Fix logic error in async chunk loading

if a chunk load was cancelled after generating stage started
it would short circuit return with a null.

however this skipped the creation of the loadTask, which some code
would then invoke in requestChunk and trigger an NPE.

This then likely left an incomplete corrupt request in the chunk map
which then crashes servers.

It should fix these isseues
Fixes #1775
Fixes #1743
Dieser Commit ist enthalten in:
Aikar 2019-02-07 00:04:29 -05:00
Ursprung 182d4f528f
Commit 7d5b217d83
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 401ADFC9891FAAFE
2 geänderte Dateien mit 30 neuen und 29 gelöschten Zeilen

Datei anzeigen

@ -1,4 +1,4 @@
From d8c055a6b9588b2fe77fdb73f7200a1a87931599 Mon Sep 17 00:00:00 2001
From 1e485c2ab878e0d28e6b70eb9ad3ace0c424dfee Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 21 Jul 2018 16:55:04 -0400
Subject: [PATCH] Async Chunk Loading and Generation
@ -1070,10 +1070,10 @@ index 68743a6b7..1dbb03a9a 100644
if (true || worldserver.worldProvider.getDimensionManager() == DimensionManager.OVERWORLD || this.getAllowNether()) { // CraftBukkit
diff --git a/src/main/java/net/minecraft/server/PaperAsyncChunkProvider.java b/src/main/java/net/minecraft/server/PaperAsyncChunkProvider.java
new file mode 100644
index 000000000..e9a38f9d9
index 000000000..896fc94a6
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PaperAsyncChunkProvider.java
@@ -0,0 +1,655 @@
@@ -0,0 +1,656 @@
+/*
+ * This file is licensed under the MIT License (MIT).
+ *
@ -1617,6 +1617,18 @@ index 000000000..e9a38f9d9
+ }
+
+ synchronized PendingChunkRequest addListener(CompletableFuture<Chunk> future, boolean gen, boolean autoSubmit) {
+ requests.incrementAndGet();
+ if (loadTask == null) {
+ // Take care of a race condition in that a request could be cancelled after the synchronize
+ // on pendingChunks, but before a listener is added, which would erase these pending tasks.
+ genTask = generationExecutor.createPendingTask(this::generateChunk, taskPriority);
+ loadTask = EXECUTOR.createPendingTask(this, taskPriority);
+ if (autoSubmit) {
+ // We will execute it outside of the synchronized context immediately after
+ loadTask.submit();
+ }
+ }
+
+ if (hasFinished) {
+ future.complete(chunk);
+ return new PendingChunkRequest(this);
@ -1632,17 +1644,6 @@ index 000000000..e9a38f9d9
+ }
+ }
+
+ requests.incrementAndGet();
+ if (loadTask == null) {
+ // Take care of a race condition in that a request could be cancelled after the synchronize
+ // on pendingChunks, but before a listener is added, which would erase these pending tasks.
+ genTask = generationExecutor.createPendingTask(this::generateChunk, taskPriority);
+ loadTask = EXECUTOR.createPendingTask(this, taskPriority);
+ if (autoSubmit) {
+ // We will execute it outside of the synchronized context immediately after
+ loadTask.submit();
+ }
+ }
+ return new PendingChunkRequest(this, gen);
+ }
+
@ -2315,7 +2316,7 @@ index a9fffa544..19ce77c4a 100644
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 5fca9e4bd..78adc8714 100644
index 8dccf9498..75c4592c2 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1021,8 +1021,12 @@ public final class CraftServer implements Server {

Datei anzeigen

@ -1,4 +1,4 @@
From a8f8a54a79674d324c92a164bd27836c3eb19757 Mon Sep 17 00:00:00 2001
From af705fcd4e7c9f933bc7f24c3ea4b1a11b6eb9f3 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 23 Oct 2018 20:25:05 -0400
Subject: [PATCH] Don't sleep after profile lookups if not needed
@ -7,7 +7,7 @@ Mojang was sleeping even if we had no more requests to go after
the current one finished, resulting in 100ms lost per profile lookup
diff --git a/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java b/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java
index 26a743722..6ed3199c3 100644
index 71e48e87b..23f1447cf 100644
--- a/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java
+++ b/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java
@@ -42,6 +42,7 @@ public class YggdrasilGameProfileRepository implements GameProfileRepository {