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.tags/v1.8.90
// if shutdown() is overridden then the override MUST call on to here | // if shutdown() is overridden then the override MUST call on to here | ||||
virtual void shutdown() {isShutdown_ = true;} | virtual void shutdown() {isShutdown_ = true;} | ||||
bool isShutdown() const {return isShutdown_;} | bool isShutdown() const {return isShutdown_;} | ||||
virtual bool cork(bool enable) = 0; | |||||
// information about this end of the socket | // information about this end of the socket | ||||
virtual int getMyPort() = 0; | virtual int getMyPort() = 0; |
return true; | return true; | ||||
} | } | ||||
bool TcpSocket::cork(int sock, bool enable) { | |||||
bool TcpSocket::cork(bool enable) { | |||||
#ifndef TCP_CORK | #ifndef TCP_CORK | ||||
return false; | return false; | ||||
#else | #else | ||||
int one = enable ? 1 : 0; | 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 false; | ||||
return true; | return true; | ||||
#endif | #endif |
virtual bool sameMachine(); | virtual bool sameMachine(); | ||||
virtual void shutdown(); | virtual void shutdown(); | ||||
virtual bool cork(bool enable); | |||||
static bool enableNagles(int sock, bool enable); | static bool enableNagles(int sock, bool enable); | ||||
static bool cork(int sock, bool enable); | |||||
static bool isListening(int sock); | static bool isListening(int sock); | ||||
static int getSockPort(int sock); | static int getSockPort(int sock); | ||||
private: | private: |
// Get the underlying TCP layer to build large packets if we send | // Get the underlying TCP layer to build large packets if we send | ||||
// multiple small responses. | // multiple small responses. | ||||
network::TcpSocket::cork(sock->getFd(), true); | |||||
sock->cork(true); | |||||
while (getInStream()->checkNoWait(1)) { | while (getInStream()->checkNoWait(1)) { | ||||
if (pendingSyncFence) { | if (pendingSyncFence) { | ||||
} | } | ||||
// Flush out everything in case we go idle after this. | // Flush out everything in case we go idle after this. | ||||
network::TcpSocket::cork(sock->getFd(), false); | |||||
sock->cork(false); | |||||
inProcessMessages = false; | inProcessMessages = false; | ||||
// mode, we will also have small fence messages around the update. We | // 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 | // need to aggregate these in order to not clog up TCP's congestion | ||||
// window. | // window. | ||||
network::TcpSocket::cork(sock->getFd(), true); | |||||
sock->cork(true); | |||||
// First take care of any updates that cannot contain framebuffer data | // First take care of any updates that cannot contain framebuffer data | ||||
// changes. | // changes. | ||||
// Then real data (if possible) | // Then real data (if possible) | ||||
writeDataUpdate(); | writeDataUpdate(); | ||||
network::TcpSocket::cork(sock->getFd(), false); | |||||
sock->cork(false); | |||||
} | } | ||||
void VNCSConnectionST::writeNoDataUpdate() | void VNCSConnectionST::writeNoDataUpdate() |