Skip to content

Commit

Permalink
Make logging shutdown more cleanly
Browse files Browse the repository at this point in the history
After shutting down the logging thread, delete each logging output entity in
turn.  This will cause the db logging thread to be cleanly shutdown as well.
  • Loading branch information
Beirdo committed May 28, 2011
1 parent 14fc37d commit d9e7da2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion mythtv/libs/libmythbase/mythlogging.cpp
Expand Up @@ -336,11 +336,12 @@ void DBLoggerThread::run(void)
bool DatabaseLogger::isDatabaseReady()
{
bool ready = false;
MythDB *db;

if ( !m_loggingTableExists )
m_loggingTableExists = DBUtil::TableExists(m_handle.string);

if ( m_loggingTableExists && GetMythDB()->HaveValidDatabase() )
if ( m_loggingTableExists && (db = GetMythDB()) && db->HaveValidDatabase() )
ready = true;

return ready;
Expand Down Expand Up @@ -600,6 +601,17 @@ void logStop(void)
{
logThread.stop();
logThread.wait();

QMutexLocker locker(&loggerListMutex);
QList<LoggerBase *>::iterator it;

for(it = loggerList.begin(); it != loggerList.end(); )
{
locker.unlock();
delete *it;
locker.relock();
it = loggerList.begin();
}
}

void threadRegister(QString name)
Expand Down

0 comments on commit d9e7da2

Please sign in to comment.