Skip to content
Browse files

Fix some edge cases for the MythSystem changes

I found the major edge case...  when the parent has been deleted and the
MythSystemSignalHandler tries to deal with the pid.  That and a possible
memory leak in the same/similar situation (depending on timing)
  • Loading branch information...
1 parent 31f09a8 commit 42aae944078492ba464bc53c80fa21b734345f4d @Beirdo Beirdo committed Jul 7, 2012
Showing with 34 additions and 15 deletions.
  1. +15 −7 mythtv/libs/libmythbase/system-unix.cpp
  2. +19 −8 mythtv/libs/libmythbase/system-windows.cpp
View
22 mythtv/libs/libmythbase/system-unix.cpp
@@ -310,6 +310,8 @@ void MythSystemManager::run(void)
LOG(VB_SYSTEM, LOG_ERR,
QString("Structure for child PID %1 already deleted!")
.arg(pid));
+ if (ms)
+ ms->DecrRef();
continue;
}
@@ -507,7 +509,10 @@ void MythSystemSignalManager::run(void)
if (!ms)
continue;
- ms->m_parent->HandlePostRun();
+ if (ms->m_parent)
+ {
+ ms->m_parent->HandlePostRun();
+ }
if (ms->m_stdpipe[0] > 0)
writeThread->remove(ms->m_stdpipe[0]);
@@ -521,13 +526,16 @@ void MythSystemSignalManager::run(void)
readThread->remove(ms->m_stdpipe[2]);
CLOSE(ms->m_stdpipe[2]);
- if (ms->GetStatus() == GENERIC_EXIT_OK)
- emit ms->finished();
- else
- emit ms->error(ms->GetStatus());
+ if (ms->m_parent)
+ {
+ if (ms->GetStatus() == GENERIC_EXIT_OK)
+ emit ms->finished();
+ else
+ emit ms->error(ms->GetStatus());
- ms->disconnect();
- ms->Unlock();
+ ms->disconnect();
+ ms->Unlock();
+ }
ms->DecrRef();
}
View
27 mythtv/libs/libmythbase/system-windows.cpp
@@ -277,11 +277,13 @@ void MythSystemManager::run(void)
// Occasionally, the caller has deleted the structure from under
// our feet. If so, just log and move on.
- if (!ms)
+ if (!ms || !ms->m_parent)
{
LOG(VB_SYSTEM, LOG_ERR,
QString("Structure for child handle %1 already deleted!")
.arg((long long)child));
+ if (ms)
+ ms->DecrRef();
continue;
}
@@ -458,7 +460,13 @@ void MythSystemSignalManager::run(void)
MythSystemWindows *ms = msList.takeFirst();
listLock.unlock();
- ms->m_parent->HandlePostRun();
+ if (!ms)
+ continue;
+
+ if (ms->m_parent)
+ {
+ ms->m_parent->HandlePostRun();
+ }
if (ms->m_stdpipe[0])
writeThread->remove(ms->m_stdpipe[0]);
@@ -472,13 +480,16 @@ void MythSystemSignalManager::run(void)
readThread->remove(ms->m_stdpipe[2]);
CLOSE(ms->m_stdpipe[2]);
- if( ms->GetStatus() == GENERIC_EXIT_OK )
- emit ms->finished();
- else
- emit ms->error(ms->GetStatus());
+ if (ms->m_parent)
+ {
+ if( ms->GetStatus() == GENERIC_EXIT_OK )
+ emit ms->finished();
+ else
+ emit ms->error(ms->GetStatus());
- ms->disconnect();
- ms->Unlock();
+ ms->disconnect();
+ ms->Unlock();
+ }
ms->DecrRef();
}

0 comments on commit 42aae94

Please sign in to comment.
Something went wrong with that request. Please try again.