Cork the connection around updates to better use the congestion window
as we might send out multiple small packets


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4804 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index bd93d63..d0cdf86 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -962,13 +962,18 @@
     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
+  // congestion window.
+  network::TcpSocket::cork(sock->getFd(), true);
+
   // First take care of any updates that cannot contain framebuffer data
   // changes.
   if (writer()->needNoDataUpdate()) {
     writer()->writeNoDataUpdate();
     requested.clear();
     if (!continuousUpdates)
-      return;
+      goto out;
   }
 
   updates.enable_copyrect(cp.useCopyRect);
@@ -977,7 +982,7 @@
   // anything right now (the framebuffer might have changed in ways we
   // haven't yet been informed of).
   if (!server->checkUpdate())
-    return;
+    goto out;
 
   // Get the lists of updates. Prior to exporting the data to the `ui' object,
   // getUpdateInfo() will normalize the `updates' object such way that its
@@ -1017,7 +1022,7 @@
   // Return if there is nothing to send the client.
 
   if (updates.is_empty() && !writer()->needFakeUpdate() && !drawRenderedCursor)
-    return;
+    goto out;
 
   // The `updates' object could change, make sure we have valid update info.
 
@@ -1090,6 +1095,9 @@
 
     requested.clear();
   }
+
+out:
+  network::TcpSocket::cork(sock->getFd(), false);
 }