]> Sergey Matveev's repositories - public-inbox.git/commitdiff
inboxidle: warn on inotify_add_watch failures
authorEric Wong <e@yhbt.net>
Mon, 6 Jul 2020 04:20:12 +0000 (04:20 +0000)
committerEric Wong <e@yhbt.net>
Mon, 6 Jul 2020 08:21:35 +0000 (08:21 +0000)
inotify_add_watch(2), open(2), stat(2) may all fail due to
permissions errors, especially when running -nntpd/-imapd
as `nobody' as recommended.

lib/PublicInbox/InboxIdle.pm

index bdb30284ac09b77b5bba5195514abc5458bada36..0cdd2e2a8e56df7a54103d5a6592c6dea06822bb 100644 (file)
@@ -41,8 +41,11 @@ sub in2_arm ($$) { # PublicInbox::Config::each_inbox callback
        $cur->[0] = $ibx;
 
        my $lock = "$dir/".($ibx->version >= 2 ? 'inbox.lock' : 'ssoma.lock');
-       my $w = $cur->[1] = $inot->watch($lock, $IN_MODIFY);
-       $self->{on_unlock}->{$w->name} = $ibx;
+       if (my $w = $cur->[1] = $inot->watch($lock, $IN_MODIFY)) {
+               $self->{on_unlock}->{$w->name} = $ibx;
+       } else {
+               warn "E: ".ref($inot)."->watch($lock, IN_MODIFY) failed: $!\n";
+       }
 
        # TODO: detect deleted packs (and possibly other files)
 }