Permalink
Browse files

Move the queue locking to a much smaller scope in LogPrintLine

We don't need to lock the queue to create the items, but only when handling
the queue.  This should make future debugging of potential deadlocks simpler,
and also make logging slightly faster in the case that two threads are trying
to "simultaneously" log something.  The only thing that needs to be serialized
is the access to the queue itself.  The rest can be in parallel.
  • Loading branch information...
1 parent dda4a4f commit 9d3bc8dcf0018092019b27e0d99156b7df6e017f @Beirdo Beirdo committed Jul 2, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 mythtv/libs/libmythbase/logging.cpp
View
4 mythtv/libs/libmythbase/logging.cpp
@@ -722,8 +722,6 @@ void LogPrintLine( uint64_t mask, LogLevel_t level, const char *file, int line,
{
va_list arguments;
- QMutexLocker qLock(&logQueueMutex);
-
int type = kMessage;
type |= (mask & VB_FLUSH) ? kFlush : 0;
type |= (mask & VB_STDIO) ? kStandardIO : 0;
@@ -748,6 +746,8 @@ void LogPrintLine( uint64_t mask, LogLevel_t level, const char *file, int line,
if (formatcopy)
free(formatcopy);
+ QMutexLocker qLock(&logQueueMutex);
+
logQueue.enqueue(item);
if (logThread && logThreadFinished && !logThread->isRunning())

0 comments on commit 9d3bc8d

Please sign in to comment.