summaryrefslogtreecommitdiff
path: root/daemon/misc.c
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2006-05-17 23:20:29 +0000
committerStef Walter <stef@memberwebs.com>2006-05-17 23:20:29 +0000
commit9a69e4e83adb5d23a04a03fddfbef37f4850d0d0 (patch)
tree2579bd45598fb1fb08fa8ca2606cfda1893ac367 /daemon/misc.c
parentacbe1e8b817da2bb32d2db79a56748d829d84baa (diff)
- Better log handling when things are fast and furious
Diffstat (limited to 'daemon/misc.c')
-rw-r--r--daemon/misc.c12
1 files changed, 11 insertions, 1 deletions
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);
}