diff options
author | ng0 <ng0@n0.is> | 2019-08-01 17:41:55 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-08-01 17:41:55 +0000 |
commit | e099a6ea0a9731d888388d5cc716be02057f4c25 (patch) | |
tree | 7a75c0a2cbfe628416c0ec142c68b9654c0acabc /src/microhttpd/mhd_send.c | |
parent | 33f02e62a70ad760fbe274afc15b07dcfc31e024 (diff) | |
download | libmicrohttpd-e099a6ea0a9731d888388d5cc716be02057f4c25.tar.gz libmicrohttpd-e099a6ea0a9731d888388d5cc716be02057f4c25.zip |
TCP_NOPUSH
Diffstat (limited to 'src/microhttpd/mhd_send.c')
-rw-r--r-- | src/microhttpd/mhd_send.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c index 87cecfb4..93fabd4f 100644 --- a/src/microhttpd/mhd_send.c +++ b/src/microhttpd/mhd_send.c | |||
@@ -83,10 +83,21 @@ pre_cork_setsockopt (struct MHD_Connection *connection, | |||
83 | sizeof (on_val)); | 83 | sizeof (on_val)); |
84 | } | 84 | } |
85 | #elif TCP_NOPUSH | 85 | #elif TCP_NOPUSH |
86 | if (want_cork) | ||
86 | { | 87 | { |
87 | const MHD_SCKT_OPT_BOOL_ on_val = 1; | 88 | const MHD_SCKT_OPT_BOOL_ on_val = 1; |
89 | /* TCP_NOPUSH has the same logic as MSG_MSG_MORE. | ||
90 | * The two are more or less equivalent by a source | ||
91 | * transformation (ie | ||
92 | * send(MSG_MORE) => "set TCP_NOPUSH + send() + clear TCP_NOPUSH". | ||
93 | * Both of them are really fairly "local", but TCP_NOPUSH has a | ||
94 | * _notion_ of persistency that is entirely lacking in MSG_MORE. | ||
95 | * ... with TCP_NOPUSH you basically have to know what your last | ||
96 | * write is, and clear the bit _before_ that write if you want | ||
97 | * to avoid bad latencies. | ||
98 | * https://yarchive.net/comp/linux/sendfile.html A thread from 2001, | ||
99 | * take with 18 grains of salt. */ | ||
88 | 100 | ||
89 | // FIXME: this must be wrong, set unconditionally irrespective of 'want_cork'! | ||
90 | ret = setsockopt (connection->socket_fd, | 101 | ret = setsockopt (connection->socket_fd, |
91 | IPPROTO_TCP, | 102 | IPPROTO_TCP, |
92 | TCP_NOPUSH, | 103 | TCP_NOPUSH, |
@@ -117,8 +128,8 @@ pre_cork_setsockopt (struct MHD_Connection *connection, | |||
117 | break; | 128 | break; |
118 | case ENOPROTOOPT: | 129 | case ENOPROTOOPT: |
119 | /* FIXME: optlen unknown, should at least log this */ | 130 | /* FIXME: optlen unknown, should at least log this */ |
120 | break; | 131 | break; |
121 | default: | 132 | default: |
122 | /* any others? man page does not list more... */ | 133 | /* any others? man page does not list more... */ |
123 | break; | 134 | break; |
124 | } | 135 | } |
@@ -163,10 +174,9 @@ post_cork_setsockopt (struct MHD_Connection *connection, | |||
163 | #elif TCP_NODELAY | 174 | #elif TCP_NODELAY |
164 | /* nothing to do */ | 175 | /* nothing to do */ |
165 | #elif TCP_NOPUSH | 176 | #elif TCP_NOPUSH |
166 | // FIXME: this must be wrong, set unconditionally irrespective of 'want_cork'! | 177 | if (! want_cork) |
167 | { | 178 | { |
168 | const MHD_SCKT_OPT_BOOL_ off_val = 0; | 179 | const MHD_SCKT_OPT_BOOL_ off_val = 0; |
169 | const MHD_SCKT_OPT_BOOL_ on_val = 1; | ||
170 | 180 | ||
171 | ret = setsockopt (connection->socket_fd, | 181 | ret = setsockopt (connection->socket_fd, |
172 | IPPROTO_TCP, | 182 | IPPROTO_TCP, |