Cleanup references on exit.

This commit is contained in:
cheatfate 2019-10-08 20:38:39 +03:00
parent e19101d287
commit 417111093e
No known key found for this signature in database
GPG Key ID: 46ADD633A7201F95
1 changed files with 3 additions and 0 deletions

View File

@ -95,6 +95,8 @@ proc tlsWriteLoop(stream: AsyncStreamWriter) {.async.} =
await future
except CancelledError:
discard
finally:
wstream.stream = nil
proc tlsReadLoop(stream: AsyncStreamReader) {.async.} =
var rstream = cast[TlsStreamReader](stream)
@ -212,6 +214,7 @@ proc tlsReadLoop(stream: AsyncStreamReader) {.async.} =
let item = wstream.queue.popFirstNoWait()
if not(item.future.finished()):
item.future.fail(rstream.error)
rstream.stream = nil
proc newTlsClientAsyncStream*(rsource: AsyncStreamReader,
wsource: AsyncStreamWriter,