about summary refs log tree commit homepage
path: root/lib/PublicInbox
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-10-30 08:11:43 +0000
committerEric Wong <e@80x24.org>2021-10-30 18:34:34 +0000
commit258365e6cd56f9039b4de7723e4950563a163c8b (patch)
tree6e42ef964f792375a78116afcb7aaea8242b8601 /lib/PublicInbox
parent8fbb1e5d9430b9403679c5701e109d43ad979f3f (diff)
downloadpublic-inbox-258365e6cd56f9039b4de7723e4950563a163c8b.tar.gz
->DESTROY ordering via "exit()" calls is tricky, and dedupe
checks were causing problems.

AFAIK, this only affects users who manually enable WAL on
lei/store/ei*/over.sqlite3.  Fortunately, there is no data
corruption as a result even though "read-only" WAL requires
write permissions.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r--lib/PublicInbox/LeiToMail.pm8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm
index 90db30e5..3c5e7e59 100644
--- a/lib/PublicInbox/LeiToMail.pm
+++ b/lib/PublicInbox/LeiToMail.pm
@@ -756,6 +756,12 @@ sub ipc_atfork_child {
         $lei->_lei_atfork_child;
         $lei->{auth}->do_auth_atfork($self) if $lei->{auth};
         $SIG{__WARN__} = PublicInbox::Eml::warn_ignore_cb();
+        $self->{git} = $self->{lei}->{ale}->git;
+        $SIG{TERM} = sub { # avoid ->DESTROY ordering problems
+                my $git = delete $self->{git};
+                $git->async_wait_all if $git;
+                exit(15 + 128);
+        };
         $self->SUPER::ipc_atfork_child;
 }
 
@@ -776,7 +782,7 @@ sub write_mail { # via ->wq_io_do
         my ($self, $smsg, $eml) = @_;
         return $self->{wcb}->(undef, $smsg, $eml) if $eml;
         $smsg->{-lms_rw} = $self->{-lms_rw};
-        $self->{lei}->{ale}->git->cat_async($smsg->{blob}, \&git_to_mail,
+        $self->{git}->cat_async($smsg->{blob}, \&git_to_mail,
                                 [$self->{wcb}, $smsg]);
 }