Attempt to synchronize the state for vanilla client completions and quit the handler if the vanilla
thread has already setup the connection. Should fix #1924
This commit is contained in:
parent
ee1e229b66
commit
b35aec4347
1 changed files with 11 additions and 2 deletions
|
@ -159,6 +159,11 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
|
||||||
@Override
|
@Override
|
||||||
public void handlerAdded(ChannelHandlerContext ctx) throws Exception
|
public void handlerAdded(ChannelHandlerContext ctx) throws Exception
|
||||||
{
|
{
|
||||||
|
if (this.state != null) {
|
||||||
|
FMLLog.getLogger().log(Level.INFO, "Opening channel which already seems to have a state set. This is a vanilla connection. Handshake handler will stop now");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FMLLog.getLogger().log(Level.TRACE, "Handshake channel activating");
|
||||||
this.state = ConnectionState.OPENING;
|
this.state = ConnectionState.OPENING;
|
||||||
// send ourselves as a user event, to kick the pipeline active
|
// send ourselves as a user event, to kick the pipeline active
|
||||||
this.handshakeChannel.pipeline().fireUserEventTriggered(this);
|
this.handshakeChannel.pipeline().fireUserEventTriggered(this);
|
||||||
|
@ -218,7 +223,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
|
||||||
FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ClientConnectedToServerEvent(manager, this.connectionType.name()));
|
FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ClientConnectedToServerEvent(manager, this.connectionType.name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void completeServerSideConnection(ConnectionType type)
|
private synchronized void completeServerSideConnection(ConnectionType type)
|
||||||
{
|
{
|
||||||
this.connectionType = type;
|
this.connectionType = type;
|
||||||
FMLLog.info("[%s] Server side %s connection established", Thread.currentThread().getName(), this.connectionType.name().toLowerCase(Locale.ENGLISH));
|
FMLLog.info("[%s] Server side %s connection established", Thread.currentThread().getName(), this.connectionType.name().toLowerCase(Locale.ENGLISH));
|
||||||
|
@ -381,7 +386,11 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
|
||||||
{
|
{
|
||||||
if (state == ConnectionState.AWAITING_HANDSHAKE)
|
if (state == ConnectionState.AWAITING_HANDSHAKE)
|
||||||
{
|
{
|
||||||
state = ConnectionState.HANDSHAKING;
|
synchronized (this) { // guard from other threads changing the state on us
|
||||||
|
if (state == ConnectionState.AWAITING_HANDSHAKE) {
|
||||||
|
state = ConnectionState.HANDSHAKING;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String channelName = msg.getChannelName();
|
String channelName = msg.getChannelName();
|
||||||
if ("FML|HS".equals(channelName) || "REGISTER".equals(channelName) || "UNREGISTER".equals(channelName))
|
if ("FML|HS".equals(channelName) || "REGISTER".equals(channelName) || "UNREGISTER".equals(channelName))
|
||||||
|
|
Loading…
Reference in a new issue