Procházet zdrojové kódy

Bug 2046: Automatically reconnect when FTP server fails to open data connection, if it previously worked

https://winscp.net/tracker/2046
(cherry picked from commit 45022cce7e588ccd8cda9d96da78cd2964f003b7)

Source commit: 5c79049b9cb0cb81174b3170ca457d498ac2b505
Martin Prikryl před 4 roky
rodič
revize
384bb10524
1 změnil soubory, kde provedl 16 přidání a 4 odebrání
  1. 16 4
      source/core/FtpFileSystem.cpp

+ 16 - 4
source/core/FtpFileSystem.cpp

@@ -3178,9 +3178,15 @@ UnicodeString __fastcall TFTPFileSystem::GotReply(unsigned int Reply, unsigned i
           MoreMessages->Add(LoadStr(AUTHENTICATION_FAILED));
         }
 
+        bool RetryTransfer = false;
         if (FLastCode == 425)
         {
-          if (!FTerminal->SessionData->FtpPasvMode)
+          if (FAnyTransferSucceeded)
+          {
+            FTerminal->LogEvent(FORMAT(L"Got %d after some previous data connections succeeded, retrying connection", (FLastCode)));
+            RetryTransfer = true;
+          }
+          else if (!FTerminal->SessionData->FtpPasvMode)
           {
             MoreMessages->Add(LoadStr(FTP_CANNOT_OPEN_ACTIVE_CONNECTION2));
             HelpKeyword = HELP_FTP_CANNOT_OPEN_ACTIVE_CONNECTION;
@@ -3207,12 +3213,18 @@ UnicodeString __fastcall TFTPFileSystem::GotReply(unsigned int Reply, unsigned i
           }
           if (ContainsText(FLastError->Strings[0], CantOpenTransferChannelMessage))
           {
-            Disconnected = true;
-            // Close only later, as we still need to use FLast* fields
-            DoClose = true;
+            FTerminal->LogEvent(L"Failed to connection data connection after some previous data connections succeeded, retrying connection");
+            RetryTransfer = true;
           }
         }
 
+        if (RetryTransfer)
+        {
+          Disconnected = true;
+          // Close only later, as we still need to use FLast* fields
+          DoClose = true;
+        }
+
         MoreMessages->AddStrings(FLastError);
         // already cleared from WaitForReply, but GotReply can be also called
         // from Closed. then make sure that error from previous command not