mirror of
https://github.com/barkeser2002/Tenet.git
synced 2026-09-25 02:19:50 +03:00
64 lines
2.9 KiB
Diff
64 lines
2.9 KiB
Diff
From d416c6e1bda9401a030c1cf0a53db1f6911546bf 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 2da5fcd1b..af05a27ee 100644
|
|
--- a/src/main/java/net/minecraft/network/NetworkManager.java
|
|
+++ b/src/main/java/net/minecraft/network/NetworkManager.java
|
|
@@ -79,6 +79,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
|
|
private PacketListener packetListener;
|
|
private IChatBaseComponent disconnectedReason;
|
|
@@ -102,6 +103,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
|
|
|
|
try {
|
|
this.setProtocol(EnumProtocol.HANDSHAKING);
|
|
@@ -307,6 +311,9 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
|
}
|
|
|
|
public void disconnect(IChatBaseComponent ichatbasecomponent) {
|
|
+ // Spigot Start
|
|
+ this.preparing = false;
|
|
+ // Spigot End
|
|
if (this.channel == null) {
|
|
this.delayedDisconnect = ichatbasecomponent;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerConnection.java b/src/main/java/net/minecraft/server/network/ServerConnection.java
|
|
index 400f9e0b6..c86091ed1 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerConnection.java
|
|
@@ -187,6 +187,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.40.1
|
|
|