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.
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index 46c5b1a..dbbf1d8 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -989,6 +989,7 @@
const RenderedCursor *cursor;
int nextRefresh, nextUpdate;
+ size_t bandwidth, maxUpdateSize;
if (continuousUpdates)
req = cuRegion.union_(requested);
@@ -1028,27 +1029,28 @@
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();