aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2018-03-22 16:01:44 +0100
committerPierre Ossman <ossman@cendio.se>2018-03-28 12:46:11 +0200
commitb53c3bf050d4ea7693f53be01b5d3ea85055c01d (patch)
treeef5bd2132d286505d4bd23cb026f1b9fec1196e4
parent74385d38902a54b06af10c1bc6fc0d322b0fabb9 (diff)
downloadtigervnc-b53c3bf050d4ea7693f53be01b5d3ea85055c01d.tar.gz
tigervnc-b53c3bf050d4ea7693f53be01b5d3ea85055c01d.zip
Avoid checking updates when desktop is stopped
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.
-rw-r--r--common/rfb/VNCServerST.cxx28
-rw-r--r--common/rfb/VNCServerST.h1
2 files changed, 18 insertions, 11 deletions
diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx
index 0008dc41..83f2b7e7 100644
--- a/common/rfb/VNCServerST.cxx
+++ b/common/rfb/VNCServerST.cxx
@@ -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);
diff --git a/common/rfb/VNCServerST.h b/common/rfb/VNCServerST.h
index e00a1f7e..584c48c2 100644
--- a/common/rfb/VNCServerST.h
+++ b/common/rfb/VNCServerST.h
@@ -195,6 +195,7 @@ namespace rfb {
// - Internal methods
void startDesktop();
+ void stopDesktop();
static LogWriter connectionsLog;
Blacklist blacklist;