Skip to content

Commit

Permalink
Check closure before performing another one
Browse files Browse the repository at this point in the history
  • Loading branch information
losizm committed Jul 19, 2020
1 parent 9feda79 commit e647296
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/main/scala/scamper/websocket/WebSocketSessionImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private[scamper] class WebSocketSessionImpl(val id: String, val target: Uri, val
Try(doClose(statusCode.toData))

try
if (statusCode != NoStatusReceived && statusCode != AbnormalClosure && statusCode != TlsHandshake)
if (!statusCode.reserved)
conn.write(makeFrame(statusCode.toData, Close))
catch {
case err: Exception => if (!closeReceived.get) doError(err)
Expand Down Expand Up @@ -214,15 +214,11 @@ private[scamper] class WebSocketSessionImpl(val id: String, val target: Uri, val
case _: SocketTimeoutException =>
close(GoingAway)

case err: SocketException =>
case err =>
if (!closeSent.get()) {
doError(err)
close(AbnormalClosure)
}

case err =>
doError(err)
close(AbnormalClosure)
}

private def doText(data: Array[Byte], last: Boolean): Unit =
Expand Down

0 comments on commit e647296

Please sign in to comment.