aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/mhd_send.c
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-07-25 16:11:18 +0000
committerng0 <ng0@n0.is>2019-07-25 16:11:18 +0000
commitc2915ac74083f5803d7d26de83b65eac4cb341a7 (patch)
tree362d5901998ea55d8a44630d2dac14c63dbf22d5 /src/microhttpd/mhd_send.c
parentadba1139a10c0cc776e8b7b8a20e00b4c33d0a9f (diff)
downloadlibmicrohttpd-c2915ac74083f5803d7d26de83b65eac4cb341a7.tar.gz
libmicrohttpd-c2915ac74083f5803d7d26de83b65eac4cb341a7.zip
pre_cork socket..
Diffstat (limited to 'src/microhttpd/mhd_send.c')
-rw-r--r--src/microhttpd/mhd_send.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 74735cbe..b22313df 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -87,12 +87,11 @@ post_cork_setsockopt (struct MHD_Connection *connection,
87 87
88int 88int
89pre_cork_setsockopt (struct MHD_Connection *connection, 89pre_cork_setsockopt (struct MHD_Connection *connection,
90 bool want_cork, 90 bool want_cork)
91 bool val)
92{ 91{
93 int ret; 92 int ret;
94 bool using_tls = false; 93 bool using_tls = false;
95 const MHD_SCKT_OPT_BOOL_ state_val = val ? 1 : 0; 94 // const MHD_SCKT_OPT_BOOL_ state_val = val ? 1 : 0;
96 const MHD_SCKT_OPT_BOOL_ off_val = 0; 95 const MHD_SCKT_OPT_BOOL_ off_val = 0;
97 const MHD_SCKT_OPT_BOOL_ on_val = 1; 96 const MHD_SCKT_OPT_BOOL_ on_val = 1;
98#ifdef HTTPS_SUPPORT 97#ifdef HTTPS_SUPPORT
@@ -107,7 +106,7 @@ pre_cork_setsockopt (struct MHD_Connection *connection,
107 } 106 }
108 107
109 // if sk_tcp_nodelay_on is already what we pass in, return. 108 // if sk_tcp_nodelay_on is already what we pass in, return.
110 if (connection->sk_tcp_nodelay_on == val) 109 if (connection->sk_tcp_nodelay_on == want_cork)
111 { 110 {
112 return 0; // return type error 111 return 0; // return type error
113 } 112 }
@@ -133,10 +132,16 @@ pre_cork_setsockopt (struct MHD_Connection *connection,
133#else 132#else
134 ret = -1; 133 ret = -1;
135#endif 134#endif
135
136 if (0 == ret) 136 if (0 == ret)
137 { 137 {
138 connection->sk_tcp_nodelay_on = val; 138#if TCP_CORK || TCP_NODELAY
139 connection->sk_tcp_nodelay_on = true;
140#elif TCP_NOPUSH
141 connection->sk_tcp_nodelay_on = false;
142#endif
139 } 143 }
144 return ret;
140} 145}
141 146
142/** 147/**
@@ -404,11 +409,14 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
404 using_tls = (0 != (connection->daemon->options & MHD_USE_TLS)); 409 using_tls = (0 != (connection->daemon->options & MHD_USE_TLS));
405#endif 410#endif
406 411
412 pre_cork_setsockopt (connection, want_cork);
413
414 /*
407#if TCP_CORK 415#if TCP_CORK
408 /* When we have CORK, we can have NODELAY on the same system, 416 // When we have CORK, we can have NODELAY on the same system,
409 * at least since Linux 2.2 and both can be combined since 417 // at least since Linux 2.2 and both can be combined since
410 * Linux 2.5.71. For more details refer to tcp(7) on Linux. 418 // Linux 2.5.71. For more details refer to tcp(7) on Linux.
411 * No other system in 2019-06 has TCP_CORK. */ 419 // No other system in 2019-06 has TCP_CORK.
412 if ((! using_tls) && (use_corknopush) && (have_cork && ! want_cork)) 420 if ((! using_tls) && (use_corknopush) && (have_cork && ! want_cork))
413 { 421 {
414 MHD_send_socket_state_cork_nodelay_ (connection, 422 MHD_send_socket_state_cork_nodelay_ (connection,
@@ -418,9 +426,9 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
418 true); 426 true);
419 } 427 }
420#elif TCP_NOPUSH 428#elif TCP_NOPUSH
421 /* TCP_NOPUSH on FreeBSD is equal to cork on Linux, with the 429 // TCP_NOPUSH on FreeBSD is equal to cork on Linux, with the
422 * exception that we know that TCP_NOPUSH will definitely 430 // exception that we know that TCP_NOPUSH will definitely
423 * exist and we can disregard TCP_NODELAY unless requested. */ 431 // exist and we can disregard TCP_NODELAY unless requested.
424 if ((! using_tls) && (use_corknopush) && (have_cork && ! want_cork)) 432 if ((! using_tls) && (use_corknopush) && (have_cork && ! want_cork))
425 { 433 {
426 MHD_send_socket_state_nopush_ (connection, true, false); 434 MHD_send_socket_state_nopush_ (connection, true, false);
@@ -432,7 +440,7 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
432 MHD_setsockopt_ (connection, TCP_NODELAY, false, false); 440 MHD_setsockopt_ (connection, TCP_NODELAY, false, false);
433 } 441 }
434#endif 442#endif
435 443 */
436#ifdef HTTPS_SUPPORT 444#ifdef HTTPS_SUPPORT
437 if (using_tls) 445 if (using_tls)
438 { 446 {