Ticket #1519: filezilla_3.0.1_keepalive.patch
File filezilla_3.0.1_keepalive.patch, 10.4 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 && IsConnected()) { 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 932 932 933 933 CServerPath path; 934 934 path.SetSafePath(COptions::Get()->GetOption(OPTION_LASTSERVERPATH)); 935 m_pState->Connect(server, false, path); 935 // FIXME: 936 // read keepalive from option 937 bool keepAlive = true; 938 m_pState->Connect(server, false, keepAlive, path); 936 939 } 937 940 938 941 void CMainFrame::OnRefresh(wxCommandEvent &event) … … 1456 1459 return; 1457 1460 } 1458 1461 1459 m_pState->Connect(pData->m_server, true, pData->m_remoteDir); 1462 // FIXME: 1463 // read keepalive from option 1464 bool keepAlive = true; 1465 m_pState->Connect(pData->m_server, true, keepAlive, pData->m_remoteDir); 1460 1466 1461 1467 if (pData->m_localDir != _T("")) 1462 1468 m_pState->SetLocalDir(pData->m_localDir); -
src/interface/quickconnectbar.cpp
diff -Nur Filezilla3/src/interface/quickconnectbar.cpp Filezilla3.patch/src/interface/quickconnectbar.cpp
old new 108 108 return; 109 109 } 110 110 111 if (!m_pState->Connect(server, true)) 111 // FIXME: 112 // read keepalive from option 113 bool keepAlive = true; 114 if (!m_pState->Connect(server, true, keepAlive)) 112 115 return; 113 116 114 117 CRecentServerList::SetMostRecentServer(server); -
src/interface/state.cpp
diff -Nur Filezilla3/src/interface/state.cpp Filezilla3.patch/src/interface/state.cpp
old new 259 259 NotifyHandlers(STATECHANGE_APPLYFILTER); 260 260 } 261 261 262 bool CState::Connect(const CServer& server, bool askBreak, const CServerPath& path /*=CServerPath()*/)262 bool CState::Connect(const CServer& server, bool askBreak, bool keepAlive /*=false*/, const CServerPath& path /*=CServerPath()*/) 263 263 { 264 264 if (!m_pEngine) 265 265 return false; … … 273 273 274 274 m_pCommandQueue->ProcessCommand(new CConnectCommand(server)); 275 275 m_pCommandQueue->ProcessCommand(new CListCommand(path)); 276 if (keepAlive) 277 m_pCommandQueue->ProcessCommand(new CKeepAliveCommand(true)); 276 278 277 279 COptions::Get()->SetLastServer(server); 278 280 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, bool keepAlive = false, const CServerPath& path = CServerPath()); 44 44 45 45 bool SetRemoteDir(const CDirectoryListing *m_pDirectoryListing, bool modified = false); 46 46 const CDirectoryListing *GetRemoteDir() const;