aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-06-24 10:40:47 +0000
committerng0 <ng0@n0.is>2019-06-25 08:01:48 +0000
commitbeae0da3aedd2c8eb40aef3882f8b34de22b17b6 (patch)
tree809c4a985bb9176e251ccfe0138cb130755088f8
parent56676ae76dad5d8cb4f600b420f227d5efe0cce8 (diff)
downloadlibmicrohttpd-beae0da3aedd2c8eb40aef3882f8b34de22b17b6.tar.gz
libmicrohttpd-beae0da3aedd2c8eb40aef3882f8b34de22b17b6.zip
mhd_send.c: fix compiler error about MSG_MORE when MSG_MORE is undefined.
-rw-r--r--src/microhttpd/mhd_send.c69
1 files changed, 55 insertions, 14 deletions
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 923fcae4..02ffceaa 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -150,8 +150,17 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
150 if (have_cork && ! want_cork) 150 if (have_cork && ! want_cork)
151 { 151 {
152 optval = 1; 152 optval = 1;
153 setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_CORK, &optval, sizeof (&optval)) || 153 setsockopt (connection->socket_fd,
154 (setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_NODELAY, &optval, sizeof (&optval)) && (connection->sk_tcp_nodelay = true)); 154 IPPROTO_TCP,
155 TCP_CORK,
156 &optval,
157 sizeof (&optval)) ||
158 (setsockopt (connection->socket_fd,
159 IPPROTO_TCP,
160 TCP_NODELAY,
161 &optval,
162 sizeof (&optval)) &&
163 (connection->sk_tcp_nodelay = true));
155 //setsockopt (cork-on); // or nodelay on // + update connection->sk_tcp_nodelay_on 164 //setsockopt (cork-on); // or nodelay on // + update connection->sk_tcp_nodelay_on
156 // When we have CORK, we can have NODELAY on the same system, 165 // When we have CORK, we can have NODELAY on the same system,
157 // at least since Linux 2.2 and both can be combined since 166 // at least since Linux 2.2 and both can be combined since
@@ -169,7 +178,11 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
169 if (have_cork && ! want_cork) 178 if (have_cork && ! want_cork)
170 { 179 {
171 optval = 1; 180 optval = 1;
172 setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_NOPUSH, &optval, sizeof (&optval)); 181 setsockopt (connection->socket_fd,
182 IPPROTO_TCP,
183 TCP_NOPUSH,
184 &optval,
185 sizeof (&optval));
173 // TODO: set corknopush to true here? 186 // TODO: set corknopush to true here?
174 // connection->sk_tcp_cork_nopush_on = true; 187 // connection->sk_tcp_cork_nopush_on = true;
175 } 188 }
@@ -182,16 +195,27 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
182 { 195 {
183 optval = 0; 196 optval = 0;
184 // setsockopt (nodelay-off); 197 // setsockopt (nodelay-off);
185 setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_NODELAY, &optval, sizeof (&optval)); 198 setsockopt (connection->socket_fd,
199 IPPROTO_TCP,
200 TCP_NODELAY,
201 &optval,
202 sizeof (&optval));
186 connection->sk_tcp_nodelay_on = false; 203 connection->sk_tcp_nodelay_on = false;
187 } 204 }
188 // ... 205 // ...
189 } 206 }
190#endif 207#endif
191 208
192 209#if MSG_MORE
193 ret = send (connection->socket_fd, buffer, buffer_size, want_cork ? MSG_MORE : 0); 210 ret = send (connection->socket_fd,
211 buffer,
212 buffer_size,
213 (want_cork ? MSG_MORE : 0));
214#else
215 ret = send (connection->socket_fd, buffer, buffer_size, 0);
216#endif
194 eno = errno; 217 eno = errno;
218
195#if TCP_CORK 219#if TCP_CORK
196 if (use_corknopush) 220 if (use_corknopush)
197 { 221 {
@@ -199,8 +223,17 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
199 { 223 {
200 optval = 0; 224 optval = 0;
201 //setsockopt (cork-off); // or nodelay off // + update connection->sk_tcp_nodelay_on 225 //setsockopt (cork-off); // or nodelay off // + update connection->sk_tcp_nodelay_on
202 setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_CORK, &optval, sizeof (&optval)) || 226 setsockopt (connection->socket_fd,
203 (setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_NODELAY, &optval, sizeof (&optval)) && (connection->sk_tcp_nodelay_on = false)); 227 IPPROTO_TCP,
228 TCP_CORK,
229 &optval,
230 sizeof (&optval)) ||
231 (setsockopt (connection->socket_fd,
232 IPPROTO_TCP,
233 TCP_NODELAY,
234 &optval,
235 sizeof (&optval)) &&
236 (connection->sk_tcp_nodelay_on = false));
204 } 237 }
205 } 238 }
206#elif TCP_NOPUSH 239#elif TCP_NOPUSH
@@ -222,7 +255,8 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
222 IPPROTO_TCP, 255 IPPROTO_TCP,
223 TCP_NODELAY, 256 TCP_NODELAY,
224 &optval, 257 &optval,
225 sizeof (&optval)) && (connection->sk_tcp_nodelay_on = true); 258 sizeof (&optval)) &&
259 (connection->sk_tcp_nodelay_on = true);
226 } 260 }
227 // ... 261 // ...
228 } 262 }
@@ -269,7 +303,12 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection,
269 { 303 {
270 optval = 0; 304 optval = 0;
271 // setsockopt (nodelay-off); 305 // setsockopt (nodelay-off);
272 setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_NODELAY, &optval, sizeof (&optval)) && (connection->sk_tcp_nodelay = false); 306 setsockopt (connection->socket_fd,
307 IPPROTO_TCP,
308 TCP_NODELAY,
309 &optval,
310 sizeof (&optval)) &&
311 (connection->sk_tcp_nodelay = false);
273 } 312 }
274 // ... 313 // ...
275 } 314 }
@@ -288,11 +327,13 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection,
288 eno = errno; 327 eno = errno;
289 if ((ret == header_len + buffer_len) && have_cork) 328 if ((ret == header_len + buffer_len) && have_cork)
290 { 329 {
291 optval = 0;
292 // response complete, definitely uncork! 330 // response complete, definitely uncork!
293 // setsockopt (cork-off); 331 optval = 0;
294 setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_CORK, &optval, sizeof (&optval)); 332 setsockopt (connection->socket_fd,
295 // connection->sk_tcp_cork_nopush_on = true; 333 IPPROTO_TCP,
334 TCP_CORK,
335 &optval,
336 sizeof (&optval));
296 } 337 }
297 errno = eno; 338 errno = eno;
298 } 339 }