]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
tail_notify: cleanups and wakeup avoidance
authorEric Wong <e@80x24.org>
Fri, 14 Jul 2023 20:35:15 +0000 (20:35 +0000)
committerEric Wong <e@80x24.org>
Sat, 15 Jul 2023 21:32:27 +0000 (21:32 +0000)
Avoid adding redundant watches at initialization, and avoid
unnecessarily wake ups when no timeout is specified.

lib/PublicInbox/TailNotify.pm

index a0347aa5f45e0631a06e5b073a54a4912c57bec7..cbbc1041d3326964d324f64d49254a48efa50ad8 100644 (file)
@@ -43,7 +43,6 @@ sub new {
        } else {
                $self->{inot} = PublicInbox::FakeInotify->new;
        }
-       $self->{inot}->watch($fn, $TAIL_MOD);
        reopen_file($self);
        $self->{inot}->watch($fn, $TAIL_MOD);
        $self;
@@ -64,6 +63,8 @@ again:
                        if (defined $end) {
                                $wait = $end - now;
                                $wait = 0 if $wait < 0;
+                       } else {
+                               undef $wait;
                        }
                }
                select($rfds, undef, undef, $wait);