From 051f9e656c2431cac99f6992f24c38204d42dc06 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Thu, 16 Nov 2017 02:57:33 -0800 Subject: [PATCH] Manager: if client is auto-attaching to a project, increase the delay before displaying the "Communicating with client" dialog from 1.5 seconds to 60 second. This allows for the time the auto-attach may take before GUI RPCs are enabled. But we do display it after 60 seconds a a safety feature, so that the user can exit BOINC if the client hangs. --- clientgui/AsyncRPC.cpp | 29 +++++++++++++++++++++-------- clientgui/MainDocument.cpp | 3 +++ clientgui/MainDocument.h | 1 + 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/clientgui/AsyncRPC.cpp b/clientgui/AsyncRPC.cpp index 47de6a9430..ee946e79d6 100644 --- a/clientgui/AsyncRPC.cpp +++ b/clientgui/AsyncRPC.cpp @@ -36,7 +36,9 @@ extern bool s_bSkipExitConfirmation; -// Delay in milliseconds before showing AsyncRPCDlg +// Delay in milliseconds before showing AsyncRPCDlg during auto-attach to project +#define RPC_WAIT_DLG_DELAY_DURING_AUTOATTACH 60000 +// Delay in milliseconds before showing AsyncRPCDlg normally #define RPC_WAIT_DLG_DELAY 1500 // How often to check for events when minimized and waiting for Demand RPC #define DELAY_WHEN_MINIMIZED 500 @@ -474,7 +476,7 @@ int CMainDocument::RequestRPC(ASYNC_RPC_REQUEST& request, bool hasPriority) { int retval = 0; int response = wxID_OK; wxMutexError mutexErr = wxMUTEX_NO_ERROR; - long delayTimeRemaining, timeToSleep; + long timeToDelay, delayTimeRemaining, timeToSleep; bool shown = false; if (!m_RPCThread) return -1; @@ -544,18 +546,29 @@ int CMainDocument::RequestRPC(ASYNC_RPC_REQUEST& request, bool hasPriority) { return -1; } // Don't show dialog if RPC completes before RPC_WAIT_DLG_DELAY - // or while BOINC is minimized + // or while BOINC is minimized or during auto-attach to project CBOINCBaseFrame* pFrame = wxGetApp().GetFrame(); wxStopWatch Dlgdelay = wxStopWatch(); m_RPCWaitDlg = new AsyncRPCDlg(); m_bWaitingForRPC = true; + if (m_bAutoAttaching) { + // client may auto-attach only when first launched + // so don't keep checking once it is false + m_bAutoAttaching = autoattach_in_progress(); + } // Allow RPC_WAIT_DLG_DELAY seconds for Demand RPC to complete before // displaying "Please Wait" dialog, but keep checking for completion. - delayTimeRemaining = RPC_WAIT_DLG_DELAY; + if (m_bAutoAttaching) { + timeToDelay = RPC_WAIT_DLG_DELAY_DURING_AUTOATTACH; + } else { + timeToDelay = RPC_WAIT_DLG_DELAY; + } + + delayTimeRemaining = timeToDelay; while (true) { if (delayTimeRemaining >= 0) { // Prevent overflow if minimized for a very long time - delayTimeRemaining = RPC_WAIT_DLG_DELAY - Dlgdelay.Time(); + delayTimeRemaining = timeToDelay - Dlgdelay.Time(); } if (pFrame) { @@ -583,7 +596,7 @@ int CMainDocument::RequestRPC(ASYNC_RPC_REQUEST& request, bool hasPriority) { wxSafeYield(NULL, true); } - // OnRPCComplete() clears m_bWaitingForRPC if RPC completed + // OnRPCComplete() clears m_bWaitingForRPC and deletes m_RPCWaitDlg if RPC completed if (! m_bWaitingForRPC) { return retval; } @@ -748,8 +761,8 @@ void CMainDocument::HandleCompletedRPC() { if (m_RPCWaitDlg->IsShown()) { m_RPCWaitDlg->EndModal(wxID_OK); } - m_RPCWaitDlg->Destroy(); - m_RPCWaitDlg = NULL; + m_RPCWaitDlg->Destroy(); + m_RPCWaitDlg = NULL; } m_bWaitingForRPC = false; } diff --git a/clientgui/MainDocument.cpp b/clientgui/MainDocument.cpp index 765b67d22a..12abdfed93 100644 --- a/clientgui/MainDocument.cpp +++ b/clientgui/MainDocument.cpp @@ -477,6 +477,9 @@ int CMainDocument::OnInit() { m_pClientManager = new CBOINCClientManager(); wxASSERT(m_pClientManager); + // client may auto-attach only when first launched + m_bAutoAttaching = autoattach_in_progress(); + m_RPCWaitDlg = NULL; m_bWaitingForRPC = false; m_bNeedRefresh = false; diff --git a/clientgui/MainDocument.h b/clientgui/MainDocument.h index f64cc9ca05..17151c375a 100644 --- a/clientgui/MainDocument.h +++ b/clientgui/MainDocument.h @@ -214,6 +214,7 @@ private: BOINC_Condition* m_pRPC_Request_Condition; wxDateTime m_dtLasAsyncRPCDlgTime; wxDateTime m_dtLastFrameViewRefreshRPCTime; + bool m_bAutoAttaching; // // Projects Tab