From c363c73b1b2a0fefab6007dc704af725d8c1e70e Mon Sep 17 00:00:00 2001
From: Jiri Hruska <jirka@fud.cz>
Date: Mon, 25 Feb 2013 01:23:10 +0100
Subject: [PATCH] ftp: Fix timeout response handling during data connection
 establishment

Makes the timeout response 421 to result in CURLE_OPERATION_TIMEDOUT
even when detected in ReceivedServerConnect() to be consistent with the
way it is handled during the standard ftp_multi_statemach() processing
by forwarding up the error codes returned by Curl_GetFTPResponse().

(Note this quick fix is not nice, reusing existing 'result' variable for
a result code even though it is an int, not CURLcode.)
---
 lib/ftp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/ftp.c b/lib/ftp.c
index dc9fc48..3b836ba 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -448,8 +448,10 @@ static CURLcode ReceivedServerConnect(struct connectdata *conn, bool *received)
   if(pp->cache_size && pp->cache && pp->cache[0] > '3') {
     /* Data connection could not be established, let's return */
     infof(data, "There is negative response in cache while serv connect\n");
-    Curl_GetFTPResponse(&nread, conn, &ftpcode);
-    return CURLE_FTP_ACCEPT_FAILED;
+    result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
+    if(!result)
+      result = CURLE_FTP_ACCEPT_FAILED;
+    return result;
   }
 
   result = Curl_socket_check(ctrl_sock, data_sock, CURL_SOCKET_BAD, 0);
-- 
1.8.1

