Pārlūkot izejas kodu

Bug 1679: Hang when doing an operation on FTP connection that disconnected on a background

https://winscp.net/tracker/1679

Source commit: 75044e4431fff9afa85d2f6b60bf9821fbb0e965
Martin Prikryl 7 gadi atpakaļ
vecāks
revīzija
77d0bbc2da
1 mainītis faili ar 7 papildinājumiem un 3 dzēšanām
  1. 7 3
      source/core/FtpFileSystem.cpp

+ 7 - 3
source/core/FtpFileSystem.cpp

@@ -2848,14 +2848,18 @@ bool __fastcall TFTPFileSystem::NoFinalLastCode()
 //---------------------------------------------------------------------------
 bool __fastcall TFTPFileSystem::KeepWaitingForReply(unsigned int & ReplyToAwait, bool WantLastCode)
 {
-  // to keep waiting,
+  // To keep waiting,
   // non-command reply must be unset,
   // the reply we wait for must be unset or
-  // last code must be unset (if we wait for it)
+  // last code must be unset (if we wait for it).
+
+  // Though make sure that disconnect makes it through always. As for example when connection is closed already,
+  // when sending commands, we may get REPLY_DISCONNECTED as a command response and no other response after,
+  // what would cause a hang.
   return
      (FReply == 0) &&
      ((ReplyToAwait == 0) ||
-      (WantLastCode && NoFinalLastCode()));
+      (WantLastCode && NoFinalLastCode() && FLAGCLEAR(ReplyToAwait, TFileZillaIntf::REPLY_DISCONNECTED)));
 }
 //---------------------------------------------------------------------------
 void __fastcall TFTPFileSystem::DoWaitForReply(unsigned int & ReplyToAwait, bool WantLastCode)