Second step, making the server skip over updates if the socket is
congested (aka frame spoiling).

I'd like to commit this soon and then look at integrating the deferred
updates with this mechanism. Should work more reliable per connection.

Rgds
-- 
Pierre Ossman            OpenSource-based Thin Client Technology
System Developer         Telephone: +46-13-21 46 00
Cendio AB                Web: http://www.cendio.com

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
Index: common/rfb/VNCSConnectionST.cxx
===================================================================
--- common/rfb/VNCSConnectionST.cxx	(revision 4718)
+++ common/rfb/VNCSConnectionST.cxx	(working copy)
@@ -37,8 +37,8 @@
   : SConnection(reverse), sock(s), server(server_),
     updates(false), image_getter(server->useEconomicTranslate),
     drawRenderedCursor(false), removeRenderedCursor(false),
-    pointerEventTime(0), accessRights(AccessDefault),
-    startTime(time(0))
+    updateTimer(this), pointerEventTime(0),
+    accessRights(AccessDefault), startTime(time(0))
 {
   setStreams(&sock->inStream(), &sock->outStream());
   peerEndpoint.buf = sock->getPeerEndpoint();
@@ -625,11 +625,42 @@
 }
 
 
+bool VNCSConnectionST::handleTimeout(Timer* t)
+{
+  fprintf(stderr, "Timer!\n");
+
+  if (t == &updateTimer)
+    writeFramebufferUpdateOrClose();
+
+  return false;
+}
+
+
+bool VNCSConnectionST::isCongested()
+{
+  int offset, space;
+
+  if (sock->outStream().bufferUsage() > 0)
+    return true;
+
+  return false;
+}
+
+
 void VNCSConnectionST::writeFramebufferUpdate()
 {
+  updateTimer.stop();
+
   if (state() != RFBSTATE_NORMAL || requested.is_empty())
     return;
 
+  // Check that we actually have some space on the link and retry in a
+  // bit if things are congested.
+  if (isCongested()) {
+    updateTimer.start(50);
+    return;
+  }
+
   // First take care of any updates that cannot contain framebuffer data
   // changes.
   if (writer()->needNoDataUpdate()) {
Index: common/rfb/VNCSConnectionST.h
===================================================================
--- common/rfb/VNCSConnectionST.h	(revision 4718)
+++ common/rfb/VNCSConnectionST.h	(working copy)
@@ -32,10 +32,12 @@
 #include <rfb/SMsgWriter.h>
 #include <rfb/TransImageGetter.h>
 #include <rfb/VNCServerST.h>
+#include <rfb/Timer.h>
 
 namespace rfb {
   class VNCSConnectionST : public SConnection,
-                           public WriteSetCursorCallback {
+                           public WriteSetCursorCallback,
+                           public Timer::Callback {
   public:
     VNCSConnectionST(VNCServerST* server_, network::Socket* s, bool reverse);
     virtual ~VNCSConnectionST();
@@ -140,8 +142,13 @@
     // WriteSetCursorCallback
     virtual void writeSetCursorCallback();
 
+    // Timer callbacks
+    virtual bool handleTimeout(Timer* t);
+
     // Internal methods
 
+    bool isCongested();
+
     // writeFramebufferUpdate() attempts to write a framebuffer update to the
     // client.
 
@@ -161,6 +168,8 @@
     bool drawRenderedCursor, removeRenderedCursor;
     Rect renderedCursorRect;
 
+    Timer updateTimer;
+
     std::set<rdr::U32> pressedKeys;
 
     time_t lastEventTime;

Attachment: signature.asc
Description: PGP signature

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Tigervnc-devel mailing list
Tigervnc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-devel

Reply via email to