|
@@ -333,7 +333,6 @@ int log_setup (char **error_string, struct main_config *config)
|
|
|
NULL,
|
|
NULL,
|
|
|
log_printf_worker_fn);
|
|
log_printf_worker_fn);
|
|
|
|
|
|
|
|
- log_setup_called = 1;
|
|
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
** Flush what we have buffered
|
|
** Flush what we have buffered
|
|
@@ -343,6 +342,9 @@ int log_setup (char **error_string, struct main_config *config)
|
|
|
internal_log_printf(__FILE__, __LINE__, LOG_LEVEL_DEBUG, "log setup\n");
|
|
internal_log_printf(__FILE__, __LINE__, LOG_LEVEL_DEBUG, "log setup\n");
|
|
|
|
|
|
|
|
atexit (log_atexit);
|
|
atexit (log_atexit);
|
|
|
|
|
+
|
|
|
|
|
+ log_setup_called = 1;
|
|
|
|
|
+
|
|
|
return (0);
|
|
return (0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -389,25 +391,6 @@ void trace (char *file, int line, int tag, int id, char *format, ...)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void log_flush(void)
|
|
|
|
|
-{
|
|
|
|
|
- struct log_entry *entry = head;
|
|
|
|
|
- struct log_entry *tmp;
|
|
|
|
|
-
|
|
|
|
|
- /* do not buffer these printouts */
|
|
|
|
|
- logmode &= ~LOG_MODE_BUFFER;
|
|
|
|
|
-
|
|
|
|
|
- while (entry) {
|
|
|
|
|
- internal_log_printf(entry->file, entry->line,
|
|
|
|
|
- entry->level, entry->str);
|
|
|
|
|
- tmp = entry;
|
|
|
|
|
- entry = entry->next;
|
|
|
|
|
- free(tmp);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- head = tail = NULL;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
static void log_atexit (void)
|
|
static void log_atexit (void)
|
|
|
{
|
|
{
|
|
|
if (log_setup_called) {
|
|
if (log_setup_called) {
|
|
@@ -415,9 +398,27 @@ static void log_atexit (void)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void log_atsegv (void)
|
|
|
|
|
|
|
+void log_flush (void)
|
|
|
{
|
|
{
|
|
|
- log_setup_called = 0;
|
|
|
|
|
- worker_thread_group_exit (&log_thread_group);
|
|
|
|
|
- worker_thread_group_atsegv (&log_thread_group);
|
|
|
|
|
|
|
+ if (log_setup_called) {
|
|
|
|
|
+ log_setup_called = 0;
|
|
|
|
|
+ worker_thread_group_exit (&log_thread_group);
|
|
|
|
|
+ worker_thread_group_atsegv (&log_thread_group);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ struct log_entry *entry = head;
|
|
|
|
|
+ struct log_entry *tmp;
|
|
|
|
|
+
|
|
|
|
|
+ /* do not buffer these printouts */
|
|
|
|
|
+ logmode &= ~LOG_MODE_BUFFER;
|
|
|
|
|
+
|
|
|
|
|
+ while (entry) {
|
|
|
|
|
+ internal_log_printf(entry->file, entry->line,
|
|
|
|
|
+ entry->level, entry->str);
|
|
|
|
|
+ tmp = entry;
|
|
|
|
|
+ entry = entry->next;
|
|
|
|
|
+ free(tmp);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ head = tail = NULL;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|