Fix mutual closing (#76)

* add mutual closing test

* fix mutual closing
This commit is contained in:
Tanguy Cizain 2021-06-28 14:52:18 +02:00 committed by GitHub
parent 2ee209af39
commit 781cb35200
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -456,6 +456,23 @@ suite "Test Closing":
await session.close()
check session.readyState == ReadyState.Closed
test "Mutual closing":
proc handle(request: HttpRequest) {.async.} =
check request.uri.path == WSPath
let server = WSServer.new(protos = ["proto"])
let ws = await server.handleRequest(request)
await ws.close()
server = createServer(
address = address,
handler = handle,
flags = {ReuseAddr})
let session = await connectClient()
await session.close()
await waitForClose(session)
check session.readyState == ReadyState.Closed
test "Server closing with valid close code 3999":
proc handle(request: HttpRequest) {.async.} =
check request.uri.path == WSPath

View File

@ -145,7 +145,7 @@ proc handleClose*(
trace "Handling close"
if ws.readyState != ReadyState.Open:
if ws.readyState != ReadyState.Open and ws.readyState != ReadyState.Closing:
trace "Connection isn't open, aborting close sequence!"
return