From dae911cec848345785365a94fc70d743254e70ee Mon Sep 17 00:00:00 2001 From: Matt Sergeant Date: Mon, 9 Aug 2004 08:13:26 +0000 Subject: [PATCH] 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 --- qpsmtpd-forkserver | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qpsmtpd-forkserver b/qpsmtpd-forkserver index 89538a1..282a3cd 100755 --- a/qpsmtpd-forkserver +++ b/qpsmtpd-forkserver @@ -114,7 +114,11 @@ while (1) { my ($port, $iaddr) = sockaddr_in($hisaddr); if ($MAXCONNIP) { 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) { ++$num_conn; }