summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-12-25 00:02:48 +0300
committerAndrei Karas <akaras@inbox.ru>2014-12-26 23:14:17 +0300
commit71efeed0e7c8b847172549d76c47f859327150bc (patch)
treea4c0a34739e63c08cddf55d695171f7a9fff1777 /src/common
parentc564291bf3f2666f709beeecad24de7d95fdf558 (diff)
downloadhercules-71efeed0e7c8b847172549d76c47f859327150bc.tar.gz
hercules-71efeed0e7c8b847172549d76c47f859327150bc.tar.bz2
hercules-71efeed0e7c8b847172549d76c47f859327150bc.tar.xz
hercules-71efeed0e7c8b847172549d76c47f859327150bc.zip
In linux enable thin-stream mode.
It should reduce latency in some cases. See more info here: https://www.kernel.org/doc/Documentation/networking/tcp-thin.txt
Diffstat (limited to 'src/common')
-rw-r--r--src/common/socket.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/common/socket.c b/src/common/socket.c
index f307dc4a9..09521c312 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -29,8 +29,12 @@
# include <errno.h>
# include <net/if.h>
# include <netdb.h>
+#if defined __linux__ || defined __linux
+# include <linux/tcp.h>
+#else
# include <netinet/in.h>
# include <netinet/tcp.h>
+#endif
# include <sys/ioctl.h>
# include <sys/socket.h>
# include <sys/time.h>
@@ -333,6 +337,13 @@ void setsocketopts(int fd, struct hSockOpt *opt) {
lopt.l_linger = 0; // Do not care
if( sSetsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&lopt, sizeof(lopt)) )
ShowWarning("setsocketopts: Unable to set SO_LINGER mode for connection #%d!\n", fd);
+
+#ifdef TCP_THIN_LINEAR_TIMEOUTS
+ setsockopt(fd, IPPROTO_TCP, TCP_THIN_LINEAR_TIMEOUTS, &yes, sizeof yes);
+#endif
+#ifdef TCP_THIN_DUPACK
+ setsockopt(fd, IPPROTO_TCP, TCP_THIN_DUPACK, &yes, sizeof yes);
+#endif
}
/*======================================