diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-02-14 16:48:35 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-02-14 16:48:35 +0100 |
commit | f1512b46b27808b0f1987a93671757e7b553eb42 (patch) | |
tree | adb96668a6a9b8d439222a2e0131dfc4aaaf3906 | |
parent | 805182fb262d39802c3af2a79a1d39c0d5dd69fb (diff) | |
download | libmicrohttpd-f1512b46b27808b0f1987a93671757e7b553eb42.tar.gz libmicrohttpd-f1512b46b27808b0f1987a93671757e7b553eb42.zip |
convert more int to bool
-rw-r--r-- | src/microhttpd/daemon.c | 28 | ||||
-rw-r--r-- | src/microhttpd/internal.h | 4 | ||||
-rw-r--r-- | src/microhttpd/response.c | 5 | ||||
-rw-r--r-- | src/microhttpd/test_upgrade.c | 6 |
4 files changed, 22 insertions, 21 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 6f09b845..97fcc813 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -686,7 +686,7 @@ urh_to_fdset (struct MHD_UpgradeResponseHandle *urh, | |||
686 | fd_setsize)) ) | 686 | fd_setsize)) ) |
687 | return MHD_NO; | 687 | return MHD_NO; |
688 | if ( (0 != urh->in_buffer_used) && | 688 | if ( (0 != urh->in_buffer_used) && |
689 | (MHD_NO == urh->was_closed) && | 689 | (! urh->was_closed) && |
690 | (MHD_INVALID_SOCKET != urh->mhd.socket) && | 690 | (MHD_INVALID_SOCKET != urh->mhd.socket) && |
691 | (! MHD_add_to_fd_set_ (urh->mhd.socket, | 691 | (! MHD_add_to_fd_set_ (urh->mhd.socket, |
692 | ws, | 692 | ws, |
@@ -694,7 +694,7 @@ urh_to_fdset (struct MHD_UpgradeResponseHandle *urh, | |||
694 | fd_setsize)) ) | 694 | fd_setsize)) ) |
695 | return MHD_NO; | 695 | return MHD_NO; |
696 | if ( (urh->in_buffer_used < urh->in_buffer_size) && | 696 | if ( (urh->in_buffer_used < urh->in_buffer_size) && |
697 | (MHD_NO == urh->was_closed) && | 697 | (! urh->was_closed) && |
698 | (MHD_INVALID_SOCKET != urh->connection->socket_fd) && | 698 | (MHD_INVALID_SOCKET != urh->connection->socket_fd) && |
699 | (! MHD_add_to_fd_set_ (urh->connection->socket_fd, | 699 | (! MHD_add_to_fd_set_ (urh->connection->socket_fd, |
700 | rs, | 700 | rs, |
@@ -985,15 +985,15 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) | |||
985 | { | 985 | { |
986 | /* Daemon shutting down, application will not receive any more data. */ | 986 | /* Daemon shutting down, application will not receive any more data. */ |
987 | #ifdef HAVE_MESSAGES | 987 | #ifdef HAVE_MESSAGES |
988 | if (MHD_NO == urh->was_closed) | 988 | if (! urh->was_closed) |
989 | { | 989 | { |
990 | MHD_DLOG (urh->connection->daemon, | 990 | MHD_DLOG (urh->connection->daemon, |
991 | _("Initiated daemon shutdown while \"upgraded\" connection was not closed.\n")); | 991 | _("Initiated daemon shutdown while \"upgraded\" connection was not closed.\n")); |
992 | } | 992 | } |
993 | #endif | 993 | #endif |
994 | urh->was_closed = MHD_YES; | 994 | urh->was_closed = true; |
995 | } | 995 | } |
996 | if (MHD_NO != urh->was_closed) | 996 | if (urh->was_closed) |
997 | { | 997 | { |
998 | /* Application was closed connections: no more data | 998 | /* Application was closed connections: no more data |
999 | * can be forwarded to application socket. */ | 999 | * can be forwarded to application socket. */ |
@@ -1111,8 +1111,8 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) | |||
1111 | } | 1111 | } |
1112 | 1112 | ||
1113 | /* handle reading from application and writing to HTTPS client */ | 1113 | /* handle reading from application and writing to HTTPS client */ |
1114 | if ( ((0 != (MHD_EPOLL_STATE_READ_READY & urh->mhd.celi)) || | 1114 | if ( ( (0 != (MHD_EPOLL_STATE_READ_READY & urh->mhd.celi)) || |
1115 | (MHD_NO != urh->was_closed)) && | 1115 | (urh->was_closed) ) && |
1116 | (urh->out_buffer_used < urh->out_buffer_size) ) | 1116 | (urh->out_buffer_used < urh->out_buffer_size) ) |
1117 | { | 1117 | { |
1118 | /* If application signaled MHD about socket closure then | 1118 | /* If application signaled MHD about socket closure then |
@@ -1132,7 +1132,7 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) | |||
1132 | buf_size); | 1132 | buf_size); |
1133 | if (-1 == res) | 1133 | if (-1 == res) |
1134 | { | 1134 | { |
1135 | if (MHD_NO != urh->was_closed) | 1135 | if (urh->was_closed) |
1136 | { | 1136 | { |
1137 | /* Connection was shut down or all data received and | 1137 | /* Connection was shut down or all data received and |
1138 | * application will not forward any more data. */ | 1138 | * application will not forward any more data. */ |
@@ -1751,7 +1751,7 @@ thread_main_handle_connection (void *data) | |||
1751 | 1751 | ||
1752 | /* "Upgraded" data will not be used in this thread from this point. */ | 1752 | /* "Upgraded" data will not be used in this thread from this point. */ |
1753 | con->urh->clean_ready = MHD_YES; | 1753 | con->urh->clean_ready = MHD_YES; |
1754 | /* If 'urh->was_closed' set to MHD_YES, connection will be | 1754 | /* If 'urh->was_closed' set to true, connection will be |
1755 | * moved immediately to cleanup list. Otherwise connection | 1755 | * moved immediately to cleanup list. Otherwise connection |
1756 | * will stay in suspended list until 'urh' will be marked | 1756 | * will stay in suspended list until 'urh' will be marked |
1757 | * with 'was_closed' by application. */ | 1757 | * with 'was_closed' by application. */ |
@@ -2496,7 +2496,7 @@ resume_suspended_connections (struct MHD_Daemon *daemon) | |||
2496 | if ( (! pos->resuming) | 2496 | if ( (! pos->resuming) |
2497 | #ifdef UPGRADE_SUPPORT | 2497 | #ifdef UPGRADE_SUPPORT |
2498 | || ( (NULL != urh) && | 2498 | || ( (NULL != urh) && |
2499 | ( (MHD_NO == urh->was_closed) || | 2499 | ( (! urh->was_closed) || |
2500 | (MHD_NO == urh->clean_ready) ) ) | 2500 | (MHD_NO == urh->clean_ready) ) ) |
2501 | #endif /* UPGRADE_SUPPORT */ | 2501 | #endif /* UPGRADE_SUPPORT */ |
2502 | ) | 2502 | ) |
@@ -3468,7 +3468,7 @@ MHD_poll_all (struct MHD_Daemon *daemon, | |||
3468 | * 'daemon->urh_head' list. */ | 3468 | * 'daemon->urh_head' list. */ |
3469 | MHD_connection_finish_forward_ (urh->connection); | 3469 | MHD_connection_finish_forward_ (urh->connection); |
3470 | urh->clean_ready = MHD_YES; | 3470 | urh->clean_ready = MHD_YES; |
3471 | /* If 'urh->was_closed' set to MHD_YES, connection will be | 3471 | /* If 'urh->was_closed' set to true, connection will be |
3472 | * moved immediately to cleanup list. Otherwise connection | 3472 | * moved immediately to cleanup list. Otherwise connection |
3473 | * will stay in suspended list until 'urh' will be marked | 3473 | * will stay in suspended list until 'urh' will be marked |
3474 | * with 'was_closed' by application. */ | 3474 | * with 'was_closed' by application. */ |
@@ -3664,7 +3664,7 @@ run_epoll_for_upgrade (struct MHD_Daemon *daemon) | |||
3664 | { | 3664 | { |
3665 | MHD_connection_finish_forward_ (urh->connection); | 3665 | MHD_connection_finish_forward_ (urh->connection); |
3666 | urh->clean_ready = MHD_YES; | 3666 | urh->clean_ready = MHD_YES; |
3667 | /* If 'urh->was_closed' set to MHD_YES, connection will be | 3667 | /* If 'urh->was_closed' set to true, connection will be |
3668 | * moved immediately to cleanup list. Otherwise connection | 3668 | * moved immediately to cleanup list. Otherwise connection |
3669 | * will stay in suspended list until 'urh' will be marked | 3669 | * will stay in suspended list until 'urh' will be marked |
3670 | * with 'was_closed' by application. */ | 3670 | * with 'was_closed' by application. */ |
@@ -5618,11 +5618,11 @@ close_all_connections (struct MHD_Daemon *daemon) | |||
5618 | else | 5618 | else |
5619 | { | 5619 | { |
5620 | #ifdef HAVE_MESSAGES | 5620 | #ifdef HAVE_MESSAGES |
5621 | if (MHD_NO == susp->urh->was_closed) | 5621 | if (! susp->urh->was_closed) |
5622 | MHD_DLOG (daemon, | 5622 | MHD_DLOG (daemon, |
5623 | _("Initiated daemon shutdown while \"upgraded\" connection was not closed.\n")); | 5623 | _("Initiated daemon shutdown while \"upgraded\" connection was not closed.\n")); |
5624 | #endif | 5624 | #endif |
5625 | susp->urh->was_closed = MHD_YES; | 5625 | susp->urh->was_closed = true; |
5626 | /* If thread-per-connection is used, connection's thread | 5626 | /* If thread-per-connection is used, connection's thread |
5627 | * may still processing "upgrade" (exiting). */ | 5627 | * may still processing "upgrade" (exiting). */ |
5628 | if (! used_thr_p_c) | 5628 | if (! used_thr_p_c) |
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h index fd2a44bb..8b15db97 100644 --- a/src/microhttpd/internal.h +++ b/src/microhttpd/internal.h | |||
@@ -1095,7 +1095,7 @@ struct MHD_UpgradeResponseHandle | |||
1095 | #endif /* HTTPS_SUPPORT */ | 1095 | #endif /* HTTPS_SUPPORT */ |
1096 | 1096 | ||
1097 | /** | 1097 | /** |
1098 | * Set to #MHD_YES after the application finished with the socket | 1098 | * Set to true after the application finished with the socket |
1099 | * by #MHD_UPGRADE_ACTION_CLOSE. | 1099 | * by #MHD_UPGRADE_ACTION_CLOSE. |
1100 | * | 1100 | * |
1101 | * When BOTH @e was_closed (changed by command from application) | 1101 | * When BOTH @e was_closed (changed by command from application) |
@@ -1104,7 +1104,7 @@ struct MHD_UpgradeResponseHandle | |||
1104 | * connection to cleanup list. | 1104 | * connection to cleanup list. |
1105 | * @remark This flag could be changed from any thread. | 1105 | * @remark This flag could be changed from any thread. |
1106 | */ | 1106 | */ |
1107 | int was_closed; | 1107 | bool was_closed; |
1108 | 1108 | ||
1109 | /** | 1109 | /** |
1110 | * Set to #MHD_YES if connection is ready for cleanup. | 1110 | * Set to #MHD_YES if connection is ready for cleanup. |
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c index ad52f806..86e3f325 100644 --- a/src/microhttpd/response.c +++ b/src/microhttpd/response.c | |||
@@ -648,6 +648,7 @@ MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh, | |||
648 | { | 648 | { |
649 | struct MHD_Connection *connection; | 649 | struct MHD_Connection *connection; |
650 | struct MHD_Daemon *daemon; | 650 | struct MHD_Daemon *daemon; |
651 | |||
651 | if (NULL == urh) | 652 | if (NULL == urh) |
652 | return MHD_NO; | 653 | return MHD_NO; |
653 | connection = urh->connection; | 654 | connection = urh->connection; |
@@ -662,11 +663,11 @@ MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh, | |||
662 | switch (action) | 663 | switch (action) |
663 | { | 664 | { |
664 | case MHD_UPGRADE_ACTION_CLOSE: | 665 | case MHD_UPGRADE_ACTION_CLOSE: |
665 | if (MHD_YES == urh->was_closed) | 666 | if (urh->was_closed) |
666 | return MHD_NO; /* Already closed. */ | 667 | return MHD_NO; /* Already closed. */ |
667 | 668 | ||
668 | /* transition to special 'closed' state for start of cleanup */ | 669 | /* transition to special 'closed' state for start of cleanup */ |
669 | urh->was_closed = MHD_YES; | 670 | urh->was_closed = true; |
670 | connection->state = MHD_CONNECTION_UPGRADE_CLOSED; | 671 | connection->state = MHD_CONNECTION_UPGRADE_CLOSED; |
671 | /* As soon as connection will be marked with BOTH | 672 | /* As soon as connection will be marked with BOTH |
672 | * 'urh->was_closed' AND 'urh->clean_ready', it will | 673 | * 'urh->was_closed' AND 'urh->clean_ready', it will |
diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c index 710af1a4..695a5e73 100644 --- a/src/microhttpd/test_upgrade.c +++ b/src/microhttpd/test_upgrade.c | |||
@@ -461,7 +461,7 @@ static pthread_t pt_client; | |||
461 | /** | 461 | /** |
462 | * Flag set to 1 once the test is finished. | 462 | * Flag set to 1 once the test is finished. |
463 | */ | 463 | */ |
464 | static int done; | 464 | static volatile bool done; |
465 | 465 | ||
466 | 466 | ||
467 | static void | 467 | static void |
@@ -728,7 +728,7 @@ run_usock_client (void *cls) | |||
728 | recv_all (*sock, | 728 | recv_all (*sock, |
729 | "Finished"); | 729 | "Finished"); |
730 | wr_close (*sock); | 730 | wr_close (*sock); |
731 | done = 1; | 731 | done = true; |
732 | return NULL; | 732 | return NULL; |
733 | } | 733 | } |
734 | 734 | ||
@@ -1005,7 +1005,7 @@ test_upgrade (int flags, | |||
1005 | pid_t pid = -1; | 1005 | pid_t pid = -1; |
1006 | #endif /* HTTPS_SUPPORT && HAVE_FORK && HAVE_WAITPID */ | 1006 | #endif /* HTTPS_SUPPORT && HAVE_FORK && HAVE_WAITPID */ |
1007 | 1007 | ||
1008 | done = 0; | 1008 | done = false; |
1009 | 1009 | ||
1010 | if (!test_tls) | 1010 | if (!test_tls) |
1011 | d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE, | 1011 | d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE, |