diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/listensocket.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/listensocket.cpp b/src/listensocket.cpp index 466b91c8b..f875bc646 100644 --- a/src/listensocket.cpp +++ b/src/listensocket.cpp @@ -22,6 +22,10 @@ #include "socket.h" #include "socketengine.h" +#ifdef USE_TCP_DEFER_ACCEPT +#include <netinet/tcp.h> +#endif + ListenSocket::ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_to) : bind_tag(tag) { @@ -38,6 +42,19 @@ ListenSocket::ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_t if (rv >= 0) rv = ServerInstance->SE->Listen(this->fd, ServerInstance->Config->MaxConn); + int timeout = tag->getInt("defer", 0); + if (timeout && !rv) + { +#ifdef USE_TCP_DEFER_ACCEPT + setsockopt(fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &timeout, sizeof(timeout)); +#elif defined USE_SO_ACCEPTFILTER + struct accept_filter_arg afa; + memset(&afa, 0, sizeof(afa)); + strcpy(afa.af_name, "dataready"); + setsockopt(fd, SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa)); +#endif + } + #ifdef IPV6_V6ONLY /* This OS supports IPv6 sockets that can also listen for IPv4 * connections. If our address is "*" or empty, enable both v4 and v6 to |