mirror of
https://github.com/status-im/nim-chronos.git
synced 2025-01-18 23:31:13 +00:00
Fix possible race condition in asyncstream close (#91)
This commit is contained in:
parent
3d745a4b0c
commit
9ea1017a06
@ -768,10 +768,11 @@ proc close*(rw: AsyncStreamRW) =
|
||||
if rw.closed():
|
||||
raise newAsyncStreamIncorrectError("Stream is already closed!")
|
||||
|
||||
rw.state = AsyncStreamState.Closed
|
||||
|
||||
proc continuation(udata: pointer) =
|
||||
if not isNil(rw.udata):
|
||||
GC_unref(cast[ref int](rw.udata))
|
||||
rw.state = AsyncStreamState.Closed
|
||||
if not(rw.future.finished()):
|
||||
rw.future.complete()
|
||||
when rw is AsyncStreamReader:
|
||||
|
Loading…
x
Reference in New Issue
Block a user