From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 6A3C11F8DF for ; Mon, 29 Jun 2020 10:34:25 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 5/5] watch: make waitpid() synchronous for Maildir scans Date: Mon, 29 Jun 2020 10:34:21 +0000 Message-Id: <20200629103421.31016-6-e@yhbt.net> In-Reply-To: <20200629103421.31016-1-e@yhbt.net> References: <20200629103421.31016-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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(-) diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm index 288f64d1e6c..d147962994e 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() synchronlusly + 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() synchronlusly # continue existing scan my $max = 10;