diff options
author | ng0 <ng0@n0.is> | 2019-07-21 11:08:58 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-07-21 11:08:58 +0000 |
commit | 5c197db398d6926dfb378bb4b4dbcf93566e9c1f (patch) | |
tree | 4122957662a9823146156b593bd4e7d2cbfeb1b0 /src/microhttpd/mhd_send.c | |
parent | 068cf22c0357b13e2f84ca6a10c6823a24264d96 (diff) | |
download | libmicrohttpd-5c197db398d6926dfb378bb4b4dbcf93566e9c1f.tar.gz libmicrohttpd-5c197db398d6926dfb378bb4b4dbcf93566e9c1f.zip |
flatten if statements, add initial TCP_NOPUSH to MHD_send_on_connection2_
Diffstat (limited to 'src/microhttpd/mhd_send.c')
-rw-r--r-- | src/microhttpd/mhd_send.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c index 8ff9b459..dc2c8d69 100644 --- a/src/microhttpd/mhd_send.c +++ b/src/microhttpd/mhd_send.c | |||
@@ -345,19 +345,17 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection, | |||
345 | #endif | 345 | #endif |
346 | 346 | ||
347 | #if TCP_NODELAY | 347 | #if TCP_NODELAY |
348 | if (! use_corknopush) | 348 | if ((! use_corknopush) && (! have_cork && want_cork)) |
349 | { | ||
350 | if (! have_cork && want_cork) | ||
351 | { | 349 | { |
352 | if (0 == setsockopt (s, | 350 | if (0 == setsockopt (s, |
353 | IPPROTO_TCP, | 351 | IPPROTO_TCP, |
354 | TCP_NODELAY, | 352 | TCP_NODELAY, |
355 | (const void *) &off_val, | 353 | (const void *) &off_val, |
356 | sizeof (off_val))) { | 354 | sizeof (off_val))) |
357 | connection->sk_tcp_nodelay = false; | 355 | { |
358 | } | 356 | connection->sk_tcp_nodelay = false; |
357 | } | ||
359 | } | 358 | } |
360 | } | ||
361 | #endif | 359 | #endif |
362 | 360 | ||
363 | vector[0].iov_base = header; | 361 | vector[0].iov_base = header; |
@@ -367,6 +365,7 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection, | |||
367 | iovcnt = sizeof (vector) / sizeof (struct iovec); | 365 | iovcnt = sizeof (vector) / sizeof (struct iovec); |
368 | ret = writev (connection->socket_fd, vector, iovcnt); | 366 | ret = writev (connection->socket_fd, vector, iovcnt); |
369 | #if TCP_CORK | 367 | #if TCP_CORK |
368 | if (use_corknopush) | ||
370 | { | 369 | { |
371 | eno; | 370 | eno; |
372 | 371 | ||
@@ -384,6 +383,27 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection, | |||
384 | } | 383 | } |
385 | return ret; | 384 | return ret; |
386 | #endif | 385 | #endif |
386 | |||
387 | #if TCP_NOPUSH | ||
388 | if (use_corknopush) | ||
389 | { | ||
390 | eno; | ||
391 | |||
392 | eno = errno; | ||
393 | if (ret == header_len + buffer_len) | ||
394 | { | ||
395 | /* Response complete, set NOPUSH to off */ | ||
396 | setsockopt (s, | ||
397 | IPPROTO_TCP, | ||
398 | TCP_NOPUSH, | ||
399 | (const void *) &off_val, | ||
400 | sizeof (off_val)); | ||
401 | } | ||
402 | errno = eno; | ||
403 | } | ||
404 | return ret; | ||
405 | #endif | ||
406 | |||
387 | #else | 407 | #else |
388 | return MHD_send_on_connection_ (connection, | 408 | return MHD_send_on_connection_ (connection, |
389 | header, | 409 | header, |