cURL / Mailing Lists / curl-library / Single Mail

curl-library

Occasionally failing FTP test592 and a solution

From: Jiří Hruška <jirka_at_fud.cz>
Date: Mon, 25 Feb 2013 03:12:18 +0100

Hi everyone,

Steve noticed me test 592 (FTP multi PORT and 421 on upload) has
failed on Tru64 after he committed some of my ping-pong code changes
[1], so I investigated if that could be really connected and found it
was not, it had been happening before. But I might share the reason
anyway now that I know it. It was caused by inconsistent handling of
timeout responses during FTP data connection establishment.

If the "421 Connection timed out" response is processed during a
standard ftp_multi_statemach() call, ftp_readresp() returns code
CURLE_OPERATION_TIMEDOUT and the connection is aborted. This is what
the test expects.

In the failing case, the 421 response was however received immediately
in the same packet as "150 Opening data connection" and stayed in the
PP cache. It was then found in ReceivedServerConnect() and retrieved
by the blocking Curl_GetFTPResponse(). This function returned
CURLE_OPERATION_TIMEOUT, but its return value was ignored and
CURLE_FTP_ACCEPT_FAILED was sent upstream. This way the connection was
closed with a proper QUIT instead, which made the test fail due to
mismatched communication log.

This behavior is hard to test in normal environment, but I verified
the failing scenario by using the lib591 executable directly with
netcat and manually typing the responses, then pasting the whole final
block "150 Opening data connection\r\n421 Connection timed out\r\n" at
once. The attached patch is one way this can be fixed.

But maybe this could be also solved the other way, because the nicer,
QUIT way might be more appropriate in this case? The server being
unable to connect back might be quite common scenario and closing the
data connection forcefully just because of that might seem too
aggressive... But the 421 response doesn't say what exactly happened,
so this probably cannot be resolved, oh well.

Kind regards,
Jiri

[1] http://curl.haxx.se/dev/log.cgi?id=20130223104226-6400#prob1
Purely by accident, I found the same failure on IRIX too:
http://curl.haxx.se/dev/log.cgi?id=20130224092545-20398#prob161

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

Received on 2013-02-25