1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-02-17 18:47:40 +01:00

Don't flush packet queue off main thread

Increases risk of deadlock if a plugin using protocollib sends a packet
async, and then a listener then reads world state, and main thread is then
blocked waiting for the queue to flush.

This will break out of the synchronized block when it jumps to the netty event loop.

See: https://gist.github.com/aikar/e7abb2ba7059149d0a91f7a226e98590
This commit is contained in:
Aikar 2020-05-04 03:07:04 -04:00
parent 5a8b71725f
commit e3105bc57a

View file

@ -14,7 +14,7 @@ With further contributions from
Co-Authored-by: Spottedleaf <spottedleaf@spottedleaf.dev>
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
index b1dededc15..e966b6edcc 100644
index b1dededc15..07e3ddb6e9 100644
--- a/src/main/java/net/minecraft/server/NetworkManager.java
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
@@ -0,0 +0,0 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
@ -73,7 +73,7 @@ index b1dededc15..e966b6edcc 100644
+
+ this.packetQueue.addAll(packets); // atomic
+ }
+ this.sendPacketQueue(); // ensure only one flush call is made
+ if (MCUtil.isMainThread()) this.sendPacketQueue();
+ // Paper end
}