]> Sergey Matveev's repositories - public-inbox.git/commitdiff
watchmaildir: limit live importer processes
authorEric Wong <e@80x24.org>
Wed, 18 Jan 2017 19:13:09 +0000 (19:13 +0000)
committerEric Wong <e@80x24.org>
Thu, 19 Jan 2017 02:11:31 +0000 (02:11 +0000)
We don't want to be triggering OOM or swapping on weaker
systems when we have dozens of inboxes as potential targets.

lib/PublicInbox/WatchMaildir.pm

index d08f2297af159b9d3b18aa1ab1152bc3d671b965..0b284bdba41bc5dcf0de46e0f8711a3f679ba3ea 100644 (file)
@@ -224,7 +224,14 @@ sub _importer_for {
                my $addr = $inbox->{-primary_address};
                PublicInbox::Import->new($git, $name, $addr, $inbox);
        };
-       $self->{importers}->{"$im"} = $im;
+
+       my $importers = $self->{importers};
+       if (scalar(keys(%$importers)) > 2) {
+               delete $importers->{"$im"};
+               _done_for_now($self);
+       }
+
+       $importers->{"$im"} = $im;
 }
 
 sub _scrubber_for {