[#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

@ -602,15 +602,20 @@ public class BungeeCord extends ProxyServer
{ {
connectionLock.writeLock().lock(); connectionLock.writeLock().lock();
try try
{
// TODO See #1218
if ( connections.get( con.getName() ) == con )
{ {
connections.remove( con.getName() ); connections.remove( con.getName() );
connectionsByOfflineUUID.remove( con.getPendingConnection().getOfflineId() ); 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" ) );
} }