summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/unfs3/unfs3/tcp_no_delay.patch
blob: b3521c63eb8c5dae3bf24f743563cd896d243fe9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
daemon.c: Add option for tcp no delay

Allow the NFS tcp sockets to conditionally use TCP_NODELAY

Upstream-Status: Submitted http://sourceforge.net/p/unfs3/bugs/5/

---
 daemon.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

--- a/daemon.c
+++ b/daemon.c
@@ -17,6 +17,7 @@
 #ifndef WIN32
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <netinet/tcp.h>
 #include <arpa/inet.h>
 #include <syslog.h>
 #else				       /* WIN32 */
@@ -75,6 +76,7 @@ unsigned int opt_mount_port = NFS_PORT;
 int opt_singleuser = FALSE;
 int opt_brute_force = FALSE;
 int opt_testconfig = FALSE;
+int opt_tcp_nodelay = FALSE;
 struct in_addr opt_bind_addr;
 int opt_readable_executables = FALSE;
 char *opt_pid_file = NULL;
@@ -208,7 +210,7 @@ static void parse_options(int argc, char
 {
 
     int opt = 0;
-    char *optstring = "bcC:de:hl:m:n:prstTuwi:x:y:";
+    char *optstring = "bcC:de:hl:m:Nn:prstTuwi:x:y:";
 
     while (opt != -1) {
 	opt = getopt(argc, argv, optstring);
@@ -295,6 +297,9 @@ static void parse_options(int argc, char
 		    exit(1);
 		}
 		break;
+	    case 'N':
+		opt_tcp_nodelay = TRUE;
+		break;
 	    case 'n':
 		opt_nfs_port = strtol(optarg, NULL, 10);
 		if (opt_nfs_port == 0) {
@@ -802,6 +807,8 @@ static SVCXPRT *create_tcp_transport(uns
 	sin.sin_addr.s_addr = opt_bind_addr.s_addr;
 	sock = socket(PF_INET, SOCK_STREAM, 0);
 	setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char *) &on, sizeof(on));
+	if (opt_tcp_nodelay)
+	    setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
 	if (bind(sock, (struct sockaddr *) &sin, sizeof(struct sockaddr))) {
 	    perror("bind");
 	    fprintf(stderr, "Couldn't bind to tcp port %d\n", port);