Ticket #1519: filezilla_3_rc1_keepalive.patch
File filezilla_3_rc1_keepalive.patch, 9.3 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/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 if (!IsConnected()) 531 return FZ_REPLY_NOTCONNECTED; 532 533 if (IsBusy()) 534 return FZ_REPLY_BUSY; 535 536 m_pCurrentCommand = command.Clone(); 537 return m_pControlSocket->KeepAlive(command); 538 } 539 528 540 void CFileZillaEnginePrivate::SendDirectoryListingNotification(const CServerPath& path, bool onList, bool modified, bool failed) 529 541 { 530 542 wxASSERT(m_pControlSocket); -
src/engine/ftpcontrolsocket.cpp
diff -Nur Filezilla3/src/engine/ftpcontrolsocket.cpp Filezilla3.patch/src/engine/ftpcontrolsocket.cpp
old new 147 147 { 148 148 LogMessage(Debug_Verbose, _T("CFtpControlSocket::OnReceive()")); 149 149 150 m_stopWatch.Start(); 151 150 152 m_pBackend->Read(m_receiveBuffer + m_bufferLen, RECVBUFFERSIZE - m_bufferLen); 151 153 152 154 if (m_pBackend->Error()) … … 386 388 case cmd_rawtransfer: 387 389 TransferParseResponse(); 388 390 break; 391 case cmd_keepalive: 392 KeepAliveParseResponse(); 393 break; 389 394 case cmd_none: 390 395 LogMessage(Debug_Verbose, _T("Out-of-order reply, ignoring.")); 391 396 break; … … 798 803 LogMessage(::Error, _T("Failed to convert command to 8 bit charset")); 799 804 return false; 800 805 } 806 m_stopWatch.Start(); 801 807 unsigned int len = (unsigned int)strlen(buffer); 802 808 bool res = CRealControlSocket::Send(buffer, len); 803 809 if (res) … … 1254 1260 return DeleteSend(prevResult); 1255 1261 case cmd_removedir: 1256 1262 return RemoveDirSend(prevResult); 1263 case cmd_keepalive: 1264 return KeepAliveSend(); 1257 1265 default: 1258 1266 LogMessage(__TFILE__, __LINE__, this, ::Debug_Warning, _T("Unknown opID (%d) in SendNextCommand"), m_pCurOpData->opId); 1259 1267 ResetOperation(FZ_REPLY_INTERNALERROR); … … 3007 3015 3008 3016 return FZ_REPLY_WOULDBLOCK; 3009 3017 } 3018 3019 class CKeepAliveOpData : public COpData 3020 { 3021 public: 3022 CKeepAliveOpData(const wxString& command) 3023 : COpData(cmd_keepalive) 3024 { 3025 m_command = command; 3026 } 3027 3028 wxString m_command; 3029 }; 3030 3031 int CFtpControlSocket::KeepAlive(const CKeepAliveCommand& command) 3032 { 3033 LogMessage(Debug_Verbose, _("CFtpControlSocket::KeepAlive")); 3034 3035 // ignore keepalive for last I/O for socket less than 15 seconds 3036 if (m_stopWatch.Time() < 15000) 3037 return FZ_REPLY_OK; 3038 // choose any command 3039 wxString commands[4] = {_T("PWD"),_T("REST 0"), _T("TYPE A"), _T("TYPE I") }; 3040 int choice=(rand()*4)/(RAND_MAX+1); 3041 m_pCurOpData = new CKeepAliveOpData(commands[choice]); 3042 3043 return SendNextCommand(); 3044 } 3045 3046 int CFtpControlSocket::KeepAliveSend() 3047 { 3048 LogMessage(Debug_Verbose, _T("CFtpControlSocket::KeepAliveSend")); 3049 3050 if (!m_pCurOpData) 3051 { 3052 LogMessage(__TFILE__, __LINE__, this, Debug_Info, _T("Empty m_pCurOpData")); 3053 ResetOperation(FZ_REPLY_INTERNALERROR); 3054 return FZ_REPLY_ERROR; 3055 } 3056 3057 CDirectoryCache cache; 3058 cache.InvalidateServer(*m_pCurrentServer); 3059 m_CurrentPath = CServerPath(); 3060 3061 CKeepAliveOpData *pData = static_cast<CKeepAliveOpData *>(m_pCurOpData); 3062 3063 if (!Send(pData->m_command)) 3064 return FZ_REPLY_ERROR; 3065 3066 return FZ_REPLY_WOULDBLOCK; 3067 } 3068 3069 int CFtpControlSocket::KeepAliveParseResponse() 3070 { 3071 LogMessage(Debug_Verbose, _T("CFtpControlSocket::KeepAliveParseResponse")); 3072 3073 int code = GetReplyCode(); 3074 if (code == 2 || code == 3) 3075 { 3076 ResetOperation(FZ_REPLY_OK); 3077 return FZ_REPLY_OK; 3078 } 3079 else 3080 { 3081 ResetOperation(FZ_REPLY_ERROR); 3082 return FZ_REPLY_ERROR; 3083 } 3084 } 3085 3010 3086 3011 3087 bool CFtpControlSocket::IsMisleadingListResponse() const 3012 3088 { -
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 wxStopWatch m_stopWatch; 28 virtual int KeepAlive(const CKeepAliveCommand& command); 29 int KeepAliveParseResponse(); 30 int KeepAliveSend(); 31 27 32 virtual int ResetOperation(int nErrorCode); 28 33 29 34 virtual int Connect(const CServer &server); -
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, … … 76 77 CServer m_Server; 77 78 }; 78 79 80 DECLARE_COMMAND(CKeepAliveCommand, cmd_keepalive) 81 }; 79 82 DECLARE_COMMAND(CDisconnectCommand, cmd_disconnect) 80 83 }; 81 84 -
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 43 43 #endif 44 44 45 45 #define TRANSFERSTATUS_TIMER_ID wxID_HIGHEST + 3 46 #define KEEPALIVE_TIMER_ID TRANSFERSTATUS_TIMER_ID + 1 46 47 47 48 static const int statbarWidths[6] = { 48 49 #ifdef __WXMSW__ … … 159 160 } 160 161 161 162 m_transferStatusTimer.SetOwner(this, TRANSFERSTATUS_TIMER_ID); 163 m_keepAliveTimer.SetOwner(this, KEEPALIVE_TIMER_ID); 162 164 163 165 CreateMenus(); 164 166 CreateToolBar(); … … 696 698 if (!m_pState->m_pCommandQueue->Idle()) 697 699 return; 698 700 701 m_keepAliveTimer.Stop(); 699 702 m_pState->m_pCommandQueue->ProcessCommand(new CDisconnectCommand()); 700 703 } 701 704 … … 769 772 m_pSendLed = 0; 770 773 m_pRecvLed = 0; 771 774 775 m_keepAliveTimer.Stop(); 776 772 777 m_transferStatusTimer.Stop(); 773 778 774 779 bool res = true; … … 826 831 CServerPath path; 827 832 path.SetSafePath(COptions::Get()->GetOption(OPTION_LASTSERVERPATH)); 828 833 m_pState->Connect(server, false, path); 834 // FIXME: 835 // need to read from options, do this only for KeepAlive enabled 836 m_keepAliveTimer.Start(1000); 829 837 } 830 838 831 839 void CMainFrame::OnRefresh(wxCommandEvent &event) … … 898 906 else 899 907 m_transferStatusTimer.Stop(); 900 908 } 909 else if (event.GetId() == KEEPALIVE_TIMER_ID && m_keepAliveTimer.IsRunning()) 910 { 911 // make sure engine and commandqueue exist 912 if (!m_pState && !m_pState->m_pEngine && !m_pState->m_pCommandQueue) 913 { 914 m_keepAliveTimer.Stop(); 915 return; 916 } 917 // just do this for idle, wait for next timer 918 if (!m_pState->m_pCommandQueue->Idle()) 919 return; 920 // if not connected, stop keepalive timer 921 if (!m_pState->m_pEngine->IsConnected()) 922 { 923 m_keepAliveTimer.Stop(); 924 return; 925 } 926 // FIXME: 927 // need to read the values from options... 928 int min_wait = 30; 929 int max_wait = 60; 930 931 // if just connected, the interval will be 1000 932 bool first_time = (m_keepAliveTimer.GetInterval() == 1000); 933 934 int waitsecond = min_wait + (int)(rand()*(max_wait - min_wait)/(RAND_MAX+1)); 935 m_keepAliveTimer.Stop(); 936 m_keepAliveTimer.Start(waitsecond * 1000); 937 // skip keepalive for just connected 938 if (first_time) 939 return; 940 m_pState->m_pCommandQueue->ProcessCommand(new CKeepAliveCommand()); 941 } 901 942 } 902 943 903 944 void CMainFrame::SetProgress(const CTransferStatus *pStatus) … … 1342 1383 } 1343 1384 1344 1385 m_pState->Connect(pData->m_server, true, pData->m_remoteDir); 1386 // FIXME: 1387 // need to read from options, do this only for KeepAlive enabled 1388 m_keepAliveTimer.Start(1000); 1345 1389 1346 1390 if (pData->m_localDir != _T("")) 1347 1391 m_pState->SetLocalDir(pData->m_localDir); -
src/interface/Mainfrm.h
diff -Nur Filezilla3/src/interface/Mainfrm.h Filezilla3.patch/src/interface/Mainfrm.h
old new 84 84 CLed* m_pRecvLed; 85 85 CLed* m_pSendLed; 86 86 wxTimer m_transferStatusTimer; 87 88 wxTimer m_keepAliveTimer; 89 87 90 CThemeProvider* m_pThemeProvider; 88 91 #if FZ_MANUALUPDATECHECK && FZ_AUTOUPDATECHECK 89 92 CUpdateWizard* m_pUpdateWizard;