aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2017-11-08 15:22:44 +0100
committerPierre Ossman <ossman@cendio.se>2017-11-08 15:22:44 +0100
commitbf003e5b1edf2877e1f47db41938bfe4ae7816b0 (patch)
tree527c21f89cd6eea18d22a09b539aea3d4d99f6de /common
parent7be73d7385421685cf6db71f6401551d583da325 (diff)
parent0a0e582597be681488b91eb818c8a1963d13adbf (diff)
downloadtigervnc-bf003e5b1edf2877e1f47db41938bfe4ae7816b0.tar.gz
tigervnc-bf003e5b1edf2877e1f47db41938bfe4ae7816b0.zip
Merge branch 'x0-xdesktop-initial-cursor' of https://github.com/x11clone/x11clone
Diffstat (limited to 'common')
-rw-r--r--common/network/Socket.h1
-rw-r--r--common/network/TcpSocket.cxx4
-rw-r--r--common/network/TcpSocket.h2
-rw-r--r--common/rdr/FdOutStream.cxx11
-rw-r--r--common/rfb/Configuration.cxx18
-rw-r--r--common/rfb/Configuration.h6
-rw-r--r--common/rfb/Timer.cxx5
-rw-r--r--common/rfb/VNCSConnectionST.cxx8
8 files changed, 42 insertions, 13 deletions
diff --git a/common/network/Socket.h b/common/network/Socket.h
index 874a59cd..7a30cacf 100644
--- a/common/network/Socket.h
+++ b/common/network/Socket.h
@@ -50,6 +50,7 @@ namespace network {
// if shutdown() is overridden then the override MUST call on to here
virtual void shutdown() {isShutdown_ = true;}
bool isShutdown() const {return isShutdown_;}
+ virtual bool cork(bool enable) = 0;
// information about this end of the socket
virtual int getMyPort() = 0;
diff --git a/common/network/TcpSocket.cxx b/common/network/TcpSocket.cxx
index cf03c10d..9603c385 100644
--- a/common/network/TcpSocket.cxx
+++ b/common/network/TcpSocket.cxx
@@ -349,12 +349,12 @@ bool TcpSocket::enableNagles(int sock, bool enable) {
return true;
}
-bool TcpSocket::cork(int sock, bool enable) {
+bool TcpSocket::cork(bool enable) {
#ifndef TCP_CORK
return false;
#else
int one = enable ? 1 : 0;
- if (setsockopt(sock, IPPROTO_TCP, TCP_CORK, (char *)&one, sizeof(one)) < 0)
+ if (setsockopt(getFd(), IPPROTO_TCP, TCP_CORK, (char *)&one, sizeof(one)) < 0)
return false;
return true;
#endif
diff --git a/common/network/TcpSocket.h b/common/network/TcpSocket.h
index a97e6839..c1b142ff 100644
--- a/common/network/TcpSocket.h
+++ b/common/network/TcpSocket.h
@@ -62,9 +62,9 @@ namespace network {
virtual bool sameMachine();
virtual void shutdown();
+ virtual bool cork(bool enable);
static bool enableNagles(int sock, bool enable);
- static bool cork(int sock, bool enable);
static bool isListening(int sock);
static int getSockPort(int sock);
private:
diff --git a/common/rdr/FdOutStream.cxx b/common/rdr/FdOutStream.cxx
index 29e864fc..8fe9df94 100644
--- a/common/rdr/FdOutStream.cxx
+++ b/common/rdr/FdOutStream.cxx
@@ -1,5 +1,6 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
* Copyright 2011 Pierre Ossman for Cendio AB
+ * Copyright 2017 Peter Astrand <astrand@cendio.se> for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -34,6 +35,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <sys/time.h>
+#include <sys/socket.h>
#endif
/* Old systems have select() in sys/time.h */
@@ -193,7 +195,14 @@ int FdOutStream::writeWithTimeout(const void* data, int length, int timeoutms)
return 0;
do {
- n = ::write(fd, data, length);
+ // select only guarantees that you can write SO_SNDLOWAT without
+ // blocking, which is normally 1. Use MSG_DONTWAIT to avoid
+ // blocking, when possible.
+#ifndef MSG_DONTWAIT
+ n = ::send(fd, (const char*)data, length, 0);
+#else
+ n = ::send(fd, (const char*)data, length, MSG_DONTWAIT);
+#endif
} while (n < 0 && (errno == EINTR));
if (n < 0)
diff --git a/common/rfb/Configuration.cxx b/common/rfb/Configuration.cxx
index a5c23028..418a0c93 100644
--- a/common/rfb/Configuration.cxx
+++ b/common/rfb/Configuration.cxx
@@ -1,5 +1,6 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
* Copyright 2004-2005 Cendio AB.
+ * Copyright 2017 Peter Astrand <astrand@cendio.se> for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -166,6 +167,23 @@ void Configuration::list(int width, int nameWidth) {
}
+bool Configuration::remove(const char* param) {
+ VoidParameter *current = head;
+ VoidParameter **prevnext = &head;
+
+ while (current) {
+ if (strcasecmp(current->getName(), param) == 0) {
+ *prevnext = current->_next;
+ return true;
+ }
+ prevnext = &current->_next;
+ current = current->_next;
+ }
+
+ return false;
+}
+
+
// -=- VoidParameter
VoidParameter::VoidParameter(const char* name_, const char* desc_,
diff --git a/common/rfb/Configuration.h b/common/rfb/Configuration.h
index d319915a..6197317b 100644
--- a/common/rfb/Configuration.h
+++ b/common/rfb/Configuration.h
@@ -80,6 +80,9 @@ namespace rfb {
// - List the parameters of this Configuration group
void list(int width=79, int nameWidth=10);
+ // - Remove a parameter from this Configuration group
+ bool remove(const char* param);
+
// - readFromFile
// Read configuration parameters from the specified file.
void readFromFile(const char* filename);
@@ -116,6 +119,9 @@ namespace rfb {
static void listParams(int width=79, int nameWidth=10) {
global()->list(width, nameWidth);
}
+ static bool removeParam(const char* param) {
+ return global()->remove(param);
+ }
private:
friend class VoidParameter;
diff --git a/common/rfb/Timer.cxx b/common/rfb/Timer.cxx
index efae36e2..71887a0f 100644
--- a/common/rfb/Timer.cxx
+++ b/common/rfb/Timer.cxx
@@ -26,11 +26,6 @@
#include <rfb/util.h>
#include <rfb/LogWriter.h>
-// XXX Lynx/OS 2.3: proto for gettimeofday()
-#ifdef Lynx
-#include <sys/proto.h>
-#endif
-
using namespace rfb;
#ifndef __NO_DEFINE_VLOG__
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index 9e58657c..0e97a784 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -168,7 +168,7 @@ void VNCSConnectionST::processMessages()
// Get the underlying TCP layer to build large packets if we send
// multiple small responses.
- network::TcpSocket::cork(sock->getFd(), true);
+ sock->cork(true);
while (getInStream()->checkNoWait(1)) {
if (pendingSyncFence) {
@@ -185,7 +185,7 @@ void VNCSConnectionST::processMessages()
}
// Flush out everything in case we go idle after this.
- network::TcpSocket::cork(sock->getFd(), false);
+ sock->cork(false);
inProcessMessages = false;
@@ -1094,7 +1094,7 @@ void VNCSConnectionST::writeFramebufferUpdate()
// mode, we will also have small fence messages around the update. We
// need to aggregate these in order to not clog up TCP's congestion
// window.
- network::TcpSocket::cork(sock->getFd(), true);
+ sock->cork(true);
// First take care of any updates that cannot contain framebuffer data
// changes.
@@ -1103,7 +1103,7 @@ void VNCSConnectionST::writeFramebufferUpdate()
// Then real data (if possible)
writeDataUpdate();
- network::TcpSocket::cork(sock->getFd(), false);
+ sock->cork(false);
}
void VNCSConnectionST::writeNoDataUpdate()