Assertion and bugfix. (#397)

This commit is contained in:
Eugene Kabanov 2023-05-30 18:45:16 +03:00 committed by GitHub
parent 36ab9c8e4a
commit 6523f741a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -222,6 +222,7 @@ proc finish(fut: FutureBase, state: FutureState) =
# 1. `finish()` is a private procedure and `state` is under our control.
# 2. `fut.state` is checked by `checkFinished()`.
fut.state = state
doAssert fut.cancelcb == nil or state != FutureState.Cancelled
fut.cancelcb = nil # release cancellation callback memory
for item in fut.callbacks.mitems():
if not(isNil(item.function)):

View File

@ -961,7 +961,7 @@ proc join*(rw: AsyncStreamRW): Future[void] =
if not(rw.future.finished()):
rw.future.addCallback(continuation, cast[pointer](retFuture))
rw.future.cancelCallback = cancellation
retFuture.cancelCallback = cancellation
else:
retFuture.complete()