[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdelibs/kioslave/ftp
From: David Faure <faure () kde ! org>
Date: 2005-03-24 10:26:24
Message-ID: 20050324102624.584113EC () office ! kde ! org
[Download RAW message or body]
CVS commit by faure:
Fixes for Sok Ann Yap's FTP server:
* Try non-passive mode if passive mode fails (this got broken by the big rewrite)
* Don't re-use the same port number for all commands - although this should be fine,
that server doesn't work when we reuse the same port (this patch is from Thiago)
M +18 -12 ftp.cc 1.219
--- kdelibs/kioslave/ftp/ftp.cc #1.218:1.219
@@ -897,4 +897,5 @@ int Ftp::ftpOpenPASVDataConnection()
m_data = new FtpSocket("PASV");
m_data->setAddress(host, port);
+ kdDebug(7102) << "Connecting to " << host << " on port " << port << endl;
return m_data->connectSocket(connectTimeout(), false);
}
@@ -1004,5 +1005,6 @@ int Ftp::ftpOpenDataConnection()
ftpCloseDataConnection();
- int iErrCode = 0; // ERR_INTERNAL : try another mode
+ int iErrCode = 0;
+ int iErrCodePASV = 0; // Remember error code from PASV
// First try passive (EPSV & PASV) modes
@@ -1010,6 +1012,7 @@ int Ftp::ftpOpenDataConnection()
{
iErrCode = ftpOpenPASVDataConnection();
- if(iErrCode != ERR_INTERNAL)
- return iErrCode;
+ if(iErrCode == 0)
+ return 0; // success
+ iErrCodePASV = iErrCode;
ftpCloseDataConnection();
@@ -1017,6 +1020,6 @@ int Ftp::ftpOpenDataConnection()
{
iErrCode = ftpOpenEPSVDataConnection();
- if(iErrCode != ERR_INTERNAL)
- return iErrCode;
+ if(iErrCode == 0)
+ return 0; // success
ftpCloseDataConnection();
}
@@ -1025,17 +1028,20 @@ int Ftp::ftpOpenDataConnection()
// use active connections any more
if (m_extControl & epsvAllSent)
- return ERR_INTERNAL;
+ return iErrCodePASV ? iErrCodePASV : iErrCode;
}
iErrCode = ftpOpenEPRTDataConnection();
- if(iErrCode != ERR_INTERNAL)
- return iErrCode;
+ if(iErrCode == 0)
+ return 0; // success
ftpCloseDataConnection();
// fall back to port mode
iErrCode = ftpOpenPortDataConnection();
- if(iErrCode != 0)
+ if(iErrCode == 0)
+ return 0; // success
+
ftpCloseDataConnection();
- return iErrCode;
+ // prefer to return the error code from PASV if any, since that's what should have \
worked in the first place + return iErrCodePASV ? iErrCodePASV : iErrCode;
}
@@ -1060,5 +1066,5 @@ int Ftp::ftpOpenPortDataConnection()
// yes, we are sure this is a KInetSocketAddress
const KInetSocketAddress* pAddr = static_cast<const \
KInetSocketAddress*>(m_control->localAddress());
- m_data->setAddress(pAddr->nodeName(), pAddr->serviceName());
+ m_data->setAddress(pAddr->nodeName(), "0");
m_data->setAddressReusable(true);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic