From d5c3f00f9f96cbf9ed227b1f8c870d5232bb9039 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 25 Jul 2019 20:32:36 +0200 Subject: simplify --- src/microhttpd/mhd_send.c | 62 +++-------------------------------------------- 1 file changed, 4 insertions(+), 58 deletions(-) diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c index fa128fa1..ee627e10 100644 --- a/src/microhttpd/mhd_send.c +++ b/src/microhttpd/mhd_send.c @@ -598,14 +598,7 @@ static int freebsd_sendfile_flags_thd_p_c_; ssize_t sendfile_adapter (struct MHD_Connection *connection) { - bool want_cork = false; - bool have_cork; - bool have_more; - bool use_corknopush; - bool using_tls = false; - ssize_t ret; - ssize_t lo_ret; const int file_fd = connection->response->fd; uint64_t left; uint64_t offsetu64; @@ -633,6 +626,8 @@ sendfile_adapter (struct MHD_Connection *connection) size_t send_size = 0; mhd_assert (MHD_resp_sender_sendfile == connection->resp_sender); + (void) pre_cork_setsockopt (connection, false); + offsetu64 = connection->response_write_position + connection->response->fd_off; left = connection->response->total_size - connection->response_write_position; /* Do not allow system to stick sending on single fast connection: @@ -772,57 +767,8 @@ sendfile_adapter (struct MHD_Connection *connection) ret = (ssize_t)len; #endif /* HAVE_FREEBSD_SENDFILE */ - ret = lo_ret; - if (0 > ret) - { - /* ! could be avoided by redefining the variable. */ - have_cork = ! connection->sk_tcp_nodelay_on; - -#ifdef MSG_MORE - have_more = true; -#else - have_more = false; -#endif - -#if TCP_NODELAY - use_corknopush = false; -#elif TCP_CORK - use_corknopush = true; -#elif TCP_NOPUSH - use_corknopush = true; -#endif + (void) post_cork_setsockopt (connection, false); -#ifdef HTTPS_SUPPORT - using_tls = (0 != (connection->daemon->options & MHD_USE_TLS)); -#endif - -#if TCP_CORK - /* When we have CORK, we can have NODELAY on the same system, - * at least since Linux 2.2 and both can be combined since - * Linux 2.5.71. For more details refer to tcp(7) on Linux. - * No other system in 2019-06 has TCP_CORK. */ - if ((! using_tls) && (use_corknopush) && (have_cork && ! want_cork)) - { - MHD_send_socket_state_cork_nodelay_ (connection, - false, - true, - true, - true); - } -#elif TCP_NOPUSH - /* TCP_NOPUSH on FreeBSD is equal to cork on Linux, with the - * exception that we know that TCP_NOPUSH will definitely - * exist and we can disregard TCP_NODELAY unless requested. */ - if ((! using_tls) && (use_corknopush) && (have_cork && ! want_cork)) - { - MHD_send_socket_state_nopush_ (connection, true, false); - } -#endif - return lo_ret; - } - else - { - return ret; - } + return ret; } #endif /* _MHD_HAVE_SENDFILE */ -- cgit v1.2.3