]> rtime.felk.cvut.cz Git - frescor/forb.git/commitdiff
Added optional TCP_NODELAY to INET proto
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 17 Jun 2009 17:22:17 +0000 (19:22 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 17 Jun 2009 17:22:17 +0000 (19:22 +0200)
This is to have graphs in benchmarks not influenced by Nagle's algorithm
in TCP.

src/proto_inet.c

index a5b616f699d8a9a47bfa4502f6b21f10702784c9..b960f01adb2e8aac0ed0e6d436c810790095c17e 100644 (file)
@@ -61,6 +61,7 @@
 #include <forb/config.h>
 #include "discovery.h"
 #include <stdlib.h>
+#include <netinet/tcp.h>
 #include "iop.h" /* FIXME: Sending hello should be handled in IOP layer */
 
 /**
@@ -147,7 +148,23 @@ inet_deserialize_addr(FORB_CDR_Codec *codec, void **addr)
        return ret;
 }
 
-int setnonblocking(int fd);
+static int
+setnonblocking(int fd);
+
+static int
+setnodelay(int fd)
+{
+       int ret = 0;
+#if 0                          /* For nice graphs in benchmarks */
+       int yes = 1;
+       ret = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes));
+       if (ret < 0) {
+               ul_logerr("setsockopt(TCP_NODELAY): %s\n", strerror(errno));
+       }
+#endif
+       return ret;
+       
+}
 
 static int
 inet_connect(forb_peer_t *peer)
@@ -180,6 +197,7 @@ inet_connect(forb_peer_t *peer)
        }
 
        setnonblocking(ipeer->socket);
+       setnodelay(ipeer->socket);
 
        struct epoll_event ev;
        struct inet_port *p = peer->port->desc.proto_priv;
@@ -288,6 +306,7 @@ inet_accept_connection(forb_port_t *port)
                close(client);
                return -1;
        }
+       setnodelay(client);
 
        peer = forb_peer_new();
        if (peer) {