Add atomic close tracking. Closes #370.
This commit is contained in:
parent
9be44d51a6
commit
2c225a05e7
@ -31,7 +31,7 @@ public class ServerConnection implements Server
|
|||||||
@Override
|
@Override
|
||||||
public synchronized void disconnect(String reason)
|
public synchronized void disconnect(String reason)
|
||||||
{
|
{
|
||||||
if ( ch.getHandle().isActive() )
|
if ( !ch.isClosed() )
|
||||||
{
|
{
|
||||||
ch.write( new PacketFFKick( reason ) );
|
ch.write( new PacketFFKick( reason ) );
|
||||||
ch.getHandle().eventLoop().schedule( new Runnable()
|
ch.getHandle().eventLoop().schedule( new Runnable()
|
||||||
|
@ -114,7 +114,7 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean isActive()
|
public boolean isActive()
|
||||||
{
|
{
|
||||||
return ch.getHandle().isActive();
|
return !ch.isClosed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -262,10 +262,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
@Override
|
@Override
|
||||||
public synchronized void disconnect(String reason)
|
public synchronized void disconnect(String reason)
|
||||||
{
|
{
|
||||||
if ( ch.getHandle().isActive() )
|
if ( !ch.isClosed() )
|
||||||
{
|
{
|
||||||
ch.write( new PacketFFKick( reason ) );
|
ch.write( new PacketFFKick( reason ) );
|
||||||
ch.getHandle().close();
|
ch.close();
|
||||||
disconnected = true;
|
disconnected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package net.md_5.bungee.netty;
|
package net.md_5.bungee.netty;
|
||||||
|
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
public class ChannelWrapper
|
public class ChannelWrapper
|
||||||
{
|
{
|
||||||
|
|
||||||
private final Channel ch;
|
private final Channel ch;
|
||||||
|
@Getter
|
||||||
|
private volatile boolean closed;
|
||||||
|
|
||||||
public ChannelWrapper(Channel ch)
|
public ChannelWrapper(Channel ch)
|
||||||
{
|
{
|
||||||
@ -14,7 +17,19 @@ public class ChannelWrapper
|
|||||||
|
|
||||||
public void write(Object packet)
|
public void write(Object packet)
|
||||||
{
|
{
|
||||||
ch.write( packet, ch.voidPromise() );
|
if ( !closed )
|
||||||
|
{
|
||||||
|
ch.write( packet, ch.voidPromise() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close()
|
||||||
|
{
|
||||||
|
if ( !closed )
|
||||||
|
{
|
||||||
|
closed = true;
|
||||||
|
ch.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Channel getHandle()
|
public Channel getHandle()
|
||||||
|
Loading…
Reference in New Issue
Block a user