aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-05-17 08:02:23 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-05-17 08:02:23 +0000
commite11710714c64f90a254dbd804f6bbf2380a28f2b (patch)
tree482a63631b06db18a97e561d29fa9ef7269676ad
parent5b0bfc298ff7eb72e6c4a27d6153821240cd4138 (diff)
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.
-rw-r--r--tests/ftpserver.pl29
1 files 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;
}