Paper/Spigot-Server-Patches/0309-Thread-Safe-Iteration-of-Chunk-Scheduler.patch
Aikar 230b8d4258
Merge pull request #1256
bfbd24c5 Fix decompile error (Hugo Manrique)
1f5d23d9 Re-add Vanished players don't have rights patch (Hugo Manrique)

* pull/1256/head:
  Fix decompile error
  Re-add Vanished players don't have rights patch
2018-07-25 19:41:35 -04:00

48 lines
1.9 KiB
Diff

From e03f8b9d7954cb8b1b292d87e3945393e19fb521 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 23 Jul 2018 19:13:06 -0400
Subject: [PATCH] Thread Safe Iteration of Chunk Scheduler
diff --git a/src/main/java/net/minecraft/server/ChunkTaskScheduler.java b/src/main/java/net/minecraft/server/ChunkTaskScheduler.java
index 7629e0d054..5ee8bedf34 100644
--- a/src/main/java/net/minecraft/server/ChunkTaskScheduler.java
+++ b/src/main/java/net/minecraft/server/ChunkTaskScheduler.java
@@ -1,8 +1,10 @@
package net.minecraft.server;
+import com.google.common.collect.Lists;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectMaps;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.EnumMap;
import java.util.Map;
import java.util.function.Consumer;
@@ -85,7 +87,13 @@ public class ChunkTaskScheduler extends Scheduler<ChunkCoordIntPair, ChunkStatus
}
public void a() {
- this.g.values().forEach((scheduler_a) -> {
+ // Paper start
+ ArrayList<Scheduler.a> list;
+ synchronized (this.g) {
+ list = Lists.newArrayList(this.g.values());
+ }
+ list.forEach((scheduler_a) -> {
+ // Paper end
ProtoChunk protochunk = (ProtoChunk) scheduler_a.a();
if (protochunk.h() && protochunk.i().d() == ChunkStatus.Type.PROTOCHUNK) {
@@ -93,6 +101,7 @@ public class ChunkTaskScheduler extends Scheduler<ChunkCoordIntPair, ChunkStatus
protochunk.setLastSaved(this.c.getTime());
this.e.saveChunk(this.c, protochunk);
protochunk.a(false);
+
} catch (IOException ioexception) {
ChunkTaskScheduler.b.error("Couldn\'t save chunk", ioexception);
} catch (ExceptionWorldConflict exceptionworldconflict) {
--
2.18.0