mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-11 11:16:09 -05:00
http: set TCP_NODELAY when creating HTTP server
Otherwise, the default HTTP server config may result in high latency. [1] https://www.extrahop.com/blog/tcp-nodelay-nagle-quickack-best-practices [2] https://eklitzke.org/the-caveats-of-tcp-nodelay
This commit is contained in:
parent
27a770b34b
commit
03d49d0f25
1 changed files with 6 additions and 0 deletions
|
@ -388,6 +388,12 @@ static bool HTTPBindAddresses(struct evhttp* http)
|
||||||
if (i->first.empty() || (addr.has_value() && addr->IsBindAny())) {
|
if (i->first.empty() || (addr.has_value() && addr->IsBindAny())) {
|
||||||
LogPrintf("WARNING: the RPC server is not safe to expose to untrusted networks such as the public internet\n");
|
LogPrintf("WARNING: the RPC server is not safe to expose to untrusted networks such as the public internet\n");
|
||||||
}
|
}
|
||||||
|
// Set the no-delay option (disable Nagle's algorithm) on the TCP socket.
|
||||||
|
evutil_socket_t fd = evhttp_bound_socket_get_fd(bind_handle);
|
||||||
|
int one = 1;
|
||||||
|
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (sockopt_arg_type)&one, sizeof(one)) == SOCKET_ERROR) {
|
||||||
|
LogInfo("WARNING: Unable to set TCP_NODELAY on RPC server socket, continuing anyway\n");
|
||||||
|
}
|
||||||
boundSockets.push_back(bind_handle);
|
boundSockets.push_back(bind_handle);
|
||||||
} else {
|
} else {
|
||||||
LogPrintf("Binding RPC on address %s port %i failed.\n", i->first, i->second);
|
LogPrintf("Binding RPC on address %s port %i failed.\n", i->first, i->second);
|
||||||
|
|
Loading…
Add table
Reference in a new issue