]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
xap_helper.pm: use do_fork to Reset and reseed
authorEric Wong <e@80x24.org>
Thu, 2 Nov 2023 09:35:26 +0000 (09:35 +0000)
committerEric Wong <e@80x24.org>
Thu, 2 Nov 2023 23:46:51 +0000 (23:46 +0000)
We may start using rand() in the worker someday if we need
to seed a hash function for caching.  It saves us some LoC
in the meantime.

lib/PublicInbox/XapHelper.pm

index f7640f4c94842321896d37f17b637f8cefd1f2c7..41c66a121b49097ae83ea0a1e211094692bf2f8d 100644 (file)
@@ -216,14 +216,9 @@ sub reap_worker { # awaitpid CB
 
 sub start_worker ($) {
        my ($nr) = @_;
-       my $pid = fork;
-       if (!defined($pid)) {
-               warn("fork: $!");
-               return undef;
-       };
+       my $pid = eval { PublicInbox::DS::do_fork } // return(warn($@));
        if ($pid == 0) {
                undef %WORKERS;
-               PublicInbox::DS::Reset();
                $SIG{TTIN} = $SIG{TTOU} = 'IGNORE';
                $SIG{CHLD} = 'DEFAULT'; # Xapian may use this
                recv_loop();