]> source.dussan.org Git - tigervnc.git/commitdiff
We were not handling the "sync next" fence properly as we sent the response
authorPierre Ossman <ossman@cendio.se>
Fri, 20 Jul 2012 10:47:00 +0000 (10:47 +0000)
committerPierre Ossman <ossman@cendio.se>
Fri, 20 Jul 2012 10:47:00 +0000 (10:47 +0000)
right after we got the request (instead of waiting for the next command).
This created a race where we could lose pixel format sync between the client
and the server.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4943 3789f03b-4d11-0410-bbf8-ca57d06f2519

common/rfb/VNCSConnectionST.cxx
common/rfb/VNCSConnectionST.h

index 1ecd78c21119cbbbdcf9007325a80d190f51b3c2..381ee21614ff1bd429e27a53865016bca76005cd 100644 (file)
@@ -66,7 +66,8 @@ struct RTTInfo {
 VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
                                    bool reverse)
   : SConnection(reverse), sock(s), inProcessMessages(false),
-    syncFence(false), fenceFlags(0), fenceDataLen(0), fenceData(NULL),
+    pendingSyncFence(false), syncFence(false), fenceFlags(0),
+    fenceDataLen(0), fenceData(NULL),
     baseRTT(-1), minRTT(-1), seenCongestion(false), pingCounter(0),
     ackedOffset(0), sentOffset(0), congWindow(0), congestionTimer(this),
     server(server_),
@@ -156,7 +157,13 @@ void VNCSConnectionST::processMessages()
     network::TcpSocket::cork(sock->getFd(), true);
 
     while (getInStream()->checkNoWait(1)) {
+      if (pendingSyncFence) {
+        syncFence = true;
+        pendingSyncFence = false;
+      }
+
       processMsg();
+
       if (syncFence) {
         writer()->writeFence(fenceFlags, fenceDataLen, fenceData);
         syncFence = false;
@@ -627,10 +634,7 @@ void VNCSConnectionST::fence(rdr::U32 flags, unsigned len, const char data[])
 {
   if (flags & fenceFlagRequest) {
     if (flags & fenceFlagSyncNext) {
-      if (syncFence)
-        vlog.error("Fence trying to synchronise another fence");
-
-      syncFence = true;
+      pendingSyncFence = true;
 
       fenceFlags = flags & (fenceFlagBlockBefore | fenceFlagBlockAfter | fenceFlagSyncNext);
       fenceDataLen = len;
index 72dc59c0e8f2c1ea9b4895a9a0f8df44a19fc46a..5eb908ab4eed1ec99a0854315a96891171c918c4 100644 (file)
@@ -183,7 +183,7 @@ namespace rfb {
 
     bool inProcessMessages;
 
-    bool syncFence;
+    bool pendingSyncFence, syncFence;
     rdr::U32 fenceFlags;
     unsigned fenceDataLen;
     char *fenceData;