Paper/Spigot-Server-Patches/0383-Fix-FileIOThread-concurrency-issues.patch
Aikar 459987d69f
More improvements to activation range, improve turtles
improved the water code so that immunity wont trigger if the entity
has the water pathfinder system active, so this improves support
for all entities that know how to behave in water.

Merged 2 EAR patches together, and removed an MCUtil method that
doesnt have a purpose anymore
2018-10-04 23:18:46 -04:00

36 lines
1.6 KiB
Diff

From 6e01cd4caf34532a9e356ae702e8bdf732171b68 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Wed, 3 Oct 2018 19:04:53 +0100
Subject: [PATCH] Fix FileIOThread concurrency issues
FileIOThread was using two volatile counters in order to track if
any pending work was in the queue, this causes potential concurrency
issues when this counter is updated from multiple threads, potentially
causing these counters to desync due to the unsafe volatile update
diff --git a/src/main/java/net/minecraft/server/FileIOThread.java b/src/main/java/net/minecraft/server/FileIOThread.java
index 97917551a4..1959bc0660 100644
--- a/src/main/java/net/minecraft/server/FileIOThread.java
+++ b/src/main/java/net/minecraft/server/FileIOThread.java
@@ -9,7 +9,7 @@ import org.apache.logging.log4j.Logger;
public class FileIOThread implements Runnable {
private static final Logger a = LogManager.getLogger();
private static final FileIOThread b = new FileIOThread();
- private final List<IAsyncChunkSaver> c = Collections.synchronizedList(Lists.newArrayList());
+ private final List<IAsyncChunkSaver> c = Collections.synchronizedList(Lists.newArrayList()); private List<IAsyncChunkSaver> getThreadedIOQueue() { return c; } // Paper - OBFHELPER
private volatile long d;
private volatile long e;
private volatile boolean f;
@@ -72,7 +72,7 @@ public class FileIOThread implements Runnable {
public void b() throws InterruptedException {
this.f = true;
- while(this.d != this.e) {
+ while(!this.getThreadedIOQueue().isEmpty()) { // Paper - check actual list size
Thread.sleep(10L);
}
--
2.19.0