diff options
Diffstat (limited to 'lib/libalpm/log.c')
-rw-r--r-- | lib/libalpm/log.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/libalpm/log.c b/lib/libalpm/log.c index f7dd5336..82c0edad 100644 --- a/lib/libalpm/log.c +++ b/lib/libalpm/log.c @@ -22,12 +22,14 @@ #include <stdarg.h> #include <errno.h> #include <syslog.h> +#include <pthread.h> /* libalpm */ #include "log.h" #include "handle.h" #include "util.h" #include "alpm.h" +#include "thread.h" /** \addtogroup alpm_log Logging Functions * @brief Functions to log using libalpm @@ -62,6 +64,7 @@ int SYMEXPORT alpm_logaction(alpm_handle_t *handle, const char *prefix, if(!(prefix && *prefix)) { prefix = "UNKNOWN"; } + _ALPM_TLOCK_LOG(handle); /* check if the logstream is open already, opening it if needed */ if(handle->logstream == NULL && handle->logfile != NULL) { @@ -83,6 +86,8 @@ int SYMEXPORT alpm_logaction(alpm_handle_t *handle, const char *prefix, } } + _ALPM_TUNLOCK_LOG(handle); + va_start(args, fmt); if(handle->usesyslog) { @@ -118,7 +123,9 @@ void _alpm_log(alpm_handle_t *handle, alpm_loglevel_t flag, const char *fmt, ... } va_start(args, fmt); + _ALPM_TLOCK_CB(handle); handle->logcb(flag, fmt, args); + _ALPM_TUNLOCK_CB(handle); va_end(args); } @@ -138,6 +145,8 @@ int _alpm_logaction(alpm_handle_t *handle, const char *prefix, prefix = "UNKNOWN"; } + _ALPM_TLOCK_LOG(handle); + if(handle->usesyslog) { /* we can't use a va_list more than once, so we need to copy it * so we can use the original when calling vfprintf below. */ @@ -162,6 +171,8 @@ int _alpm_logaction(alpm_handle_t *handle, const char *prefix, fflush(handle->logstream); } + _ALPM_TUNLOCK_LOG(handle); + return ret; } |