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)

View File

@ -251,14 +251,15 @@ public class IOState
{
closeInfo = close;
// Turn off further output
outputAvailable = false;
boolean in = inputAvailable;
boolean out = outputAvailable;
if (closeHandshakeSource == CloseHandshakeSource.NONE)
{
closeHandshakeSource = CloseHandshakeSource.LOCAL;
}
out = false;
outputAvailable = false;
LOG.debug("onCloseLocal(), input={}, output={}",in,out);
@ -320,14 +321,15 @@ public class IOState
closeInfo = close;
// turn off further input
inputAvailable = false;
boolean in = inputAvailable;
boolean out = outputAvailable;
if (closeHandshakeSource == CloseHandshakeSource.NONE)
{
closeHandshakeSource = CloseHandshakeSource.REMOTE;
}
in = false;
inputAvailable = false;
if (LOG.isDebugEnabled())
LOG.debug("onCloseRemote(), input={}, output={}",in,out);