diff options
author | Eric Wong <e@80x24.org> | 2019-01-05 10:41:15 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-01-05 10:41:15 +0000 |
commit | 97c6b564fd79e47ae6fca8de273c2aeaf2f5bea5 (patch) | |
tree | b6f2433ceafc18e00ff6dab20eca02352deb833e /lib/PublicInbox/InboxWritable.pm | |
parent | 847c0309da7af8a16935f92bb1965f6a1ba538e7 (diff) | |
download | public-inbox-97c6b564fd79e47ae6fca8de273c2aeaf2f5bea5.tar.gz |
Clearly the AltId stuff was never tested for v2. Ensure this tricky filter (which reuses Msgmap to avoid introducing new serial numbers) doesn't trigger deadlocks SQLite due to opening a DB for writing multiple times. I went through several iterations of this change before going with this one, which is the least intrusive I could fine.
Diffstat (limited to 'lib/PublicInbox/InboxWritable.pm')
-rw-r--r-- | lib/PublicInbox/InboxWritable.pm | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/PublicInbox/InboxWritable.pm b/lib/PublicInbox/InboxWritable.pm index 87c9ada9..2f1ca6f0 100644 --- a/lib/PublicInbox/InboxWritable.pm +++ b/lib/PublicInbox/InboxWritable.pm @@ -46,9 +46,16 @@ sub importer { } sub filter { - my ($self) = @_; + my ($self, $im) = @_; my $f = $self->{filter}; if ($f && $f =~ /::/) { + # v2 keeps msgmap open, which causes conflicts for filters + # such as PublicInbox::Filter::RubyLang which overload msgmap + # for a predictable serial number. + if ($im && ($self->{version} || 1) >= 2 && $self->{altid}) { + $im->done; + } + my @args = (-inbox => $self); # basic line splitting, only # Perhaps we can have proper quote splitting one day... @@ -100,7 +107,7 @@ sub maildir_path_load ($) { sub import_maildir { my ($self, $dir) = @_; my $im = $self->importer(1); - my $filter = $self->filter; + foreach my $sub (qw(cur new tmp)) { -d "$dir/$sub" or die "$dir is not a Maildir (missing $sub)\n"; } @@ -109,7 +116,8 @@ sub import_maildir { while (defined(my $fn = readdir($dh))) { next unless is_maildir_basename($fn); my $mime = maildir_file_load("$dir/$fn") or next; - if ($filter) { + + if (my $filter = $self->filter($im)) { my $ret = $filter->scrub($mime) or return; return if $ret == REJECT(); $mime = $ret; |