libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 5c197db398d6926dfb378bb4b4dbcf93566e9c1f
parent 068cf22c0357b13e2f84ca6a10c6823a24264d96
Author: ng0 <ng0@n0.is>
Date:   Sun, 21 Jul 2019 11:08:58 +0000

flatten if statements, add initial TCP_NOPUSH to MHD_send_on_connection2_

Diffstat:
Msrc/microhttpd/mhd_send.c | 34+++++++++++++++++++++++++++-------
1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c @@ -345,19 +345,17 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection, #endif #if TCP_NODELAY - if (! use_corknopush) - { - if (! have_cork && want_cork) + if ((! use_corknopush) && (! have_cork && want_cork)) { if (0 == setsockopt (s, IPPROTO_TCP, TCP_NODELAY, (const void *) &off_val, - sizeof (off_val))) { - connection->sk_tcp_nodelay = false; - } + sizeof (off_val))) + { + connection->sk_tcp_nodelay = false; + } } - } #endif vector[0].iov_base = header; @@ -367,6 +365,7 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection, iovcnt = sizeof (vector) / sizeof (struct iovec); ret = writev (connection->socket_fd, vector, iovcnt); #if TCP_CORK + if (use_corknopush) { eno; @@ -384,6 +383,27 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection, } return ret; #endif + +#if TCP_NOPUSH + if (use_corknopush) + { + eno; + + eno = errno; + if (ret == header_len + buffer_len) + { + /* Response complete, set NOPUSH to off */ + setsockopt (s, + IPPROTO_TCP, + TCP_NOPUSH, + (const void *) &off_val, + sizeof (off_val)); + } + errno = eno; + } + return ret; +#endif + #else return MHD_send_on_connection_ (connection, header,