diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-07-25 20:11:46 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-07-25 20:11:46 +0200 |
commit | 9ed35bc8df36b4e52d96d404e233bf3a73b2d2b7 (patch) | |
tree | 456d67544f35e77a3dedc00e0b22098823c214ee | |
parent | 6a9e9a52f3c505b875391f7fcc7a29860344130a (diff) | |
download | libmicrohttpd-9ed35bc8df36b4e52d96d404e233bf3a73b2d2b7.tar.gz libmicrohttpd-9ed35bc8df36b4e52d96d404e233bf3a73b2d2b7.zip |
show not tell
-rw-r--r-- | src/microhttpd/mhd_send.c | 74 |
1 files changed, 2 insertions, 72 deletions
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c index b90cac8b..d680f55b 100644 --- a/src/microhttpd/mhd_send.c +++ b/src/microhttpd/mhd_send.c | |||
@@ -352,9 +352,6 @@ MHD_send_on_connection_ (struct MHD_Connection *connection, | |||
352 | enum MHD_SendSocketOptions options) | 352 | enum MHD_SendSocketOptions options) |
353 | { | 353 | { |
354 | bool want_cork; | 354 | bool want_cork; |
355 | bool have_cork; | ||
356 | bool have_more; | ||
357 | bool use_corknopush; | ||
358 | bool using_tls = false; | 355 | bool using_tls = false; |
359 | MHD_socket s = connection->socket_fd; | 356 | MHD_socket s = connection->socket_fd; |
360 | ssize_t ret; | 357 | ssize_t ret; |
@@ -397,50 +394,12 @@ MHD_send_on_connection_ (struct MHD_Connection *connection, | |||
397 | have_more = false; | 394 | have_more = false; |
398 | #endif | 395 | #endif |
399 | 396 | ||
400 | #if TCP_NODELAY | ||
401 | use_corknopush = false; | ||
402 | #elif TCP_CORK | ||
403 | use_corknopush = true; | ||
404 | #elif TCP_NOPUSH | ||
405 | use_corknopush = true; | ||
406 | #endif | ||
407 | |||
408 | #ifdef HTTPS_SUPPORT | 397 | #ifdef HTTPS_SUPPORT |
409 | using_tls = (0 != (connection->daemon->options & MHD_USE_TLS)); | 398 | using_tls = (0 != (connection->daemon->options & MHD_USE_TLS)); |
410 | #endif | 399 | #endif |
411 | if (! (have_more || using_tls)) | 400 | if (! (have_more || using_tls)) |
412 | pre_cork_setsockopt (connection, want_cork); | 401 | pre_cork_setsockopt (connection, want_cork); |
413 | 402 | ||
414 | /* | ||
415 | #if TCP_CORK | ||
416 | // When we have CORK, we can have NODELAY on the same system, | ||
417 | // at least since Linux 2.2 and both can be combined since | ||
418 | // Linux 2.5.71. For more details refer to tcp(7) on Linux. | ||
419 | // No other system in 2019-06 has TCP_CORK. | ||
420 | if ((! using_tls) && (use_corknopush) && (have_cork && ! want_cork)) | ||
421 | { | ||
422 | MHD_send_socket_state_cork_nodelay_ (connection, | ||
423 | false, | ||
424 | true, | ||
425 | true, | ||
426 | true); | ||
427 | } | ||
428 | #elif TCP_NOPUSH | ||
429 | // TCP_NOPUSH on FreeBSD is equal to cork on Linux, with the | ||
430 | // exception that we know that TCP_NOPUSH will definitely | ||
431 | // exist and we can disregard TCP_NODELAY unless requested. | ||
432 | if ((! using_tls) && (use_corknopush) && (have_cork && ! want_cork)) | ||
433 | { | ||
434 | MHD_send_socket_state_nopush_ (connection, true, false); | ||
435 | } | ||
436 | #endif | ||
437 | #if TCP_NODELAY | ||
438 | if ((! using_tls) && (! use_corknopush) && (! have_cork && want_cork)) | ||
439 | { | ||
440 | MHD_setsockopt_ (connection, TCP_NODELAY, false, false); | ||
441 | } | ||
442 | #endif | ||
443 | */ | ||
444 | #ifdef HTTPS_SUPPORT | 403 | #ifdef HTTPS_SUPPORT |
445 | if (using_tls) | 404 | if (using_tls) |
446 | { | 405 | { |
@@ -519,37 +478,8 @@ MHD_send_on_connection_ (struct MHD_Connection *connection, | |||
519 | #endif /* EPOLL_SUPPORT */ | 478 | #endif /* EPOLL_SUPPORT */ |
520 | } | 479 | } |
521 | 480 | ||
522 | post_cork_setsockopt (connection, want_cork); | 481 | if (! (have_more || using_tls)) |
523 | /* | 482 | post_cork_setsockopt (connection, want_cork); |
524 | #if TCP_CORK | ||
525 | if ((! using_tls) && (use_corknopush) && (! have_cork && want_cork && ! have_more)) | ||
526 | { | ||
527 | MHD_send_socket_state_cork_nodelay_ (connection, | ||
528 | true, | ||
529 | false, | ||
530 | false, | ||
531 | false); | ||
532 | } | ||
533 | #elif TCP_NOPUSH | ||
534 | // We don't have MSG_MORE. The OS which implement NOPUSH implement | ||
535 | // it in a similar way to TCP_CORK on Linux. This means we can just | ||
536 | // disregard the else branch for TCP_NODELAY which we had to use | ||
537 | // for the TCP_CORK case here. | ||
538 | // XXX: Verify this statement and finetune if necessary for | ||
539 | // other systems, as only FreeBSD was checked. | ||
540 | if ((! using_tls) && (use_corknopush) && (have_cork && ! want_cork)) | ||
541 | { | ||
542 | MHD_send_socket_state_nopush_ (connection, true, false); | ||
543 | } | ||
544 | #endif | ||
545 | |||
546 | #if TCP_NODELAY | ||
547 | if ((! using_tls) && (! use_corknopush) && (have_cork && ! want_cork)) | ||
548 | { | ||
549 | MHD_setsockopt_ (connection, TCP_NODELAY, true, true); | ||
550 | } | ||
551 | #endif | ||
552 | */ | ||
553 | return ret; | 483 | return ret; |
554 | } | 484 | } |
555 | 485 | ||