From 812da460cfbd147a7fe0e8b480d1bd5c43f41661 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Fri, 23 Nov 2018 17:48:02 +0100 Subject: [PATCH] Abort unsafe lossless refresh early We need to check earlier if we are going to send this refresh or not. Otherwise we send out pings pointlessly, and we also stall the request loop with a client as we clear the requested region without actually sending an update message. --- common/rfb/VNCSConnectionST.cxx | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx index 46c5b1a4..dbbf1d80 100644 --- a/common/rfb/VNCSConnectionST.cxx +++ b/common/rfb/VNCSConnectionST.cxx @@ -989,6 +989,7 @@ void VNCSConnectionST::writeLosslessRefresh() const RenderedCursor *cursor; int nextRefresh, nextUpdate; + size_t bandwidth, maxUpdateSize; if (continuousUpdates) req = cuRegion.union_(requested); @@ -1028,27 +1029,28 @@ void VNCSConnectionST::writeLosslessRefresh() if (needRenderedCursor()) cursor = server->getRenderedCursor(); - writeRTTPing(); - // FIXME: If continuous updates aren't used then the client might // be slower than frameRate in its requests and we could // afford a larger update size nextUpdate = server->msToNextUpdate(); - if (nextUpdate > 0) { - size_t bandwidth, maxUpdateSize; - // FIXME: Bandwidth estimation without congestion control - bandwidth = congestion.getBandwidth(); + // Don't bother if we're about to send a real update + if (nextUpdate == 0) + return; - // FIXME: Hard coded value for maximum CPU throughput - if (bandwidth > 5000000) - bandwidth = 5000000; + // FIXME: Bandwidth estimation without congestion control + bandwidth = congestion.getBandwidth(); - maxUpdateSize = bandwidth * nextUpdate / 1000; + // FIXME: Hard coded value for maximum CPU throughput + if (bandwidth > 5000000) + bandwidth = 5000000; - encodeManager.writeLosslessRefresh(req, server->getPixelBuffer(), - cursor, maxUpdateSize); - } + maxUpdateSize = bandwidth * nextUpdate / 1000; + + writeRTTPing(); + + encodeManager.writeLosslessRefresh(req, server->getPixelBuffer(), + cursor, maxUpdateSize); writeRTTPing(); -- 2.39.5