]> granicus.if.org Git - pdns/commitdiff
dnsdist did not set TCP_NODELAY, causing needless latency
authorbert hubert <bert.hubert@netherlabs.nl>
Fri, 5 Oct 2018 10:58:18 +0000 (12:58 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Fri, 5 Oct 2018 10:58:18 +0000 (12:58 +0200)
Winfried and others noted that our TLS responses were super slow. This turned out to be caused by the Nagle
algorithm which we failed to disable. https://en.wikipedia.org/wiki/Nagle%27s_algorithm

pdns/dnsdist-tcp.cc

index d7a6e80bd421637f551386f235a749b8c299b545..0ea59d7911a21829adc7681972c93fcf37a4e901 100644 (file)
@@ -32,6 +32,7 @@
 #include "threadname.hh"
 #include <thread>
 #include <atomic>
+#include <netinet/tcp.h>
 
 using std::thread;
 using std::atomic;
@@ -715,7 +716,7 @@ void* tcpAcceptorThread(void* p)
         continue;
       }
 #endif
-
+      SSetsockopt(ci->fd, SOL_TCP, TCP_NODELAY, 1); // disable NAGLE
       if(g_maxTCPQueuedConnections > 0 && g_tcpclientthreads->getQueuedCount() >= g_maxTCPQueuedConnections) {
         close(ci->fd);
         delete ci;