[mythtv-users] RE:Waited 2 seconds... Still... Any more ideas?

Eloy A. Paris peloy at chapus.net
Sun Jan 11 08:26:53 EST 2004


Jason Ferrara <jason at discordia.org> writes:

> Where does one get this patch?

It was sent by Mark Frey to the mythtv-dev mailing list. The subject of
the e-mail was "[PATCH] Eliminate backend race condition".

I am including the patch for your convenience.

This patch apparently has fixed the darn freezes (no freezes in lots of
hours of live TV), so kudos to Mark.

It's not clear to me, though, why some people were more prone to get the
freezes than others, or why others never saw them at all.

Eloy.-

? be2frz.diff
Index: programs/mythbackend/mainserver.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/mainserver.cpp,v
retrieving revision 1.111
diff -u -r1.111 mainserver.cpp
--- programs/mythbackend/mainserver.cpp	7 Jan 2004 04:37:27 -0000	1.111
+++ programs/mythbackend/mainserver.cpp	9 Jan 2004 18:46:44 -0000
@@ -32,18 +32,21 @@
 class ProcessRequestThread : public QThread
 {
   public:
-    ProcessRequestThread(MainServer *ms) { parent = ms; dostuff = false; }
+    ProcessRequestThread(MainServer *ms) { parent = ms;}
    
     void setup(QSocket *sock)
     {
+        prtlock.lock();
         socket = sock;
-        dostuff = true;
+        prtlock.unlock();
         waitCond.wakeOne();
     }
 
     void killit(void)
     {
+        prtlock.lock();
         threadlives = false;
+        prtlock.unlock();
         waitCond.wakeOne();
     }
 
@@ -51,18 +54,17 @@
     {
         threadlives = true;
 
-        while (threadlives)
+        prtlock.lock();
+        while (true)
         {
-            if (!dostuff)
-                waitCond.wait();
+            waitCond.wait(&prtlock);
+            if(!threadlives)
+                break;
 
-            if (dostuff)
-            {
-                parent->ProcessRequest(socket);
-                dostuff = false;
-                parent->MarkUnused(this);
-            }
+            parent->ProcessRequest(socket);
+            parent->MarkUnused(this);
         }
+        prtlock.unlock();
     }
 
   private:
@@ -70,8 +72,8 @@
 
     QSocket *socket;
 
+    QMutex prtlock;
     QWaitCondition waitCond;
-    bool dostuff;
     bool threadlives;
 };
 


More information about the mythtv-users mailing list