Issue #4907 - moved to close state if any close frame is received

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2020-05-27 10:10:12 +10:00
parent d8fb116e12
commit 277561e48b
1 changed files with 11 additions and 10 deletions

View File

@ -206,6 +206,16 @@ public class JettyWebSocketFrameHandler implements FrameHandler
}
}
// If we have received a close frame, set state to closed to disallow suspends and resumes.
byte opCode = frame.getOpCode();
if (opCode == OpCode.CLOSE)
{
synchronized (this)
{
state = SuspendState.CLOSED;
}
}
// Send to raw frame handling on user side (eg: WebSocketFrameListener)
if (frameHandle != null)
{
@ -237,7 +247,7 @@ public class JettyWebSocketFrameHandler implements FrameHandler
callback::failed
);
switch (frame.getOpCode())
switch (opCode)
{
case OpCode.CLOSE:
onCloseFrame(frame, callback);
@ -313,15 +323,6 @@ public class JettyWebSocketFrameHandler implements FrameHandler
return;
}
// If we have received the final close frame set state to closed to disallow suspends and resumes.
if (!session.getCoreSession().isOutputOpen())
{
synchronized (this)
{
state = SuspendState.CLOSED;
}
}
try
{
if (closeHandle != null)