Skip to content

Commit

Permalink
Issue #4907 - moved to close state if any close frame is received
Browse files Browse the repository at this point in the history
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
  • Loading branch information
lachlan-roberts committed May 27, 2020
1 parent d8fb116 commit 277561e
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,16 @@ public void onFrame(Frame frame, Callback callback)
}
}

// 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)
{
Expand Down Expand Up @@ -237,7 +247,7 @@ public void onFrame(Frame frame, Callback callback)
callback::failed
);

switch (frame.getOpCode())
switch (opCode)
{
case OpCode.CLOSE:
onCloseFrame(frame, callback);
Expand Down Expand Up @@ -313,15 +323,6 @@ private void notifyOnClose(CloseStatus closeStatus, Callback callback)
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)
Expand Down

0 comments on commit 277561e

Please sign in to comment.