Skip to content

Commit

Permalink
Fix compilation of loggingserver.cpp in Qt 5.
Browse files Browse the repository at this point in the history
Qt 5 flagged some non-threadsafe code. I've added TODO FIXME comments at the two locations where the bugs result in bad behavior and not just inaccurate debugging message.
  • Loading branch information
daniel-kristjansson authored and jyavenard committed Mar 8, 2013
1 parent d735cc2 commit 81a2ef3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions mythtv/libs/libmythbase/loggingserver.cpp
Expand Up @@ -1201,7 +1201,7 @@ void LogForwardThread::expireClients(void)
QString clientId = logClientToDel.takeFirst();
logClientCount.deref();
LOG(VB_GENERAL, LOG_INFO, QString("Expiring client %1 (#%2)")
.arg(clientId).arg(logClientCount));
.arg(clientId).arg(logClientCount.fetchAndAddOrdered(0)));
LoggerListItem *item = logClientMap.take(clientId);
if (!item)
continue;
Expand All @@ -1228,8 +1228,10 @@ void LogForwardThread::expireClients(void)
delete list;
}

// TODO FIXME: This is not thread-safe!
// just this daemon left
if (logClientCount == 1 && m_shutdownTimer && !m_shutdownTimer->isActive())
if (logClientCount.fetchAndAddOrdered(0) == 1 &&
m_shutdownTimer && !m_shutdownTimer->isActive())
{
LOG(VB_GENERAL, LOG_INFO, "Starting 5min shutdown timer");
m_shutdownTimer->start(5*60*1000);
Expand Down Expand Up @@ -1307,9 +1309,10 @@ void LogForwardThread::forwardMessage(LogMessage *msg)

logClientCount.ref();
LOG(VB_GENERAL, LOG_INFO, QString("New Client: %1 (#%2)")
.arg(clientId).arg(logClientCount));
.arg(clientId).arg(logClientCount.fetchAndAddOrdered(0)));

if (logClientCount > 1 && m_shutdownTimer &&
// TODO FIXME This is not thread-safe!
if (logClientCount.fetchAndAddOrdered(0) > 1 && m_shutdownTimer &&
m_shutdownTimer->isActive())
{
LOG(VB_GENERAL, LOG_INFO, "Aborting shutdown timer");
Expand Down

0 comments on commit 81a2ef3

Please sign in to comment.