From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: 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.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 05DA8207D2 for ; Mon, 26 Jun 2017 17:45:26 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] watch: avoid potential race condition while quitting Date: Mon, 26 Jun 2017 17:45:25 +0000 Message-Id: <20170626174525.2979-1-e@80x24.org> List-Id: We must not trigger future activity when initializing a -watch shutdown. --- lib/PublicInbox/WatchMaildir.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm index 8e10e43..5ae3d21 100644 --- a/lib/PublicInbox/WatchMaildir.pm +++ b/lib/PublicInbox/WatchMaildir.pm @@ -225,7 +225,7 @@ sub watch { sub trigger_scan { my ($self, $base) = @_; - my $dir = $self->{scandir} or die "not watch-ing, yet\n"; + my $dir = $self->{scandir} or return; open my $fh, '>', "$dir/$base" or die "open $dir/$base failed: $!\n"; close $fh or die "close $dir/$base failed: $!\n"; } @@ -235,6 +235,7 @@ sub scan { if ($path =~ /quit\z/) { %{$self->{opendirs}} = (); _done_for_now($self); + delete $self->{scandir}; $self->{quit} = 1; return; } -- EW