libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit f1512b46b27808b0f1987a93671757e7b553eb42
parent 805182fb262d39802c3af2a79a1d39c0d5dd69fb
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue, 14 Feb 2017 16:48:35 +0100

convert more int to bool

Diffstat:
Msrc/microhttpd/daemon.c | 28++++++++++++++--------------
Msrc/microhttpd/internal.h | 4++--
Msrc/microhttpd/response.c | 5+++--
Msrc/microhttpd/test_upgrade.c | 6+++---
4 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -686,7 +686,7 @@ urh_to_fdset (struct MHD_UpgradeResponseHandle *urh, fd_setsize)) ) return MHD_NO; if ( (0 != urh->in_buffer_used) && - (MHD_NO == urh->was_closed) && + (! urh->was_closed) && (MHD_INVALID_SOCKET != urh->mhd.socket) && (! MHD_add_to_fd_set_ (urh->mhd.socket, ws, @@ -694,7 +694,7 @@ urh_to_fdset (struct MHD_UpgradeResponseHandle *urh, fd_setsize)) ) return MHD_NO; if ( (urh->in_buffer_used < urh->in_buffer_size) && - (MHD_NO == urh->was_closed) && + (! urh->was_closed) && (MHD_INVALID_SOCKET != urh->connection->socket_fd) && (! MHD_add_to_fd_set_ (urh->connection->socket_fd, rs, @@ -985,15 +985,15 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) { /* Daemon shutting down, application will not receive any more data. */ #ifdef HAVE_MESSAGES - if (MHD_NO == urh->was_closed) + if (! urh->was_closed) { MHD_DLOG (urh->connection->daemon, _("Initiated daemon shutdown while \"upgraded\" connection was not closed.\n")); } #endif - urh->was_closed = MHD_YES; + urh->was_closed = true; } - if (MHD_NO != urh->was_closed) + if (urh->was_closed) { /* Application was closed connections: no more data * can be forwarded to application socket. */ @@ -1111,8 +1111,8 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) } /* handle reading from application and writing to HTTPS client */ - if ( ((0 != (MHD_EPOLL_STATE_READ_READY & urh->mhd.celi)) || - (MHD_NO != urh->was_closed)) && + if ( ( (0 != (MHD_EPOLL_STATE_READ_READY & urh->mhd.celi)) || + (urh->was_closed) ) && (urh->out_buffer_used < urh->out_buffer_size) ) { /* If application signaled MHD about socket closure then @@ -1132,7 +1132,7 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) buf_size); if (-1 == res) { - if (MHD_NO != urh->was_closed) + if (urh->was_closed) { /* Connection was shut down or all data received and * application will not forward any more data. */ @@ -1751,7 +1751,7 @@ thread_main_handle_connection (void *data) /* "Upgraded" data will not be used in this thread from this point. */ con->urh->clean_ready = MHD_YES; - /* If 'urh->was_closed' set to MHD_YES, connection will be + /* If 'urh->was_closed' set to true, connection will be * moved immediately to cleanup list. Otherwise connection * will stay in suspended list until 'urh' will be marked * with 'was_closed' by application. */ @@ -2496,7 +2496,7 @@ resume_suspended_connections (struct MHD_Daemon *daemon) if ( (! pos->resuming) #ifdef UPGRADE_SUPPORT || ( (NULL != urh) && - ( (MHD_NO == urh->was_closed) || + ( (! urh->was_closed) || (MHD_NO == urh->clean_ready) ) ) #endif /* UPGRADE_SUPPORT */ ) @@ -3468,7 +3468,7 @@ MHD_poll_all (struct MHD_Daemon *daemon, * 'daemon->urh_head' list. */ MHD_connection_finish_forward_ (urh->connection); urh->clean_ready = MHD_YES; - /* If 'urh->was_closed' set to MHD_YES, connection will be + /* If 'urh->was_closed' set to true, connection will be * moved immediately to cleanup list. Otherwise connection * will stay in suspended list until 'urh' will be marked * with 'was_closed' by application. */ @@ -3664,7 +3664,7 @@ run_epoll_for_upgrade (struct MHD_Daemon *daemon) { MHD_connection_finish_forward_ (urh->connection); urh->clean_ready = MHD_YES; - /* If 'urh->was_closed' set to MHD_YES, connection will be + /* If 'urh->was_closed' set to true, connection will be * moved immediately to cleanup list. Otherwise connection * will stay in suspended list until 'urh' will be marked * with 'was_closed' by application. */ @@ -5618,11 +5618,11 @@ close_all_connections (struct MHD_Daemon *daemon) else { #ifdef HAVE_MESSAGES - if (MHD_NO == susp->urh->was_closed) + if (! susp->urh->was_closed) MHD_DLOG (daemon, _("Initiated daemon shutdown while \"upgraded\" connection was not closed.\n")); #endif - susp->urh->was_closed = MHD_YES; + susp->urh->was_closed = true; /* If thread-per-connection is used, connection's thread * may still processing "upgrade" (exiting). */ if (! used_thr_p_c) diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h @@ -1095,7 +1095,7 @@ struct MHD_UpgradeResponseHandle #endif /* HTTPS_SUPPORT */ /** - * Set to #MHD_YES after the application finished with the socket + * Set to true after the application finished with the socket * by #MHD_UPGRADE_ACTION_CLOSE. * * When BOTH @e was_closed (changed by command from application) @@ -1104,7 +1104,7 @@ struct MHD_UpgradeResponseHandle * connection to cleanup list. * @remark This flag could be changed from any thread. */ - int was_closed; + bool was_closed; /** * Set to #MHD_YES if connection is ready for cleanup. diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c @@ -648,6 +648,7 @@ MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh, { struct MHD_Connection *connection; struct MHD_Daemon *daemon; + if (NULL == urh) return MHD_NO; connection = urh->connection; @@ -662,11 +663,11 @@ MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh, switch (action) { case MHD_UPGRADE_ACTION_CLOSE: - if (MHD_YES == urh->was_closed) + if (urh->was_closed) return MHD_NO; /* Already closed. */ /* transition to special 'closed' state for start of cleanup */ - urh->was_closed = MHD_YES; + urh->was_closed = true; connection->state = MHD_CONNECTION_UPGRADE_CLOSED; /* As soon as connection will be marked with BOTH * 'urh->was_closed' AND 'urh->clean_ready', it will diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c @@ -461,7 +461,7 @@ static pthread_t pt_client; /** * Flag set to 1 once the test is finished. */ -static int done; +static volatile bool done; static void @@ -728,7 +728,7 @@ run_usock_client (void *cls) recv_all (*sock, "Finished"); wr_close (*sock); - done = 1; + done = true; return NULL; } @@ -1005,7 +1005,7 @@ test_upgrade (int flags, pid_t pid = -1; #endif /* HTTPS_SUPPORT && HAVE_FORK && HAVE_WAITPID */ - done = 0; + done = false; if (!test_tls) d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE,