From c265481528208a832c5731b8da597554f2a8f693 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 18 Jan 2017 19:13:09 +0000 Subject: [PATCH] watchmaildir: limit live importer processes 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 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm index d08f2297..0b284bdb 100644 --- a/lib/PublicInbox/WatchMaildir.pm +++ b/lib/PublicInbox/WatchMaildir.pm @@ -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 { -- 2.44.0