From a6d0366f59164b0f6cf07d4d43dbe2a057b3465d Mon Sep 17 00:00:00 2001 From: Eric Heien Date: Fri, 22 Nov 2002 00:13:47 +0000 Subject: [PATCH] windows error reporting fixes svn path=/trunk/boinc/; revision=648 --- client/app.C | 34 +++++++++++++++++++++------------- client/app.h | 1 + client/client_state.C | 6 ++++-- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/client/app.C b/client/app.C index 39ca0e3e45..e3ca525871 100644 --- a/client/app.C +++ b/client/app.C @@ -385,8 +385,6 @@ int ACTIVE_TASK_SET::insert(ACTIVE_TASK* atp) { // bool ACTIVE_TASK_SET::poll() { ACTIVE_TASK* atp; - char path[256]; - int n; #ifdef _WIN32 unsigned long exit_code; @@ -417,11 +415,13 @@ bool ACTIVE_TASK_SET::poll() { atp->result->exit_status = atp->exit_status; CloseHandle(atp->pid_handle); CloseHandle(atp->thread_handle); + atp->read_stderr_file(); + clean_out_dir(atp->slot_dir); } } } - return found; + return found; #endif #if HAVE_SYS_RESOURCE_H @@ -459,21 +459,29 @@ bool ACTIVE_TASK_SET::poll() { #endif #endif - // check for the stderr file, copy to result record - // - sprintf(path, "%s%s%s", atp->slot_dir, PATH_SEPARATOR, STDERR_FILE); - FILE* f = fopen(path, "r"); - if (f) { - n = fread(atp->result->stderr_out, 1, STDERR_MAX_LEN, f); - atp->result->stderr_out[STDERR_MAX_LEN-1] = 0; - fclose(f); - } - + atp->read_stderr_file(); clean_out_dir(atp->slot_dir); return true; } +// check for the stderr file, copy to result record +// +bool ACTIVE_TASK::read_stderr_file() { + char path[256]; + int n; + + sprintf(path, "%s%s%s", slot_dir, PATH_SEPARATOR, STDERR_FILE); + FILE* f = fopen(path, "r"); + if (f) { + n = fread(result->stderr_out, 1, STDERR_MAX_LEN, f); + result->stderr_out[n] = 0; + fclose(f); + return true; + } + return false; +} + // Find the ACTIVE_TASK in the current set with the matching PID // ACTIVE_TASK* ACTIVE_TASK_SET::lookup_pid(int pid) { diff --git a/client/app.h b/client/app.h index a445a049a9..0942981f2b 100644 --- a/client/app.h +++ b/client/app.h @@ -76,6 +76,7 @@ public: bool check_app_status_files(); double est_time_to_completion(); + bool read_stderr_file(); int write(FILE*); int parse(FILE*, CLIENT_STATE*); diff --git a/client/client_state.C b/client/client_state.C index 479c0b8aeb..f436f5b287 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -739,7 +739,8 @@ bool CLIENT_STATE::garbage_collect() { // any errors (MD5, RSA, etc) fail_num = rp->wup->had_failure(); if (fail_num) { - rp->exit_status = fail_num; + if (!rp->exit_status) // If we don't already have an error for this file + rp->exit_status = fail_num; if (rp->state < RESULT_READY_TO_ACK) { rp->state = RESULT_READY_TO_ACK; } @@ -754,7 +755,8 @@ bool CLIENT_STATE::garbage_collect() { // fail_num = rp->output_files[i].file_info->had_failure(); if (fail_num) { - rp->exit_status = fail_num; + if (!rp->exit_status) // If we don't already have an error for this file + rp->exit_status = fail_num; if (rp->state < RESULT_READY_TO_ACK) { rp->state = RESULT_READY_TO_ACK; }