libmicrohttpd

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

commit 984e0e964e6c0ad8cb96f51161fadebb6589e959
parent f5631e46aaaea2317b8d6b0385e2a6c9dde8350d
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Tue, 11 Oct 2016 15:21:32 +0000

Rename 'MHD_USE_PIPE_FOR_SHUTDOWN' -> 'MHD_USE_ITC' to reflect real meaning of option

Diffstat:
Mdoc/libmicrohttpd.texi | 10+++++-----
Msrc/include/microhttpd.h | 46++++++++++++++++++++++++----------------------
Msrc/microhttpd/daemon.c | 14+++++++-------
Msrc/testcurl/test_quiesce.c | 4++--
4 files changed, 38 insertions(+), 36 deletions(-)

diff --git a/doc/libmicrohttpd.texi b/doc/libmicrohttpd.texi @@ -562,7 +562,7 @@ connect HTTP clients to the HTTP server. This option is incompatible with using a thread pool; if it is used, @code{MHD_OPTION_THREAD_POOL_SIZE} is ignored. -@item MHD_USE_PIPE_FOR_SHUTDOWN +@item MHD_USE_ITC @cindex quiesce Force MHD to use a signal pipe to notify the event loop (of threads) of our shutdown. This is required if an appliction uses @@ -643,12 +643,12 @@ four for @code{stdin}, @code{stdout}, @code{stderr} and the server socket). In other words, the default is as large as possible. If the connection limit is reached, MHD's behavior depends a bit on -other options. If @code{MHD_USE_PIPE_FOR_SHUTDOWN} was given, MHD +other options. If @code{MHD_USE_ITC} was given, MHD will stop accepting connections on the listen socket. This will cause the operating system to queue connections (up to the @code{listen()} limit) above the connection limit. Those connections will be held until MHD is done processing at least one of the active connections. -If @code{MHD_USE_PIPE_FOR_SHUTDOWN} is not set, then MHD will continue +If @code{MHD_USE_ITC} is not set, then MHD will continue to @code{accept()} and immediately @code{close()} these connections. Note that if you set a low connection limit, you can easily get into @@ -1548,7 +1548,7 @@ server is behind NAT and needs to connect out to the HTTP client, or if you are building a proxy. If you use this API in conjunction with a internal select or a thread -pool, you must set the option @code{MHD_USE_PIPE_FOR_SHUTDOWN} to +pool, you must set the option @code{MHD_USE_ITC} to ensure that the freshly added connection is immediately processed by MHD. @@ -2900,7 +2900,7 @@ MHD_USE_EPOLL_INTERNALLY can be used. @item MHD_FEATURE_SHUTDOWN_LISTEN_SOCKET Get whether shutdown on listen socket to signal other threads is supported. If not supported flag -MHD_USE_PIPE_FOR_SHUTDOWN is automatically forced. +MHD_USE_ITC is automatically forced. @item MHD_FEATURE_SOCKETPAIR Get whether a @code{socketpair()} is used internally instead of diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -635,22 +635,24 @@ enum MHD_FLAG MHD_USE_EPOLL_INTERNALLY /** - * Force MHD to use a signal pipe to notify the event loop (of - * threads) of our shutdown. This is required if an appliction uses - * #MHD_USE_SELECT_INTERNALLY or #MHD_USE_THREAD_PER_CONNECTION and - * then performs #MHD_quiesce_daemon (which eliminates our ability - * to signal termination via the listen socket). In these modes, - * #MHD_quiesce_daemon will fail if this option was not set. Also, - * use of this option is automatic (as in, you do not even have to - * specify it), if #MHD_USE_NO_LISTEN_SOCKET is specified. In - * "external" `select()` mode, this option is always simply ignored. - * MHD can be build for use a pair of sockets instead of a pipe. - * Pair of sockets is forced on W32. - * - * You must also use this option if you use internal select mode - * or a thread pool in conjunction with #MHD_add_connection. - */ - MHD_USE_PIPE_FOR_SHUTDOWN = 1024, + * Use inter-thread communication channel. + * #MHD_USE_ITC can be used with internal select/poll/other + * or #MHD_USE_THREAD_PER_CONNECTION and is ignored with any + * "external" mode. + * It's required for use of #MHD_quiesce_daemon + * or #MHD_add_connection. + * This option is enforced by #MHD_USE_SUSPEND_RESUME or + * #MHD_USE_NO_LISTEN_SOCKET. + * #MHD_USE_ITC is always used automatically on platforms + * where select()/poll()/other ignore shutdown of listen + * socket. + */ + MHD_USE_ITC = 1024, + +/** @deprecated */ +#define MHD_USE_PIPE_FOR_SHUTDOWN \ + _MHD_DEPR_IN_MACRO("Value MHD_USE_PIPE_FOR_SHUTDOWN is deprecated, use MHD_USE_ITC") \ + MHD_USE_ITC /** * Use a single socket for IPv4 and IPv6. @@ -668,9 +670,9 @@ enum MHD_FLAG /** * Enable suspend/resume functions, which also implies setting up - * pipes to signal resume. + * ITC to signal resume. */ - MHD_USE_SUSPEND_RESUME = 8192 | MHD_USE_PIPE_FOR_SHUTDOWN, + MHD_USE_SUSPEND_RESUME = 8192 | MHD_USE_ITC, /** * Enable TCP_FASTOPEN option. This option is only available on Linux with a @@ -1634,7 +1636,7 @@ MHD_start_daemon (unsigned int flags, * that an existing thread is still using it). * * Note that some thread modes require the caller to have passed - * #MHD_USE_PIPE_FOR_SHUTDOWN when using this API. If this daemon is + * #MHD_USE_ITC when using this API. If this daemon is * in one of those modes and this option was not given to * #MHD_start_daemon, this function will return #MHD_INVALID_SOCKET. * @@ -1666,7 +1668,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon); * * If you use this API in conjunction with a internal select or a * thread pool, you must set the option - * #MHD_USE_PIPE_FOR_SHUTDOWN to ensure that the freshly added + * #MHD_USE_ITC to ensure that the freshly added * connection is immediately processed by MHD. * * The given client socket will be managed (and closed!) by MHD after @@ -1968,7 +1970,7 @@ MHD_queue_response (struct MHD_Connection *connection, * thread-per-connection!) for a while. * * If you use this API in conjunction with a internal select or a - * thread pool, you must set the option #MHD_USE_PIPE_FOR_SHUTDOWN to + * thread pool, you must set the option #MHD_USE_ITC to * ensure that a resumed connection is immediately processed by MHD. * * Suspended connections continue to count against the total number of @@ -2798,7 +2800,7 @@ enum MHD_FEATURE /** * Get whether shutdown on listen socket to signal other * threads is supported. If not supported flag - * #MHD_USE_PIPE_FOR_SHUTDOWN is automatically forced. + * #MHD_USE_ITC is automatically forced. */ MHD_FEATURE_SHUTDOWN_LISTEN_SOCKET = 8, diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -2112,7 +2112,7 @@ internal_add_connection (struct MHD_Daemon *daemon, * thread-per-connection!) for a while. * * If you use this API in conjunction with a internal select or a - * thread pool, you must set the option #MHD_USE_PIPE_FOR_SHUTDOWN to + * thread pool, you must set the option #MHD_USE_ITC to * ensure that a resumed connection is immediately processed by MHD. * * Suspended connections continue to count against the total number of @@ -2307,7 +2307,7 @@ resume_suspended_connections (struct MHD_Daemon *daemon) * * If you use this API in conjunction with a internal select or a * thread pool, you must set the option - * #MHD_USE_PIPE_FOR_SHUTDOWN to ensure that the freshly added + * #MHD_USE_ITC to ensure that the freshly added * connection is immediately processed by MHD. * * The given client socket will be managed (and closed!) by MHD after @@ -2878,7 +2878,7 @@ MHD_select (struct MHD_Daemon *daemon, place. */ if ( (MHD_INVALID_SOCKET != daemon->socket_fd) && (MHD_ITC_IS_VALID_(daemon->itc)) && - (0 != (daemon->options & MHD_USE_PIPE_FOR_SHUTDOWN)) && + (0 != (daemon->options & MHD_USE_ITC)) && ( (daemon->connections == daemon->connection_limit) || (MHD_YES == daemon->at_limit) ) ) { @@ -3742,7 +3742,7 @@ MHD_start_daemon (unsigned int flags, * sure that socket is not used anymore, call #MHD_stop_daemon. * * Note that some thread modes require the caller to have passed - * #MHD_USE_PIPE_FOR_SHUTDOWN when using this API. If this daemon is + * #MHD_USE_ITC when using this API. If this daemon is * in one of those modes and this option was not given to * #MHD_start_daemon, this function will return #MHD_INVALID_SOCKET. * @@ -3765,7 +3765,7 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, - "Using MHD_quiesce_daemon in this mode requires MHD_USE_PIPE_FOR_SHUTDOWN\n"); + "Using MHD_quiesce_daemon in this mode requires MHD_USE_ITC\n"); #endif return MHD_INVALID_SOCKET; } @@ -4448,7 +4448,7 @@ MHD_start_daemon_va (unsigned int flags, daemon->custom_error_log_cls = stderr; #endif #ifdef HAVE_LISTEN_SHUTDOWN - use_pipe = (0 != (daemon->options & (MHD_USE_NO_LISTEN_SOCKET | MHD_USE_PIPE_FOR_SHUTDOWN))); + use_pipe = (0 != (daemon->options & (MHD_USE_NO_LISTEN_SOCKET | MHD_USE_ITC))); #else use_pipe = 1; /* yes, must use pipe to signal shutdown */ #endif @@ -5271,7 +5271,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) { /* fd might be MHD_INVALID_SOCKET here due to 'MHD_quiesce_daemon' */ if ( (MHD_INVALID_SOCKET != fd) && - (0 == (daemon->options & MHD_USE_PIPE_FOR_SHUTDOWN)) ) + (0 == (daemon->options & MHD_USE_ITC)) ) (void) shutdown (fd, SHUT_RDWR); } diff --git a/src/testcurl/test_quiesce.c b/src/testcurl/test_quiesce.c @@ -204,12 +204,12 @@ testGet (int type, int pool_count, int poll_flag) cbc.size = 2048; cbc.pos = 0; if (pool_count > 0) { - d = MHD_start_daemon (type | MHD_USE_DEBUG | MHD_USE_PIPE_FOR_SHUTDOWN | poll_flag, + d = MHD_start_daemon (type | MHD_USE_DEBUG | MHD_USE_ITC | poll_flag, 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_THREAD_POOL_SIZE, pool_count, MHD_OPTION_END); } else { - d = MHD_start_daemon (type | MHD_USE_DEBUG | MHD_USE_PIPE_FOR_SHUTDOWN | poll_flag, + d = MHD_start_daemon (type | MHD_USE_DEBUG | MHD_USE_ITC | poll_flag, 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); } if (d == NULL)