From 6523f741a65b27d3973df9a68771447e53bf8ee2 Mon Sep 17 00:00:00 2001 From: Eugene Kabanov Date: Tue, 30 May 2023 18:45:16 +0300 Subject: [PATCH] Assertion and bugfix. (#397) --- chronos/asyncfutures2.nim | 1 + chronos/streams/asyncstream.nim | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/chronos/asyncfutures2.nim b/chronos/asyncfutures2.nim index b575a1f..9a9879c 100644 --- a/chronos/asyncfutures2.nim +++ b/chronos/asyncfutures2.nim @@ -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)): diff --git a/chronos/streams/asyncstream.nim b/chronos/streams/asyncstream.nim index 6abb019..931453d 100644 --- a/chronos/streams/asyncstream.nim +++ b/chronos/streams/asyncstream.nim @@ -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()