]> source.dussan.org Git - tigervnc.git/commitdiff
Fixed unreasonably high CPU utilization in cases when new connection has
authorConstantin Kaplinsky <const@tightvnc.com>
Tue, 5 Dec 2006 08:03:18 +0000 (08:03 +0000)
committerConstantin Kaplinsky <const@tightvnc.com>
Tue, 5 Dec 2006 08:03:18 +0000 (08:03 +0000)
been accepted but polling was not activated yet.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2182 3789f03b-4d11-0410-bbf8-ca57d06f2519

unix/x0vncserver/PollingScheduler.cxx
unix/x0vncserver/PollingScheduler.h
unix/x0vncserver/x0vncserver.cxx

index c9d8d6022f2e18d6e0576c8a449cc452ab7c9842..65420ffbe286787e3bc617c2f9ec349abe8a3fd3 100644 (file)
@@ -55,6 +55,11 @@ void PollingScheduler::reset()
   m_initialState = true;
 }
 
+bool PollingScheduler::isRunning()
+{
+  return !m_initialState;
+}
+
 void PollingScheduler::newPass()
 {
   TimeMillis timeNow;
index 2e3e5be70b18cb963ca5e3f0625edd661c39791b..2bf5a4957d6861524a8ee3850eeda626a502316f 100644 (file)
@@ -41,6 +41,9 @@ public:
   // Reset the object into the initial state (no polling performed).
   void reset();
 
+  // Check if the object is active (not in the initial state).
+  bool isRunning();
+
   // Tell the scheduler that new polling pass is just being started.
   void newPass();
 
index 48be662ed8f1909cd7c915226645a984ab2c25cb..78e1cc05d48228415691960f12c3ac59d96f1660 100644 (file)
@@ -513,7 +513,10 @@ int main(int argc, char** argv)
         }
       }
 
-      if (clients_connected) {
+      if (!clients_connected)
+        sched.reset();
+
+      if (sched.isRunning()) {
         int wait_ms = sched.millisRemaining();
         if (wait_ms > 500) {
           wait_ms = 500;
@@ -523,7 +526,6 @@ int main(int argc, char** argv)
         // fprintf(stderr, "[%d]\t", wait_ms);
 #endif
       } else {
-        sched.reset();
         tv.tv_usec = 100000;
       }
       tv.tv_sec = 0;