Skip to content
Browse files

Remove potential deadlock on MythSystem IO threads.

This performs finer grained locking against the file descriptor type map
in the IO handling mechanisms for MythSystem. If the read thread wakes
up and has data to process at the exact moment the external thread is
handing off a newly started child to the manager for handling, the two
may hit fdLock and MythSystemIOHandler::m_pLock from opposite
directions, deadlocking both threads.

Fixes #11066

Signed-off-by: Raymond Wagner <rwagner@mythtv.org>
  • Loading branch information...
1 parent 127b32e commit b5fbc746115308475100c53c17420234da9a2a10 @jkt628 jkt628 committed with wagnerrp Sep 3, 2012
Showing with 8 additions and 4 deletions.
  1. +4 −2 mythtv/libs/libmythbase/system-unix.cpp
  2. +4 −2 mythtv/libs/libmythbase/system-windows.cpp
View
6 mythtv/libs/libmythbase/system-unix.cpp
@@ -444,7 +444,6 @@ void MythSystemManager::append(MythSystemUnix *ms)
m_pMap.insert(ms->m_pid, ms);
m_mapLock.unlock();
- fdLock.lock();
if( ms->GetSetting("UseStdin") )
writeThread->insert(ms->m_stdpipe[0], ms->GetBuffer(0));
@@ -453,7 +452,9 @@ void MythSystemManager::append(MythSystemUnix *ms)
FDType_t *fdType = new FDType_t;
fdType->ms = ms;
fdType->type = 1;
+ fdLock.lock();
fdMap.insert( ms->m_stdpipe[1], fdType );
+ fdLock.unlock();
readThread->insert(ms->m_stdpipe[1], ms->GetBuffer(1));
}
@@ -462,10 +463,11 @@ void MythSystemManager::append(MythSystemUnix *ms)
FDType_t *fdType = new FDType_t;
fdType->ms = ms;
fdType->type = 2;
+ fdLock.lock();
fdMap.insert( ms->m_stdpipe[2], fdType );
+ fdLock.unlock();
readThread->insert(ms->m_stdpipe[2], ms->GetBuffer(2));
}
- fdLock.unlock();
}
void MythSystemManager::jumpAbort(void)
View
6 mythtv/libs/libmythbase/system-windows.cpp
@@ -402,7 +402,6 @@ void MythSystemManager::append(MythSystemWindows *ms)
ChildListRebuild();
m_mapLock.unlock();
- fdLock.lock();
if( ms->GetSetting("UseStdin") )
writeThread->insert(ms->m_stdpipe[0], ms->GetBuffer(0));
@@ -411,7 +410,9 @@ void MythSystemManager::append(MythSystemWindows *ms)
FDType_t *fdType = new FDType_t;
fdType->ms = ms;
fdType->type = 1;
+ fdLock.lock();
fdMap.insert( ms->m_stdpipe[1], fdType );
+ fdLock.unlock();
readThread->insert(ms->m_stdpipe[1], ms->GetBuffer(1));
}
@@ -420,10 +421,11 @@ void MythSystemManager::append(MythSystemWindows *ms)
FDType_t *fdType = new FDType_t;
fdType->ms = ms;
fdType->type = 2;
+ fdLock.lock();
fdMap.insert( ms->m_stdpipe[2], fdType );
+ fdLock.unlock();
readThread->insert(ms->m_stdpipe[2], ms->GetBuffer(2));
}
- fdLock.unlock();
}
void MythSystemManager::jumpAbort(void)

0 comments on commit b5fbc74

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