cURL / Mailing Lists / curl-library / Single Mail


Re[4]: ftp downloading operation result

From: Spoon Man <>
Date: Wed, 27 Jul 2011 13:57:02 +0400

26 July  2011, 19:05 from Spoon Man <>:


Actually, it reproduces in version 7.21.7 too. I still didn't test on trunk, but there is same ftp_doing() implementation. I propose following fix:

diff -u curl-7.21.7/lib/ftp.c curl-7.21.7-1/lib/ftp.c
--- curl-7.21.7/lib/ftp.c       2011-06-07 00:10:13.000000000 +0400
+++ curl-7.21.7-1/lib/ftp.c     2011-07-26 18:41:34.000000000 +0400
@@ -4104,6 +4104,11 @@
   CURLcode result;
   result = ftp_multi_statemach(conn, dophase_done);
+  if (result != CURLE_OK) {
+    failf(conn->data, "DO phase is failed");
+    return result;
+  }
   if(*dophase_done) {
     result = ftp_dophase_done(conn, FALSE /* not connected */ );

But I'm not quite sure whether it completely fixes the problem.

And another problem is unexpected timeout.

Here are my debug printout:

2011-07-26 18:39:21.172 MSK INFOTEXT: ftp.c(1772):ftp_state_pasv_resp(): connecting to SOCKS4
2011-07-26 18:39:21.172 MSK INFOTEXT: socks.c(145):Curl_SOCKS4(): working. timeout = 299905
2011-07-26 18:39:21.172 MSK INFOTEXT: socks.c(82):Curl_blockread_all():conntime(299936) > conn_timeout(299905)
2011-07-26 18:39:21.172 MSK INFOTEXT: Failed to receive SOCKS4 connect request ack. result=28 timeout=299905 sock=75
2011-07-26 18:39:21.172 MSK INFOTEXT: ftp.c(1775): ftp_state_pasv_resp(): Curl_SOCKS4() returned 7

No real timeout has occured (it would be 5 minutes). I guess a connection time remains set to the first time stamp it was created.
I'd like to propose another fix for both error loss in ftp_doing() and incorrect timeout handling in SOCKS connection. I guess attachements are allowed in the mailing list?

It works fine on my system which makes multiple ftp download through SOCKS4 proxy.

The timeout fix is to use Curl_timeleft() function in Curl_blockread_all(). The problem actually was that It substracted connection create (== structure allocation) time from current time and compared it with timeout value provided by Curl_timeleft(). It is mix-up. Curl_timeleft() already returns value we want and does a calculation with t_startsingle time; we are not interested in creation time when connection being reused.

Please verify it or correct if I haven't understood the logic.

List admin:

Received on 2011-07-27