When waiting for the second connect, we now use alarm to timeout the waiting.
This is necessary in case the client never connects or somehow fails to do it timely. The timeout used now is only 2 seconds, which might cause problems on really slow hosts but longer times are painful when doing torture testing on FTP test cases. I'm not sure how this 'alarm' functionality works on Windows or other systems that don't actually have the alarm() function.
This commit is contained in:
@@ -433,13 +433,32 @@ sub PASV_command {
|
||||
printf("229 Entering Passive Mode (|||%d|)\n", $pasvport);
|
||||
}
|
||||
|
||||
my $paddr = accept(SOCK, Server2);
|
||||
|
||||
my $paddr;
|
||||
eval {
|
||||
local $SIG{ALRM} = sub { die "alarm\n" };
|
||||
alarm 2; # assume swift operations!
|
||||
$paddr = accept(SOCK, Server2);
|
||||
alarm 0;
|
||||
};
|
||||
if ($@) {
|
||||
# timed out
|
||||
|
||||
close(Server2);
|
||||
logmsg "accept failed\n";
|
||||
return;
|
||||
}
|
||||
else {
|
||||
logmsg "accept worked\n";
|
||||
|
||||
my($iport,$iaddr) = sockaddr_in($paddr);
|
||||
my $name = gethostbyaddr($iaddr,AF_INET);
|
||||
|
||||
close(Server2); # close the listener when its served its purpose!
|
||||
|
||||
logmsg "data connection from $name [", inet_ntoa($iaddr), "] at port $iport\n";
|
||||
logmsg "data connection from $name [", inet_ntoa($iaddr),
|
||||
"] at port $iport\n";
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user