Re: bug in mirror, patch attached

"Alexander V. Lukyanov" <[email protected]> Tue, 20 Nov 2007 12:07:07 +0300
Newsgroups gmane.network.lftp.devel
Message-ID <[email protected]>
On Mon, Nov 19, 2007 at 04:08:21PM -0000, J. Maurice wrote:
> While trying to fetch this "devel" folder, lftp will always hang while
> waiting for the directory listing. This seems to be due to the directory
> being empty, and so the server just sends back a 226 reply. Apparently,

Here is a better patch.

--
   Alexander.
diff (text/plain, 1.1 KB)
Index: ftpclass.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/ftpclass.cc,v
retrieving revision 1.433
diff -u -p -r1.433 ftpclass.cc
--- ftpclass.cc	8 Nov 2007 07:59:29 -0000	1.433
+++ ftpclass.cc	20 Nov 2007 09:02:16 -0000
@@ -332,6 +332,9 @@ void Ftp::TransferCheck(int act)
    {
       copy_done=true;
       conn->CloseAbortedDataConnection();
+
+      if(!conn->received_150 && state!=DATA_OPEN_STATE)
+	 goto simulate_eof;
    }
    if(act==211)
    {
@@ -384,12 +387,7 @@ void Ftp::TransferCheck(int act)
       return;
    }
    if(NonError5XX(act))
-   {
-      DataClose();
-      state=EOF_STATE;
-      eof=true; // simulate eof
-      return;
-   }
+      goto simulate_eof;
    if(act==426 && copy_mode==COPY_NONE)
    {
       if(conn->data_sock==-1 && strstr(line,"Broken pipe"))
@@ -398,6 +396,13 @@ void Ftp::TransferCheck(int act)
    if(is2XX(act) && conn->data_sock==-1)
       eof=true;
    NoFileCheck(act);
+   return;
+
+simulate_eof:
+   DataClose();
+   state=EOF_STATE;
+   eof=true;
+   return;
 }
 
 void Ftp::LoginCheck(int act)