From 94f939f899661d619f0c0dcf4f07fc594c3e3e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B5ivo=20Leedj=C3=A4rv?= Date: Sun, 31 Mar 2024 19:13:13 +0200 Subject: [PATCH] Fix update propagation stop request not working --- src/transport.ml | 1 - src/uicommon.ml | 10 ++++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/transport.ml b/src/transport.ml index 533c6648b..6d0a6e38f 100644 --- a/src/transport.ml +++ b/src/transport.ml @@ -55,7 +55,6 @@ let maxThreads () = let run dispenseTask = let runConcurrent limit dispenseTask = - let dispenseTask () = if Abort.isAll () then None else dispenseTask () in let avail = ref limit in let rec runTask thr = Lwt.try_bind thr diff --git a/src/uicommon.ml b/src/uicommon.ml index ee546ecf0..6dd6a4067 100644 --- a/src/uicommon.ml +++ b/src/uicommon.ml @@ -649,12 +649,15 @@ let transportStart () = Transport.logStart () let transportFinish () = Transport.logFinish () let transportItems items pRiThisRound makeAction = + if Abort.isAll () then () else let waiter = Lwt.wait () in let outstanding = ref 0 in let starting () = incr outstanding in let completed () = decr outstanding; - if !outstanding = 0 then begin + if !outstanding = 0 || (!outstanding = 1 && Abort.isAll ()) then begin + (* If there is a stop request then we might not get the [completed] + notice for the dispense loop itself, so we also stop at count 1. *) try Lwt.wakeup waiter () with Invalid_argument _ -> () end in @@ -682,7 +685,10 @@ let transportItems items pRiThisRound makeAction = in let rec dispenseAction () = let i = !idx in - if i < im then begin + if Abort.isAll () then begin + stopDispense (); + dispenseDone () + end else if i < im then begin let item = items.(i) in incr idx; if pRiThisRound item then