From e11710714c64f90a254dbd804f6bbf2380a28f2b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 17 May 2004 08:02:23 +0000 Subject: 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. --- tests/ftpserver.pl | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index 13c4b8218..02d0fd7f4 100644 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -433,13 +433,32 @@ sub PASV_command { printf("229 Entering Passive Mode (|||%d|)\n", $pasvport); } - my $paddr = accept(SOCK, Server2); - my($iport,$iaddr) = sockaddr_in($paddr); - my $name = gethostbyaddr($iaddr,AF_INET); - close(Server2); # close the listener when its served its purpose! + 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"; - logmsg "data connection from $name [", inet_ntoa($iaddr), "] at port $iport\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"; + } return; } -- cgit v1.2.3