View | Details | Raw Unified | Return to bug 6745
Collapse All | Expand All

(-)spamd/spamd.raw (-13 / +22 lines)
Lines 589-594 Link Here
589
my $timeout_child;        # processing timeout (headers->finish), 0=no timeout
589
my $timeout_child;        # processing timeout (headers->finish), 0=no timeout
590
my $clients_per_child;    # number of clients each child should process
590
my $clients_per_child;    # number of clients each child should process
591
my %children;             # current children
591
my %children;             # current children
592
my @children_exited;
592
593
593
if ( defined $opt{'max-children'} ) {
594
if ( defined $opt{'max-children'} ) {
594
  $childlimit = $opt{'max-children'};
595
  $childlimit = $opt{'max-children'};
Lines 1033-1038 Link Here
1033
# child_handler()  if !$scaling || am_running_on_windows();
1034
# child_handler()  if !$scaling || am_running_on_windows();
1034
  child_handler();  # it doesn't hurt to call child_handler unconditionally
1035
  child_handler();  # it doesn't hurt to call child_handler unconditionally
1035
1036
1037
  child_cleaner();
1038
1036
  do_sighup_restart()  if defined $got_sighup;
1039
  do_sighup_restart()  if defined $got_sighup;
1037
1040
1038
  for (my $i = keys %children; $i < $childlimit; $i++) {
1041
  for (my $i = keys %children; $i < $childlimit; $i++) {
Lines 2534-2546 Link Here
2534
    #
2537
    #
2535
    my $pid = waitpid(-1, WNOHANG);
2538
    my $pid = waitpid(-1, WNOHANG);
2536
    last if !$pid || $pid == -1;
2539
    last if !$pid || $pid == -1;
2537
    my $child_stat = $?;
2540
    push(@children_exited, [$pid, $?, $sig, time]);
2541
  }
2538
2542
2539
    if (!defined $children{$pid}) {
2543
  $SIG{CHLD} = \&child_handler;    # reset as necessary, should be at end
2540
      # ignore this child; we didn't realise we'd forked it. bug 4237
2544
}
2541
      next;
2542
    }
2543
2545
2546
# takes care of dead children, as noted by a child_handler()
2547
# called in a main program flow (not from a signal handler)
2548
#
2549
sub child_cleaner {
2550
  while (@children_exited) {
2551
    my $tuple = shift(@children_exited);
2552
    next if !$tuple;  # just in case
2553
    my($pid, $child_stat, $sig, $timestamp) = @$tuple;
2554
2555
    # ignore this child if we didn't realise we'd forked it. bug 4237
2556
    next if !defined $children{$pid};
2557
2544
    # remove them from our child listing
2558
    # remove them from our child listing
2545
    delete $children{$pid};
2559
    delete $children{$pid};
2546
2560
Lines 2550-2564 Link Here
2550
      my $sock = $backchannel->get_socket_for_child($pid);
2564
      my $sock = $backchannel->get_socket_for_child($pid);
2551
      if ($sock) { $sock->close(); }
2565
      if ($sock) { $sock->close(); }
2552
    }
2566
    }
2553
2567
    info("spamd: handled cleanup of child pid [%s]%s: %s",
2554
    unless ($Mail::SpamAssassin::Logger::LOG_SA{INHIBIT_LOGGING_IN_SIGCHLD_HANDLER}) {
2568
         $pid, (defined $sig ? " due to SIG$sig" : ""),
2555
      info("spamd: handled cleanup of child pid [%s]%s: %s",
2569
         exit_status_str($child_stat,0));
2556
           $pid, (defined $sig ? " due to SIG$sig" : ""),
2557
           exit_status_str($child_stat,0));
2558
    }
2559
  }
2570
  }
2560
2561
  $SIG{CHLD} = \&child_handler;    # reset as necessary, should be at end
2562
}
2571
}
2563
2572
2564
sub restart_handler {
2573
sub restart_handler {

Return to bug 6745