diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-08-07 08:26:32 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-08-07 08:26:32 +0100 |
commit | 8bcdcfc6c8e93dda7e5eeb2122bf2ed5772f00a3 (patch) | |
tree | 918a3479201b873eb8cfd5c8f9c8728cda8885ba | |
parent | be8b130d14166145787f4e8e9b194b98c98c873d (diff) | |
download | rspamd-8bcdcfc6c8e93dda7e5eeb2122bf2ed5772f00a3.tar.gz rspamd-8bcdcfc6c8e93dda7e5eeb2122bf2ed5772f00a3.zip |
[Feature] Set TCP_NODELAY for milter sockets
Issue: #1790
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | config.h.in | 1 | ||||
-rw-r--r-- | src/libutil/unix-std.h | 4 | ||||
-rw-r--r-- | src/rspamd_proxy.c | 12 |
4 files changed, 18 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 82498acdf..e6a89c7cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -905,6 +905,7 @@ CHECK_INCLUDE_FILES(sys/file.h HAVE_SYS_FILE_H) CHECK_INCLUDE_FILES(sys/utsname.h HAVE_SYS_UTSNAME_H) CHECK_INCLUDE_FILES(sys/resource.h HAVE_SYS_RESOURCE_H) CHECK_INCLUDE_FILES(netinet/in.h HAVE_NETINET_IN_H) +CHECK_INCLUDE_FILES(netinet/tcp.h HAVE_NETINET_TCP_H) CHECK_INCLUDE_FILES(arpa/inet.h HAVE_ARPA_INET_H) CHECK_INCLUDE_FILES(netdb.h HAVE_NETDB_H) CHECK_INCLUDE_FILES(syslog.h HAVE_SYSLOG_H) diff --git a/config.h.in b/config.h.in index 29a2a4581..ef2bb1097 100644 --- a/config.h.in +++ b/config.h.in @@ -55,6 +55,7 @@ #cmakedefine HAVE_NANOSLEEP 1 #cmakedefine HAVE_NETDB_H 1 #cmakedefine HAVE_NETINET_IN_H 1 +#cmakedefine HAVE_NETINET_TCP_H 1 #cmakedefine HAVE_NFTW 1 #cmakedefine HAVE_OASYNC 1 #cmakedefine HAVE_ONOFOLLOW 1 diff --git a/src/libutil/unix-std.h b/src/libutil/unix-std.h index b1c8b6a02..218a35ffa 100644 --- a/src/libutil/unix-std.h +++ b/src/libutil/unix-std.h @@ -77,4 +77,8 @@ #include <libgen.h> #endif +#ifdef HAVE_SYS_SOCKET_H +#include <sys/socket.h> +#endif + #endif diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c index a2521fec1..be0980102 100644 --- a/src/rspamd_proxy.c +++ b/src/rspamd_proxy.c @@ -35,6 +35,10 @@ #include "libserver/milter.h" #include "contrib/zstd/zstd.h" +#ifdef HAVE_NETINET_TCP_H +#include <netinet/tcp.h> /* for TCP_NODELAY */ +#endif + /* Rotate keys each minute by default */ #define DEFAULT_ROTATION_TIME 60.0 #define DEFAULT_RETRIES 5 @@ -2006,6 +2010,14 @@ proxy_accept_socket (gint fd, short what, void *arg) rspamd_inet_address_to_string (addr), rspamd_inet_address_get_port (addr)); +#ifdef TCP_NODELAY + gint sopt = 1; + + if (setsockopt (nfd, SOL_TCP, TCP_NODELAY, &sopt, sizeof (sopt)) == -1) { + msg_warn_session ("cannot set TCP_NODELAY: %s", strerror (errno)); + } +#endif + rspamd_milter_handle_socket (nfd, NULL, session->pool, ctx->ev_base, |