From 44d9f62f34e0561d83ea32941f0ea1b529b1490d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 16 Aug 2008 09:28:15 -0700 Subject: core rewrite (decode,player,outputBuffer,playlist) This is a huge refactoring of the core mpd process. The queueing/buffering mechanism is heavily reworked. The player.c code has been merged into outputBuffer (the actual ring buffering logic is handled by ringbuf.c); and decode.c actually handles decoding stuff. The end result is several hundreds of lines shorter, even though we still have a lot of DEBUG statements left in there for tracing and a lot of assertions, too. --- src/log.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/log.c') diff --git a/src/log.c b/src/log.c index 8a2d48410..aac7349d1 100644 --- a/src/log.c +++ b/src/log.c @@ -75,6 +75,7 @@ static void do_log(FILE *fp, const char *fmt, va_list args) { if (!stdout_mode) fwrite(log_date(), LOG_DATE_LEN, 1, fp); + fprintf(fp, "%08x: ", pthread_self()); vfprintf(fp, fmt, args); } -- cgit v1.2.3 From 3befb84a6a7a95de7e0e94c2f0bd9936ecb60668 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 19 Aug 2008 03:01:39 -0700 Subject: log.c: thread-safety for warning log I'm really no fan of the warning log, it's too complex for how little it gets used; but fixing it is another problem. --- src/log.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/log.c') diff --git a/src/log.c b/src/log.c index aac7349d1..2f4c1af0f 100644 --- a/src/log.c +++ b/src/log.c @@ -29,6 +29,7 @@ static unsigned int logLevel = LOG_LEVEL_LOW; static int warningFlushed; static int stdout_mode = 1; static char *warningBuffer; +static pthread_mutex_t warning_buffer_lock = PTHREAD_MUTEX_INITIALIZER; static int out_fd = -1; static int err_fd = -1; static const char *out_filename; @@ -81,7 +82,10 @@ static void do_log(FILE *fp, const char *fmt, va_list args) void flushWarningLog(void) { - char *s = warningBuffer; + char *s; + + pthread_mutex_lock(&warning_buffer_lock); + s = warningBuffer; DEBUG("flushing warning messages\n"); @@ -98,8 +102,8 @@ void flushWarningLog(void) warningBuffer = NULL; } - warningFlushed = 1; + pthread_mutex_unlock(&warning_buffer_lock); DEBUG("done flushing warning messages\n"); } @@ -189,10 +193,14 @@ void WARNING(const char *fmt, ...) { va_list args; va_start(args, fmt); - if (warningFlushed) { + + pthread_mutex_lock(&warning_buffer_lock); + if (warningFlushed) do_log(stderr, fmt, args); - } else + else buffer_warning(fmt, args); + pthread_mutex_unlock(&warning_buffer_lock); + va_end(args); } -- cgit v1.2.3