Skip to content

Commit

Permalink
delayer: Handle drained queue properly
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Julien-Elie committed Jan 20, 2024
1 parent 976df9a commit 2f3d5f7
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions backends/delayer.in
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down Expand Up @@ -244,9 +242,9 @@ with some I<args> 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
Expand Down

0 comments on commit 2f3d5f7

Please sign in to comment.