Changeset: 7245a779bf0e for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7245a779bf0e Modified Files: gdk/gdk_private.h gdk/gdk_tracer.c gdk/gdk_utils.c Branch: Oct2020 Log Message:
Initialize tracer early. diffs (111 lines): diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h --- a/gdk/gdk_private.h +++ b/gdk/gdk_private.h @@ -168,7 +168,7 @@ gdk_return GDKssort_rev(void *restrict h gdk_return GDKssort(void *restrict h, void *restrict t, const void *restrict base, size_t n, int hs, int ts, int tpe) __attribute__((__warn_unused_result__)) __attribute__((__visibility__("hidden"))); -void GDKtracer_init(void) +void GDKtracer_init(const char *dbname, const char *dbtrace) __attribute__((__visibility__("hidden"))); gdk_return GDKunlink(int farmid, const char *dir, const char *nme, const char *extension) __attribute__((__visibility__("hidden"))); diff --git a/gdk/gdk_tracer.c b/gdk/gdk_tracer.c --- a/gdk/gdk_tracer.c +++ b/gdk/gdk_tracer.c @@ -95,24 +95,20 @@ get_timestamp(char *datetime, size_t dts // When BASIC adapter is active, all the log messages are getting printed to a file. // This function prepares a file in order to write the contents of the buffer when necessary. static gdk_return -_GDKtracer_init_basic_adptr(void) +GDKtracer_init_trace_file(const char *dbpath, const char *dbtrace) { - const char *trace_path; - - trace_path = GDKgetenv("gdk_dbtrace"); - if (trace_path == NULL) { - trace_path = GDKgetenv("gdk_dbpath"); - if (trace_path == NULL) { + if (dbtrace == NULL) { + if (dbpath == NULL) { active_tracer = stderr; return GDK_SUCCEED; } if (strconcat_len(file_name, sizeof(file_name), - trace_path, DIR_SEP_STR, FILE_NAME, NULL) + dbpath, DIR_SEP_STR, FILE_NAME, NULL) >= sizeof(file_name)) { goto too_long; } } else { - if (strcpy_len(file_name, trace_path, sizeof(file_name)) + if (strcpy_len(file_name, dbtrace, sizeof(file_name)) >= sizeof(file_name)) { goto too_long; } @@ -137,6 +133,13 @@ static gdk_return return GDK_FAIL; } +static gdk_return +_GDKtracer_init_basic_adptr(void) +{ + return GDKtracer_init_trace_file(GDKgetenv("gdk_dbpath"), + GDKgetenv("gdk_dbtrace")); +} + static void set_level_for_layer(int layer, int lvl) @@ -418,13 +421,14 @@ GDKtracer_reset_adapter(void) static bool add_ts; /* add timestamp to error message to stderr */ void -GDKtracer_init(void) +GDKtracer_init(const char *dbpath, const char *dbtrace) { #ifdef _MSC_VER add_ts = GetFileType(GetStdHandle(STD_ERROR_HANDLE)) != FILE_TYPE_PIPE; #else add_ts = isatty(2) || lseek(2, 0, SEEK_CUR) != (off_t) -1 || errno != ESPIPE; #endif + (void) GDKtracer_init_trace_file(dbpath, dbtrace); } void @@ -510,12 +514,8 @@ GDKtracer_log(const char *file, const ch if (active_tracer == NULL || active_tracer == stderr) return; } - MT_lock_set(&lock); - if (file_name[0] == 0) { - MT_lock_unset(&lock); + if (active_tracer == NULL) return; - } - MT_lock_unset(&lock); if (syserr) fprintf(active_tracer, "%s: %s\n", buffer, syserr); else diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c --- a/gdk/gdk_utils.c +++ b/gdk/gdk_utils.c @@ -743,7 +743,8 @@ gdk_return GDKinit(opt *set, int setlen, bool embedded) { static bool first = true; - char *dbpath = mo_find_option(set, setlen, "gdk_dbpath"); + const char *dbpath = mo_find_option(set, setlen, "gdk_dbpath"); + const char *dbtrace = mo_find_option(set, setlen, "gdk_dbtrace"); const char *p; opt *n; int i, nlen = 0; @@ -807,7 +808,7 @@ GDKinit(opt *set, int setlen, bool embed /* BBP was locked by BBPexit() */ BBPunlock(); } - GDKtracer_init(); + GDKtracer_init(dbpath, dbtrace); errno = 0; if (!GDKinmemory() && !GDKenvironment(dbpath)) return GDK_FAIL; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list