2015-01-05 03:32:01 +00:00
|
|
|
From d7d0fcb6b3ec5a9a23ca9fe379b329091596c40a Mon Sep 17 00:00:00 2001
|
2014-07-21 20:46:54 +00:00
|
|
|
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/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
|
2014-11-28 01:17:45 +00:00
|
|
|
index 65b66cd..b4eb893 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/NetworkManager.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
|
2014-11-28 01:17:45 +00:00
|
|
|
@@ -35,6 +35,7 @@ public class NetworkManager extends SimpleChannelInboundHandler {
|
|
|
|
public SocketAddress j;
|
2014-07-21 20:46:54 +00:00
|
|
|
public java.util.UUID spoofedUUID;
|
2014-11-28 01:17:45 +00:00
|
|
|
public com.mojang.authlib.properties.Property[] spoofedProfile;
|
2014-07-21 20:46:54 +00:00
|
|
|
+ public boolean preparing = true;
|
|
|
|
// Spigot End
|
2014-11-28 01:17:45 +00:00
|
|
|
private PacketListener k;
|
|
|
|
private IChatBaseComponent l;
|
|
|
|
@@ -49,6 +50,9 @@ public class NetworkManager extends SimpleChannelInboundHandler {
|
2014-07-21 20:46:54 +00:00
|
|
|
super.channelActive(channelhandlercontext);
|
2014-11-28 01:17:45 +00:00
|
|
|
this.i = channelhandlercontext.channel();
|
|
|
|
this.j = this.i.remoteAddress();
|
2014-07-21 20:46:54 +00:00
|
|
|
+ // Spigot Start
|
|
|
|
+ this.preparing = false;
|
|
|
|
+ // Spigot End
|
|
|
|
|
2014-11-28 01:17:45 +00:00
|
|
|
try {
|
|
|
|
this.a(EnumProtocol.HANDSHAKING);
|
|
|
|
@@ -163,6 +167,9 @@ public class NetworkManager extends SimpleChannelInboundHandler {
|
2014-07-21 20:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void close(IChatBaseComponent ichatbasecomponent) {
|
|
|
|
+ // Spigot Start
|
|
|
|
+ this.preparing = false;
|
|
|
|
+ // Spigot End
|
2014-11-28 01:17:45 +00:00
|
|
|
if (this.i.isOpen()) {
|
|
|
|
this.i.close(); // We can't wait as this may be called from an event loop.
|
|
|
|
this.l = ichatbasecomponent;
|
2014-07-21 20:46:54 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/ServerConnection.java b/src/main/java/net/minecraft/server/ServerConnection.java
|
2014-11-28 01:17:45 +00:00
|
|
|
index 6c6ffa7..de1b3d1 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/ServerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ServerConnection.java
|
2014-11-28 01:17:45 +00:00
|
|
|
@@ -71,6 +71,10 @@ public class ServerConnection {
|
2014-07-21 20:46:54 +00:00
|
|
|
|
2014-11-28 01:17:45 +00:00
|
|
|
if (!networkmanager.h()) {
|
|
|
|
if (!networkmanager.g()) {
|
|
|
|
+ // Spigot Start
|
|
|
|
+ // Fix a race condition where a NetworkManager could be unregistered just before connection.
|
|
|
|
+ if (networkmanager.preparing) continue;
|
|
|
|
+ // Spigot End
|
|
|
|
iterator.remove();
|
|
|
|
networkmanager.l();
|
|
|
|
} else {
|
2014-07-21 20:46:54 +00:00
|
|
|
--
|
2014-11-28 01:17:45 +00:00
|
|
|
2.1.0
|
2014-07-21 20:46:54 +00:00
|
|
|
|