]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
setTCPNoDelay() for dnsdist console. Yak.
authorbert hubert <bert.hubert@netherlabs.nl>
Tue, 26 Apr 2016 11:39:08 +0000 (13:39 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Tue, 26 Apr 2016 11:39:08 +0000 (13:39 +0200)
pdns/misc.cc
pdns/misc.hh

index 1b7a545b134906997e47ee3a3c67e5e89fc0334a..3b2c6670d68f25585959cff0b38f609380a18614 100644 (file)
@@ -46,6 +46,7 @@
 #include <boost/optional.hpp>
 #include <poll.h>
 #include <iomanip>
+#include <netinet/tcp.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -1047,6 +1048,17 @@ bool setSocketTimestamps(int fd)
   return true; // we pretend this happened.
 }
 
+void setTCPNoDelay(int sock)
+{
+  int flag = 1;
+  setsockopt(sock,            /* socket affected */
+             IPPROTO_TCP,     /* set option at TCP level */
+             TCP_NODELAY,     /* name of option */
+             (char *) &flag,  /* the cast is historical cruft */
+             sizeof(flag));    /* length of option value */
+}
+
+
 bool setNonBlocking(int sock)
 {
   int flags=fcntl(sock,F_GETFL,0);
index 7b2713fbf5bb148a117929376d3107c9fbf9f23f..a0ea680a920b437003d4ec8fb2201d6aed95132a 100644 (file)
@@ -600,6 +600,7 @@ bool setBlocking( int sock );
 
 //! Sets the socket into non-blocking mode.
 bool setNonBlocking( int sock );
+void setTCPNoDelay(int sock);
 bool isNonBlocking(int sock);
 int closesocket(int fd);
 bool setCloseOnExec(int sock);