]> source.dussan.org Git - tigervnc.git/commitdiff
Avoid checking updates when desktop is stopped
authorPierre Ossman <ossman@cendio.se>
Thu, 22 Mar 2018 15:01:44 +0000 (16:01 +0100)
committerPierre Ossman <ossman@cendio.se>
Wed, 28 Mar 2018 10:46:11 +0000 (12:46 +0200)
No need to run all the update machinery when there is no client
connected.

This commit also cleans up the stop handling a bit by moving it to
its own method.

common/rfb/VNCServerST.cxx
common/rfb/VNCServerST.h

index 0008dc416982fcbd78f9ba6d80959f49dc4b7091..83f2b7e718b8fa1b64688c979e4f0c5fbeb1a36f 100644 (file)
@@ -1,5 +1,5 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
- * Copyright 2009-2017 Pierre Ossman for Cendio AB
+ * Copyright 2009-2018 Pierre Ossman for Cendio AB
  * 
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -105,10 +105,7 @@ VNCServerST::~VNCServerST()
   }
 
   // Stop the desktop object if active, *only* after deleting all clients!
-  if (desktopStarted) {
-    desktopStarted = false;
-    desktop->stop();
-  }
+  stopDesktop();
 
   if (comparer)
     comparer->logStats();
@@ -154,12 +151,8 @@ void VNCServerST::removeSocket(network::Socket* sock) {
       delete *ci;
 
       // - Check that the desktop object is still required
-      if (authClientCount() == 0 && desktopStarted) {
-        slog.debug("no authenticated clients - stopping desktop");
-        desktopStarted = false;
-        desktop->stop();
-        stopFrameClock();
-      }
+      if (authClientCount() == 0)
+        stopDesktop();
 
       if (comparer)
         comparer->logStats();
@@ -552,6 +545,16 @@ void VNCServerST::startDesktop()
   }
 }
 
+void VNCServerST::stopDesktop()
+{
+  if (desktopStarted) {
+    slog.debug("stopping desktop");
+    desktopStarted = false;
+    desktop->stop();
+    stopFrameClock();
+  }
+}
+
 int VNCServerST::authClientCount() {
   int count = 0;
   std::list<VNCSConnectionST*>::iterator ci;
@@ -576,6 +579,8 @@ void VNCServerST::startFrameClock()
     return;
   if (blockCounter > 0)
     return;
+  if (!desktopStarted)
+    return;
 
   // The first iteration will be just half a frame as we get a very
   // unstable update rate if we happen to be perfectly in sync with
@@ -603,6 +608,7 @@ void VNCServerST::writeUpdate()
   std::list<VNCSConnectionST*>::iterator ci, ci_next;
 
   assert(blockCounter == 0);
+  assert(desktopStarted);
 
   comparer->getUpdateInfo(&ui, pb->getRect());
   toCheck = ui.changed.union_(ui.copied);
index e00a1f7e3d4a9635a7af5757a6a5393ac0c19126..584c48c2ec51db39d9999b7782ca3264aaee13b4 100644 (file)
@@ -195,6 +195,7 @@ namespace rfb {
     // - Internal methods
 
     void startDesktop();
+    void stopDesktop();
 
     static LogWriter connectionsLog;
     Blacklist blacklist;