From 685b824aa88a03a8b70507d5d2454a744468075a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 1 Mar 2006 15:02:07 +0000 Subject: r13770: - do fsync() on the debug fd, as we do in samba3, I have an report that smbd memory usage grows to 1,5 GB or more without this... - make log_timestamp static metze (This used to be commit 551dd12baf9340ab070c8a8edca6b56770243a61) --- source4/lib/util/debug.c | 40 +++++++++++++++++++++------------------- source4/lib/util/debug.h | 3 --- 2 files changed, 21 insertions(+), 22 deletions(-) (limited to 'source4/lib/util') diff --git a/source4/lib/util/debug.c b/source4/lib/util/debug.c index 3a71ed2df6..4cf7c21641 100644 --- a/source4/lib/util/debug.c +++ b/source4/lib/util/debug.c @@ -46,6 +46,24 @@ static struct { const char *prog_name; } state; +static void log_timestring(int level, const char *location, const char *func) +{ + char *t = NULL; + char *s = NULL; + + if (state.logtype != DEBUG_FILE) return; + + t = timestring(NULL, time(NULL)); + if (!t) return; + + asprintf(&s, "[%s, %d %s:%s()]\n", t, level, location, func); + talloc_free(t); + if (!s) return; + + write(state.fd, s, strlen(s)); + free(s); +} + /* the backend for debug messages. Note that the DEBUG() macro has already ensured that the log level has been met before this is called @@ -60,7 +78,7 @@ void do_debug_header(int level, const char *location, const char *func) the backend for debug messages. Note that the DEBUG() macro has already ensured that the log level has been met before this is called */ -void do_debug(const char *format, ...) +void do_debug(const char *format, ...) _PRINTF_ATTRIBUTE(1,2) { va_list ap; char *s = NULL; @@ -76,6 +94,7 @@ void do_debug(const char *format, ...) va_end(ap); write(state.fd, s, strlen(s)); + fsync(state.fd); free(s); } @@ -119,6 +138,7 @@ void reopen_logs(void) } if (old_fd > 2) { + fsync(old_fd); close(old_fd); } } @@ -173,24 +193,6 @@ void print_suspicious_usage(const char* from, const char* info) } } -void log_timestring(int level, const char *location, const char *func) -{ - char *t = NULL; - char *s = NULL; - - if (state.logtype != DEBUG_FILE) return; - - t = timestring(NULL, time(NULL)); - if (!t) return; - - asprintf(&s, "[%s, %d %s:%s()]\n", t, level, location, func); - talloc_free(t); - if (!s) return; - - write(state.fd, s, strlen(s)); - free(s); -} - uint32_t get_task_id(void) { if (debug_handlers.ops.get_task_id) { diff --git a/source4/lib/util/debug.h b/source4/lib/util/debug.h index 8ff937e7b9..4cd5759119 100644 --- a/source4/lib/util/debug.h +++ b/source4/lib/util/debug.h @@ -43,9 +43,6 @@ struct debug_ops { void (*log_task_id)(int fd); }; -void do_debug_header(int level, const char *location, const char *func); -void do_debug(const char *, ...) PRINTF_ATTRIBUTE(1,2); - extern int DEBUGLEVEL; #define DEBUGLVL(level) ((level) <= DEBUGLEVEL) -- cgit