On Fri, Sep 11, 2009 at 07:19:15PM -0400, Justin Piszcz wrote:
> With lftp-4.0.0 (and the 3.x beta versions w/torrent support) lockup if
> you try to mirror several directories at the same time.  The lftp program
> is responsive, but all of the mirrors that you run, just sit waiting for
> response forever:

Please try this patch.

--
   Alexander.                      | http://www.yars.free.net/~lav/  
Index: ftpclass.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/ftpclass.cc,v
retrieving revision 1.460
diff -u -p -r1.460 ftpclass.cc
--- ftpclass.cc 21 Jul 2009 11:30:34 -0000      1.460
+++ ftpclass.cc 15 Sep 2009 07:13:34 -0000
@@ -1615,7 +1615,7 @@ int   Ftp::Do()
           || (mode==LONG_LIST && !use_stat_for_list)))
       {
         assert(conn->data_sock==-1);
-        conn->data_sock=SocketCreateTCP(conn->peer_sa.sa.sa_family);
+        
conn->data_sock=SocketCreateUnboundTCP(conn->peer_sa.sa.sa_family,hostname);
         if(conn->data_sock==-1)
         {
            LogError(0,"socket(data): %s",strerror(errno));
Index: network.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/network.cc,v
retrieving revision 1.5
diff -u -p -r1.5 network.cc
--- network.cc  21 Jul 2009 11:30:35 -0000      1.5
+++ network.cc  15 Sep 2009 07:17:10 -0000
@@ -183,7 +183,7 @@ void Networker::SetSocketMaxseg(int sock
 #endif
 }
 
-int Networker::SocketCreate(int af,int type,int proto,const char *hostname)
+int Networker::SocketCreateUnbound(int af,int type,int proto,const char 
*hostname)
 {
    int s=socket(af,type,proto);
    if(s<0)
@@ -192,7 +192,10 @@ int Networker::SocketCreate(int af,int t
    NonBlock(s);
    CloseOnExec(s);
    SetSocketBuffer(s,ResMgr::Query("net:socket-buffer",hostname));
-
+   return s;
+}
+void Networker::SocketBindStd(int s,int af,const char *hostname)
+{
    const char *b=0;
    sockaddr_u bind_addr;
    memset(&bind_addr,0,sizeof(bind_addr));
@@ -217,15 +220,34 @@ int Networker::SocketCreate(int af,int t
       if(res==-1)
         ProtoLog::LogError(0,"bind(socket, %s): %s",b,strerror(errno));
    }
+}
+int Networker::SocketCreate(int af,int type,int proto,const char *hostname)
+{
+   int s=SocketCreateUnbound(af,type,proto,hostname);
+   if(s<0)
+      return s;
+   SocketBindStd(s,af,hostname);
    return s;
 }
+void Networker::SocketTuneTCP(int s,const char *hostname)
+{
+   KeepAlive(s);
+   SetSocketMaxseg(s,ResMgr::Query("net:socket-maxseg",hostname));
+}
 int Networker::SocketCreateTCP(int af,const char *hostname)
 {
    int s=SocketCreate(af,SOCK_STREAM,IPPROTO_TCP,hostname);
    if(s<0)
       return s;
-   KeepAlive(s);
-   SetSocketMaxseg(s,ResMgr::Query("net:socket-maxseg",hostname));
+   SocketTuneTCP(s,hostname);
+   return s;
+}
+int Networker::SocketCreateUnboundTCP(int af,const char *hostname)
+{
+   int s=SocketCreateUnbound(af,SOCK_STREAM,IPPROTO_TCP,hostname);
+   if(s<0)
+      return s;
+   SocketTuneTCP(s,hostname);
    return s;
 }
 int Networker::SocketConnect(int fd,const sockaddr_u *u)
Index: network.h
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/network.h,v
retrieving revision 1.4
diff -u -p -r1.4 network.h
--- network.h   21 Jul 2009 11:30:35 -0000      1.4
+++ network.h   15 Sep 2009 07:17:15 -0000
@@ -75,8 +75,12 @@ protected:
    static int SocketAccept(int fd,sockaddr_u *u,const char *hostname=0);
    static void SetSocketBuffer(int sock,int socket_buffer);
    static void SetSocketMaxseg(int sock,int socket_maxseg);
+   static void SocketBindStd(int s,int af,const char *hostname);
    static int SocketCreate(int af,int type,int proto,const char *hostname);
+   static void SocketTuneTCP(int s,const char *hostname);
    static int SocketCreateTCP(int af,const char *hostname);
+   static int SocketCreateUnbound(int af,int type,int proto,const char 
*hostname);
+   static int SocketCreateUnboundTCP(int af,const char *hostname);
 };
 
 #endif //NETWORK_H

Reply via email to