]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
When waiting for the second connect, we now use alarm to timeout the waiting.
authorDaniel Stenberg <daniel@haxx.se>
Mon, 17 May 2004 08:02:23 +0000 (08:02 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 17 May 2004 08:02:23 +0000 (08:02 +0000)
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

index 13c4b821885aad0545655d672a0df5926b0518f9..02d0fd7f423f00c730a35cfbb0bcf5f6c3efb70b 100644 (file)
@@ -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;
 }