474936 - WebSocketSessions are not always cleaned out from openSessions

+ Calling onSessionOpen() before App.onOpen()
  This helps, as there is a race for the onSessionOpen()
  in the original behavior with short lived sockets.
  The short lived socket could handle onSessionClosed()
  before onSessionOpen() had a chance, making the close
  fail to remove the session from openSessions, and then
  the slower add occurs later, adding it into the openSession
+ Minor cleanup in IOState
This commit is contained in:
Joakim Erdfelt 2015-09-25 09:43:25 -07:00
parent 1bca608b48
commit f22fcde971
2 changed files with 11 additions and 7 deletions

View File

@ -400,12 +400,14 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Web
// confirmed close of local endpoint
notifyClose(close.getStatusCode(),close.getReason());
break;
case OPEN:
case CONNECTED:
// notify session listeners
for (SessionListener listener : sessionListeners)
{
try
{
if (LOG.isDebugEnabled())
LOG.debug("{}.onSessionOpen()", listener.getClass().getSimpleName());
listener.onSessionOpened(this);
}
catch (Throwable t)
@ -435,7 +437,7 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Web
// Connect remote
remote = new WebSocketRemoteEndpoint(connection,outgoingHandler,getBatchMode());
// Open WebSocket
websocket.openSession(this);

View File

@ -250,6 +250,9 @@ public class IOState
synchronized (this)
{
closeInfo = close;
// Turn off further output
outputAvailable = false;
boolean in = inputAvailable;
boolean out = outputAvailable;
@ -257,9 +260,7 @@ public class IOState
{
closeHandshakeSource = CloseHandshakeSource.LOCAL;
}
out = false;
outputAvailable = false;
LOG.debug("onCloseLocal(), input={}, output={}",in,out);
if (!in && !out)
@ -319,6 +320,9 @@ public class IOState
}
closeInfo = close;
// turn off further input
inputAvailable = false;
boolean in = inputAvailable;
boolean out = outputAvailable;
@ -326,8 +330,6 @@ public class IOState
{
closeHandshakeSource = CloseHandshakeSource.REMOTE;
}
in = false;
inputAvailable = false;
if (LOG.isDebugEnabled())
LOG.debug("onCloseRemote(), input={}, output={}",in,out);