diff options
author | Pierre Ossman <ossman@cendio.se> | 2016-04-29 15:35:56 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2016-04-29 15:35:56 +0200 |
commit | a40ab204bda8cc4ebe5f061c8a5776a1505f1b53 (patch) | |
tree | 1e886acb6b80ee5cb78e8279fef4c8a5fc89bda8 | |
parent | 16419cce135e9880e8d816acb7ded0249f795453 (diff) | |
download | tigervnc-a40ab204bda8cc4ebe5f061c8a5776a1505f1b53.tar.gz tigervnc-a40ab204bda8cc4ebe5f061c8a5776a1505f1b53.zip |
Asynchronously retry update on congestion
We now get notifications when the output buffer empties, and we
already caught incoming RTT pongs, meaning we can now react at the
proper time to retry a congested update rather than use a timer.
-rw-r--r-- | common/rfb/VNCSConnectionST.cxx | 17 | ||||
-rw-r--r-- | common/rfb/VNCSConnectionST.h | 2 |
2 files changed, 7 insertions, 12 deletions
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx index 0f4ca942..3a072ef0 100644 --- a/common/rfb/VNCSConnectionST.cxx +++ b/common/rfb/VNCSConnectionST.cxx @@ -75,8 +75,7 @@ VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s, pingCounter(0), congestionTimer(this), server(server_), updates(false), updateRenderedCursor(false), removeRenderedCursor(false), - continuousUpdates(false), encodeManager(this), - updateTimer(this), pointerEventTime(0), + continuousUpdates(false), encodeManager(this), pointerEventTime(0), accessRights(AccessDefault), startTime(time(0)) { setStreams(&sock->inStream(), &sock->outStream()); @@ -196,6 +195,10 @@ void VNCSConnectionST::flushSocket() try { setSocketTimeouts(); sock->outStream().flush(); + // Flushing the socket might release an update that was previously + // delayed because of congestion. + if (sock->outStream().bufferUsage() == 0) + writeFramebufferUpdate(); } catch (rdr::Exception &e) { close(e.str()); } @@ -741,9 +744,7 @@ void VNCSConnectionST::supportsContinuousUpdates() bool VNCSConnectionST::handleTimeout(Timer* t) { try { - if (t == &updateTimer) - writeFramebufferUpdate(); - else if (t == &congestionTimer) + if (t == &congestionTimer) updateCongestion(); else if (t == &queryConnectTimer) { if (state() == RFBSTATE_QUERYING) @@ -939,8 +940,6 @@ void VNCSConnectionST::writeFramebufferUpdate() bool needNewUpdateInfo; bool drawRenderedCursor; - updateTimer.stop(); - // We're in the middle of processing a command that's supposed to be // synchronised. Allowing an update to slip out right now might violate // that synchronisation. @@ -960,10 +959,8 @@ void VNCSConnectionST::writeFramebufferUpdate() // Check that we actually have some space on the link and retry in a // bit if things are congested. - if (isCongested()) { - updateTimer.start(50); + if (isCongested()) return; - } // In continuous mode, we will be outputting at least three distinct // messages. We need to aggregate these in order to not clog up TCP's diff --git a/common/rfb/VNCSConnectionST.h b/common/rfb/VNCSConnectionST.h index 55b7ca3e..3f0163a3 100644 --- a/common/rfb/VNCSConnectionST.h +++ b/common/rfb/VNCSConnectionST.h @@ -205,8 +205,6 @@ namespace rfb { Region cuRegion; EncodeManager encodeManager; - Timer updateTimer; - std::set<rdr::U32> pressedKeys; time_t lastEventTime; |