diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-07-25 20:32:36 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-07-25 20:32:36 +0200 |
commit | d5c3f00f9f96cbf9ed227b1f8c870d5232bb9039 (patch) | |
tree | 05fa63bffe13bd697de548992c16686947f8fec9 | |
parent | be5ba4767f4e64099f673f24cace9d6817651356 (diff) | |
download | libmicrohttpd-d5c3f00f9f96cbf9ed227b1f8c870d5232bb9039.tar.gz libmicrohttpd-d5c3f00f9f96cbf9ed227b1f8c870d5232bb9039.zip |
simplify
-rw-r--r-- | src/microhttpd/mhd_send.c | 62 |
1 files 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_; | |||
598 | ssize_t | 598 | ssize_t |
599 | sendfile_adapter (struct MHD_Connection *connection) | 599 | sendfile_adapter (struct MHD_Connection *connection) |
600 | { | 600 | { |
601 | bool want_cork = false; | ||
602 | bool have_cork; | ||
603 | bool have_more; | ||
604 | bool use_corknopush; | ||
605 | bool using_tls = false; | ||
606 | |||
607 | ssize_t ret; | 601 | ssize_t ret; |
608 | ssize_t lo_ret; | ||
609 | const int file_fd = connection->response->fd; | 602 | const int file_fd = connection->response->fd; |
610 | uint64_t left; | 603 | uint64_t left; |
611 | uint64_t offsetu64; | 604 | uint64_t offsetu64; |
@@ -633,6 +626,8 @@ sendfile_adapter (struct MHD_Connection *connection) | |||
633 | size_t send_size = 0; | 626 | size_t send_size = 0; |
634 | mhd_assert (MHD_resp_sender_sendfile == connection->resp_sender); | 627 | mhd_assert (MHD_resp_sender_sendfile == connection->resp_sender); |
635 | 628 | ||
629 | (void) pre_cork_setsockopt (connection, false); | ||
630 | |||
636 | offsetu64 = connection->response_write_position + connection->response->fd_off; | 631 | offsetu64 = connection->response_write_position + connection->response->fd_off; |
637 | left = connection->response->total_size - connection->response_write_position; | 632 | left = connection->response->total_size - connection->response_write_position; |
638 | /* Do not allow system to stick sending on single fast connection: | 633 | /* Do not allow system to stick sending on single fast connection: |
@@ -772,57 +767,8 @@ sendfile_adapter (struct MHD_Connection *connection) | |||
772 | ret = (ssize_t)len; | 767 | ret = (ssize_t)len; |
773 | #endif /* HAVE_FREEBSD_SENDFILE */ | 768 | #endif /* HAVE_FREEBSD_SENDFILE */ |
774 | 769 | ||
775 | ret = lo_ret; | 770 | (void) post_cork_setsockopt (connection, false); |
776 | if (0 > ret) | ||
777 | { | ||
778 | /* ! could be avoided by redefining the variable. */ | ||
779 | have_cork = ! connection->sk_tcp_nodelay_on; | ||
780 | |||
781 | #ifdef MSG_MORE | ||
782 | have_more = true; | ||
783 | #else | ||
784 | have_more = false; | ||
785 | #endif | ||
786 | |||
787 | #if TCP_NODELAY | ||
788 | use_corknopush = false; | ||
789 | #elif TCP_CORK | ||
790 | use_corknopush = true; | ||
791 | #elif TCP_NOPUSH | ||
792 | use_corknopush = true; | ||
793 | #endif | ||
794 | 771 | ||
795 | #ifdef HTTPS_SUPPORT | 772 | return ret; |
796 | using_tls = (0 != (connection->daemon->options & MHD_USE_TLS)); | ||
797 | #endif | ||
798 | |||
799 | #if TCP_CORK | ||
800 | /* When we have CORK, we can have NODELAY on the same system, | ||
801 | * at least since Linux 2.2 and both can be combined since | ||
802 | * Linux 2.5.71. For more details refer to tcp(7) on Linux. | ||
803 | * No other system in 2019-06 has TCP_CORK. */ | ||
804 | if ((! using_tls) && (use_corknopush) && (have_cork && ! want_cork)) | ||
805 | { | ||
806 | MHD_send_socket_state_cork_nodelay_ (connection, | ||
807 | false, | ||
808 | true, | ||
809 | true, | ||
810 | true); | ||
811 | } | ||
812 | #elif TCP_NOPUSH | ||
813 | /* TCP_NOPUSH on FreeBSD is equal to cork on Linux, with the | ||
814 | * exception that we know that TCP_NOPUSH will definitely | ||
815 | * exist and we can disregard TCP_NODELAY unless requested. */ | ||
816 | if ((! using_tls) && (use_corknopush) && (have_cork && ! want_cork)) | ||
817 | { | ||
818 | MHD_send_socket_state_nopush_ (connection, true, false); | ||
819 | } | ||
820 | #endif | ||
821 | return lo_ret; | ||
822 | } | ||
823 | else | ||
824 | { | ||
825 | return ret; | ||
826 | } | ||
827 | } | 773 | } |
828 | #endif /* _MHD_HAVE_SENDFILE */ | 774 | #endif /* _MHD_HAVE_SENDFILE */ |