summaryrefslogtreecommitdiff
path: root/source4/lib/util
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-03-01 15:02:07 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:52:11 -0500
commit685b824aa88a03a8b70507d5d2454a744468075a (patch)
treeeb674c77887a708fb441c00b5f4cc5cf9a493899 /source4/lib/util
parentcaeba73a335d429010626810ddd6dc40f84295e6 (diff)
downloadsamba-685b824aa88a03a8b70507d5d2454a744468075a.tar.gz
samba-685b824aa88a03a8b70507d5d2454a744468075a.tar.bz2
samba-685b824aa88a03a8b70507d5d2454a744468075a.zip
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)
Diffstat (limited to 'source4/lib/util')
-rw-r--r--source4/lib/util/debug.c40
-rw-r--r--source4/lib/util/debug.h3
2 files changed, 21 insertions, 22 deletions
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)