diff --git a/api/boinc_api.C b/api/boinc_api.C index fe4e48086c..e0b552af55 100644 --- a/api/boinc_api.C +++ b/api/boinc_api.C @@ -469,7 +469,10 @@ void boinc_exit(int status) { // stops endless exit()/atexit() loops. _exit(status); #else - // POSIX exit call. + // arrange to exit with given status even if errors happen + // in atexit() functions + // + set_signal_exit_code(status); exit(status); #endif } diff --git a/checkin_notes b/checkin_notes index 05474d284f..9a7f10bd85 100644 --- a/checkin_notes +++ b/checkin_notes @@ -5081,3 +5081,14 @@ Rom 23 June 2008 BOINCTaskBar.cpp clientgui/msw/ taskbarex.cpp, .h + +David 23 June 2008 + - API, Unix: when boinc_finish(x) is called, exit with code x + even if signals happen in the atexit() handling + - API: don't print XML parse warnings for init_data.xml file + + api/ + boinc_api.C + lib/ + app_ipc.C + diagnostics.C,h diff --git a/html/inc/bolt_util.inc b/html/inc/bolt_util.inc index 3a19e3be6f..2f3a23ef94 100644 --- a/html/inc/bolt_util.inc +++ b/html/inc/bolt_util.inc @@ -53,6 +53,10 @@ function request_info($user, $course) { page_tail(); } +function compare_snapshot_filename($course_id, $select_name, $xset_name) { + return "../bolt_snap/compare_snapshot_".$course_id."_".$select_name."_".$xset_name.".json"; +} + ////// stuff related to snapshots // a "snapshot" is a condensed representation of the results @@ -62,7 +66,9 @@ function request_info($user, $course) { // xset_result: the user's first completion of the xset // select_finished: the user's last completion of the select before this -function write_compare_snapshot($course_id, $select_name, $xset_name, $start) { +function write_compare_snapshot($course_id, $select_name, $xset_name, $dur) { + $now = time(); + $start = $now - $dur*86400; $xrs = BoltXsetResult::enum( "course_id=$course_id and name='$xset_name' and create_time >= $start" ); @@ -96,15 +102,20 @@ function write_compare_snapshot($course_id, $select_name, $xset_name, $start) { $a[$uid] = $x; } } - $filename = "compare_snapshot_$course_id_$select_name_$xset_name.json"; + $filename = compare_snapshot_filename($course_id, $select_name, $xset_name); $f = fopen($filename, "w"); - fwrite($f, json_encode($a)); + + $s = null; + $s->recs = $a; + $s->dur = $dur; + $s->time = $now; + fwrite($f, json_encode($s)); fclose($f); - return $a; + return $s; } function read_compare_snapshot($course_id, $select_name, $xset_name) { - $filename = "compare_snapshot_".$course_id."_".$select_name."_".$xset_name.".json"; + $filename = compare_snapshot_filename($course_id, $select_name, $xset_name); $f = @fopen($filename, "r"); if (!$f) return null; $x = fread($f, filesize($filename)); diff --git a/html/user/bolt_compare.php b/html/user/bolt_compare.php index dc63067d5c..74b4295bfb 100644 --- a/html/user/bolt_compare.php +++ b/html/user/bolt_compare.php @@ -68,10 +68,11 @@ function choose_xset($top_unit) { } function compare_aux($snap) { + print_r($snap); // for each select alternative, build an array of xset scores // $a = array(); - foreach ($snap as $x) { + foreach ($snap->recs as $uid=>$x) { //$a[$x->select_finished_name][] = $x->xset_result->score; } @@ -93,20 +94,25 @@ function show_snap_form($top_unit) { $xset_name = get_str('xset_name'); page_head("Data snapshot"); $s = read_compare_snapshot($course_id, $select_name, $xset_name); + if ($s) { - $end = date_str($s->end); + $end = date_str($s->time); echo " - A data snapshot exists for the $$s->dur days prior to $end. + A data snapshot exists for the $s->dur days prior to $end. "; button( "bolt_compare.php?action=compare&course_id=$course_id", "Use this snapshot" ); + } else { + echo "There is currently no snapshot."; } echo "
- - + + + + Create a new snapshot using data from the last days. @@ -115,11 +121,13 @@ function show_snap_form($top_unit) { page_tail(); } -function snap_action($select_name, $xset_name) { +function snap_action() { + global $course_id; + $select_name = get_str('select_name'); + $xset_name = get_str('xset_name'); $dur = get_int('dur'); - $start = time() - $dur*86400; - $s = write_compare_snapshot($select_name, $xset_name, $start); - compare_aux($a); + $s = write_compare_snapshot($course_id, $select_name, $xset_name, $dur); + compare_aux($s); } function show_choice($top_unit) { diff --git a/lib/app_ipc.C b/lib/app_ipc.C index 89c012147e..0e30237d3e 100644 --- a/lib/app_ipc.C +++ b/lib/app_ipc.C @@ -249,7 +249,7 @@ int parse_init_data_file(FILE* f, APP_INIT_DATA& ai) { if (xp.parse_double(tag, "checkpoint_period", ai.checkpoint_period)) continue; if (xp.parse_double(tag, "fraction_done_start", ai.fraction_done_start)) continue; if (xp.parse_double(tag, "fraction_done_end", ai.fraction_done_end)) continue; - xp.skip_unexpected(tag, true, "parse_init_data_file"); + xp.skip_unexpected(tag, false, "parse_init_data_file"); } fprintf(stderr, "parse_init_data_file: no end tag\n"); return ERR_XML_PARSE; diff --git a/lib/diagnostics.C b/lib/diagnostics.C index b1ce04184f..d04c744f0c 100644 --- a/lib/diagnostics.C +++ b/lib/diagnostics.C @@ -90,24 +90,24 @@ int __cdecl boinc_message_reporting(int reportType, char *szMsg, int *retVal){ switch(reportType){ - case _CRT_WARN: - case _CRT_ERROR: + case _CRT_WARN: + case _CRT_ERROR: - if (flags & BOINC_DIAG_TRACETOSTDERR) { - fprintf(stderr, szMsg); - } + if (flags & BOINC_DIAG_TRACETOSTDERR) { + fprintf(stderr, szMsg); + } - if (flags & BOINC_DIAG_TRACETOSTDOUT) { - fprintf(stdout, szMsg); - } + if (flags & BOINC_DIAG_TRACETOSTDOUT) { + fprintf(stdout, szMsg); + } - break; - case _CRT_ASSERT: + break; + case _CRT_ASSERT: - fprintf(stderr, "ASSERT: %s\n", szMsg); + fprintf(stderr, "ASSERT: %s\n", szMsg); - (*retVal) = 1; - break; + (*retVal) = 1; + break; } @@ -141,9 +141,6 @@ int boinc_finish_diag() { return diagnostics_finish(); } - -// to setup an unhandled exception filter on Windows -// int boinc_install_signal_handlers() { #ifdef _WIN32 SetUnhandledExceptionFilter(boinc_catch_signal); @@ -577,20 +574,26 @@ void boinc_set_signal_handler_force(int sig, void(*handler)(int)) { #endif /* HAVE_SIGACTION */ } +// exit code to use if signalled; can be changed +static int signal_exit_code = EXIT_SIGNAL; + +void set_signal_exit_code(int x) { + signal_exit_code = x; +} void boinc_catch_signal(int signal) { switch(signal) { - case SIGHUP: fprintf(stderr, "SIGHUP: terminal line hangup\n"); - return; - case SIGINT: fprintf(stderr, "SIGINT: interrupt program\n"); break; - case SIGILL: fprintf(stderr, "SIGILL: illegal instruction\n"); break; - case SIGABRT: fprintf(stderr, "SIGABRT: abort called\n"); break; - case SIGBUS: fprintf(stderr, "SIGBUS: bus error\n"); break; - case SIGSEGV: fprintf(stderr, "SIGSEGV: segmentation violation\n"); break; - case SIGSYS: fprintf(stderr, "SIGSYS: system call given invalid argument\n"); break; - case SIGPIPE: fprintf(stderr, "SIGPIPE: write on a pipe with no reader\n"); - return; - default: fprintf(stderr, "unknown signal %d\n", signal); break; + case SIGHUP: fprintf(stderr, "SIGHUP: terminal line hangup\n"); + return; + case SIGINT: fprintf(stderr, "SIGINT: interrupt program\n"); break; + case SIGILL: fprintf(stderr, "SIGILL: illegal instruction\n"); break; + case SIGABRT: fprintf(stderr, "SIGABRT: abort called\n"); break; + case SIGBUS: fprintf(stderr, "SIGBUS: bus error\n"); break; + case SIGSEGV: fprintf(stderr, "SIGSEGV: segmentation violation\n"); break; + case SIGSYS: fprintf(stderr, "SIGSYS: system call given invalid argument\n"); break; + case SIGPIPE: fprintf(stderr, "SIGPIPE: write on a pipe with no reader\n"); + return; + default: fprintf(stderr, "unknown signal %d\n", signal); break; } #ifdef __GLIBC__ @@ -606,10 +609,9 @@ void boinc_catch_signal(int signal) { #endif fprintf(stderr, "\nExiting...\n"); - _exit(EXIT_SIGNAL); + _exit(signal_exit_code); } - #endif // diff --git a/lib/diagnostics.h b/lib/diagnostics.h index b149eaf4e7..f82ffc65d1 100644 --- a/lib/diagnostics.h +++ b/lib/diagnostics.h @@ -129,6 +129,7 @@ extern void boinc_set_signal_handler_force(int sig, void(*handler)(int)); extern void boinc_trace(const char *pszFormat, ...); extern void boinc_info(const char *pszFormat, ...); +extern void set_signal_exit_code(int); #ifdef __cplusplus }