From c8937f3f528ed4765f6de1d28c2c7be96869049c Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Thu, 6 Jan 2011 09:13:47 -0500 Subject: [PATCH] TCP_NODELAY --- server/net.c | 6 ++++++ server/test1.c | 6 ++++++ server/test1_latency.c | 6 ++++++ server/test3.c | 6 ++++++ server/test3_latency.c | 6 ++++++ 5 files changed, 30 insertions(+) diff --git a/server/net.c b/server/net.c index c0776b8..a5d848b 100644 --- a/server/net.c +++ b/server/net.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,11 @@ static void accept_connection(int servfd, short what, void *arg) { return; } + { + int i = 1; + ICHECK(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &i, sizeof(i)), "setsockopt TCP_NODELAY"); + } + start_relay(&s, fd); } diff --git a/server/test1.c b/server/test1.c index 65e3c3b..0beab33 100644 --- a/server/test1.c +++ b/server/test1.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -44,6 +45,11 @@ int main(int argc, char *argv[]) { if (connect(fd, (struct sockaddr *) &s, sizeof(s)) < 0) return 1; + { + int i = 1; + setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &i, sizeof(i)); + } + f = fdopen(fd, "a+"); fprintf(f, "(9:subscribe5:test10:0:5:test15:login)(4:post7:factory(6:create5:queue(2:q1)5:test11:k)0:)(4:post2:q1(9:subscribe0:5:test18:consumer5:test11:k)0:)\n"); diff --git a/server/test1_latency.c b/server/test1_latency.c index 2e7034d..3dc0149 100644 --- a/server/test1_latency.c +++ b/server/test1_latency.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -83,6 +84,11 @@ int main(int argc, char *argv[]) { if (connect(fd, (struct sockaddr *) &s, sizeof(s)) < 0) return 1; + { + int i = 1; + setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &i, sizeof(i)); + } + f = fdopen(fd, "a+"); fprintf(f, "(9:subscribe5:test10:0:5:test15:login)(4:post7:factory(6:create5:queue(2:q1)5:test11:k)0:)(4:post2:q1(9:subscribe0:5:test18:consumer5:test11:k)0:)\n"); diff --git a/server/test3.c b/server/test3.c index 27c3c60..48a2c59 100644 --- a/server/test3.c +++ b/server/test3.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,11 @@ int main(int argc, char *argv[]) { if (connect(fd, (struct sockaddr *) &s, sizeof(s)) < 0) return 1; + { + int i = 1; + setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &i, sizeof(i)); + } + f = fdopen(fd, "a+"); fprintf(f, "(9:subscribe5:test30:0:5:test35:login)"); diff --git a/server/test3_latency.c b/server/test3_latency.c index c90a3b6..36a17a7 100644 --- a/server/test3_latency.c +++ b/server/test3_latency.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -79,6 +80,11 @@ int main(int argc, char *argv[]) { if (connect(fd, (struct sockaddr *) &s, sizeof(s)) < 0) return 1; + { + int i = 1; + setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &i, sizeof(i)); + } + f = fdopen(fd, "a+"); fprintf(f, "(9:subscribe5:test30:0:5:test35:login)");