commit 5df71088736f5695d0cbf570d7f9d6971a38349d
parent 331bc629164bffc2e7d63adb8d37df3d341be075
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Tue, 1 Dec 2020 20:06:44 +0300
daemon.c: fixed: set TCP_NODELAY for externally added connections as well
if platform suppots TCP_CORK or TCP_NOPUSH
Diffstat:
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
@@ -2459,6 +2459,20 @@ new_connection_prepare_ (struct MHD_Daemon *daemon,
return MHD_NO;
}
connection->sk_cork_on = false;
+#if defined(MHD_TCP_CORK_NOPUSH) || defined(MHD_USE_MSG_MORE)
+ /* We will use TCP_CORK or TCP_NOPUSH or MSG_MORE to control
+ transmission, disable Nagle's algorithm (always) */
+ if ( (0 != MHD_socket_set_nodelay_ (client_socket,
+ true)) &&
+ (EOPNOTSUPP != errno) )
+ {
+#ifdef HAVE_MESSAGES
+ MHD_DLOG (daemon,
+ _ ("Failed to disable TCP Nagle on socket: %s\n"),
+ MHD_socket_last_strerr_ ());
+#endif
+ }
+#endif
connection->connection_timeout = daemon->connection_timeout;
if (NULL == (connection->addr = malloc (addrlen)))
@@ -3507,20 +3521,6 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
}
return MHD_NO;
}
-#if defined(MHD_TCP_CORK_NOPUSH) || defined(MHD_USE_MSG_MORE)
- /* We will use TCP_CORK or TCP_NOPUSH or MSG_MORE to control
- transmission, disable Nagle's algorithm (always) */
- if ( (0 != MHD_socket_set_nodelay_ (s,
- true)) &&
- (EOPNOTSUPP != errno) )
- {
-#ifdef HAVE_MESSAGES
- MHD_DLOG (daemon,
- _ ("Failed to disable TCP Nagle on socket: %s\n"),
- MHD_socket_last_strerr_ ());
-#endif
- }
-#endif
#if ! defined(USE_ACCEPT4) || ! defined(HAVE_SOCK_NONBLOCK)
if (! MHD_socket_nonblocking_ (s))
{