Check if there are workers before trying to notify them (#2593)

* Fix #2591

We need to check if there are workers before trying to notify
them...
This commit is contained in:
Spottedleaf 2019-09-29 13:29:56 -07:00
parent 14ef983c25
commit 13d4dd046d

View file

@ -121,7 +121,7 @@ tasks required to be executed by the chunk load task (i.e lighting
and some poi tasks).
diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
index 92c32c48d..f4d5db02f 100644
index 92c32c48d2..f4d5db02f7 100644
--- a/src/main/java/co/aikar/timings/WorldTimingsHandler.java
+++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
@@ -0,0 +0,0 @@ public class WorldTimingsHandler {
@ -161,7 +161,7 @@ index 92c32c48d..f4d5db02f 100644
public static Timing getTickList(WorldServer worldserver, String timingsType) {
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index 5942c3438..61eeb6747 100644
index 5942c3438e..61eeb6747a 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -0,0 +0,0 @@
@ -237,7 +237,7 @@ index 5942c3438..61eeb6747 100644
+ }
}
diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java
index 23626bef3..1edcecd2e 100644
index 23626bef3a..1edcecd2ee 100644
--- a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java
+++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java
@@ -0,0 +0,0 @@ import java.util.concurrent.Executors;
@ -318,7 +318,7 @@ index 23626bef3..1edcecd2e 100644
diff --git a/src/main/java/com/destroystokyo/paper/io/IOUtil.java b/src/main/java/com/destroystokyo/paper/io/IOUtil.java
new file mode 100644
index 000000000..5af0ac3d9
index 0000000000..5af0ac3d9e
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/io/IOUtil.java
@@ -0,0 +0,0 @@
@ -386,7 +386,7 @@ index 000000000..5af0ac3d9
+}
diff --git a/src/main/java/com/destroystokyo/paper/io/PaperFileIOThread.java b/src/main/java/com/destroystokyo/paper/io/PaperFileIOThread.java
new file mode 100644
index 000000000..4f10a8311
index 0000000000..4f10a8311e
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/io/PaperFileIOThread.java
@@ -0,0 +0,0 @@
@ -1053,7 +1053,7 @@ index 000000000..4f10a8311
+}
diff --git a/src/main/java/com/destroystokyo/paper/io/PrioritizedTaskQueue.java b/src/main/java/com/destroystokyo/paper/io/PrioritizedTaskQueue.java
new file mode 100644
index 000000000..78bd238f4
index 0000000000..78bd238f4c
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/io/PrioritizedTaskQueue.java
@@ -0,0 +0,0 @@
@ -1335,7 +1335,7 @@ index 000000000..78bd238f4
+}
diff --git a/src/main/java/com/destroystokyo/paper/io/QueueExecutorThread.java b/src/main/java/com/destroystokyo/paper/io/QueueExecutorThread.java
new file mode 100644
index 000000000..ee906b594
index 0000000000..ee906b594b
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/io/QueueExecutorThread.java
@@ -0,0 +0,0 @@
@ -1582,7 +1582,7 @@ index 000000000..ee906b594
+}
diff --git a/src/main/java/com/destroystokyo/paper/io/chunk/ChunkLoadTask.java b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkLoadTask.java
new file mode 100644
index 000000000..305da4786
index 0000000000..305da47868
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkLoadTask.java
@@ -0,0 +0,0 @@
@ -1737,7 +1737,7 @@ index 000000000..305da4786
+}
diff --git a/src/main/java/com/destroystokyo/paper/io/chunk/ChunkSaveTask.java b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkSaveTask.java
new file mode 100644
index 000000000..60312b85f
index 0000000000..60312b85f9
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkSaveTask.java
@@ -0,0 +0,0 @@
@ -1855,7 +1855,7 @@ index 000000000..60312b85f
+}
diff --git a/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTask.java b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTask.java
new file mode 100644
index 000000000..1dfa8abfd
index 0000000000..1dfa8abfd8
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTask.java
@@ -0,0 +0,0 @@
@ -1901,7 +1901,7 @@ index 000000000..1dfa8abfd
+}
diff --git a/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTaskManager.java b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTaskManager.java
new file mode 100644
index 000000000..b1b48a6f4
index 0000000000..1d69715e26
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTaskManager.java
@@ -0,0 +0,0 @@
@ -2304,8 +2304,8 @@ index 000000000..b1b48a6f4
+
+ ChunkSaveTask chunkSaveTask = this.chunkSaveTasks.get(chunkKey);
+ if (chunkSaveTask != null) {
+ chunkSaveTask.raisePriority(priority);
+ if (chunkSaveTask.isScheduled() && chunkSaveTask.getPriority() != PrioritizedTaskQueue.COMPLETING_PRIORITY) {
+ final boolean raised = chunkSaveTask.raisePriority(priority);
+ if (chunkSaveTask.isScheduled() && raised) {
+ // only notify if we're in queue to be executed
+ this.internalScheduleNotify();
+ }
@ -2313,8 +2313,8 @@ index 000000000..b1b48a6f4
+
+ ChunkLoadTask chunkLoadTask = this.chunkLoadTasks.get(chunkKey);
+ if (chunkLoadTask != null) {
+ chunkLoadTask.raisePriority(priority);
+ if (chunkLoadTask.isScheduled() && chunkLoadTask.getPriority() != PrioritizedTaskQueue.COMPLETING_PRIORITY) {
+ final boolean raised = chunkLoadTask.raisePriority(priority);
+ if (chunkLoadTask.isScheduled() && raised) {
+ // only notify if we're in queue to be executed
+ this.internalScheduleNotify();
+ }
@ -2334,6 +2334,9 @@ index 000000000..b1b48a6f4
+ }
+
+ protected void internalScheduleNotify() {
+ if (this.workers == null) {
+ return;
+ }
+ for (final QueueExecutorThread<ChunkTask> worker : this.workers) {
+ if (worker.notifyTasks()) {
+ // break here since we only want to wake up one worker for scheduling one task
@ -2344,7 +2347,7 @@ index 000000000..b1b48a6f4
+
+}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index e0bd03b3b..f793ba08e 100644
index e0bd03b3be..f793ba08e7 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider {
@ -2514,7 +2517,7 @@ index e0bd03b3b..f793ba08e 100644
} finally {
playerChunkMap.callbackExecutor.run();
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index a02807411..98cc4efcf 100644
index a028074112..98cc4efcf5 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -0,0 +0,0 @@ import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
@ -2783,7 +2786,7 @@ index a02807411..98cc4efcf 100644
nbttagcompound1.set("PostProcessing", a(ichunkaccess.l()));
diff --git a/src/main/java/net/minecraft/server/ChunkStatus.java b/src/main/java/net/minecraft/server/ChunkStatus.java
index e324989b4..abb0d69d2 100644
index e324989b46..abb0d69d2f 100644
--- a/src/main/java/net/minecraft/server/ChunkStatus.java
+++ b/src/main/java/net/minecraft/server/ChunkStatus.java
@@ -0,0 +0,0 @@ public class ChunkStatus {
@ -2795,7 +2798,7 @@ index e324989b4..abb0d69d2 100644
return ChunkStatus.r.getInt(chunkstatus.c());
}
diff --git a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java
index d521d25cf..84024e6ba 100644
index d521d25cf5..84024e6ba4 100644
--- a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java
+++ b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java
@@ -0,0 +0,0 @@ public abstract class IAsyncTaskHandler<R extends Runnable> implements Mailbox<R
@ -2808,7 +2811,7 @@ index d521d25cf..84024e6ba 100644
;
}
diff --git a/src/main/java/net/minecraft/server/IChunkLoader.java b/src/main/java/net/minecraft/server/IChunkLoader.java
index 3f14392e6..39f6ddb1d 100644
index 3f14392e6e..39f6ddb1d2 100644
--- a/src/main/java/net/minecraft/server/IChunkLoader.java
+++ b/src/main/java/net/minecraft/server/IChunkLoader.java
@@ -0,0 +0,0 @@ package net.minecraft.server;
@ -2880,7 +2883,7 @@ index 3f14392e6..39f6ddb1d 100644
}
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
index 23d1935dd..14f8b6104 100644
index 23d1935dd5..14f8b61042 100644
--- a/src/main/java/net/minecraft/server/MCUtil.java
+++ b/src/main/java/net/minecraft/server/MCUtil.java
@@ -0,0 +0,0 @@ public final class MCUtil {
@ -2894,7 +2897,7 @@ index 23d1935dd..14f8b6104 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 229336040..d2c029973 100644
index 2293360407..d2c0299730 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@ -2906,7 +2909,7 @@ index 229336040..d2c029973 100644
public String getServerIp() {
diff --git a/src/main/java/net/minecraft/server/NibbleArray.java b/src/main/java/net/minecraft/server/NibbleArray.java
index 90c096876..eb2c06155 100644
index 90c096876e..eb2c061550 100644
--- a/src/main/java/net/minecraft/server/NibbleArray.java
+++ b/src/main/java/net/minecraft/server/NibbleArray.java
@@ -0,0 +0,0 @@ public class NibbleArray {
@ -2918,7 +2921,7 @@ index 90c096876..eb2c06155 100644
return this.a == null ? new NibbleArray() : new NibbleArray((byte[]) this.a.clone());
}
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
index af934ef8b..34d0ab0d5 100644
index af934ef8bc..34d0ab0d5e 100644
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
@@ -0,0 +0,0 @@ public class PlayerChunk {
@ -2944,7 +2947,7 @@ index af934ef8b..34d0ab0d5 100644
completablefuture = (CompletableFuture) this.statusFutures.get(i);
if (completablefuture != null) {
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index fd0d2b6e6..9daf64bad 100644
index fd0d2b6e67..9daf64bad4 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@ -3439,7 +3442,7 @@ index fd0d2b6e6..9daf64bad 100644
return this.n;
}
diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java
index a8c8ace46..22144eb00 100644
index a8c8ace46c..22144eb002 100644
--- a/src/main/java/net/minecraft/server/RegionFile.java
+++ b/src/main/java/net/minecraft/server/RegionFile.java
@@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable {
@ -3452,7 +3455,7 @@ index a8c8ace46..22144eb00 100644
this.b.close();
}
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
index d2b328945..d3d610742 100644
index d2b3289450..d3d6107422 100644
--- a/src/main/java/net/minecraft/server/RegionFileCache.java
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
@@ -0,0 +0,0 @@ public abstract class RegionFileCache implements AutoCloseable {
@ -3481,7 +3484,7 @@ index d2b328945..d3d610742 100644
RegionFile regionfile = a(pos, true);
diff --git a/src/main/java/net/minecraft/server/RegionFileSection.java b/src/main/java/net/minecraft/server/RegionFileSection.java
index 4b3e0c0f0..04b7dab64 100644
index 4b3e0c0f01..04b7dab646 100644
--- a/src/main/java/net/minecraft/server/RegionFileSection.java
+++ b/src/main/java/net/minecraft/server/RegionFileSection.java
@@ -0,0 +0,0 @@ public class RegionFileSection<R extends MinecraftSerializable> extends RegionFi
@ -3583,7 +3586,7 @@ index 4b3e0c0f0..04b7dab64 100644
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/server/TicketType.java b/src/main/java/net/minecraft/server/TicketType.java
index 9c114d2d3..e3150f85a 100644
index 9c114d2d37..e3150f85a5 100644
--- a/src/main/java/net/minecraft/server/TicketType.java
+++ b/src/main/java/net/minecraft/server/TicketType.java
@@ -0,0 +0,0 @@ public class TicketType<T> {
@ -3595,7 +3598,7 @@ index 9c114d2d3..e3150f85a 100644
public static <T> TicketType<T> a(String s, Comparator<T> comparator) {
return new TicketType<>(s, comparator, 0L);
diff --git a/src/main/java/net/minecraft/server/VillagePlace.java b/src/main/java/net/minecraft/server/VillagePlace.java
index 316959064..0e98b7803 100644
index 3169590641..0e98b7803b 100644
--- a/src/main/java/net/minecraft/server/VillagePlace.java
+++ b/src/main/java/net/minecraft/server/VillagePlace.java
@@ -0,0 +0,0 @@ public class VillagePlace extends RegionFileSection<VillagePlaceSection> {
@ -3684,7 +3687,7 @@ index 316959064..0e98b7803 100644
HAS_SPACE(VillagePlaceRecord::d), IS_OCCUPIED(VillagePlaceRecord::e), ANY((villageplacerecord) -> {
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index f1ad7be75..0c1f4e6e1 100644
index f1ad7be754..0c1f4e6e1e 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -0,0 +0,0 @@ public class WorldServer extends World {
@ -3777,7 +3780,7 @@ index f1ad7be75..0c1f4e6e1 100644
public void doTick(BooleanSupplier booleansupplier) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 4a035f0f0..3d5aa7e8d 100644
index 4a035f0f0b..3d5aa7e8d9 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -0,0 +0,0 @@ public class CraftWorld implements World {
@ -3839,7 +3842,7 @@ index 4a035f0f0..3d5aa7e8d 100644
@Override
public int getViewDistance() {
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
index a1d93200e..6ca0ebfde 100644
index a1d93200e6..6ca0ebfdee 100644
--- a/src/main/java/org/spigotmc/WatchdogThread.java
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
@@ -0,0 +0,0 @@ import java.lang.management.ThreadInfo;