From: Eric Wong Date: Tue, 14 Nov 2023 22:46:57 +0000 (+0000) Subject: ds: run @post_loop_do if any user-queued events run X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be47d4e60203f2861ade6e2a449bcdbe198c0d36;p=thirdparty%2Fpublic-inbox.git ds: run @post_loop_do if any user-queued events run This ensures we can notice shutdown events in one-shot scripts like -cindex (and eventually -clone/-fetch/-compact) without forcing another real event to fire. --- diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index da26efc43..4c8b502f4 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -144,13 +144,14 @@ sub next_tick () { # https://rt.perl.org/Public/Bug/Display.html?id=114340 blessed($obj) ? $obj->event_step : $obj->(); } + 1; } # runs timers and returns milliseconds for next one, or next event loop sub RunTimers { - next_tick(); + my $ran = next_tick(); - return ($nextq ? 0 : $loop_timeout) unless @Timers; + return ($nextq || $ran ? 0 : $loop_timeout) unless @Timers; my $now = now(); @@ -159,10 +160,11 @@ sub RunTimers { my $to_run = shift(@Timers); delete $UniqTimer{$to_run->[1] // ''}; $to_run->[2]->(@$to_run[3..$#$to_run]); + $ran = 1; } # timers may enqueue into nextq: - return 0 if $nextq; + return 0 if $nextq || $ran; return $loop_timeout unless @Timers;