When REAPER is called by SIGCHLD, it can start in the middle of the loop

over values %childstatus in the MAXCONNIP block.  This can cause $rip to be
deleted by REAPER while we're using it.  Perl will die saying "Use of freed
value in iteration".
 -- brian@SoftHome.net


git-svn-id: https://svn.perl.org/qpsmtpd/trunk@286 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Matt Sergeant 2004-08-09 08:13:26 +00:00
parent cbb7b5dba3
commit dae911cec8

View File

@ -114,7 +114,11 @@ while (1) {
my ($port, $iaddr) = sockaddr_in($hisaddr); my ($port, $iaddr) = sockaddr_in($hisaddr);
if ($MAXCONNIP) { if ($MAXCONNIP) {
my $num_conn = 0; my $num_conn = 0;
foreach my $rip (values %childstatus) { # If we for-loop directly over values %childstatus, a SIGCHLD can call
# REAPER and slip $rip out from under us. Causes "Use of freed value in
# iteration" under perl 5.8.4.
my @rip = values %childstatus;
foreach my $rip (@rip) {
if ($rip eq $iaddr) { if ($rip eq $iaddr) {
++$num_conn; ++$num_conn;
} }