diff options
author | Eric Wong <e@80x24.org> | 2023-10-17 23:37:59 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-10-18 20:50:30 +0000 |
commit | a4cf3bd57d17577b6dd791d4f0f8e76758d0aafe (patch) | |
tree | b15a6f5d269a9ec0e984d4e5b2cedac5f9388d1a /lib/PublicInbox/IPC.pm | |
parent | e6e098ab8ebf5eefceee10fc165e192cf6bd8e91 (diff) | |
download | public-inbox-a4cf3bd57d17577b6dd791d4f0f8e76758d0aafe.tar.gz |
This ensures we handle RNG reseeding and resetting the event loop properly in child processes after forking.
Diffstat (limited to 'lib/PublicInbox/IPC.pm')
-rw-r--r-- | lib/PublicInbox/IPC.pm | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/lib/PublicInbox/IPC.pm b/lib/PublicInbox/IPC.pm index 5964645e..3292d960 100644 --- a/lib/PublicInbox/IPC.pm +++ b/lib/PublicInbox/IPC.pm @@ -102,12 +102,8 @@ sub ipc_worker_spawn { pipe(my $r_res, my $w_res); my $sigset = $oldset // PublicInbox::DS::block_signals(); $self->ipc_atfork_prepare; - my $seed = rand(0xffffffff); - my $pid = fork; + my $pid = PublicInbox::DS::do_fork; if ($pid == 0) { - srand($seed); - eval { Net::SSLeay::randomize() }; - eval { PublicInbox::DS->Reset }; delete @$self{qw(-wq_s1 -wq_s2 -wq_workers -wq_ppid)}; $w_req = $r_res = undef; $w_res->autoflush(1); @@ -341,13 +337,9 @@ sub _wq_worker_start { my ($self, $oldset, $fields, $one, @cb_args) = @_; my ($bcast1, $bcast2); $one or socketpair($bcast1, $bcast2, AF_UNIX, SOCK_SEQPACKET, 0); - my $seed = rand(0xffffffff); - my $pid = fork; + my $pid = PublicInbox::DS::do_fork; if ($pid == 0) { - srand($seed); - eval { Net::SSLeay::randomize() }; undef $bcast1; - eval { PublicInbox::DS->Reset }; delete @$self{qw(-wq_s1 -wq_ppid)}; $self->{-wq_worker_nr} = keys %{delete($self->{-wq_workers}) // {}}; |