- SCR: Follow the Mac's lead and gracefully exit the Data Management

thread.  Preserve the handle to take more drastic actions should
        that not work.
        
    clientscr/
        mac_saver_module.cpp, .h
        screensaver.cpp
        screensaver_win.cpp, .h

svn path=/branches/boinc_core_release_6_8/; revision=23261
This commit is contained in:
Rom Walton 2011-03-25 15:58:41 +00:00
parent 18bffc2296
commit 679dd6e9f2
6 changed files with 36 additions and 18 deletions

View File

@ -6705,3 +6705,13 @@ Rom 25 Feb 2011
/
configure.ac
version.h
Rom 14 Mar 2011
- SCR: Follow the Mac's lead and gracefully exit the Data Management
thread. Preserve the handle to take more drastic actions should
that not work.
clientscr/
mac_saver_module.cpp, .h
screensaver.cpp
screensaver_win.cpp, .h

View File

@ -127,7 +127,8 @@ protected:
RESULTS results;
bool m_bResetCoreState;
bool m_QuitDataManagementProc;
bool m_bQuitDataManagementProc;
bool m_bDataManagementProcStopped;
bool m_bV5_GFX_app_is_running;

View File

@ -162,7 +162,8 @@ CScreensaver::CScreensaver() {
m_CoreClientPID = nil;
setSSMessageText(0);
m_CurrentBannerMessage = 0;
m_QuitDataManagementProc = false;
m_bQuitDataManagementProc = false;
m_bDataManagementProcStopped = false;
m_BrandText = "BOINC";
m_hDataManagementThread = NULL;
@ -556,20 +557,19 @@ bool CScreensaver::CreateDataManagementThread() {
bool CScreensaver::DestroyDataManagementThread() {
int i;
m_QuitDataManagementProc = true; // Tell DataManagementProc thread to exit
for (i=0; i<10; i++) { // Wait up to 1 second for DataManagementProc thread to exit
if (m_hDataManagementThread == NULL) return true;
m_bQuitDataManagementProc = true; // Tell DataManagementProc thread to exit
for (int i=0; i<10; i++) { // Wait up to 1 second for DataManagementProc thread to exit
if (m_bDataManagementProcStopped) return true;
boinc_sleep(0.1);
}
rpc->close(); // In case DataManagementProc is hung waiting for RPC
m_hDataManagementThread = NULL; // Don't delay more if this routine is called again.
if (m_hGraphicsApplication) {
terminate_screensaver(m_hGraphicsApplication, NULL);
m_hGraphicsApplication = 0;
}
return true;
}

View File

@ -533,7 +533,7 @@ void *CScreensaver::DataManagementProc()
// ***
// Are we supposed to exit the screensaver?
if (m_QuitDataManagementProc) { // If main thread has requested we exit
if (m_bQuitDataManagementProc) { // If main thread has requested we exit
if (m_hGraphicsApplication || graphics_app_result_ptr) {
if (m_bDefault_gfx_running) {
terminate_default_screensaver(m_hGraphicsApplication);
@ -544,14 +544,14 @@ void *CScreensaver::DataManagementProc()
previous_result_ptr = NULL;
m_hGraphicsApplication = 0;
}
m_hDataManagementThread = NULL; // Tell main thread that we exited
return 0; // Exit the thread
m_bDataManagementProcStopped = true; // Tell main thread that we exited
return 0; // Exit the thread
}
boinc_sleep(0.25);
}
// ***
// *** Things that should be run frequently.
// *** Things that should be run less frequently.
// *** 1 time per second.
// ***
@ -559,7 +559,7 @@ void *CScreensaver::DataManagementProc()
if ((m_dwBlankScreen) && (time(0) > m_dwBlankTime)) {
BOINCTRACE(_T("CScreensaver::DataManagementProc - Time to blank\n"));
SetError(FALSE, SCRAPPERR_SCREENSAVERBLANKED); // Blanked - hide moving BOINC logo
m_QuitDataManagementProc = true;
m_bQuitDataManagementProc = true;
continue; // Code above will exit the thread
}

View File

@ -141,7 +141,7 @@ INT WINAPI WinMain(
}
retval = BOINCSS.Run();
// Cleanup any existing screensaver objects and handles
BOINCSS.Cleanup();
@ -199,7 +199,8 @@ CScreensaver::CScreensaver() {
m_hDataManagementThread = NULL;
m_hGraphicsApplication = NULL;
m_bResetCoreState = TRUE;
m_QuitDataManagementProc = FALSE;
m_bQuitDataManagementProc = FALSE;
m_bDataManagementProcStopped = FALSE;
memset(&m_running_result, 0, sizeof(m_running_result));
ZeroMemory(m_Monitors, sizeof(m_Monitors));
@ -282,7 +283,7 @@ HRESULT CScreensaver::Create(HINSTANCE hInstance) {
if (rpc == NULL) rpc = new RPC_CLIENT;
// Create the screen saver window(s)
// Create the screen saver window(s)
if (m_SaverMode == sm_preview ||
m_SaverMode == sm_full
) {
@ -388,8 +389,8 @@ HRESULT CScreensaver::Cleanup() {
TerminateProcess(m_hGraphicsApplication, 0);
m_hGraphicsApplication = NULL;
}
if (rpc) {
rpc->close();
delete rpc;
rpc = NULL;
}
@ -1093,6 +1094,11 @@ BOOL CScreensaver::CreateDataManagementThread() {
// Terminate the thread that is used to talk to the daemon.
//
BOOL CScreensaver::DestroyDataManagementThread() {
m_bQuitDataManagementProc = true; // Tell DataManagementProc thread to exit
for (int i = 0; i < 50; i++) { // Wait up to 5 second for DataManagementProc thread to exit
if (m_bDataManagementProcStopped) return true;
boinc_sleep(0.1);
}
if (!TerminateThread(m_hDataManagementThread, 0)) {
BOINCTRACE(_T("CScreensaver::DestoryDataManagementThread: Failed to terminate data management thread '%d'\n"), GetLastError());
return FALSE;

View File

@ -209,7 +209,8 @@ protected:
HANDLE m_hDataManagementThread;
HANDLE m_hGraphicsApplication;
BOOL m_bResetCoreState;
bool m_QuitDataManagementProc;
bool m_bQuitDataManagementProc;
bool m_bDataManagementProcStopped;
bool m_bV5_GFX_app_is_running;
int m_iLastResultShown;
time_t m_tLastResultChangeTime;