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.

This commit is contained in:
Charlie Fenton 2017-11-16 02:57:33 -08:00
parent 97ae786d3d
commit 051f9e656c
3 changed files with 25 additions and 8 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -214,6 +214,7 @@ private:
BOINC_Condition* m_pRPC_Request_Condition;
wxDateTime m_dtLasAsyncRPCDlgTime;
wxDateTime m_dtLastFrameViewRefreshRPCTime;
bool m_bAutoAttaching;
//
// Projects Tab