summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'daemon')
-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);
}