diff options
author | ilsimo <ilsimo> | 2006-06-04 12:10:02 +0000 |
---|---|---|
committer | ilsimo <ilsimo> | 2006-06-04 12:10:02 +0000 |
commit | 9e2235ceaa574e8c9dc1d6f3fff32138989b4242 (patch) | |
tree | 5157243189fdb2b6898ac21a5707e88ff33d4871 /common/log.c | |
parent | e9400d44e908991c6b6cd945934ac1a3d2bd4276 (diff) | |
download | xrdp-proprietary-9e2235ceaa574e8c9dc1d6f3fff32138989b4242.tar.gz xrdp-proprietary-9e2235ceaa574e8c9dc1d6f3fff32138989b4242.zip |
making (hopefully) the logging system thread-safe
Diffstat (limited to 'common/log.c')
-rw-r--r-- | common/log.c | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/common/log.c b/common/log.c index 14d438ab..091e144d 100644 --- a/common/log.c +++ b/common/log.c @@ -15,12 +15,6 @@ xrdp: A Remote Desktop Protocol server. Copyright (C) Jay Sorg 2005-2006 - - session manager - linux only - - log.c: logging code - */ #include "sys/types.h" @@ -37,12 +31,17 @@ static struct log_config *l_cfg; +/* threading additions */ +#ifdef LOG_ENABLE_THREAD +#include "nptl/pthread.h" +static pthread_mutex_t log_lock; +static pthread_mutexattr_t log_lock_attr; +#endif + /** * - * Opens log file - * + * @brief Opens log file * @param fname log file name - * * @return see open(2) return values * */ @@ -53,10 +52,8 @@ static int log_file_open(const char* fname) /** * - * Converts xrdp log level to syslog logging level - * + * @brief Converts xrdp log level to syslog logging level * @param xrdp logging level - * * @return syslog equivalent logging level * */ @@ -79,11 +76,10 @@ static int log_xrdp2syslog(const int lvl) } /** - * - * Converts xrdp log level to syslog logging level - * - * @param xrdp logging level - * + *ring + * @brief Converts xrdp log level to syslog logging level + * @param lvl logging level + * @param str pointer to a st * @return syslog equivalent logging level * */ @@ -167,8 +163,15 @@ log_message(const unsigned int lvl, const char* msg, ...) { /* log to console */ g_printf((char*) buff); + /* log to application logfile */ +#ifdef LOG_ENABLE_THREAD + pthread_mutex_lock(&log_lock); +#endif return g_file_write(l_cfg->fd, (char*) buff, g_strlen((char*) buff)); +#ifdef LOG_ENABLE_THREAD + pthread_mutex_unlock(&log_lock); +#endif } return 0; } @@ -225,6 +228,11 @@ log_start(const char* progname, const char* logfile, const unsigned int loglvl, /* if syslog is enabled, open it */ if (l_cfg->enable_syslog) openlog(l_cfg->program_name, LOG_CONS | LOG_PID, LOG_DAEMON); +#ifdef LOG_ENABLE_THREAD + pthread_mutexattr_init(&log_lock_attr); + pthread_mutex_init(&log_lock, &log_lock_attr); +#endif + return LOG_STARTUP_OK; } @@ -295,4 +303,3 @@ log_text2level(char* buf) return LOG_LEVEL_DEBUG; } - |