浏览代码

Consistently logging opening and closing of the data connection

Source commit: 482d3dbf98738ebb468d6374ce322e7339ce8c6c
Martin Prikryl 9 年之前
父节点
当前提交
6b6719a101
共有 3 个文件被更改,包括 31 次插入24 次删除
  1. 29 23
      source/filezilla/FtpControlSocket.cpp
  2. 1 0
      source/filezilla/FtpControlSocket.h
  3. 1 1
      source/filezilla/TransferSocket.cpp

+ 29 - 23
source/filezilla/FtpControlSocket.cpp

@@ -2274,20 +2274,11 @@ void CFtpControlSocket::List(BOOL bFinish, int nError /*=FALSE*/, CServerPath pa
 
     if (pData->bPasv)
     {
-      CString hostname;
-      hostname.Format(L"%s:%d", pData->host, pData->port);
-      CString str;
-      str.Format(IDS_STATUSMSG_CONNECTING, hostname);
-      ShowStatus(str, FZ_LOG_PROGRESS);
-
       // if PASV create the socket & initiate outbound data channel connection
-      if (!m_pTransferSocket->Connect(pData->host,pData->port))
+      if (!ConnectTransferSocket(pData->host, pData->port))
       {
-        if (GetLastError()!=WSAEWOULDBLOCK)
-        {
-          ResetOperation(FZ_REPLY_ERROR);
-          return;
-        }
+        ResetOperation(FZ_REPLY_ERROR);
+        return;
       }
     }
 
@@ -2297,6 +2288,25 @@ void CFtpControlSocket::List(BOOL bFinish, int nError /*=FALSE*/, CServerPath pa
     Send(cmd);
 }
 
+bool CFtpControlSocket::ConnectTransferSocket(const CString & host, UINT port)
+{
+  CString hostname;
+  hostname.Format(L"%s:%d", host, port);
+  CString str;
+  str.Format(IDS_STATUSMSG_CONNECTING, hostname);
+  ShowStatus(str, FZ_LOG_PROGRESS);
+
+  bool result = true;
+  if (!m_pTransferSocket->Connect(host, port))
+  {
+    if (GetLastError() != WSAEWOULDBLOCK)
+    {
+      result = false;
+    }
+  }
+  return result;
+}
+
 void CFtpControlSocket::ListFile(CString filename, const CServerPath &path)
 {
   USES_CONVERSION;
@@ -4023,14 +4033,10 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi
         bError=TRUE;
       else if(pData->bPasv)
       {
-        // if PASV create the socket & initiate outbound data channel connection
-        if (!m_pTransferSocket->Connect(pData->host,pData->port))
+        if (!ConnectTransferSocket(pData->host, pData->port))
         {
-          if (GetLastError()!=WSAEWOULDBLOCK)
-          {
-            bError=TRUE;
-            ShowStatus(IDS_ERRORMSG_CANTGETLIST,FZ_LOG_ERROR);
-          }
+          bError=TRUE;
+          ShowStatus(IDS_ERRORMSG_CANTGETLIST,FZ_LOG_ERROR);
         }
       }
     }
@@ -4280,11 +4286,11 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi
     else
     {
       if (pData->bPasv)
-      {// if PASV create the socket & initiate outbound data channel connection
-        if (!m_pTransferSocket->Connect(pData->host,pData->port))
+      {
+        // if PASV create the socket & initiate outbound data channel connection
+        if (!ConnectTransferSocket(pData->host, pData->port))
         {
-          if (GetLastError()!=WSAEWOULDBLOCK)
-            bError=TRUE;
+          bError=TRUE;
         }
       }
     }

+ 1 - 0
source/filezilla/FtpControlSocket.h

@@ -150,6 +150,7 @@ protected:
   void Close();
   BOOL Connect(CString hostAddress, UINT nHostPort);
   CString ConvertDomainName(CString domain);
+  bool ConnectTransferSocket(const CString & host, UINT port);
 
   struct t_ActiveList
   {

+ 1 - 1
source/filezilla/TransferSocket.cpp

@@ -444,7 +444,7 @@ void CTransferSocket::OnClose(int nErrorCode)
     return;
   }
 
-  m_pOwner->ShowStatus(L"Data connection closed", FZ_LOG_INFO);
+  m_pOwner->ShowStatus(L"Data connection closed", FZ_LOG_PROGRESS);
 
   OnReceive(0);
   CloseAndEnsureSendClose(0);