]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
ds: run @post_loop_do if any user-queued events run
authorEric Wong <e@80x24.org>
Tue, 14 Nov 2023 22:46:57 +0000 (22:46 +0000)
committerEric Wong <e@80x24.org>
Wed, 15 Nov 2023 08:01:46 +0000 (08:01 +0000)
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

index da26efc4368309a34278cb596320ca29249b4a1b..4c8b502f484d8a93d74579f833e87f0cc9b0138e 100644 (file)
@@ -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;