#3438: Fix possible race condition in duplicate player check
This commit is contained in:
parent
df20effacc
commit
f5157f12a4
@ -753,7 +753,7 @@ public class BungeeCord extends ProxyServer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addConnection(UserConnection con)
|
public boolean addConnection(UserConnection con)
|
||||||
{
|
{
|
||||||
UUID offlineId = con.getPendingConnection().getOfflineId();
|
UUID offlineId = con.getPendingConnection().getOfflineId();
|
||||||
if ( offlineId != null && offlineId.version() != 3 )
|
if ( offlineId != null && offlineId.version() != 3 )
|
||||||
@ -763,6 +763,10 @@ public class BungeeCord extends ProxyServer
|
|||||||
connectionLock.writeLock().lock();
|
connectionLock.writeLock().lock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if ( connections.containsKey( con.getName() ) || connectionsByUUID.containsKey( con.getUniqueId() ) || connectionsByOfflineUUID.containsKey( offlineId ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
connections.put( con.getName(), con );
|
connections.put( con.getName(), con );
|
||||||
connectionsByUUID.put( con.getUniqueId(), con );
|
connectionsByUUID.put( con.getUniqueId(), con );
|
||||||
connectionsByOfflineUUID.put( offlineId, con );
|
connectionsByOfflineUUID.put( offlineId, con );
|
||||||
@ -770,6 +774,7 @@ public class BungeeCord extends ProxyServer
|
|||||||
{
|
{
|
||||||
connectionLock.writeLock().unlock();
|
connectionLock.writeLock().unlock();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeConnection(UserConnection con)
|
public void removeConnection(UserConnection con)
|
||||||
|
@ -153,7 +153,7 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public void init()
|
public boolean init()
|
||||||
{
|
{
|
||||||
this.entityRewrite = EntityMap.getEntityMap( getPendingConnection().getVersion() );
|
this.entityRewrite = EntityMap.getEntityMap( getPendingConnection().getVersion() );
|
||||||
|
|
||||||
@ -172,6 +172,8 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
|
|
||||||
// Set whether the connection has a 1.8 FML marker in the handshake.
|
// Set whether the connection has a 1.8 FML marker in the handshake.
|
||||||
forgeClientHandler.setFmlTokenInHandshake( this.getPendingConnection().getExtraDataInHandshake().contains( ForgeConstants.FML_HANDSHAKE_TOKEN ) );
|
forgeClientHandler.setFmlTokenInHandshake( this.getPendingConnection().getExtraDataInHandshake().contains( ForgeConstants.FML_HANDSHAKE_TOKEN ) );
|
||||||
|
|
||||||
|
return BungeeCord.getInstance().addConnection( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendPacket(PacketWrapper packet)
|
public void sendPacket(PacketWrapper packet)
|
||||||
|
@ -613,7 +613,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
|
|
||||||
private void finish2()
|
private void finish2()
|
||||||
{
|
{
|
||||||
userCon.init();
|
if ( !userCon.init() )
|
||||||
|
{
|
||||||
|
disconnect( bungee.getTranslation( "already_connected_proxy" ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new UpstreamBridge( bungee, userCon ) );
|
ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new UpstreamBridge( bungee, userCon ) );
|
||||||
bungee.getPluginManager().callEvent( new PostLoginEvent( userCon ) );
|
bungee.getPluginManager().callEvent( new PostLoginEvent( userCon ) );
|
||||||
|
@ -54,7 +54,6 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
this.bungee = bungee;
|
this.bungee = bungee;
|
||||||
this.con = con;
|
this.con = con;
|
||||||
|
|
||||||
BungeeCord.getInstance().addConnection( con );
|
|
||||||
con.getTabListHandler().onConnect();
|
con.getTabListHandler().onConnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user