From 149d014441d13220e47ac5e637ca87b9334fa682 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Tue, 26 Apr 2016 13:39:08 +0200 Subject: [PATCH] setTCPNoDelay() for dnsdist console. Yak. --- pdns/misc.cc | 12 ++++++++++++ pdns/misc.hh | 1 + 2 files changed, 13 insertions(+) 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); -- 2.47.2