From: bert hubert Date: Tue, 26 Apr 2016 11:39:08 +0000 (+0200) Subject: setTCPNoDelay() for dnsdist console. Yak. X-Git-Tag: rec-4.0.0-alpha3~40^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=149d014441d13220e47ac5e637ca87b9334fa682;p=thirdparty%2Fpdns.git setTCPNoDelay() for dnsdist console. Yak. --- diff --git a/pdns/misc.cc b/pdns/misc.cc index 1b7a545b13..3b2c6670d6 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -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); diff --git a/pdns/misc.hh b/pdns/misc.hh index 7b2713fbf5..a0ea680a92 100644 --- a/pdns/misc.hh +++ b/pdns/misc.hh @@ -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);