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/Watch.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/Watch.pm')
-rw-r--r-- | lib/PublicInbox/Watch.pm | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/lib/PublicInbox/Watch.pm b/lib/PublicInbox/Watch.pm index 3426d4a7..41b77dc1 100644 --- a/lib/PublicInbox/Watch.pm +++ b/lib/PublicInbox/Watch.pm @@ -385,7 +385,6 @@ sub watch_atfork_child ($) { my ($self) = @_; delete $self->{pids}; delete $self->{opendirs}; - PublicInbox::DS->Reset; my $sig = delete $self->{sig}; $sig->{CHLD} = $sig->{HUP} = $sig->{USR1} = 'DEFAULT'; # TERM/QUIT/INT call ->quit, which works in both parent+child @@ -413,11 +412,8 @@ sub imap_idle_reap { # awaitpid callback sub imap_idle_fork { my ($self, $uri, $intvl) = @_; return if $self->{quit}; - my $seed = rand(0xffffffff); - my $pid = fork // die "fork: $!"; + my $pid = PublicInbox::DS::do_fork; if ($pid == 0) { - srand($seed); - eval { Net::SSLeay::randomize() }; watch_atfork_child($self); watch_imap_idle_1($self, $uri, $intvl); _exit(0); @@ -477,11 +473,8 @@ sub poll_fetch_fork { # DS::add_timer callback my @imap = grep { # push() always returns > 0 $_->scheme =~ m!\Aimaps?!i ? 1 : (push(@nntp, $_) < 0) } @$uris; - my $seed = rand(0xffffffff); - my $pid = fork // die "fork: $!"; + my $pid = PublicInbox::DS::do_fork; if ($pid == 0) { - srand($seed); - eval { Net::SSLeay::randomize() }; watch_atfork_child($self); watch_imap_fetch_all($self, \@imap) if @imap; watch_nntp_fetch_all($self, \@nntp) if @nntp; |