Ticket #3509: networkcontrol.patch.txt

File networkcontrol.patch.txt, 1.9 KB (added by russell@…, 17 years ago)
Line 
1Index: programs/mythfrontend/networkcontrol.h
2===================================================================
3--- programs/mythfrontend/networkcontrol.h      (revision 13501)
4+++ programs/mythfrontend/networkcontrol.h      (working copy)
5@@ -11,6 +11,7 @@
6 #include <qmap.h>
7 #include <qmutex.h>
8 #include <qvaluelist.h>
9+#include <qwaitcondition.h>
10 
11 class MainServer;
12 
13@@ -62,6 +63,7 @@
14 
15     QValueList<QString> networkControlCommands;
16     QMutex ncLock;
17+    QWaitCondition ncCond;
18 
19     QValueList<QString> networkControlReplies;
20     QMutex nrLock;
21Index: programs/mythfrontend/networkcontrol.cpp
22===================================================================
23--- programs/mythfrontend/networkcontrol.cpp    (revision 13501)
24+++ programs/mythfrontend/networkcontrol.cpp    (working copy)
25@@ -212,31 +212,21 @@
26 void NetworkControl::RunCommandThread(void)
27 {
28     QString command;
29-    int commands = 0;
30 
31     for (;;)
32     {
33         pthread_testcancel();
34 
35         ncLock.lock();
36-        commands = networkControlCommands.size();
37+        while (!networkControlCommands.size()) {
38+            ncCond.wait(&ncLock);
39+            pthread_testcancel();
40+        }
41+        command = networkControlCommands.front();
42+        networkControlCommands.pop_front();
43         ncLock.unlock();
44 
45-        while (commands)
46-        {
47-            ncLock.lock();
48-            command = networkControlCommands.front();
49-            networkControlCommands.pop_front();
50-            ncLock.unlock();
51-
52-            processNetworkControlCommand(command);
53-
54-            ncLock.lock();
55-            commands = networkControlCommands.size();
56-            ncLock.unlock();
57-        }
58-
59-        usleep(50000);
60+        processNetworkControlCommand(command);
61     }
62 }
63 
64@@ -341,6 +331,7 @@
65 
66         ncLock.lock();
67         networkControlCommands.push_back(lineIn);
68+        ncCond.wakeOne();
69         ncLock.unlock();
70     }
71 }