From: Anders Björklund Date: Mon, 22 Apr 2019 13:09:18 +0000 (+0200) Subject: Fix bugs in the newly introduced tracing mode (#386) X-Git-Tag: v3.7~13 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=f08edbb7a0615dbacc6ac43456cbf18d2380551d;p=thirdparty%2Fccache.git Fix bugs in the newly introduced tracing mode (#386) * The tracefile variable is not used anymore This caused trace files to be left in /tmp * Fix crash in tracing mode, caused by logging Unfortunately cc_log() requires conf to work --- diff --git a/src/ccache.c b/src/ccache.c index 1433eb179..da6bf3602 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -3554,7 +3554,6 @@ static void trace_start(const char *json) { trace_file = json; - cc_log("Starting tracing: %s", json); MTR_META_PROCESS_NAME(MYNAME); trace_id = (void *) ((long) getpid()); MTR_START("program", "ccache", trace_id); @@ -3563,17 +3562,12 @@ trace_start(const char *json) static void trace_stop(void *context) { - const char *json = (const char *) context; - if (str_eq(json, "")) { - json = format("%s%s", output_obj, ".ccache-trace"); - } - cc_log("Stopping tracing: %s", json); + (void) context; + const char *json = format("%s%s", output_obj, ".ccache-trace"); MTR_FINISH("program", "ccache", trace_id); mtr_flush(); mtr_shutdown(); - if (!str_eq(trace_file, json)) { - move_file(trace_file, json, 0); - } + move_file(trace_file, json, 0); } static const char * @@ -3608,8 +3602,6 @@ initialize(void) tracefile = format("%s/trace.%d.json", tmpdir(), (int)getpid()); trace_init(tracefile); -#else - cc_log("Error: tracing is not enabled!"); #endif } @@ -3683,12 +3675,14 @@ initialize(void) umask(conf->umask); } -#ifdef MTR_ENABLED if (tracefile != NULL) { +#ifdef MTR_ENABLED trace_start(tracefile); - exitfn_add(trace_stop, tracefile); - } + exitfn_add(trace_stop, NULL); +#else + cc_log("Error: tracing is not enabled!"); #endif + } } // Reset the global state. Used by the test suite.