Fix double lock in ServerConnection

This commit is contained in:
Alfie Cleveland 2016-11-26 22:06:23 -06:00 committed by Zach Brown
parent 8c27c1fd27
commit ed90e5b3a6
No known key found for this signature in database
GPG key ID: CC9DA35FC5450B76

View file

@ -1,4 +1,4 @@
From 657ccc96c1093a23903aad6575111bc6fa51bd59 Mon Sep 17 00:00:00 2001
From b08b9267a815bb5ed31fc5f94479dd3b54c529a2 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 16 May 2016 23:19:16 -0400
Subject: [PATCH] Avoid blocking on Network Manager creation
@ -6,10 +6,10 @@ Subject: [PATCH] Avoid blocking on Network Manager creation
Per Paper issue 294
diff --git a/src/main/java/net/minecraft/server/ServerConnection.java b/src/main/java/net/minecraft/server/ServerConnection.java
index 6a71ebb..5cde4be 100644
index 6a71ebb..faf7b60 100644
--- a/src/main/java/net/minecraft/server/ServerConnection.java
+++ b/src/main/java/net/minecraft/server/ServerConnection.java
@@ -60,6 +60,17 @@ public class ServerConnection {
@@ -60,6 +60,15 @@ public class ServerConnection {
public volatile boolean d;
private final List<ChannelFuture> g = Collections.synchronizedList(Lists.<ChannelFuture>newArrayList());
private final List<NetworkManager> h = Collections.synchronizedList(Lists.<NetworkManager>newArrayList());
@ -17,17 +17,15 @@ index 6a71ebb..5cde4be 100644
+ private final List<NetworkManager> pending = Collections.synchronizedList(Lists.<NetworkManager>newArrayList());
+ private void addPending() {
+ synchronized (pending) {
+ synchronized (this.h) { // Paper - OBFHELPER - List of network managers
+ this.h.addAll(pending);
+ pending.clear();
+ }
+ this.h.addAll(pending); // Paper - OBFHELPER - List of network managers
+ pending.clear();
+ }
+ }
+ // Paper end
public ServerConnection(MinecraftServer minecraftserver) {
this.f = minecraftserver;
@@ -94,7 +105,7 @@ public class ServerConnection {
@@ -94,7 +103,7 @@ public class ServerConnection {
channel.pipeline().addLast("timeout", new ReadTimeoutHandler(30)).addLast("legacy_query", new LegacyPingHandler(ServerConnection.this)).addLast("splitter", new PacketSplitter()).addLast("decoder", new PacketDecoder(EnumProtocolDirection.SERVERBOUND)).addLast("prepender", new PacketPrepender()).addLast("encoder", new PacketEncoder(EnumProtocolDirection.CLIENTBOUND));
NetworkManager networkmanager = new NetworkManager(EnumProtocolDirection.SERVERBOUND);
@ -36,7 +34,7 @@ index 6a71ebb..5cde4be 100644
channel.pipeline().addLast("packet_handler", networkmanager);
networkmanager.setPacketListener(new HandshakeListener(ServerConnection.this.f, networkmanager));
}
@@ -123,6 +134,7 @@ public class ServerConnection {
@@ -123,6 +132,7 @@ public class ServerConnection {
synchronized (this.h) {
// Spigot Start