Waterfall/BungeeCord-Patches/0018-Resolve-sendData-deadlocks.patch

48 lines
1.6 KiB
Diff
Raw Normal View History

From a01374cdf7cd8a968e6f84ca92aaa27c10017113 Mon Sep 17 00:00:00 2001
From: Tux <write@imaginarycode.com>
Date: Fri, 12 Feb 2016 23:55:53 -0500
Subject: [PATCH] Resolve sendData() deadlocks
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java b/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java
index cab2c21b..3dab3422 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java
@@ -108,19 +108,22 @@ public class BungeeServerInfo implements ServerInfo
Preconditions.checkNotNull( channel, "channel" );
Preconditions.checkNotNull( data, "data" );
- synchronized ( packetQueue )
- {
- Server server = ( players.isEmpty() ) ? null : players.iterator().next().getServer();
- if ( server != null )
- {
- server.sendData( channel, data );
- return true;
- } else if ( queue )
- {
- packetQueue.add( new PluginMessage( channel, data, false ) );
+ Server server;
+
+ synchronized (players) {
+ server = players.isEmpty() ? null : players.iterator().next().getServer();
+ }
+
+ if (server != null) {
+ server.sendData(channel, data);
+ return true;
+ } else if (queue) {
+ synchronized (packetQueue) {
+ packetQueue.add(new PluginMessage(channel, data, false));
}
- return false;
}
+
+ return false;
}
@Override
--
2.25.0