aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Åstrand (astrand) <astrand@cendio.se>2017-10-10 12:56:04 +0200
committerPeter Åstrand (astrand) <astrand@cendio.se>2017-11-08 10:40:12 +0100
commit01dc1a67dc5afad21822930d34b2b44eec414790 (patch)
tree2474cb838280811aa003e32e82e7a017597c4166
parent3112f50062d57835148b5540cce1be5fa63a512b (diff)
downloadtigervnc-01dc1a67dc5afad21822930d34b2b44eec414790.tar.gz
tigervnc-01dc1a67dc5afad21822930d34b2b44eec414790.zip
Define cork() as pure virtual in Socket class
This makes it possible to create a derived class from Socket which is not TCP based, without having VNCSConnectionST.cxx trying to call setsockopt() on a non-socket.
-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/rfb/VNCSConnectionST.cxx8
4 files changed, 8 insertions, 7 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/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index d9bb2815..2f8889d2 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;
@@ -1093,7 +1093,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.
@@ -1102,7 +1102,7 @@ void VNCSConnectionST::writeFramebufferUpdate()
// Then real data (if possible)
writeDataUpdate();
- network::TcpSocket::cork(sock->getFd(), false);
+ sock->cork(false);
}
void VNCSConnectionST::writeNoDataUpdate()