diff options
| author | Wladimir J. van der Laan <[email protected]> | 2015-10-23 09:29:20 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2015-10-23 09:29:49 +0200 |
| commit | b2b173acabea78f5e613db3d0cdf5e23aeed1e9a (patch) | |
| tree | 270790adb3840c7e29587cdaf9e6f44bfd1beaa3 /src/net.cpp | |
| parent | Merge pull request #6848 (diff) | |
| parent | Set TCP_NODELAY on P2P sockets. (diff) | |
| download | discoin-b2b173acabea78f5e613db3d0cdf5e23aeed1e9a.tar.xz discoin-b2b173acabea78f5e613db3d0cdf5e23aeed1e9a.zip | |
Merge pull request #6867
a4e28b3 Set TCP_NODELAY on P2P sockets. (Gregory Maxwell)
Diffstat (limited to 'src/net.cpp')
| -rw-r--r-- | src/net.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/net.cpp b/src/net.cpp index 87c4f0af0..58b946f4a 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -963,6 +963,15 @@ static void AcceptConnection(const ListenSocket& hListenSocket) { return; } + // According to the internet TCP_NODELAY is not carried into accepted sockets + // on all platforms. Set it again here just to be sure. + int set = 1; +#ifdef WIN32 + setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (const char*)&set, sizeof(int)); +#else + setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (void*)&set, sizeof(int)); +#endif + if (CNode::IsBanned(addr) && !whitelisted) { LogPrintf("connection from %s dropped (banned)\n", addr.ToString()); @@ -1790,8 +1799,11 @@ bool BindListenPort(const CService &addrBind, string& strError, bool fWhiteliste // Allow binding if the port is still in TIME_WAIT state after // the program was closed and restarted. setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (void*)&nOne, sizeof(int)); + // Disable Nagle's algorithm + setsockopt(hListenSocket, IPPROTO_TCP, TCP_NODELAY, (void*)&nOne, sizeof(int)); #else setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (const char*)&nOne, sizeof(int)); + setsockopt(hListenSocket, IPPROTO_TCP, TCP_NODELAY, (const char*)&nOne, sizeof(int)); #endif // Set to non-blocking, incoming connections will also inherit this |