From 8a4e48c6f4ac13e71fdb2a65c0d5ce3a9d65db45 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 17 May 2016 11:37:54 +0000 Subject: [PATCH] add MHD_CONNECTION_INFO_CONNECTION_SUSPENDED --- ChangeLog | 4 ++++ doc/libmicrohttpd.texi | 9 +++++++++ src/include/microhttpd.h | 12 +++++++++++- src/microhttpd/connection.c | 2 ++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a0019716..108e18a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Tue May 17 13:32:21 CEST 2016 + Allow clients to determine whether a connection is suspended; + introduces MHD_CONNECTION_INFO_CONNECTION_SUSPENDED. -CG/FC + Sun May 15 12:17:25 CEST 2016 Fix handling system or process resource limit exhaustion upon accept(). -CG/CP diff --git a/doc/libmicrohttpd.texi b/doc/libmicrohttpd.texi index 408f471d..ed2e58c9 100644 --- a/doc/libmicrohttpd.texi +++ b/doc/libmicrohttpd.texi @@ -2119,6 +2119,10 @@ to resume a suspended connection at any time. Calling this function on a connection that was not previously suspended will result in undefined behavior. +You can check whether a connection is currently suspended using +@code{MHD_get_connection_info} by querying for +@code{MHD_CONNECTION_INFO_CONNECTION_SUSPENDED}. + @table @var @item connection the connection to resume @@ -2637,6 +2641,11 @@ automatically (if the platform supports it). As the connection callbacks are invoked in between, those might be used to set different values for TCP-CORK and TCP-NODELAY in the meantime. +@item MHD_CONNECTION_INFO_CONNECTION_SUSPENDED +Returns pointer to an integer that is @code{MHD_YES} if the connection +is currently suspended (and thus can be safely resumed) and +@code{MHD_NO} otherwise. + @item MHD_CONNECTION_INFO_SOCKET_CONTEXT Returns the client-specific pointer to a @code{void *} that was (possibly) set during a @code{MHD_NotifyConnectionCallback} when the diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h index da993bd4..0941c7b8 100644 --- a/src/include/microhttpd.h +++ b/src/include/microhttpd.h @@ -1156,6 +1156,11 @@ union MHD_ConnectionInfo */ int /* enum gnutls_protocol */ protocol; + /** + * The suspended status of a connection. + */ + int /* MHD_YES or MHD_NO */ suspended; + /** * Connect socket */ @@ -1255,8 +1260,13 @@ enum MHD_ConnectionInfoType * fresh for each HTTP request, while the "socket_context" is fresh * for each socket. */ - MHD_CONNECTION_INFO_SOCKET_CONTEXT + MHD_CONNECTION_INFO_SOCKET_CONTEXT, + /** + * Check wheter the connection is suspended. + * @ingroup request + */ + MHD_CONNECTION_INFO_CONNECTION_SUSPENDED }; diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index d9ba4807..2668bb62 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c @@ -3013,6 +3013,8 @@ MHD_get_connection_info (struct MHD_Connection *connection, return (const union MHD_ConnectionInfo *) &connection->socket_fd; case MHD_CONNECTION_INFO_SOCKET_CONTEXT: return (const union MHD_ConnectionInfo *) &connection->socket_context; + case MHD_CONNECTION_INFO_CONNECTION_SUSPENDED: + return (const union MHD_ConnectionInfo *) &connection->suspended; default: return NULL; };