- 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

svn path=/trunk/boinc/; revision=15454
This commit is contained in:
David Anderson 2008-06-23 19:51:07 +00:00
parent d1cff66f64
commit 6e731f0b7a
7 changed files with 81 additions and 45 deletions

View File

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

View File

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

View File

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

View File

@ -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 "
<form action=bolt_compare.php>
<form type=hidden name=action value=snapshot_create>
<form type=hidden name=course_id value=$course_id>
<input type=hidden name=action value=snap_action>
<input type=hidden name=course_id value=$course_id>
<input type=hidden name=select_name value=\"$select_name\">
<input type=hidden name=xset_name value=\"$xset_name\">
Create a new snapshot using data from the last
<input name=dur> days.
<input type=submit value=OK>
@ -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) {

View File

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

View File

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

View File

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