summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2021-04-13 18:00:08 +0200
committerSimon Rettberg2021-04-14 13:17:59 +0200
commit33497bd260d242c32fdebe06a20803b2c6a68338 (patch)
treea871ef6f64cdab059280b075916bc7674f1b30e1
parent[SERVER] Make prefetching synchronous (diff)
downloaddnbd3-33497bd260d242c32fdebe06a20803b2c6a68338.tar.gz
dnbd3-33497bd260d242c32fdebe06a20803b2c6a68338.tar.xz
dnbd3-33497bd260d242c32fdebe06a20803b2c6a68338.zip
[SERVER] Set TCP_NODELAY on outgoing connections
This will send all (block) requests immediately at sometimes more overhead, but slighly less delays. Since the outgoing connection on a client is only used very lightly, this tradeoff should always make sense.
-rw-r--r--src/shared/sockhelper.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/shared/sockhelper.c b/src/shared/sockhelper.c
index 585afe7..1970447 100644
--- a/src/shared/sockhelper.c
+++ b/src/shared/sockhelper.c
@@ -2,6 +2,7 @@
#include <dnbd3/shared/log.h>
#include <dnbd3/types.h>
#include <arpa/inet.h> // inet_ntop
+#include <netinet/tcp.h>
#include <netdb.h>
#include <stdio.h>
#include <unistd.h>
@@ -53,7 +54,9 @@ int sock_connect(const dnbd3_host_t * const addr, const int connect_ms, const in
} else {
sock_setTimeout( client_sock, connect_ms );
}
- int e2;
+ // NODELAY makes sense for the client side, which should be all users in this code base
+ int e2 = 1;
+ setsockopt( client_sock, IPPROTO_TCP, TCP_NODELAY, (void *)&e2, sizeof(e2) );
for ( int i = 0; i < 5; ++i ) {
int ret = connect( client_sock, (struct sockaddr *)&ss, addrlen );
e2 = errno;