From eb0af2b2713b1c688c79bd6ad5455d76176a2f65 Mon Sep 17 00:00:00 2001 From: Christopher Zimmermann Date: Tue, 4 Jan 2022 22:11:47 +0100 Subject: [PATCH] Remove obsolete second wakeup_paused It was introduced in d5822af9a80b745515e0988541d7a43ed9a6faba. If I understand it correctly this was done to prevent calling select without timeout while there were pending paused promises. Since now we explicitely check for this condition and call select with zero timeout (`should_block_waiting_for_io`). This extra `wakeup_paused` seems to be obsolete. --- CHANGES | 4 ++++ src/unix/lwt_main.ml | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index f57e5ca135..51bbec6f34 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,10 @@ * Fix win32_spawn leaking dev_null fd in the parent process. (#906, Antonin Décimo) * Prefer SetHandleInformation to DuplicateHandle in set_close_on_exec for sockets. DuplicateHandle mustn't be used on sockets. (#907, Antonin Décimo) +====== Misc ====== + + * Resolve paused promises only once in main loop. This lets Lwt.pause behave identical to Lwt_unix.yield.(#917, Christopher Zimmermann) + ===== 5.5.0 ===== ====== Deprecations ====== diff --git a/src/unix/lwt_main.ml b/src/unix/lwt_main.ml index 0cac449b87..17ea3c5a1a 100644 --- a/src/unix/lwt_main.ml +++ b/src/unix/lwt_main.ml @@ -26,8 +26,6 @@ let abandon_yielded_and_paused () = let run p = let rec run_loop () = - (* Fulfill paused promises now. *) - Lwt.wakeup_paused (); match Lwt.poll p with | Some x -> x @@ -40,7 +38,7 @@ let run p = Lwt.paused_count () = 0 && Lwt_sequence.is_empty yielded in Lwt_engine.iter should_block_waiting_for_io; - (* Fulfill paused promises again. *) + (* Fulfill paused promises. *) Lwt.wakeup_paused (); (* Fulfill yield promises. *)