From a49178807cb318c19082c1b970aab942acffd565 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 29 Jun 2020 10:34:21 +0000 Subject: watch: make waitpid() synchronous for Maildir scans 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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/PublicInbox/WatchMaildir.pm') diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm index 288f64d1..e3df8515 100644 --- a/lib/PublicInbox/WatchMaildir.pm +++ b/lib/PublicInbox/WatchMaildir.pm @@ -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; -- cgit v1.2.3-24-ge0c7