aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/mhd_send.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/mhd_send.c')
-rw-r--r--src/microhttpd/mhd_send.c53
1 files changed, 23 insertions, 30 deletions
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 18fa617f..36007929 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -24,37 +24,33 @@
24 * @author ng0 <ng0@n0.is> 24 * @author ng0 <ng0@n0.is>
25 */ 25 */
26 26
27// to be used in: send_param_adapter, MHD_send_ 27/* TODO: sendfile() wrappers. */
28// and every place where sendfile(), sendfile64(), setsockopt()
29// are used.
30// TODO: sendfile() wrappers.
31 28
32#include "mhd_send.h" 29#include "mhd_send.h"
33 30
34// NOTE: TCP_CORK == TCP_NOPUSH in FreeBSD.
35// TCP_CORK is Linux.
36// TCP_CORK/TCP_NOPUSH: don't send out partial frames.
37// TCP_NODELAY: disable Nagle (aggregate data based on
38// buffer pressur).
39// TODO: It is possible that Solaris/SunOS depending on
40// the linked library needs a different setsockopt usage:
41// https://stackoverflow.com/questions/48670299/setsockopt-usage-in-linux-and-solaris-invalid-argument-in-solaris
42
43/* 31/*
44 * https://svnweb.freebsd.org/base/head/sys/netinet/tcp_usrreq.c?view=markup&pathrev=346360 32 * NOTE:
33 * It might be possible that Solaris/SunOS depending on the linked library needs a different setsockopt usage:
34 * https://stackoverflow.com/questions/48670299/setsockopt-usage-in-linux-and-solaris-invalid-argument-in-solaris
35 *
45 * Approximately in 2007 work began to make TCP_NOPUSH in FreeBSD 36 * Approximately in 2007 work began to make TCP_NOPUSH in FreeBSD
46 * behave like TCP_CORK in Linux. Thus we define them to be one and 37 * behave like TCP_CORK in Linux. Thus we define them to be one and
47 * the same, which again could be platform dependent (NetBSD does 38 * the same, which again could be platform dependent (NetBSD does
48 * (so far) only provide a FreeBSD compatibility here, for example). 39 * (so far) only provide a FreeBSD compatibility here, for example).
49 * Since we only deal with IPPROTO_TCP flags in this file and nowhere 40 * Since we only deal with IPPROTO_TCP flags in this file and nowhere
50 * else, we don't have to move this elsewhere for now. 41 * else, we don't have to move this elsewhere for now.
51*/ 42 * https://svnweb.freebsd.org/base/head/sys/netinet/tcp_usrreq.c?view=markup&pathrev=346360
52/* 43 *
53#if ! defined(TCP_CORK) && defined(TCP_NOPUSH) 44 * verbose notes, remove when done:
54#define TCP_CORK TCP_NOPUSH 45 * TCP_CORK == TCP_NOPUSH in FreeBSD.
55#endif 46 * TCP_CORK is Linux.
56*/ 47 * TCP_CORK/TCP_NOPUSH: don't send out partial frames.
57/* 48 * TCP_NODELAY: disable Nagle (aggregate data based on buffer pressur)
49 *
50 * to be used in: send_param_adapter, MHD_send_
51 * and every place where sendfile(), sendfile64(), setsockopt() are used.
52 *
53 * Fix this up in doxygen style:
58 * -- OBJECTIVE: 54 * -- OBJECTIVE:
59 * connection: use member 'socket', and remember the 55 * connection: use member 'socket', and remember the
60 * current state of the socket-options (cork/nocork/nodelay/whatever) 56 * current state of the socket-options (cork/nocork/nodelay/whatever)
@@ -152,17 +148,14 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
152 { 148 {
153 connection->sk_tcp_nodelay = true; 149 connection->sk_tcp_nodelay = true;
154 } 150 }
155 //setsockopt (cork-on); // or nodelay on // + update connection->sk_tcp_nodelay_on 151 /* When we have CORK, we can have NODELAY on the same system,
156 // When we have CORK, we can have NODELAY on the same system, 152 * at least since Linux 2.2 and both can be combined since
157 // at least since Linux 2.2 and both can be combined since 153 * Linux 2.5.71. See tcp(7). No other system in 2019-06 has TCP_CORK. */
158 // Linux 2.5.71. See tcp(7). No other system in 2019-06 has TCP_CORK.
159 } 154 }
160#elif TCP_NOPUSH 155#elif TCP_NOPUSH
161 /* 156 /* TCP_NOPUSH on FreeBSD is equal to cork on Linux, with the
162 * TCP_NOPUSH on FreeBSD is equal to cork on Linux, with the 157 * exception that we know that TCP_NOPUSH will definitely
163 * exception that we know that TCP_NOPUSH will definitely 158 * exist and we can disregard TCP_NODELAY unless requested. */
164 * exist and we can disregard TCP_NODELAY unless requested.
165 */
166 if ((use_corknopush) && (have_cork && ! want_cork)) 159 if ((use_corknopush) && (have_cork && ! want_cork))
167 { 160 {
168 if (0 == setsockopt (connection->socket_fd, 161 if (0 == setsockopt (connection->socket_fd,