]> Sergey Matveev's repositories - public-inbox.git/commitdiff
watch: make waitpid() synchronous for Maildir scans
authorEric Wong <e@yhbt.net>
Mon, 29 Jun 2020 10:34:21 +0000 (10:34 +0000)
committerEric Wong <e@yhbt.net>
Tue, 30 Jun 2020 03:05:54 +0000 (03:05 +0000)
Maildir scanning still happens in the main process.  Scanning
dozens of Maildirs is still time-consuming and monopolizes the
event loop during WatchMaildir::event_step.  This can cause
cause zombies to accumulate before Sigfd::event_step triggers
DS::reap_pids.

lib/PublicInbox/WatchMaildir.pm

index 288f64d1e6c23e1fd53dfbf1d094dff5379f734e..e3df85159e7d9af50d93c7ce3f9d7dd9b0701ef4 100644 (file)
@@ -123,9 +123,9 @@ sub new {
 
 sub _done_for_now {
        my ($self) = @_;
-       my $importers = $self->{importers};
-       foreach my $im (values %$importers) {
-               $im->done;
+       local $PublicInbox::DS::in_loop = 0; # waitpid() synchronously
+       for (values %{$self->{importers}}) {
+               $_->done if $_; # $_ may be undef during cleanup
        }
 }
 
@@ -936,6 +936,7 @@ sub fs_scan_step {
        my ($self) = @_;
        return if $self->{quit};
        my $op = shift @{$self->{ops}};
+       local $PublicInbox::DS::in_loop = 0; # waitpid() synchronously
 
        # continue existing scan
        my $max = 10;