mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2024-11-24 15:16:26 +00:00
64 lines
2.9 KiB
Diff
64 lines
2.9 KiB
Diff
From c0eb4a50b076f77a85b9215255a1d02be4a448c6 Mon Sep 17 00:00:00 2001
|
|
From: Jonas Konrad <me@yawk.at>
|
|
Date: Fri, 25 Apr 2014 23:46:46 +0200
|
|
Subject: [PATCH] Fix race condition that could kill connections before they
|
|
were initiated
|
|
|
|
Because NetworkManagers are registered before they get their channel in
|
|
channelActive, the ServerConnection would remove them sometimes because
|
|
it thought they were disconnected. This commit fixes this by introducing
|
|
a 'preparing' variable that is true while the NetworkManager is not
|
|
initialized. The ServerConnection does not remove NetworkManagers with
|
|
this flag.
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/NetworkManager.java b/src/main/java/net/minecraft/network/NetworkManager.java
|
|
index 4ea9b2bfcf..1cae281e6d 100644
|
|
--- a/src/main/java/net/minecraft/network/NetworkManager.java
|
|
+++ b/src/main/java/net/minecraft/network/NetworkManager.java
|
|
@@ -99,6 +99,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
|
// Spigot Start
|
|
public java.util.UUID spoofedUUID;
|
|
public com.mojang.authlib.properties.Property[] spoofedProfile;
|
|
+ public boolean preparing = true;
|
|
// Spigot End
|
|
@Nullable
|
|
private volatile PacketListener disconnectListener;
|
|
@@ -128,6 +129,9 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
|
super.channelActive(channelhandlercontext);
|
|
this.channel = channelhandlercontext.channel();
|
|
this.address = this.channel.remoteAddress();
|
|
+ // Spigot Start
|
|
+ this.preparing = false;
|
|
+ // Spigot End
|
|
if (this.delayedDisconnect != null) {
|
|
this.disconnect(this.delayedDisconnect);
|
|
}
|
|
@@ -470,6 +474,9 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
|
}
|
|
|
|
public void disconnect(DisconnectionDetails disconnectiondetails) {
|
|
+ // Spigot Start
|
|
+ this.preparing = false;
|
|
+ // Spigot End
|
|
if (this.channel == null) {
|
|
this.delayedDisconnect = disconnectiondetails;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerConnection.java b/src/main/java/net/minecraft/server/network/ServerConnection.java
|
|
index 85fb253c16..b66b9e5c27 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerConnection.java
|
|
@@ -193,6 +193,10 @@ public class ServerConnection {
|
|
networkmanager.setReadOnly();
|
|
}
|
|
} else {
|
|
+ // Spigot Start
|
|
+ // Fix a race condition where a NetworkManager could be unregistered just before connection.
|
|
+ if (networkmanager.preparing) continue;
|
|
+ // Spigot End
|
|
iterator.remove();
|
|
networkmanager.handleDisconnection();
|
|
}
|
|
--
|
|
2.47.0
|
|
|