summaryrefslogtreecommitdiff
path: root/src/log.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2011-04-20 13:40:15 (GMT)
committerChristian Pointner <equinox@helsinki.at>2011-04-20 13:40:15 (GMT)
commit336cc3d0101ebc6d7a0e2cd509d351951f804368 (patch)
tree722d8ce63d5dd3fa75884db808114c1c583aafdb /src/log.c
parent9bb444e208beac4e25e0cdcbff5904f818b8e8fd (diff)
switched to multifdsink
no pthread at log (usign GThread instead) file_list ist now thread safe
Diffstat (limited to 'src/log.c')
-rw-r--r--src/log.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/log.c b/src/log.c
index ed13f74..073f216 100644
--- a/src/log.c
+++ b/src/log.c
@@ -32,7 +32,8 @@
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
-#include <pthread.h>
+
+#include <glib.h>
#define SYSLOG_NAMES
#include <syslog.h>
@@ -182,14 +183,15 @@ void log_init()
{
stdlog.max_prio_ = 0;
stdlog.targets_.first_ = NULL;
- pthread_mutex_init(&(stdlog.log_mutex_), NULL);
+ g_thread_init(NULL);
+ stdlog.log_mutex_ = g_mutex_new();
}
void log_close()
{
- pthread_mutex_lock(&(stdlog.log_mutex_));
+ g_mutex_lock(stdlog.log_mutex_);
log_targets_clear(&stdlog.targets_);
- pthread_mutex_unlock(&(stdlog.log_mutex_));
+ g_mutex_unlock(stdlog.log_mutex_);
}
void update_max_prio()
@@ -208,10 +210,10 @@ int log_add_target(const char* conf)
if(!conf)
return -1;
- pthread_mutex_lock(&(stdlog.log_mutex_));
+ g_mutex_lock(stdlog.log_mutex_);
int ret = log_targets_add(&stdlog.targets_, conf);
if(!ret) update_max_prio();
- pthread_mutex_unlock(&(stdlog.log_mutex_));
+ g_mutex_unlock(stdlog.log_mutex_);
return ret;
}
@@ -227,9 +229,9 @@ void log_printf(log_prio_t prio, const char* fmt, ...)
vsnprintf(msg, MSG_LENGTH_MAX, fmt, args);
va_end(args);
- pthread_mutex_lock(&(stdlog.log_mutex_));
+ g_mutex_lock(stdlog.log_mutex_);
log_targets_log(&stdlog.targets_, prio, msg);
- pthread_mutex_unlock(&(stdlog.log_mutex_));
+ g_mutex_unlock(stdlog.log_mutex_);
}
void log_print_hex_dump(log_prio_t prio, const uint8_t* buf, uint32_t len)
@@ -256,7 +258,7 @@ void log_print_hex_dump(log_prio_t prio, const uint8_t* buf, uint32_t len)
ptr+=3;
}
}
- pthread_mutex_lock(&(stdlog.log_mutex_));
+ g_mutex_lock(stdlog.log_mutex_);
log_targets_log(&stdlog.targets_, prio, msg);
- pthread_mutex_unlock(&(stdlog.log_mutex_));
+ g_mutex_unlock(stdlog.log_mutex_);
}