[#1218] Check which player instance we remove from the connection maps.

Legitimate but slightly sneaky fix for the issue of racing for addition / removal. An alternate fix would be a multimap.
This commit is contained in:
md_5 2014-09-12 18:45:50 +10:00
parent efdedbd4e8
commit dcc9be9dfe
2 changed files with 9 additions and 3 deletions

View File

@ -146,7 +146,7 @@ public class BungeeCord extends ProxyServer
private ConnectionThrottle connectionThrottle; private ConnectionThrottle connectionThrottle;
private final ModuleManager moduleManager = new ModuleManager(); private final ModuleManager moduleManager = new ModuleManager();
{ {
// TODO: Proper fallback when we interface the manager // TODO: Proper fallback when we interface the manager
getPluginManager().registerCommand( null, new CommandReload() ); getPluginManager().registerCommand( null, new CommandReload() );
@ -603,14 +603,19 @@ public class BungeeCord extends ProxyServer
connectionLock.writeLock().lock(); connectionLock.writeLock().lock();
try try
{ {
connections.remove( con.getName() ); // TODO See #1218
connectionsByOfflineUUID.remove( con.getPendingConnection().getOfflineId() ); if ( connections.get( con.getName() ) == con )
{
connections.remove( con.getName() );
connectionsByOfflineUUID.remove( con.getPendingConnection().getOfflineId() );
}
} finally } finally
{ {
connectionLock.writeLock().unlock(); connectionLock.writeLock().unlock();
} }
} }
@Override
public Collection<String> getDisabledCommands() public Collection<String> getDisabledCommands()
{ {
return config.getDisabledCommands(); return config.getDisabledCommands();

View File

@ -379,6 +379,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
ProxiedPlayer old = bungee.getPlayer( getName() ); ProxiedPlayer old = bungee.getPlayer( getName() );
if ( old != null ) if ( old != null )
{ {
// TODO See #1218
old.disconnect( bungee.getTranslation( "already_connected" ) ); old.disconnect( bungee.getTranslation( "already_connected" ) );
} }