mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 07:48:53 +01:00
Defensive copy chunk list to avoid "effective CME" - Fixes #313
Lighting operations apparently can load chunks, which will cause an NPE in the same fashion you would trigger a CME during the chunk iteration.
This commit is contained in:
parent
bd7c76a1cf
commit
6d06f31c10
1 changed files with 14 additions and 11 deletions
|
@ -1,4 +1,4 @@
|
|||
From 30eb1836f00bc0acb416356296137ec1881a4c09 Mon Sep 17 00:00:00 2001
|
||||
From 77660fb147000a0103f9794ef134092519efb742 Mon Sep 17 00:00:00 2001
|
||||
From: Byteflux <byte@byteflux.net>
|
||||
Date: Wed, 2 Mar 2016 00:52:31 -0600
|
||||
Subject: [PATCH] Lighting Queue
|
||||
|
@ -6,7 +6,7 @@ Subject: [PATCH] Lighting Queue
|
|||
This provides option to queue lighting updates to ensure they do not cause the server lag
|
||||
|
||||
diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
|
||||
index e778911..f90f5bf 100644
|
||||
index e7789117b..f90f5bf84 100644
|
||||
--- a/src/main/java/co/aikar/timings/WorldTimingsHandler.java
|
||||
+++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
|
||||
@@ -50,6 +50,8 @@ public class WorldTimingsHandler {
|
||||
|
@ -27,7 +27,7 @@ index e778911..f90f5bf 100644
|
|||
}
|
||||
}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
index 2767ffb..f7a0c18 100644
|
||||
index 2767ffb78..f7a0c18a8 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -149,4 +149,10 @@ public class PaperWorldConfig {
|
||||
|
@ -42,7 +42,7 @@ index 2767ffb..f7a0c18 100644
|
|||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 1c0108e..b80f951 100644
|
||||
index 1c0108ef1..b80f95159 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -33,6 +33,7 @@ public class Chunk {
|
||||
|
@ -85,7 +85,7 @@ index 1c0108e..b80f951 100644
|
|||
|
||||
TileEntity tileentity;
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
index 17d39bb..df3ce72 100644
|
||||
index 17d39bb0f..df3ce72e2 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
@@ -280,6 +280,7 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||
|
@ -97,7 +97,7 @@ index 17d39bb..df3ce72 100644
|
|||
// Update neighbor counts
|
||||
for (int x = -2; x < 3; x++) {
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 127d11c..2e72b8c 100644
|
||||
index 6a1c7b7f0..538745e7d 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -716,7 +716,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
|
||||
|
@ -119,13 +119,15 @@ index 127d11c..2e72b8c 100644
|
|||
|
||||
diff --git a/src/main/java/net/minecraft/server/PaperLightingQueue.java b/src/main/java/net/minecraft/server/PaperLightingQueue.java
|
||||
new file mode 100644
|
||||
index 0000000..2350fe3
|
||||
index 000000000..d8d3e1efd
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/minecraft/server/PaperLightingQueue.java
|
||||
@@ -0,0 +1,98 @@
|
||||
@@ -0,0 +1,101 @@
|
||||
+package net.minecraft.server;
|
||||
+
|
||||
+import co.aikar.timings.Timing;
|
||||
+import it.unimi.dsi.fastutil.objects.ObjectCollection;
|
||||
+
|
||||
+import java.util.ArrayDeque;
|
||||
+
|
||||
+class PaperLightingQueue {
|
||||
|
@ -145,7 +147,8 @@ index 0000000..2350fe3
|
|||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ for (Chunk chunk : ((WorldServer) world).getChunkProviderServer().chunks.values()) {
|
||||
+ ObjectCollection<Chunk> loadedChunks = ((WorldServer) world).getChunkProviderServer().chunks.values();
|
||||
+ for (Chunk chunk : loadedChunks.toArray(new Chunk[loadedChunks.size()])) {
|
||||
+ if (chunk.lightingQueue.processQueue(startTime, maxTickTime)) {
|
||||
+ break START;
|
||||
+ }
|
||||
|
@ -222,7 +225,7 @@ index 0000000..2350fe3
|
|||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index 804b994..8cb3a98 100644
|
||||
index 1143b3e01..63a6a9855 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -387,7 +387,7 @@ public abstract class World implements IBlockAccess {
|
||||
|
@ -235,5 +238,5 @@ index 804b994..8cb3a98 100644
|
|||
}
|
||||
|
||||
--
|
||||
2.9.3
|
||||
2.11.0
|
||||
|
||||
|
|
Loading…
Reference in a new issue