Ticket #1519: filezilla3_rc1_keepalive3.patch
File filezilla3_rc1_keepalive3.patch, 9.8 KB (added by , 16 years ago) |
---|
-
src/engine/ControlSocket.h
diff -Nur Filezilla3/src/engine/ControlSocket.h Filezilla3.patch/src/engine/ControlSocket.h
old new 115 115 virtual int Chmod(const CChmodCommand& command) { return FZ_REPLY_NOTSUPPORTED; } 116 116 virtual bool Connected() const = 0; 117 117 118 virtual int KeepAlive(const CKeepAliveCommand& command) { return FZ_REPLY_OK; } 119 118 120 // If m_pCurrentOpData is zero, this function returns the current command 119 121 // from the engine. 120 122 enum Command GetCurrentCommandId() const; -
src/engine/FileZillaEngine.cpp
diff -Nur Filezilla3/src/engine/FileZillaEngine.cpp Filezilla3.patch/src/engine/FileZillaEngine.cpp
old new 70 70 case cmd_chmod: 71 71 res = Chmod(reinterpret_cast<const CChmodCommand&>(command)); 72 72 break; 73 case cmd_keepalive: 74 res = KeepAlive(reinterpret_cast<const CKeepAliveCommand &>(command)); 75 break; 73 76 default: 74 77 return FZ_REPLY_SYNTAXERROR; 75 78 } -
src/engine/commands.cpp
diff -Nur Filezilla3/src/engine/commands.cpp Filezilla3.patch/src/engine/commands.cpp
old new 10 10 return m_Server; 11 11 } 12 12 13 CKeepAliveCommand::CKeepAliveCommand(bool keepAlive /*=true*/) 14 : m_keepAlive(keepAlive) 15 { 16 } 17 18 bool CKeepAliveCommand::IsKeepAlive() const 19 { 20 return m_keepAlive; 21 } 22 13 23 CListCommand::CListCommand(bool refresh /*=false*/) 14 24 : m_refresh(refresh) 15 25 { -
src/engine/engineprivate.cpp
diff -Nur Filezilla3/src/engine/engineprivate.cpp Filezilla3.patch/src/engine/engineprivate.cpp
old new 525 525 return m_pControlSocket->Chmod(command); 526 526 } 527 527 528 int CFileZillaEnginePrivate::KeepAlive(const CKeepAliveCommand& command) 529 { 530 m_pCurrentCommand = command.Clone(); 531 return m_pControlSocket->KeepAlive(command); 532 } 533 528 534 void CFileZillaEnginePrivate::SendDirectoryListingNotification(const CServerPath& path, bool onList, bool modified, bool failed) 529 535 { 530 536 wxASSERT(m_pControlSocket); -
src/engine/ftpcontrolsocket.cpp
diff -Nur Filezilla3/src/engine/ftpcontrolsocket.cpp Filezilla3.patch/src/engine/ftpcontrolsocket.cpp
old new 24 24 #define LOGON_CUSTOMCOMMANDS 10 25 25 #define LOGON_DONE 11 26 26 27 #define KEEPALIVE_TIMER_ID wxID_HIGHEST + 5 28 27 29 BEGIN_EVENT_TABLE(CFtpControlSocket, CRealControlSocket) 28 30 EVT_FZ_EXTERNALIPRESOLVE(wxID_ANY, CFtpControlSocket::OnExternalIPAddress) 31 EVT_TIMER(wxID_ANY, CFtpControlSocket::OnTimer) 29 32 END_EVENT_TABLE(); 30 33 31 34 CRawTransferOpData::CRawTransferOpData() … … 137 140 m_pTlsSocket = 0; 138 141 m_protectDataChannel = false; 139 142 m_lastTypeBinary = -1; 143 m_bEnableKeepAlive = false; 144 m_keepAliveTimer.SetOwner(this, KEEPALIVE_TIMER_ID); 140 145 } 141 146 142 147 CFtpControlSocket::~CFtpControlSocket() … … 147 152 { 148 153 LogMessage(Debug_Verbose, _T("CFtpControlSocket::OnReceive()")); 149 154 155 m_keepAliveStopWatch.Start(); 156 150 157 m_pBackend->Read(m_receiveBuffer + m_bufferLen, RECVBUFFERSIZE - m_bufferLen); 151 158 152 159 if (m_pBackend->Error()) 153 160 { 154 161 if (m_pBackend->LastError() != wxSOCKET_WOULDBLOCK) 155 162 { 163 m_bEnableKeepAlive = false; 164 m_keepAliveTimer.Stop(); 156 165 LogMessage(::Error, _("Disconnected from server")); 157 166 DoClose(); 158 167 } … … 344 353 345 354 if (m_repliesToSkip) 346 355 { 356 SetWait(false); 347 357 LogMessage(Debug_Info, _T("Skipping reply after cancelled operation.")); 348 358 if (m_Response[0] != '1') 349 359 m_repliesToSkip--; … … 798 808 LogMessage(::Error, _T("Failed to convert command to 8 bit charset")); 799 809 return false; 800 810 } 811 m_keepAliveStopWatch.Start(); 801 812 unsigned int len = (unsigned int)strlen(buffer); 802 813 bool res = CRealControlSocket::Send(buffer, len); 803 814 if (res) … … 3006 3017 } 3007 3018 3008 3019 return FZ_REPLY_WOULDBLOCK; 3020 } 3021 3022 int CFtpControlSocket::KeepAlive(const CKeepAliveCommand& command) 3023 { 3024 LogMessage(Debug_Verbose, _T("CFtpControlSocket::KeepAlive")); 3025 3026 if (command.IsKeepAlive()) 3027 { 3028 if (!m_bEnableKeepAlive) 3029 { 3030 m_bEnableKeepAlive = true; 3031 // FIXME: 3032 // read keepalive option here 3033 int min_wait = 30; 3034 int max_wait = 60; 3035 int waitsecond = min_wait + (int)(rand()*(max_wait - min_wait)/(RAND_MAX+1)); 3036 m_keepAliveTimer.Start(waitsecond * 1000); 3037 } 3038 } 3039 else 3040 { 3041 if (m_bEnableKeepAlive) 3042 { 3043 m_bEnableKeepAlive = false; 3044 m_keepAliveTimer.Stop(); 3045 } 3046 } 3047 3048 m_bEnableKeepAlive = true; 3049 return FZ_REPLY_OK; 3050 } 3051 3052 void CFtpControlSocket::DoKeepAlive() 3053 { 3054 LogMessage(Debug_Verbose, _T("CFtpControlSocket::DoKeepAlive")); 3055 3056 // ignore keepalive for last I/O for socket less than 15 seconds 3057 if (m_keepAliveStopWatch.Time() < 15000) 3058 return; 3059 // choose any command 3060 wxString commands[4] = {_T("PWD"),_T("REST 0"), _T("NOOP"), _T("STAT") }; 3061 int choice=(rand()*4)/(RAND_MAX+1); 3062 3063 m_repliesToSkip++; 3064 Send(commands[choice]); 3065 return; 3066 } 3067 3068 void CFtpControlSocket::OnTimer(wxTimerEvent& event) 3069 { 3070 if (event.GetId() == KEEPALIVE_TIMER_ID) 3071 { 3072 if (m_keepAliveTimer.IsRunning()) 3073 { 3074 m_keepAliveTimer.Stop(); 3075 if (m_bEnableKeepAlive) { 3076 // FIXME: 3077 // need to read the values from options... 3078 int min_wait = 30; 3079 int max_wait = 60; 3080 3081 int waitsecond = min_wait + (int)(rand()*(max_wait - min_wait)/(RAND_MAX+1)); 3082 m_keepAliveTimer.Start(waitsecond * 1000); 3083 DoKeepAlive(); 3084 } 3085 } 3086 } 3087 else 3088 CControlSocket::OnTimer(event); 3009 3089 } 3010 3090 3011 3091 bool CFtpControlSocket::IsMisleadingListResponse() const -
src/engine/ftpcontrolsocket.h
diff -Nur Filezilla3/src/engine/ftpcontrolsocket.h Filezilla3.patch/src/engine/ftpcontrolsocket.h
old new 24 24 25 25 protected: 26 26 27 bool m_bEnableKeepAlive; 28 wxTimer m_keepAliveTimer; 29 wxStopWatch m_keepAliveStopWatch; 30 virtual int KeepAlive(const CKeepAliveCommand& command); 31 void DoKeepAlive(); 32 27 33 virtual int ResetOperation(int nErrorCode); 28 34 29 35 virtual int Connect(const CServer &server); … … 128 134 129 135 DECLARE_EVENT_TABLE(); 130 136 void OnExternalIPAddress(fzExternalIPResolveEvent& event); 137 void OnTimer(wxTimerEvent& event); 131 138 }; 132 139 133 140 class CIOThread; -
src/include/commands.h
diff -Nur Filezilla3/src/include/commands.h Filezilla3.patch/src/include/commands.h
old new 19 19 cmd_rename, 20 20 cmd_chmod, 21 21 cmd_raw, 22 cmd_keepalive, 22 23 23 24 // Only used internally 24 25 cmd_cwd, … … 74 75 const CServer GetServer() const; 75 76 protected: 76 77 CServer m_Server; 78 }; 79 80 DECLARE_COMMAND(CKeepAliveCommand, cmd_keepalive) 81 CKeepAliveCommand(bool keepAlive = true); 82 83 bool IsKeepAlive() const; 84 85 protected: 86 bool m_keepAlive; 77 87 }; 78 88 79 89 DECLARE_COMMAND(CDisconnectCommand, cmd_disconnect) -
src/include/engineprivate.h
diff -Nur Filezilla3/src/include/engineprivate.h Filezilla3.patch/src/include/engineprivate.h
old new 69 69 int Mkdir(const CMkdirCommand& command); 70 70 int Rename(const CRenameCommand& command); 71 71 int Chmod(const CChmodCommand& command); 72 int KeepAlive(const CKeepAliveCommand& command); 72 73 73 74 int ContinueConnect(); 74 75 -
src/interface/Mainfrm.cpp
diff -Nur Filezilla3/src/interface/Mainfrm.cpp Filezilla3.patch/src/interface/Mainfrm.cpp
old new 825 825 826 826 CServerPath path; 827 827 path.SetSafePath(COptions::Get()->GetOption(OPTION_LASTSERVERPATH)); 828 m_pState->Connect(server, false, path); 828 // FIXME: 829 // read keepalive from option 830 bool keepAlive = true; 831 m_pState->Connect(server, false, path, keepAlive); 829 832 } 830 833 831 834 void CMainFrame::OnRefresh(wxCommandEvent &event) … … 1341 1344 return; 1342 1345 } 1343 1346 1344 m_pState->Connect(pData->m_server, true, pData->m_remoteDir); 1347 // FIXME: 1348 // read keepalive from option 1349 bool keepAlive = true; 1350 m_pState->Connect(pData->m_server, true, pData->m_remoteDir, keepAlive); 1345 1351 1346 1352 if (pData->m_localDir != _T("")) 1347 1353 m_pState->SetLocalDir(pData->m_localDir); -
src/interface/state.cpp
diff -Nur Filezilla3/src/interface/state.cpp Filezilla3.patch/src/interface/state.cpp
old new 247 247 NotifyHandlers(STATECHANGE_APPLYFILTER); 248 248 } 249 249 250 bool CState::Connect(const CServer& server, bool askBreak, const CServerPath& path /*=CServerPath()*/ )250 bool CState::Connect(const CServer& server, bool askBreak, const CServerPath& path /*=CServerPath()*/, bool keepAlive) 251 251 { 252 252 if (!m_pEngine) 253 253 return false; … … 261 261 262 262 m_pCommandQueue->ProcessCommand(new CConnectCommand(server)); 263 263 m_pCommandQueue->ProcessCommand(new CListCommand(path)); 264 if (keepAlive) 265 m_pCommandQueue->ProcessCommand(new CKeepAliveCommand(true)); 264 266 265 267 COptions::Get()->SetLastServer(server); 266 268 COptions::Get()->SetOption(OPTION_LASTSERVERPATH, path.GetSafePath()); -
src/interface/state.h
diff -Nur Filezilla3/src/interface/state.h Filezilla3.patch/src/interface/state.h
old new 40 40 static bool LocalDirHasParent(const wxString& dir); 41 41 static bool LocalDirIsWriteable(const wxString& dir); 42 42 43 bool Connect(const CServer& server, bool askBreak, const CServerPath& path = CServerPath() );43 bool Connect(const CServer& server, bool askBreak, const CServerPath& path = CServerPath(), bool keepAlive = false); 44 44 45 45 bool SetRemoteDir(const CDirectoryListing *m_pDirectoryListing, bool modified = false); 46 46 const CDirectoryListing *GetRemoteDir() const;