From 4e71788aba6a852d10ef513d7f419d86d4fc95ab Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Mon, 27 May 2019 14:00:20 -0400 Subject: [PATCH] Work around kqueue transport bug with fallback connections. --- .../connection/client/ConnectedPlayer.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java index d06f797b4..5bb3ec2db 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java @@ -404,15 +404,18 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { } if (connectedServer == null) { - // The player isn't yet connected to a server. - Optional nextServer = getNextServerToTry(rs); - if (nextServer.isPresent()) { - // There can't be any connection in flight now. - resetInFlightConnection(); - createConnectionRequest(nextServer.get()).fireAndForget(); - } else { - disconnect(friendlyReason); - } + // The player isn't yet connected to a server. Note that we need to do this in a future run + // of the event loop due to an issue with the Netty kqueue transport. + minecraftConnection.eventLoop().execute(() -> { + Optional nextServer = getNextServerToTry(rs); + if (nextServer.isPresent()) { + // There can't be any connection in flight now. + resetInFlightConnection(); + createConnectionRequest(nextServer.get()).fireAndForget(); + } else { + disconnect(friendlyReason); + } + }); } else { boolean kickedFromCurrent = connectedServer.getServer().equals(rs); ServerKickResult result;