From 9a69e4e83adb5d23a04a03fddfbef37f4850d0d0 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 17 May 2006 23:20:29 +0000 Subject: - Better log handling when things are fast and furious --- ChangeLog | 1 + daemon/misc.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index fe622e8..9f5bfad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 0.5.1 - Fix problem with NTLM connection caching + - Better log handling when things are fast and furious 0.5 - Added Dummy handler diff --git a/daemon/misc.c b/daemon/misc.c index bb88d06..7b60422 100644 --- a/daemon/misc.c +++ b/daemon/misc.c @@ -32,6 +32,8 @@ extern int g_debuglevel; extern int g_daemonized; extern pthread_mutex_t g_mutex; +/* For printing out sane logs */ +static pthread_mutex_t g_log_mutex = PTHREAD_MUTEX_INITIALIZER; /* ----------------------------------------------------------------------- * Error Handling @@ -98,18 +100,26 @@ void ha_messagex(const ha_request_t* rq, int level, const char* msg, ...) { va_list ap; + pthread_mutex_lock (&g_log_mutex); + va_start(ap, msg); vmessage(rq, level, 0, msg, ap); va_end(ap); + + pthread_mutex_unlock (&g_log_mutex); } void ha_message(const ha_request_t* rq, int level, const char* msg, ...) { va_list ap; + pthread_mutex_lock (&g_log_mutex); + va_start(ap, msg); vmessage(rq, level, 1, msg, ap); va_end(ap); + + pthread_mutex_unlock (&g_log_mutex); } @@ -201,7 +211,7 @@ void ha_lock(pthread_mutex_t* mtx) if(r == EBUSY) { wait = 1; - ha_message(NULL, LOG_DEBUG, "thread will block: %d", pthread_self()); + ha_messagex(NULL, LOG_DEBUG, "thread will block: %d", pthread_self()); r = pthread_mutex_lock(mtx); } -- cgit v1.2.3