]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Watch.pm
watch: IMAP and NNTP polling can use the same interval
[public-inbox.git] / lib / PublicInbox / Watch.pm
index 66b0c8b138e8fb9f1bb2a988fad5ec2888758a62..90d82d21401e0a227acb2256d9bffd0613aaa97e 100644 (file)
@@ -464,17 +464,18 @@ sub poll_fetch_fork { # DS::add_timer callback
        my ($self, $intvl, $uris) = @_;
        return if $self->{quit};
        watch_atfork_parent($self);
+       my @nntp;
+       my @imap = grep { # push() always returns > 0
+               $_->scheme =~ m!\Aimaps?!i ? 1 : (push(@nntp, $_) < 0)
+       } @$uris;
        my $seed = rand(0xffffffff);
        my $pid = fork // die "fork: $!";
        if ($pid == 0) {
                srand($seed);
                eval { Net::SSLeay::randomize() };
                watch_atfork_child($self);
-               if ($uris->[0]->scheme =~ m!\Aimaps?!i) {
-                       watch_imap_fetch_all($self, $uris);
-               } else {
-                       watch_nntp_fetch_all($self, $uris);
-               }
+               watch_imap_fetch_all($self, \@imap) if @imap;
+               watch_nntp_fetch_all($self, \@nntp) if @nntp;
                _exit(0);
        }
        $self->{pids}->{$pid} = undef;