From be47d4e60203f2861ade6e2a449bcdbe198c0d36 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 14 Nov 2023 22:46:57 +0000 Subject: 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. --- lib/PublicInbox/DS.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/PublicInbox/DS.pm') diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index da26efc4..4c8b502f 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; -- cgit v1.2.3-24-ge0c7