client request app quit on exit

svn path=/trunk/boinc/; revision=1055
This commit is contained in:
Eric Heien 2003-03-12 19:21:29 +00:00
parent 9572d88f59
commit 5d0c4f45b2
3 changed files with 12 additions and 6 deletions

View File

@ -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, "<user_name>%s</user_name>\n", ai.user_name);
}
if (strlen(ai.comm_obj_name)) {
fprintf(f, "<comm_obj_name>%s</comm_obj_name>\n", ai.comm_obj_name);
}
fprintf(f,
"<wu_cpu_time>%f</wu_cpu_time>\n"
"<user_total_credit>%f</user_total_credit>\n"
@ -542,6 +549,7 @@ int parse_init_data_file(FILE* f, APP_INIT_DATA& ai) {
}
else if (parse_str(buf, "<user_name>", ai.user_name, sizeof(ai.user_name))) continue;
else if (parse_str(buf, "<team_name>", ai.team_name, sizeof(ai.team_name))) continue;
else if (parse_str(buf, "<comm_obj_name>", ai.comm_obj_name, sizeof(ai.comm_obj_name))) continue;
else if (parse_double(buf, "<user_total_credit>", ai.user_total_credit)) continue;
else if (parse_double(buf, "<user_expavg_credit>", ai.user_expavg_credit)) continue;
else if (parse_double(buf, "<host_total_credit>", ai.host_total_credit)) continue;

View File

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

View File

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