[mythtv] Re: [Patch] Re: [BUG?] Threading / Sockets problem with
master and slave backends
Malc
malc at porsche.demon.co.uk
Mon Sep 12 20:47:44 UTC 2005
Skipped content of type multipart/alternative-------------- next part --------------
Index: programs/mythbackend/playbacksock.cpp
===================================================================
--- programs/mythbackend/playbacksock.cpp (revision 7191)
+++ programs/mythbackend/playbacksock.cpp (working copy)
@@ -2,6 +2,9 @@
#include <iostream>
+// C headers
+#include <unistd.h>
+
using namespace std;
#include "playbacksock.h"
@@ -59,7 +62,23 @@
bool PlaybackSock::SendReceiveStringList(QStringList &strlist)
{
- sock->Lock();
+ int itertry = 0;
+
+ if (!sock->tryLock()) {
+ VERBOSE(VB_IMPORTANT, " PlaybackSock::SendReceiveStringList trying to send - could not obtain Mutex lock -- waiting" );
+ while (!sock->tryLock() && itertry<=20) {
+ usleep(100000);
+ itertry ++;
+// sock->Lock();
+ }
+ if (itertry>= 20) {
+ //don't send
+ VERBOSE(VB_IMPORTANT, " PlaybackSock::SendReceiveStringList - did not send receive" );
+ return 0;
+ }
+ VERBOSE(VB_IMPORTANT, " PlaybackSock::SendReceiveStringList - loxk eventually obtained - contuning " );
+ }
+ // Carry on
sock->UpRef();
sockLock.lock();
Index: programs/mythbackend/server.h
===================================================================
--- programs/mythbackend/server.h (revision 7191)
+++ programs/mythbackend/server.h (working copy)
@@ -20,6 +20,7 @@
bool IsInProcess(void) { return inUse; }
void Lock() { lock.lock(); }
+ bool tryLock() { return lock.tryLock(); }
void Unlock() { lock.unlock(); }
protected:
More information about the mythtv-dev
mailing list