diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-11-04 11:42:22 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-11-04 11:42:22 +0100 |
commit | 82ce5348c515ab89da8521241c5d7c56d220ef45 (patch) | |
tree | afa91e68949bc4e59aa135ebbd0f5292b2156bda | |
parent | e5c74b3a125cee3f4c0dda04d04c9251c8ab116c (diff) | |
download | libmicrohttpd-82ce5348c515ab89da8521241c5d7c56d220ef45.tar.gz libmicrohttpd-82ce5348c515ab89da8521241c5d7c56d220ef45.zip |
use MHD_YES/NO instead of 0/!0
-rw-r--r-- | src/microhttpd/daemon.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 944b0384..f9ecc2ec 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -1404,27 +1404,28 @@ thread_main_handle_connection (void *data) | |||
1404 | #endif | 1404 | #endif |
1405 | #undef EXTRA_SLOTS | 1405 | #undef EXTRA_SLOTS |
1406 | #ifdef HAVE_POLL | 1406 | #ifdef HAVE_POLL |
1407 | const _MHD_bool use_poll = (0 != (daemon->options & MHD_USE_POLL)); | 1407 | const int use_poll = (0 != (daemon->options & MHD_USE_POLL)); |
1408 | #else /* ! HAVE_POLL */ | 1408 | #else /* ! HAVE_POLL */ |
1409 | const _MHD_bool use_poll = 0; | 1409 | const int use_poll = MHD_NO; |
1410 | #endif /* ! HAVE_POLL */ | 1410 | #endif /* ! HAVE_POLL */ |
1411 | 1411 | ||
1412 | while ( (MHD_YES != daemon->shutdown) && | 1412 | while ( (MHD_YES != daemon->shutdown) && |
1413 | (MHD_CONNECTION_CLOSED != con->state) ) | 1413 | (MHD_CONNECTION_CLOSED != con->state) ) |
1414 | { | 1414 | { |
1415 | const unsigned int timeout = daemon->connection_timeout; | 1415 | const unsigned int timeout = daemon->connection_timeout; |
1416 | _MHD_bool was_suspended = 0; | 1416 | int was_suspended = MHD_NO; |
1417 | #ifdef UPGRADE_SUPPORT | 1417 | #ifdef UPGRADE_SUPPORT |
1418 | struct MHD_UpgradeResponseHandle * const urh = con->urh; | 1418 | struct MHD_UpgradeResponseHandle * const urh = con->urh; |
1419 | #else /* ! UPGRADE_SUPPORT */ | 1419 | #else /* ! UPGRADE_SUPPORT */ |
1420 | static const void * const urh = NULL; | 1420 | static const void * const urh = NULL; |
1421 | #endif /* ! UPGRADE_SUPPORT */ | 1421 | #endif /* ! UPGRADE_SUPPORT */ |
1422 | 1422 | ||
1423 | if (MHD_NO != con->suspended && NULL == urh) | 1423 | if ( (MHD_NO != con->suspended) && |
1424 | (NULL == urh) ) | ||
1424 | { | 1425 | { |
1425 | /* Connection was suspended, wait for resume. */ | 1426 | /* Connection was suspended, wait for resume. */ |
1426 | was_suspended = !0; | 1427 | was_suspended = MHD_YES; |
1427 | if (!use_poll) | 1428 | if (! use_poll) |
1428 | { | 1429 | { |
1429 | FD_ZERO (&rs); | 1430 | FD_ZERO (&rs); |
1430 | if (! MHD_add_to_fd_set_ (MHD_itc_r_fd_ (daemon->itc), | 1431 | if (! MHD_add_to_fd_set_ (MHD_itc_r_fd_ (daemon->itc), |
@@ -1439,7 +1440,10 @@ thread_main_handle_connection (void *data) | |||
1439 | goto exit; | 1440 | goto exit; |
1440 | } | 1441 | } |
1441 | if (0 > MHD_SYS_select_ (MHD_itc_r_fd_ (daemon->itc) + 1, | 1442 | if (0 > MHD_SYS_select_ (MHD_itc_r_fd_ (daemon->itc) + 1, |
1442 | &rs, NULL, NULL, NULL)) | 1443 | &rs, |
1444 | NULL, | ||
1445 | NULL, | ||
1446 | NULL)) | ||
1443 | { | 1447 | { |
1444 | const int err = MHD_socket_get_error_(); | 1448 | const int err = MHD_socket_get_error_(); |
1445 | 1449 | ||
@@ -1460,7 +1464,9 @@ thread_main_handle_connection (void *data) | |||
1460 | p[0].events = POLLIN; | 1464 | p[0].events = POLLIN; |
1461 | p[0].fd = MHD_itc_r_fd_ (daemon->itc); | 1465 | p[0].fd = MHD_itc_r_fd_ (daemon->itc); |
1462 | p[0].revents = 0; | 1466 | p[0].revents = 0; |
1463 | if (0 > MHD_sys_poll_ (p, 1, -1)) | 1467 | if (0 > MHD_sys_poll_ (p, |
1468 | 1, | ||
1469 | -1)) | ||
1464 | { | 1470 | { |
1465 | if (MHD_SCKT_LAST_ERR_IS_(MHD_SCKT_EINTR_)) | 1471 | if (MHD_SCKT_LAST_ERR_IS_(MHD_SCKT_EINTR_)) |
1466 | continue; | 1472 | continue; |
@@ -1477,10 +1483,11 @@ thread_main_handle_connection (void *data) | |||
1477 | continue; /* Check again for resume. */ | 1483 | continue; /* Check again for resume. */ |
1478 | } /* End of "suspended" branch. */ | 1484 | } /* End of "suspended" branch. */ |
1479 | 1485 | ||
1480 | if ( was_suspended && (0 != con->connection_timeout) ) | 1486 | if ( (MHD_YES == was_suspended) && |
1487 | (0 != con->connection_timeout) ) | ||
1481 | { | 1488 | { |
1482 | con->last_activity = MHD_monotonic_sec_counter(); /* Reset timeout timer. */ | 1489 | con->last_activity = MHD_monotonic_sec_counter(); /* Reset timeout timer. */ |
1483 | was_suspended = 0; | 1490 | was_suspended = MHD_NO; |
1484 | } | 1491 | } |
1485 | 1492 | ||
1486 | tvp = NULL; | 1493 | tvp = NULL; |
@@ -2473,8 +2480,9 @@ resume_suspended_connections (struct MHD_Daemon *daemon) | |||
2473 | next = pos->next; | 2480 | next = pos->next; |
2474 | if ( (MHD_NO == pos->resuming) | 2481 | if ( (MHD_NO == pos->resuming) |
2475 | #ifdef UPGRADE_SUPPORT | 2482 | #ifdef UPGRADE_SUPPORT |
2476 | || ((NULL != urh) && | 2483 | || ( (NULL != urh) && |
2477 | ((MHD_NO == urh->was_closed) || (MHD_NO == urh->clean_ready))) | 2484 | ( (MHD_NO == urh->was_closed) || |
2485 | (MHD_NO == urh->clean_ready) ) ) | ||
2478 | #endif /* UPGRADE_SUPPORT */ | 2486 | #endif /* UPGRADE_SUPPORT */ |
2479 | ) | 2487 | ) |
2480 | continue; | 2488 | continue; |
@@ -2533,7 +2541,8 @@ resume_suspended_connections (struct MHD_Daemon *daemon) | |||
2533 | MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); | 2541 | MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); |
2534 | if (MHD_NO != ret) | 2542 | if (MHD_NO != ret) |
2535 | { /* Wake up suspended connections. */ | 2543 | { /* Wake up suspended connections. */ |
2536 | if ( !MHD_itc_activate_(daemon->itc, "w")) | 2544 | if (! MHD_itc_activate_(daemon->itc, |
2545 | "w")) | ||
2537 | #ifdef HAVE_MESSAGES | 2546 | #ifdef HAVE_MESSAGES |
2538 | MHD_DLOG (daemon, | 2547 | MHD_DLOG (daemon, |
2539 | _("Failed to signal resume of connection via inter-thread communication channel.")); | 2548 | _("Failed to signal resume of connection via inter-thread communication channel.")); |