From b8b1e96d837bf50b8a0f50f68bcd098eb999eec2 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Fri, 20 Jul 2012 10:47:00 +0000 Subject: [PATCH] We were not handling the "sync next" fence properly as we sent the response 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 | 14 +++++++++----- common/rfb/VNCSConnectionST.h | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx index 1ecd78c2..381ee216 100644 --- a/common/rfb/VNCSConnectionST.cxx +++ b/common/rfb/VNCSConnectionST.cxx @@ -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; diff --git a/common/rfb/VNCSConnectionST.h b/common/rfb/VNCSConnectionST.h index 72dc59c0..5eb908ab 100644 --- a/common/rfb/VNCSConnectionST.h +++ b/common/rfb/VNCSConnectionST.h @@ -183,7 +183,7 @@ namespace rfb { bool inProcessMessages; - bool syncFence; + bool pendingSyncFence, syncFence; rdr::U32 fenceFlags; unsigned fenceDataLen; char *fenceData; -- 2.39.5