slight cleanup

git-svn-id: https://svn.perl.org/qpsmtpd/trunk@287 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Robert Spier 2004-08-09 15:40:56 +00:00
parent dae911cec8
commit 1eefd49c22

View File

@ -113,17 +113,16 @@ 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 = 1; # seed with current value
# 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 # If we for-loop directly over values %childstatus, a SIGCHLD
# iteration" under perl 5.8.4. # 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; my @rip = values %childstatus;
foreach my $rip (@rip) { foreach my $rip (@rip) {
if ($rip eq $iaddr) { ++$num_conn if (defined $rip && $rip eq $iaddr) {
++$num_conn;
}
} }
++$num_conn; # count this connection, too :)
if ($num_conn > $MAXCONNIP) { if ($num_conn > $MAXCONNIP) {
my $rem_ip = inet_ntoa($iaddr); my $rem_ip = inet_ntoa($iaddr);
::log(LOGINFO,"Too many connections from $rem_ip: " ::log(LOGINFO,"Too many connections from $rem_ip: "