From fe570894fc8890772748d411ece71cd0dc10fb53 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Wed, 19 Apr 2006 23:28:08 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=9975 --- api/boinc_api.C | 9 +++++++++ api/graphics_api.C | 6 ++++++ checkin_notes | 13 +++++++++++-- lib/diagnostics.C | 19 +++++++++++++++++-- lib/diagnostics.h | 6 ++++++ 5 files changed, 49 insertions(+), 4 deletions(-) diff --git a/api/boinc_api.C b/api/boinc_api.C index ff6d190243..7e7132ed6e 100644 --- a/api/boinc_api.C +++ b/api/boinc_api.C @@ -246,12 +246,21 @@ static bool update_app_progress( // the following 2 functions are used for apps without graphics // int boinc_init() { + int retval; + if (!is_diagnostics_initialized()) { + retval = boinc_init_diagnostics(BOINC_DIAG_USEDEFULATS); + if (retval) return retval; + } boinc_options_defaults(options); return boinc_init_options(&options); } int boinc_init_options(BOINC_OPTIONS* opt) { int retval; + if (!is_diagnostics_initialized()) { + retval = boinc_init_diagnostics(BOINC_DIAG_USEDEFULATS); + if (retval) return retval; + } retval = boinc_init_options_general(*opt); if (retval) return retval; return set_worker_timer(); diff --git a/api/graphics_api.C b/api/graphics_api.C index 61f2523d18..c41d3a8e61 100755 --- a/api/graphics_api.C +++ b/api/graphics_api.C @@ -23,6 +23,7 @@ #include "config.h" #endif +#include "diagnostics.h" #include "boinc_api.h" #include "graphics_impl.h" #include "graphics_api.h" @@ -41,6 +42,11 @@ static void init_main_state() { } int boinc_init_graphics(void (*worker)()) { + int retval; + if (!is_diagnostics_initialized()) { + retval = boinc_init_diagnostics(BOINC_DIAG_USEDEFULATS); + if (retval) return retval; + } init_main_state(); return boinc_init_graphics_impl(worker, &boinc_main_state); } diff --git a/checkin_notes b/checkin_notes index 59b17fda39..fc3d0045f0 100755 --- a/checkin_notes +++ b/checkin_notes @@ -4060,7 +4060,6 @@ David 19 Apr 2006 sched/ server_types.C - Walt 19 Apr 2006 - Code cleanup: remove duplicate calls to xml_unescape. - Bug Fix: Change HTTP redirect limit to 50 @@ -4072,7 +4071,17 @@ Walt 19 Apr 2006 until the connection attempt completes or times out. client/ - http_curl.C + http_curl.C lib/ proxy_info.C +Rom 19 Apr 2006 + - If an application hasn't initialized the diagnostics system, provide + reasonable defaults and initialize it for them. This only handles + the boinc_init() and boinc_init_graphics() cases. + + api/ + boinc_api.C + graphics_api.C + lib/ + diagnostics.C, .h diff --git a/lib/diagnostics.C b/lib/diagnostics.C index 7fa0e90fbc..ca63adc543 100644 --- a/lib/diagnostics.C +++ b/lib/diagnostics.C @@ -61,6 +61,7 @@ #define MAX_STDOUT_FILE_SIZE 2048*1024 +static int diagnostics_initialized = false; static int flags; static char stdout_log[256]; static char stdout_archive[256]; @@ -98,6 +99,13 @@ static void boinc_catch_signal(int signal); #endif +// has the diagnostics library been initialized?. +// +int is_diagnostics_initialized(){ + return diagnostics_initialized; +} + + // stub function for initializing the diagnostics environment. // int boinc_init_diagnostics(int _flags) { @@ -140,7 +148,6 @@ int boinc_install_signal_handlers() { int diagnostics_init( int _flags, const char* stdout_prefix, const char* stderr_prefix ) { - flags = _flags; snprintf(stdout_log, sizeof(stdout_log), "%s.txt", stdout_prefix); snprintf(stdout_archive, sizeof(stdout_archive), "%s.old", stdout_prefix); @@ -260,7 +267,10 @@ int diagnostics_init( if (match_tag(buf, "")) break; else if (parse_str(buf, "", boinc_dir, 256)) continue; else if (parse_str(buf, "", symstore, 256)) continue; - else if (match_tag(buf, "")) boinc_proxy_enabled = true; + else if (match_tag(buf, "")) { + boinc_proxy_enabled = true; + continue; + } else if (parse_str(buf, "", proxy_address, 256)) continue; else if (parse_int(buf, "", proxy_port)) continue; } @@ -274,6 +284,11 @@ int diagnostics_init( } } + + // We have completed initializing the diagnostics system. + diagnostics_initialized = true; + + return BOINC_SUCCESS; } diff --git a/lib/diagnostics.h b/lib/diagnostics.h index 189118923a..a33175d882 100644 --- a/lib/diagnostics.h +++ b/lib/diagnostics.h @@ -53,6 +53,11 @@ #define BOINC_DIAG_TRACETOSTDOUT 0x00000400L #define BOINC_DIAG_HEAPCHECKEVERYALLOC 0x00000800L #define BOINC_DIAG_BOINCAPPLICATION 0x00001000L +#define BOINC_DIAG_USEDEFULATS BOINC_DIAG_DUMPCALLSTACKENABLED | \ + BOINC_DIAG_HEAPCHECKENABLED | \ + BOINC_DIAG_MEMORYLEAKCHECKENABLED | \ + BOINC_DIAG_REDIRECTSTDERR | \ + BOINC_DIAG_TRACETOSTDERR // thread types used for dumping backtraces @@ -73,6 +78,7 @@ extern "C" { #endif // These are functions common to all platforms +extern int is_diagnostics_initialized(); extern int boinc_init_diagnostics(int flags); extern int boinc_finish_diag(); extern int boinc_install_signal_handlers();