From 2f3d5f74f7083d0d8ff3f345df5ac03ed03cca75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20=C3=89LIE?= Date: Sat, 20 Jan 2024 22:54:42 +0100 Subject: [PATCH] delayer: Handle drained queue properly If the queue runs empty, there are several warnings about uninitialized values. Rewrite the queue handling to avoid duplicate checks. Thanks to Christoph Biedl for the patch. --- backends/delayer.in | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/backends/delayer.in b/backends/delayer.in index e44d569ab..e0bca6cf9 100644 --- a/backends/delayer.in +++ b/backends/delayer.in @@ -73,18 +73,16 @@ while (1) { push(@queue, "$exp:$line"); } - if ($#queue < 0) { - undef $timeout; - next; - } - - my ($first, $line) = split(/:/, $queue[0], 2); - while ($#queue >= 0 && $first <= $now) { + undef $timeout; + while (@queue) { + my ($first, $line) = split(/:/, $queue[0], 2); + if ($first > $now) { + $timeout = $first - $now; + last; + } print OUT $line; shift(@queue); - ($first, $line) = split(/:/, $queue[0], 2); } - $timeout = $first - $now; } __END__ @@ -244,9 +242,9 @@ with some I parameters. =head1 BUGS -If the standard input is closed (when for instance the feed is closed), all -lines in the store are printed immediately, breaking the contract of delaying -them, unless the B<--store> option is used. +If the standard input is closed (when for instance the feed is closed or +restarted), all lines in the store are printed immediately, breaking the +contract of delaying them, unless the B<--store> option is used. If the number of articles in that feed is rather low (just a few articles per delay time or less), some effects of buffering will delay the transmission