aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2020-09-20 15:33:26 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2020-09-20 15:33:26 +0300
commit8a731a26ae3c5ed5387b933f039569a6f4a8e3e4 (patch)
treea2b403b23203f64dfa5fb1d235038185f90b203b
parent669ddcc0a2bb288f800bc27313dc568d369c3b2d (diff)
downloadlibmicrohttpd-8a731a26ae3c5ed5387b933f039569a6f4a8e3e4.tar.gz
libmicrohttpd-8a731a26ae3c5ed5387b933f039569a6f4a8e3e4.zip
daemon.c: optimisation for MHD_YES/MHD_NO comparison
-rw-r--r--src/microhttpd/daemon.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index ce19d79a..775faa0b 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -462,7 +462,7 @@ MHD_ip_limit_add (struct MHD_Daemon *daemon,
462 /* Test if there is room for another connection; if so, 462 /* Test if there is room for another connection; if so,
463 * increment count */ 463 * increment count */
464 result = (key->count < daemon->per_ip_connection_limit) ? MHD_YES : MHD_NO; 464 result = (key->count < daemon->per_ip_connection_limit) ? MHD_YES : MHD_NO;
465 if (MHD_YES == result) 465 if (MHD_NO != result)
466 ++key->count; 466 ++key->count;
467 467
468 MHD_ip_count_unlock (daemon); 468 MHD_ip_count_unlock (daemon);
@@ -3716,7 +3716,7 @@ MHD_select (struct MHD_Daemon *daemon,
3716 maxsock = MHD_INVALID_SOCKET; 3716 maxsock = MHD_INVALID_SOCKET;
3717 err_state = MHD_NO; 3717 err_state = MHD_NO;
3718 if ( (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) && 3718 if ( (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) &&
3719 (MHD_YES == resume_suspended_connections (daemon)) && 3719 (MHD_NO != resume_suspended_connections (daemon)) &&
3720 (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) ) 3720 (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) )
3721 may_block = MHD_NO; 3721 may_block = MHD_NO;
3722 3722
@@ -3804,7 +3804,7 @@ MHD_select (struct MHD_Daemon *daemon,
3804 &rs); 3804 &rs);
3805 } 3805 }
3806 tv = NULL; 3806 tv = NULL;
3807 if (MHD_YES == err_state) 3807 if (MHD_NO != err_state)
3808 may_block = MHD_NO; 3808 may_block = MHD_NO;
3809 if (MHD_NO == may_block) 3809 if (MHD_NO == may_block)
3810 { 3810 {
@@ -3813,7 +3813,7 @@ MHD_select (struct MHD_Daemon *daemon,
3813 tv = &timeout; 3813 tv = &timeout;
3814 } 3814 }
3815 else if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && 3815 else if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
3816 (MHD_YES == MHD_get_timeout (daemon, &ltimeout)) ) 3816 (MHD_NO != MHD_get_timeout (daemon, &ltimeout)) )
3817 { 3817 {
3818 /* ltimeout is in ms */ 3818 /* ltimeout is in ms */
3819 timeout.tv_usec = (ltimeout % 1000) * 1000; 3819 timeout.tv_usec = (ltimeout % 1000) * 1000;
@@ -3842,7 +3842,7 @@ MHD_select (struct MHD_Daemon *daemon,
3842#endif 3842#endif
3843 return MHD_NO; 3843 return MHD_NO;
3844 } 3844 }
3845 if (MHD_YES == internal_run_from_select (daemon, 3845 if (MHD_NO != internal_run_from_select (daemon,
3846 &rs, 3846 &rs,
3847 &ws, 3847 &ws,
3848 &es)) 3848 &es))
@@ -3873,7 +3873,7 @@ MHD_poll_all (struct MHD_Daemon *daemon,
3873#endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ 3873#endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */
3874 3874
3875 if ( (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) && 3875 if ( (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) &&
3876 (MHD_YES == resume_suspended_connections (daemon)) ) 3876 (MHD_NO != resume_suspended_connections (daemon)) )
3877 may_block = MHD_NO; 3877 may_block = MHD_NO;
3878 3878
3879 /* count number of connections and thus determine poll set size */ 3879 /* count number of connections and thus determine poll set size */
@@ -3931,7 +3931,7 @@ MHD_poll_all (struct MHD_Daemon *daemon,
3931 if (may_block == MHD_NO) 3931 if (may_block == MHD_NO)
3932 timeout = 0; 3932 timeout = 0;
3933 else if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || 3933 else if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) ||
3934 (MHD_YES != MHD_get_timeout (daemon, 3934 (MHD_NO == MHD_get_timeout (daemon,
3935 &ltimeout)) ) 3935 &ltimeout)) )
3936 timeout = -1; 3936 timeout = -1;
3937 else 3937 else
@@ -4453,12 +4453,12 @@ MHD_epoll (struct MHD_Daemon *daemon,
4453 } 4453 }
4454 4454
4455 if ( (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) && 4455 if ( (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) &&
4456 (MHD_YES == resume_suspended_connections (daemon)) ) 4456 (MHD_NO != resume_suspended_connections (daemon)) )
4457 may_block = MHD_NO; 4457 may_block = MHD_NO;
4458 4458
4459 if (MHD_YES == may_block) 4459 if (MHD_NO != may_block)
4460 { 4460 {
4461 if (MHD_YES == MHD_get_timeout (daemon, 4461 if (MHD_NO != MHD_get_timeout (daemon,
4462 &timeout_ll)) 4462 &timeout_ll))
4463 { 4463 {
4464 if (timeout_ll >= (MHD_UNSIGNED_LONG_LONG) INT_MAX) 4464 if (timeout_ll >= (MHD_UNSIGNED_LONG_LONG) INT_MAX)
@@ -4534,7 +4534,7 @@ MHD_epoll (struct MHD_Daemon *daemon,
4534 * Do not accept more then 10 connections at once. The rest will 4534 * Do not accept more then 10 connections at once. The rest will
4535 * be accepted on next turn (level trigger is used for listen 4535 * be accepted on next turn (level trigger is used for listen
4536 * socket). */ 4536 * socket). */
4537 while ( (MHD_YES == MHD_accept_connection (daemon)) && 4537 while ( (MHD_NO != MHD_accept_connection (daemon)) &&
4538 (series_length < 10) && 4538 (series_length < 10) &&
4539 (daemon->connections < daemon->connection_limit) && 4539 (daemon->connections < daemon->connection_limit) &&
4540 (! daemon->at_limit) ) 4540 (! daemon->at_limit) )
@@ -5417,7 +5417,7 @@ parse_options_va (struct MHD_Daemon *daemon,
5417 case MHD_OPTION_CONNECTION_MEMORY_LIMIT: 5417 case MHD_OPTION_CONNECTION_MEMORY_LIMIT:
5418 case MHD_OPTION_CONNECTION_MEMORY_INCREMENT: 5418 case MHD_OPTION_CONNECTION_MEMORY_INCREMENT:
5419 case MHD_OPTION_THREAD_STACK_SIZE: 5419 case MHD_OPTION_THREAD_STACK_SIZE:
5420 if (MHD_YES != parse_options (daemon, 5420 if (MHD_NO == parse_options (daemon,
5421 servaddr, 5421 servaddr,
5422 opt, 5422 opt,
5423 (size_t) oa[i].value, 5423 (size_t) oa[i].value,
@@ -5434,7 +5434,7 @@ parse_options_va (struct MHD_Daemon *daemon,
5434 case MHD_OPTION_LISTENING_ADDRESS_REUSE: 5434 case MHD_OPTION_LISTENING_ADDRESS_REUSE:
5435 case MHD_OPTION_LISTEN_BACKLOG_SIZE: 5435 case MHD_OPTION_LISTEN_BACKLOG_SIZE:
5436 case MHD_OPTION_SERVER_INSANITY: 5436 case MHD_OPTION_SERVER_INSANITY:
5437 if (MHD_YES != parse_options (daemon, 5437 if (MHD_NO == parse_options (daemon,
5438 servaddr, 5438 servaddr,
5439 opt, 5439 opt,
5440 (unsigned int) oa[i].value, 5440 (unsigned int) oa[i].value,
@@ -5444,7 +5444,7 @@ parse_options_va (struct MHD_Daemon *daemon,
5444 /* all options taking 'enum' */ 5444 /* all options taking 'enum' */
5445#ifdef HTTPS_SUPPORT 5445#ifdef HTTPS_SUPPORT
5446 case MHD_OPTION_HTTPS_CRED_TYPE: 5446 case MHD_OPTION_HTTPS_CRED_TYPE:
5447 if (MHD_YES != parse_options (daemon, 5447 if (MHD_NO == parse_options (daemon,
5448 servaddr, 5448 servaddr,
5449 opt, 5449 opt,
5450 (gnutls_credentials_type_t) oa[i].value, 5450 (gnutls_credentials_type_t) oa[i].value,
@@ -5454,7 +5454,7 @@ parse_options_va (struct MHD_Daemon *daemon,
5454#endif /* HTTPS_SUPPORT */ 5454#endif /* HTTPS_SUPPORT */
5455 /* all options taking 'MHD_socket' */ 5455 /* all options taking 'MHD_socket' */
5456 case MHD_OPTION_LISTEN_SOCKET: 5456 case MHD_OPTION_LISTEN_SOCKET:
5457 if (MHD_YES != parse_options (daemon, 5457 if (MHD_NO == parse_options (daemon,
5458 servaddr, 5458 servaddr,
5459 opt, 5459 opt,
5460 (MHD_socket) oa[i].value, 5460 (MHD_socket) oa[i].value,
@@ -5463,7 +5463,7 @@ parse_options_va (struct MHD_Daemon *daemon,
5463 break; 5463 break;
5464 /* all options taking 'int' */ 5464 /* all options taking 'int' */
5465 case MHD_OPTION_STRICT_FOR_CLIENT: 5465 case MHD_OPTION_STRICT_FOR_CLIENT:
5466 if (MHD_YES != parse_options (daemon, 5466 if (MHD_NO == parse_options (daemon,
5467 servaddr, 5467 servaddr,
5468 opt, 5468 opt,
5469 (int) oa[i].value, 5469 (int) oa[i].value,
@@ -5481,7 +5481,7 @@ parse_options_va (struct MHD_Daemon *daemon,
5481 case MHD_OPTION_ARRAY: 5481 case MHD_OPTION_ARRAY:
5482 case MHD_OPTION_HTTPS_CERT_CALLBACK: 5482 case MHD_OPTION_HTTPS_CERT_CALLBACK:
5483 case MHD_OPTION_HTTPS_CERT_CALLBACK2: 5483 case MHD_OPTION_HTTPS_CERT_CALLBACK2:
5484 if (MHD_YES != parse_options (daemon, 5484 if (MHD_NO == parse_options (daemon,
5485 servaddr, 5485 servaddr,
5486 opt, 5486 opt,
5487 oa[i].ptr_value, 5487 oa[i].ptr_value,
@@ -5495,7 +5495,7 @@ parse_options_va (struct MHD_Daemon *daemon,
5495 case MHD_OPTION_EXTERNAL_LOGGER: 5495 case MHD_OPTION_EXTERNAL_LOGGER:
5496 case MHD_OPTION_UNESCAPE_CALLBACK: 5496 case MHD_OPTION_UNESCAPE_CALLBACK:
5497 case MHD_OPTION_GNUTLS_PSK_CRED_HANDLER: 5497 case MHD_OPTION_GNUTLS_PSK_CRED_HANDLER:
5498 if (MHD_YES != parse_options (daemon, 5498 if (MHD_NO == parse_options (daemon,
5499 servaddr, 5499 servaddr,
5500 opt, 5500 opt,
5501 (void *) oa[i].value, 5501 (void *) oa[i].value,
@@ -5505,7 +5505,7 @@ parse_options_va (struct MHD_Daemon *daemon,
5505 break; 5505 break;
5506 /* options taking size_t-number followed by pointer */ 5506 /* options taking size_t-number followed by pointer */
5507 case MHD_OPTION_DIGEST_AUTH_RANDOM: 5507 case MHD_OPTION_DIGEST_AUTH_RANDOM:
5508 if (MHD_YES != parse_options (daemon, 5508 if (MHD_NO == parse_options (daemon,
5509 servaddr, 5509 servaddr,
5510 opt, 5510 opt,
5511 (size_t) oa[i].value, 5511 (size_t) oa[i].value,
@@ -5877,7 +5877,7 @@ MHD_start_daemon_va (unsigned int flags,
5877#endif /* HTTPS_SUPPORT */ 5877#endif /* HTTPS_SUPPORT */
5878 5878
5879 5879
5880 if (MHD_YES != parse_options_va (daemon, 5880 if (MHD_NO == parse_options_va (daemon,
5881 &servaddr, 5881 &servaddr,
5882 ap)) 5882 ap))
5883 { 5883 {
@@ -6388,7 +6388,7 @@ MHD_start_daemon_va (unsigned int flags,
6388#endif 6388#endif
6389 goto free_and_fail; 6389 goto free_and_fail;
6390 } 6390 }
6391 if (MHD_YES != setup_epoll_to_listen (daemon)) 6391 if (MHD_NO == setup_epoll_to_listen (daemon))
6392 goto free_and_fail; 6392 goto free_and_fail;
6393 } 6393 }
6394#endif /* EPOLL_SUPPORT */ 6394#endif /* EPOLL_SUPPORT */
@@ -6531,7 +6531,7 @@ MHD_start_daemon_va (unsigned int flags,
6531 ++d->connection_limit; 6531 ++d->connection_limit;
6532#ifdef EPOLL_SUPPORT 6532#ifdef EPOLL_SUPPORT
6533 if ( (0 != (*pflags & MHD_USE_EPOLL)) && 6533 if ( (0 != (*pflags & MHD_USE_EPOLL)) &&
6534 (MHD_YES != setup_epoll_to_listen (d)) ) 6534 (MHD_NO == setup_epoll_to_listen (d)) )
6535 goto thread_failed; 6535 goto thread_failed;
6536#endif 6536#endif
6537 /* Must init cleanup connection mutex for each worker */ 6537 /* Must init cleanup connection mutex for each worker */