[MEDIUM] implement option tcp-smart-accept at the frontend
This option disables TCP quick ack upon accept. It is also
automatically enabled in HTTP mode, unless the option is
explicitly disabled with "no option tcp-smart-accept".
This saves one packet per connection which can bring reasonable
amounts of bandwidth for servers processing small requests.
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 4d0ae35..ed0812c 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -18,6 +18,8 @@
#include <string.h>
#include <time.h>
+#include <netinet/tcp.h>
+
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/stat.h>
@@ -263,6 +265,11 @@
goto tcp_close_return;
}
+#ifdef TCP_QUICKACK
+ if (listener->options & LI_O_NOQUICKACK)
+ setsockopt(fd, SOL_TCP, TCP_QUICKACK, (char *) &zero, sizeof(zero));
+#endif
+
/* the socket is ready */
listener->fd = fd;
listener->state = LI_LISTEN;