Avoid adding redundant watches at initialization, and avoid
unnecessarily wake ups when no timeout is specified.
---
 lib/PublicInbox/TailNotify.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/TailNotify.pm b/lib/PublicInbox/TailNotify.pm
index a0347aa5..cbbc1041 100644
--- a/lib/PublicInbox/TailNotify.pm
+++ b/lib/PublicInbox/TailNotify.pm
@@ -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);

Reply via email to