From 5d0c4f45b2d0c9d15f80523c5f4a90ed0676986c Mon Sep 17 00:00:00 2001 From: Eric Heien Date: Wed, 12 Mar 2003 19:21:29 +0000 Subject: [PATCH] client request app quit on exit svn path=/trunk/boinc/; revision=1055 --- api/boinc_api.C | 10 +++++++++- api/boinc_api.h | 1 + client/app.C | 7 ++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/api/boinc_api.C b/api/boinc_api.C index 6c462d4dd7..4d889655bf 100644 --- a/api/boinc_api.C +++ b/api/boinc_api.C @@ -78,6 +78,7 @@ extern BOOL win_loop_done; #include "boinc_api.h" #ifdef _WIN32 +HANDLE hQuitRequest; LONG CALLBACK boinc_catch_signal(EXCEPTION_POINTERS *ExceptionInfo); #else extern void boinc_catch_signal(int signal); @@ -311,11 +312,13 @@ bool boinc_time_to_checkpoint() { #ifdef _WIN32 DWORD eventState; // Check if core client has requested us to exit - WaitForSingleObject(quitRequestEvent, 0L); + eventState = WaitForSingleObject(hQuitRequest, 0L); switch (eventState) { case WAIT_OBJECT_0: case WAIT_ABANDONED: + time_to_quit = true; + break; } #endif @@ -464,6 +467,7 @@ int set_timer(double period) { NULL, // dwUser TIME_PERIODIC // fuEvent ); + hQuitRequest = OpenEvent(EVENT_ALL_ACCESS, FALSE, aid.comm_obj_name); #ifdef BOINC_APP_GRAPHICS // Create the event object used to signal between the // worker and event threads @@ -509,6 +513,9 @@ int write_init_data_file(FILE* f, APP_INIT_DATA& ai) { if (strlen(ai.user_name)) { fprintf(f, "%s\n", ai.user_name); } + if (strlen(ai.comm_obj_name)) { + fprintf(f, "%s\n", ai.comm_obj_name); + } fprintf(f, "%f\n" "%f\n" @@ -542,6 +549,7 @@ int parse_init_data_file(FILE* f, APP_INIT_DATA& ai) { } else if (parse_str(buf, "", ai.user_name, sizeof(ai.user_name))) continue; else if (parse_str(buf, "", ai.team_name, sizeof(ai.team_name))) continue; + else if (parse_str(buf, "", ai.comm_obj_name, sizeof(ai.comm_obj_name))) continue; else if (parse_double(buf, "", ai.user_total_credit)) continue; else if (parse_double(buf, "", ai.user_expavg_credit)) continue; else if (parse_double(buf, "", ai.host_total_credit)) continue; diff --git a/api/boinc_api.h b/api/boinc_api.h index aaf27ba9be..17903e59ad 100755 --- a/api/boinc_api.h +++ b/api/boinc_api.h @@ -55,6 +55,7 @@ struct APP_INIT_DATA { char app_preferences[4096]; char user_name[256]; char team_name[256]; + char comm_obj_name[256]; // name to identify shared memory segments, signals, etc double wu_cpu_time; // cpu time from previous sessions double user_total_credit; double user_expavg_credit; diff --git a/client/app.C b/client/app.C index 289a7867ff..83e939c2c2 100644 --- a/client/app.C +++ b/client/app.C @@ -137,6 +137,7 @@ int ACTIVE_TASK::start(bool first_time) { safe_strncpy(aid.user_name, wup->project->user_name, sizeof(aid.user_name)); safe_strncpy(aid.team_name, wup->project->team_name, sizeof(aid.team_name)); + sprintf(aid.comm_obj_name, "boinc_%d", slot); if (wup->project->project_specific_prefs) { extract_venue( wup->project->project_specific_prefs, @@ -269,7 +270,6 @@ int ACTIVE_TASK::start(bool first_time) { #ifdef _WIN32 PROCESS_INFORMATION process_info; STARTUPINFO startup_info; - SECURITY_ATTRIBUTES quit_handle_attrs; char slotdirpath[256]; char cmd_line[512]; int win_error; @@ -280,10 +280,7 @@ int ACTIVE_TASK::start(bool first_time) { startup_info.lpReserved = NULL; startup_info.lpDesktop = ""; - quit_handle_attrs.nLength = sizeof(SECURITY_ATTRIBUTES); - quit_handle_attrs.lpSecurityDescriptor = NULL; - quit_handle_attrs.bInheritHandle = TRUE; - quitRequestEvent = CreateEvent( &quit_handle_attrs, FALSE, FALSE, + quitRequestEvent = CreateEvent(0, TRUE, FALSE, aid.comm_obj_name); // NOTE: in Windows, stderr is redirected within boinc_init();