This fixes cases where watch is handling both Maildirs and IMAP
connections. While we're at it, close open directories in the
IMAP children to save FDs.
my ($self) = @_;
delete $self->{idle_pids};
delete $self->{poll_pids};
my ($self) = @_;
delete $self->{idle_pids};
delete $self->{poll_pids};
+ delete $self->{opendirs};
PublicInbox::DS->Reset;
PublicInbox::Sigfd::sig_setmask($self->{oldset});
%SIG = (%SIG, %{$self->{sig}});
}
PublicInbox::DS->Reset;
PublicInbox::Sigfd::sig_setmask($self->{oldset});
%SIG = (%SIG, %{$self->{sig}});
}
+sub watch_atfork_parent ($) {
+ my ($self) = @_;
+ _done_for_now($self);
+ $self->{mics} = {}; # going to be forking, so disconnect
+}
+
sub imap_idle_reap { # PublicInbox::DS::dwaitpid callback
my ($self, $pid) = @_;
my $uri_intvl = delete $self->{idle_pids}->{$pid} or
sub imap_idle_reap { # PublicInbox::DS::dwaitpid callback
my ($self, $pid) = @_;
my $uri_intvl = delete $self->{idle_pids}->{$pid} or
return if $self->{quit};
my $idle_todo = $self->{idle_todo};
if ($idle_todo && @$idle_todo) {
return if $self->{quit};
my $idle_todo = $self->{idle_todo};
if ($idle_todo && @$idle_todo) {
- $self->{mics} = {}; # going to be forking, so disconnect
+ watch_atfork_parent($self);
while (my $uri_intvl = shift(@$idle_todo)) {
imap_idle_fork($self, $uri_intvl);
}
while (my $uri_intvl = shift(@$idle_todo)) {
imap_idle_fork($self, $uri_intvl);
}
sub imap_fetch_fork ($$$) {
my ($self, $intvl, $uris) = @_;
return if $self->{quit};
sub imap_fetch_fork ($$$) {
my ($self, $intvl, $uris) = @_;
return if $self->{quit};
- $self->{mics} = {}; # going to be forking, so disconnect
+ watch_atfork_parent($self);
defined(my $pid = fork) or die "fork: $!";
if ($pid == 0) {
watch_atfork_child($self);
defined(my $pid = fork) or die "fork: $!";
if ($pid == 0) {
watch_atfork_child($self);