]> source.dussan.org Git - tigervnc.git/commitdiff
Push query connect timeout back in to Xvnc 521/head
authorPierre Ossman <ossman@cendio.se>
Wed, 4 Oct 2017 14:21:57 +0000 (16:21 +0200)
committerPierre Ossman <ossman@cendio.se>
Wed, 4 Oct 2017 14:21:57 +0000 (16:21 +0200)
It was moved to the common code in f8e3b34c6, but it was unreliable
because the state could sometimes get out of sync. Push it back in
to Xvnc since it isn't necessarily something all servers will have.

common/rfb/ServerCore.cxx
common/rfb/ServerCore.h
common/rfb/VNCSConnectionST.cxx
common/rfb/VNCSConnectionST.h
unix/xserver/hw/vnc/XserverDesktop.cc
unix/xserver/hw/vnc/XserverDesktop.h

index 59a7cff36b9b6d9e33d5d8e3af3388d81ba9e4ac..b1097a3ee45c2223f7190313d4a7d8a348bda398 100644 (file)
@@ -101,8 +101,3 @@ rfb::BoolParameter rfb::Server::queryConnect
 ("QueryConnect",
  "Prompt the local user to accept or reject incoming connections.",
  false);
-rfb::IntParameter rfb::Server::queryConnectTimeout
-("QueryConnectTimeout",
- "Number of seconds to show the Accept Connection dialog before "
- "rejecting the connection",
- 10);
index 37923cc1fcb939bc91cfa933de4a8b8bc3ddb8ee..f915c7a7a948c3f12e2839aaa2d6670e6952e70a 100644 (file)
@@ -49,7 +49,6 @@ namespace rfb {
     static BoolParameter sendCutText;
     static BoolParameter acceptSetDesktopSize;
     static BoolParameter queryConnect;
-    static IntParameter queryConnectTimeout;
 
   };
 
index b183c056164d40ce3872e1fd57ebc87ef49c0afe..d9bb28155255d63413a95ba2603442290f4e064a 100644 (file)
@@ -71,7 +71,7 @@ static Cursor emptyCursor(0, 0, Point(0, 0), NULL);
 VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
                                    bool reverse)
   : sock(s), reverseConnection(reverse),
-    queryConnectTimer(this), inProcessMessages(false),
+    inProcessMessages(false),
     pendingSyncFence(false), syncFence(false), fenceFlags(0),
     fenceDataLen(0), fenceData(NULL),
     baseRTT(-1), congWindow(0), ackedOffset(0), sentOffset(0),
@@ -485,10 +485,8 @@ void VNCSConnectionST::queryConnection(const char* userName)
   CharArray reason;
   VNCServerST::queryResult qr = server->queryConnection(sock, userName,
                                                         &reason.buf);
-  if (qr == VNCServerST::PENDING) {
-    queryConnectTimer.start(rfb::Server::queryConnectTimeout * 1000);
+  if (qr == VNCServerST::PENDING)
     return;
-  }
 
   // - If server returns ACCEPT/REJECT then pass result to SConnection
   approveConnection(qr == VNCServerST::ACCEPT, reason.buf);
@@ -870,10 +868,6 @@ bool VNCSConnectionST::handleTimeout(Timer* t)
   try {
     if (t == &congestionTimer)
       updateCongestion();
-    else if (t == &queryConnectTimer) {
-      if (state() == RFBSTATE_QUERYING)
-        approveConnection(false, "The attempt to prompt the user to accept the connection failed");
-    }
   } catch (rdr::Exception& e) {
     close(e.str());
   }
index 9b7b14bbfcf12cdf3906568acec8726aed5f7280..42eb85adec9af8f13723d418dc8f82d0cbd6071f 100644 (file)
@@ -185,8 +185,6 @@ namespace rfb {
     CharArray peerEndpoint;
     bool reverseConnection;
 
-    Timer queryConnectTimer;
-
     bool inProcessMessages;
 
     bool pendingSyncFence, syncFence;
index dd1d4ca02055a9e09662078ceebe5d464de8782a..c68a0775f1af39d142ef64a69bb54c912cca983e 100644 (file)
@@ -57,6 +57,11 @@ BoolParameter rawKeyboard("RawKeyboard",
                           "Send keyboard events straight through and "
                           "avoid mapping them to the current keyboard "
                           "layout", false);
+IntParameter queryConnectTimeout("QueryConnectTimeout",
+                                 "Number of seconds to show the "
+                                 "Accept Connection dialog before "
+                                 "rejecting the connection",
+                                 10);
 
 class FileHTTPServer : public rfb::HTTPServer {
 public:
@@ -107,7 +112,7 @@ XserverDesktop::XserverDesktop(int screenIndex_,
     server(0), httpServer(0),
     listeners(listeners_), httpListeners(httpListeners_),
     directFbptr(true),
-    queryConnectId(0)
+    queryConnectId(0), queryConnectTimer(this)
 {
   format = pf;
 
@@ -301,7 +306,7 @@ XserverDesktop::queryConnection(network::Socket* sock,
 {
   int count;
 
-  if (queryConnectId) {
+  if (queryConnectTimer.isStarted()) {
     *reason = strDup("Another connection is currently being queried.");
     return rfb::VNCServerST::REJECT;
   }
@@ -319,6 +324,8 @@ XserverDesktop::queryConnection(network::Socket* sock,
   queryConnectId = (uint32_t)(intptr_t)sock;
   queryConnectSocket = sock;
 
+  queryConnectTimer.start(queryConnectTimeout * 1000);
+
   return rfb::VNCServerST::PENDING;
 }
 
@@ -557,14 +564,14 @@ void XserverDesktop::getQueryConnect(uint32_t* opaqueId,
 {
   *opaqueId = queryConnectId;
 
-  if (queryConnectId == 0) {
+  if (!queryConnectTimer.isStarted()) {
     *address = "";
     *username = "";
     *timeout = 0;
   } else {
     *address = queryConnectAddress.buf;
     *username = queryConnectUsername.buf;
-    *timeout = rfb::Server::queryConnectTimeout;
+    *timeout = queryConnectTimeout;
   }
 }
 
@@ -574,6 +581,7 @@ void XserverDesktop::approveConnection(uint32_t opaqueId, bool accept,
   if (queryConnectId == opaqueId) {
     server->approveConnection(queryConnectSocket, accept, rejectMsg);
     queryConnectId = 0;
+    queryConnectTimer.stop();
   }
 }
 
@@ -783,3 +791,14 @@ void XserverDesktop::keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down)
 
   vncKeyboardEvent(keysym, keycode, down);
 }
+
+bool XserverDesktop::handleTimeout(Timer* t)
+{
+  if (t == &queryConnectTimer) {
+    server->approveConnection(queryConnectSocket, false,
+                              "The attempt to prompt the user to "
+                              "accept the connection failed");
+  }
+
+  return false;
+}
index 9e7dfd1ee4409920eee223f2a1eb7194c92ce880..2a378ea15e855ecea6d20297939d7c15e6b8dff1 100644 (file)
@@ -47,7 +47,8 @@ namespace network { class TcpListener; class Socket; class SocketServer; }
 
 class XserverDesktop : public rfb::SDesktop, public rfb::FullFramePixelBuffer,
                        public rdr::Substitutor,
-                       public rfb::VNCServerST::QueryConnectionHandler {
+                       public rfb::VNCServerST::QueryConnectionHandler,
+                       public rfb::Timer::Callback {
 public:
 
   XserverDesktop(int screenIndex,
@@ -113,6 +114,8 @@ protected:
                          network::SocketServer* sockserv,
                          bool read, bool write);
 
+  virtual bool handleTimeout(rfb::Timer* t);
+
 private:
   rfb::ScreenSet computeScreenLayout();
 
@@ -127,6 +130,7 @@ private:
   network::Socket* queryConnectSocket;
   rfb::CharArray queryConnectAddress;
   rfb::CharArray queryConnectUsername;
+  rfb::Timer queryConnectTimer;
 
 #ifdef RANDR
   typedef std::map<intptr_t, rdr::U32> OutputIdMap;