summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGavin Hurlbut <ghurlbut@mythtv.org>2010-12-16 05:31:53 (GMT)
committer Gavin Hurlbut <ghurlbut@mythtv.org>2010-12-16 05:35:03 (GMT)
commit2425dd93b44464c989d7cac048649ca44212f85e (patch)
tree56cc9d0dd4e8cee587279c5168a69e9266758e5d
parenta7a0ec56ab0055add737a5e80b5425404bd65667 (diff)
Change the QMutex to QSemaphore in myth_system
Seems QMutex must be locked/unlocked in the same thread, or it throws errors. As we were locking in one thread, and unlocking in another, this caused asserts when using a debug Qt build. Based on a patch from Lawrence Rust <lvr@softsystem.co.uk> Fixes Ticket 9378
-rw-r--r--mythtv/libs/libmythdb/mythsystem.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/mythtv/libs/libmythdb/mythsystem.cpp b/mythtv/libs/libmythdb/mythsystem.cpp
index 994ef93..c3f8367 100644
--- a/mythtv/libs/libmythdb/mythsystem.cpp
+++ b/mythtv/libs/libmythdb/mythsystem.cpp
@@ -44,7 +44,7 @@
#ifndef USING_MINGW
typedef struct {
- QMutex mutex;
+ QSemaphore ready;
uint result;
time_t timeout;
bool background;
@@ -107,7 +107,7 @@ void MythSystemReaper::run(void)
kill(pid, SIGTERM);
usleep(500);
kill(pid, SIGKILL);
- pidData->mutex.unlock();
+ pidData->ready.release(1);
}
count = m_pidMap.size();
m_mapLock.unlock();
@@ -167,8 +167,8 @@ void MythSystemReaper::run(void)
if( pidData->background )
delete pidData;
- else
- pidData->mutex.unlock();
+ else
+ pidData->ready.release(1);
}
}
@@ -178,6 +178,8 @@ uint MythSystemReaper::waitPid( pid_t pid, time_t timeout, bool background,
PidData_t *pidData = new PidData_t;
uint result;
+ pidData->ready.release(1); // Initialize
+
if( timeout > 0 )
pidData->timeout = time(NULL) + timeout;
else
@@ -185,14 +187,14 @@ uint MythSystemReaper::waitPid( pid_t pid, time_t timeout, bool background,
pidData->background = background;
- pidData->mutex.lock();
+ pidData->ready.acquire(1);
m_mapLock.lock();
m_pidMap.insert( pid, pidData );
m_mapLock.unlock();
if( !background ) {
/* Now we wait for the thread to see the SIGCHLD */
- while( !pidData->mutex.tryLock(100) )
+ while( !pidData->ready.tryAcquire(1,100) )
if (processEvents)
qApp->processEvents();