libmicrohttpd

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

commit 959d55ec5eea5b5d68fed524d1b48184c4763620
parent 35b58f8e099f6b9f9fd9e1061e011cc8a2a0bdc1
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Mon,  7 Nov 2016 17:08:03 +0300

Renamed MHD flags. Now all flags are in forms MHD_USE_* or MHD_ALLOW_*.

Diffstat:
Mdoc/libmicrohttpd.texi | 10+++++-----
Msrc/examples/benchmark.c | 2+-
Msrc/examples/upgrade_example.c | 2+-
Msrc/include/microhttpd.h | 23+++++++++++++++++------
Msrc/microhttpd/connection.c | 6+++---
Msrc/microhttpd/daemon.c | 30+++++++++++++++---------------
Msrc/microhttpd/response.c | 2+-
Msrc/microhttpd/test_upgrade.c | 4++--
Msrc/testcurl/test_quiesce_stream.c | 4++--
9 files changed, 47 insertions(+), 36 deletions(-)

diff --git a/doc/libmicrohttpd.texi b/doc/libmicrohttpd.texi @@ -542,7 +542,7 @@ want to benchmark your application to see if this makes any difference for you. -@item MHD_SUPPRESS_DATE_NO_CLOCK +@item MHD_USE_SUPPRESS_DATE_NO_CLOCK @cindex date @cindex clock @cindex embedded systems @@ -579,7 +579,7 @@ Using this option also guarantees that MHD will not call @code{shutdown()} on the listen socket, which means a parent process can continue to use the socket. -@item MHD_USE_SUSPEND_RESUME +@item MHD_ALLOW_SUSPEND_RESUME Enables using @code{MHD_suspend_connection} and @code{MHD_resume_connection}, as performing these calls requires some additional inter-thred communication channels to be created, and code @@ -591,7 +591,7 @@ Enable TCP_FASTOPEN on the listen socket. TCP_FASTOPEN is currently supported on Linux >= 3.6. On other systems using this option with cause @code{MHD_start_daemon} to fail. -@item MHD_USE_UPGRADE +@item MHD_ALLOW_UPGRADE @cindex upgrade This option must be set if you want to upgrade connections (via ``101 Switching Protocols'' responses). This requires MHD to @@ -2098,7 +2098,7 @@ upgrade is performed is negotiated between server and client in additional headers, in particular the ``Upgrade'' header. MHD supports switching protocols using this mechanism only if the -@code{MHD_USE_SUSPEND_RESUME} flag has been set when starting +@code{MHD_ALLOW_SUSPEND_RESUME} flag has been set when starting the daemon. If this flag has been set, applications can upgrade a connection by queueing a response (using the @code{MHD_HTTP_SWITCHING_PROTOCOLS} status code) which must @@ -2201,7 +2201,7 @@ select, internal select or thread pool; not applicable to 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 @code{MHD_USE_SUSPEND_RESUME} to +thread pool, you must set the option @code{MHD_ALLOW_SUSPEND_RESUME} to ensure that a resumed connection is immediately processed by MHD. Suspended connections continue to count against the total number of diff --git a/src/examples/benchmark.c b/src/examples/benchmark.c @@ -134,7 +134,7 @@ main (int argc, char *const *argv) MHD_HTTP_HEADER_CONNECTION, "close"); #endif - d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_SUPPRESS_DATE_NO_CLOCK + d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_SUPPRESS_DATE_NO_CLOCK #ifdef EPOLL_SUPPORT | MHD_USE_EPOLL | MHD_USE_EPOLL_TURBO #endif diff --git a/src/examples/upgrade_example.c b/src/examples/upgrade_example.c @@ -275,7 +275,7 @@ main (int argc, printf ("%s PORT\n", argv[0]); return 1; } - d = MHD_start_daemon (MHD_USE_UPGRADE | MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, + d = MHD_start_daemon (MHD_ALLOW_UPGRADE | MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, atoi (argv[1]), NULL, NULL, &ahc_echo, NULL, diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -126,7 +126,7 @@ typedef intptr_t ssize_t; * Current version of the library. * 0x01093001 = 1.9.30-1. */ -#define MHD_VERSION 0x00095205 +#define MHD_VERSION 0x00095206 /** * MHD-internal return code for "YES". @@ -601,7 +601,12 @@ enum MHD_FLAG * and that DO provide other mechanisms for cache control. See also * RFC 2616, section 14.18 (exception 3). */ - MHD_SUPPRESS_DATE_NO_CLOCK = 128, + MHD_USE_SUPPRESS_DATE_NO_CLOCK = 128, + +/** @deprecated */ +#define MHD_SUPPRESS_DATE_NO_CLOCK \ + _MHD_DEPR_IN_MACRO("Value MHD_SUPPRESS_DATE_NO_CLOCK is deprecated, use MHD_USE_SUPPRESS_DATE_NO_CLOCK instead") \ + MHD_USE_SUPPRESS_DATE_NO_CLOCK /** * Run without a listen socket. This option only makes sense if @@ -645,7 +650,7 @@ enum MHD_FLAG * "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 + * This option is enforced by #MHD_ALLOW_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 @@ -676,7 +681,13 @@ enum MHD_FLAG * Enable suspend/resume functions, which also implies setting up * ITC to signal resume. */ - MHD_USE_SUSPEND_RESUME = 8192 | MHD_USE_ITC, + MHD_ALLOW_SUSPEND_RESUME = 8192 | MHD_USE_ITC, + +/** @deprecated */ +#define MHD_USE_SUSPEND_RESUME \ + _MHD_DEPR_IN_MACRO("Value MHD_USE_SUSPEND_RESUME is deprecated, use MHD_ALLOW_SUSPEND_RESUME instead") \ + MHD_ALLOW_SUSPEND_RESUME + /** * Enable TCP_FASTOPEN option. This option is only available on Linux with a @@ -690,7 +701,7 @@ enum MHD_FLAG * "Upgrade" may require usage of additional internal resources, * which we do not want to use unless necessary. */ - MHD_USE_UPGRADE = 32768 + MHD_ALLOW_UPGRADE = 32768 }; @@ -2859,7 +2870,7 @@ enum MHD_FEATURE /** * Get whether HTTP "Upgrade" is supported. - * If supported then #MHD_USE_UPGRADE, #MHD_upgrade_action() and + * If supported then #MHD_ALLOW_UPGRADE, #MHD_upgrade_action() and * #MHD_create_response_for_upgrade() can be used. */ MHD_FEATURE_UPGRADE = 17 diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -1046,7 +1046,7 @@ build_header_response (struct MHD_Connection *connection) /* estimate size */ size = off + 2; /* +2 for extra "\r\n" at the end */ kind = MHD_HEADER_KIND; - if ( (0 == (connection->daemon->options & MHD_SUPPRESS_DATE_NO_CLOCK)) && + if ( (0 == (connection->daemon->options & MHD_USE_SUPPRESS_DATE_NO_CLOCK)) && (NULL == MHD_get_response_header (connection->response, MHD_HTTP_HEADER_DATE)) ) get_date_string (date); @@ -3455,11 +3455,11 @@ MHD_queue_response (struct MHD_Connection *connection, #ifdef UPGRADE_SUPPORT daemon = connection->daemon; if ( (NULL != response->upgrade_handler) && - (0 == (daemon->options & MHD_USE_UPGRADE)) ) + (0 == (daemon->options & MHD_ALLOW_UPGRADE)) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, - _("Attempted 'upgrade' connection on daemon without MHD_USE_UPGRADE option!\n")); + _("Attempted 'upgrade' connection on daemon without MHD_ALLOW_UPGRADE option!\n")); #endif return MHD_NO; } diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -2350,8 +2350,8 @@ MHD_suspend_connection (struct MHD_Connection *connection) struct MHD_Daemon *daemon; daemon = connection->daemon; - if (MHD_USE_SUSPEND_RESUME != (daemon->options & MHD_USE_SUSPEND_RESUME)) - MHD_PANIC (_("Cannot suspend connections without enabling MHD_USE_SUSPEND_RESUME!\n")); + if (MHD_ALLOW_SUSPEND_RESUME != (daemon->options & MHD_ALLOW_SUSPEND_RESUME)) + MHD_PANIC (_("Cannot suspend connections without enabling MHD_ALLOW_SUSPEND_RESUME!\n")); if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) { MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); @@ -2415,8 +2415,8 @@ MHD_resume_connection (struct MHD_Connection *connection) struct MHD_Daemon *daemon; daemon = connection->daemon; - if (MHD_USE_SUSPEND_RESUME != (daemon->options & MHD_USE_SUSPEND_RESUME)) - MHD_PANIC (_("Cannot resume connections without enabling MHD_USE_SUSPEND_RESUME!\n")); + if (MHD_ALLOW_SUSPEND_RESUME != (daemon->options & MHD_ALLOW_SUSPEND_RESUME)) + MHD_PANIC (_("Cannot resume connections without enabling MHD_ALLOW_SUSPEND_RESUME!\n")); if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); connection->resuming = MHD_YES; @@ -2960,7 +2960,7 @@ MHD_run_from_select (struct MHD_Daemon *daemon, struct MHD_UpgradeResponseHandle *urh; struct MHD_UpgradeResponseHandle *urhn; #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ - unsigned int mask = MHD_USE_SUSPEND_RESUME | MHD_USE_EPOLL_INTERNALLY | + unsigned int mask = MHD_ALLOW_SUSPEND_RESUME | MHD_USE_EPOLL_INTERNALLY | MHD_USE_SELECT_INTERNALLY | MHD_USE_POLL_INTERNALLY | MHD_USE_THREAD_PER_CONNECTION; /* Clear ITC to avoid spinning select */ @@ -2972,7 +2972,7 @@ MHD_run_from_select (struct MHD_Daemon *daemon, MHD_itc_clear_ (daemon->itc); /* Resuming external connections when using an extern mainloop */ - if (MHD_USE_SUSPEND_RESUME == (daemon->options & mask)) + if (MHD_ALLOW_SUSPEND_RESUME == (daemon->options & mask)) resume_suspended_connections (daemon); #ifdef EPOLL_SUPPORT @@ -3077,7 +3077,7 @@ MHD_select (struct MHD_Daemon *daemon, err_state = MHD_NO; if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) { - if ( (MHD_USE_SUSPEND_RESUME == (daemon->options & MHD_USE_SUSPEND_RESUME)) && + if ( (MHD_ALLOW_SUSPEND_RESUME == (daemon->options & MHD_ALLOW_SUSPEND_RESUME)) && (MHD_YES == resume_suspended_connections (daemon)) ) may_block = MHD_NO; @@ -3227,7 +3227,7 @@ MHD_poll_all (struct MHD_Daemon *daemon, struct MHD_UpgradeResponseHandle *urhn; #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ - if ( (MHD_USE_SUSPEND_RESUME == (daemon->options & MHD_USE_SUSPEND_RESUME)) && + if ( (MHD_ALLOW_SUSPEND_RESUME == (daemon->options & MHD_ALLOW_SUSPEND_RESUME)) && (MHD_YES == resume_suspended_connections (daemon)) ) may_block = MHD_NO; @@ -3839,7 +3839,7 @@ MHD_epoll (struct MHD_Daemon *daemon, /* we handle resumes here because we may have ready connections that will not be placed into the epoll list immediately. */ - if (MHD_USE_SUSPEND_RESUME == (daemon->options & MHD_USE_SUSPEND_RESUME)) + if (MHD_ALLOW_SUSPEND_RESUME == (daemon->options & MHD_ALLOW_SUSPEND_RESUME)) (void) resume_suspended_connections (daemon); /* process events for connections */ @@ -4635,7 +4635,7 @@ setup_epoll_to_listen (struct MHD_Daemon *daemon) if (-1 == daemon->epoll_fd) return MHD_NO; #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) - if (0 != (MHD_USE_UPGRADE & daemon->options)) + if (0 != (MHD_ALLOW_UPGRADE & daemon->options)) { daemon->epoll_upgrade_fd = setup_epoll_fd (daemon); if (MHD_INVALID_SOCKET == daemon->epoll_upgrade_fd) @@ -4736,10 +4736,10 @@ MHD_start_daemon_va (unsigned int flags, if (0 != (flags & MHD_USE_TCP_FASTOPEN)) return NULL; #endif - if (0 != (flags & MHD_USE_UPGRADE)) + if (0 != (flags & MHD_ALLOW_UPGRADE)) { #ifdef UPGRADE_SUPPORT - flags |= MHD_USE_SUSPEND_RESUME; + flags |= MHD_ALLOW_SUSPEND_RESUME; #else /* ! UPGRADE_SUPPORT */ return NULL; #endif /* ! UPGRADE_SUPPORT */ @@ -5445,7 +5445,7 @@ close_all_connections (struct MHD_Daemon *daemon) struct MHD_Connection *pos; const bool used_thr_p_c = (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)); #ifdef UPGRADE_SUPPORT - const bool upg_allowed = (0 != (daemon->options & MHD_USE_UPGRADE)); + const bool upg_allowed = (0 != (daemon->options & MHD_ALLOW_UPGRADE)); #endif /* UPGRADE_SUPPORT */ #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) struct MHD_UpgradeResponseHandle *urh; @@ -5471,7 +5471,7 @@ close_all_connections (struct MHD_Daemon *daemon) running into the check for there not being any suspended connections left in case of a tight race with a recently resumed connection. */ - if (0 != (MHD_USE_SUSPEND_RESUME & daemon->options)) + if (0 != (MHD_ALLOW_SUSPEND_RESUME & daemon->options)) { daemon->resuming = MHD_YES; /* Force check for pending resume. */ resume_suspended_connections (daemon); @@ -5621,7 +5621,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) if (NULL == daemon) return; - if (0 != (MHD_USE_SUSPEND_RESUME & daemon->options)) + if (0 != (MHD_ALLOW_SUSPEND_RESUME & daemon->options)) resume_suspended_connections (daemon); daemon->shutdown = MHD_YES; diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c @@ -692,7 +692,7 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response, struct MHD_UpgradeResponseHandle *urh; size_t rbo; - if (0 == (daemon->options & MHD_USE_UPGRADE)) + if (0 == (daemon->options & MHD_ALLOW_UPGRADE)) return MHD_NO; if (NULL == diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c @@ -1004,7 +1004,7 @@ test_upgrade (int flags, done = 0; if (!test_tls) - d = MHD_start_daemon (flags | MHD_USE_DEBUG | MHD_USE_UPGRADE, + d = MHD_start_daemon (flags | MHD_USE_DEBUG | MHD_ALLOW_UPGRADE, 1080, NULL, NULL, &ahc_upgrade, NULL, @@ -1015,7 +1015,7 @@ test_upgrade (int flags, MHD_OPTION_END); #ifdef HTTPS_SUPPORT else - d = MHD_start_daemon (flags | MHD_USE_DEBUG | MHD_USE_UPGRADE | MHD_USE_TLS, + d = MHD_start_daemon (flags | MHD_USE_DEBUG | MHD_ALLOW_UPGRADE | MHD_USE_TLS, 1080, NULL, NULL, &ahc_upgrade, NULL, diff --git a/src/testcurl/test_quiesce_stream.c b/src/testcurl/test_quiesce_stream.c @@ -170,8 +170,8 @@ main() unsigned int daemon_flags = MHD_USE_SELECT_INTERNALLY | MHD_USE_EPOLL - | MHD_USE_SUSPEND_RESUME - | MHD_USE_PIPE_FOR_SHUTDOWN; + | MHD_ALLOW_SUSPEND_RESUME + | MHD_USE_ITC; /* Create daemon */ struct MHD_Daemon *daemon = MHD_start_daemon (daemon_flags,