about summary refs log tree commit homepage
path: root/lib/PublicInbox/DS.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-11-14 22:46:57 +0000
committerEric Wong <e@80x24.org>2023-11-15 08:01:46 +0000
commitbe47d4e60203f2861ade6e2a449bcdbe198c0d36 (patch)
treeb4fda1dfc126248b2f91473849de2669bdacc661 /lib/PublicInbox/DS.pm
parentaf2b7781f179f4317e35d0a247c522e026cbbb3a (diff)
downloadpublic-inbox-be47d4e60203f2861ade6e2a449bcdbe198c0d36.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/DS.pm')
-rw-r--r--lib/PublicInbox/DS.pm8
1 files changed, 5 insertions, 3 deletions
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;