Przeglądaj źródła

add MHD_CONNECTION_INFO_CONNECTION_SUSPENDED

Christian Grothoff 9 lat temu
rodzic
commit
8a4e48c6f4
4 zmienionych plików z 26 dodań i 1 usunięć
  1. 4 0
      ChangeLog
  2. 9 0
      doc/libmicrohttpd.texi
  3. 11 1
      src/include/microhttpd.h
  4. 2 0
      src/microhttpd/connection.c

+ 4 - 0
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
 Sun May 15 12:17:25 CEST 2016
 	Fix handling system or process resource limit exhaustion upon
 	Fix handling system or process resource limit exhaustion upon
 	accept(). -CG/CP
 	accept(). -CG/CP

+ 9 - 0
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
 on a connection that was not previously suspended will result in
 undefined behavior.
 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
 @table @var
 @item connection
 @item connection
 the connection to resume
 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
 callbacks are invoked in between, those might be used to set different
 values for TCP-CORK and TCP-NODELAY in the meantime.
 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
 @item MHD_CONNECTION_INFO_SOCKET_CONTEXT
 Returns the client-specific pointer to a @code{void *} that was
 Returns the client-specific pointer to a @code{void *} that was
 (possibly) set during a @code{MHD_NotifyConnectionCallback} when the
 (possibly) set during a @code{MHD_NotifyConnectionCallback} when the

+ 11 - 1
src/include/microhttpd.h

@@ -1156,6 +1156,11 @@ union MHD_ConnectionInfo
    */
    */
   int /* enum gnutls_protocol */ protocol;
   int /* enum gnutls_protocol */ protocol;
 
 
+  /**
+   * The suspended status of a connection.
+   */
+  int /* MHD_YES or MHD_NO */ suspended;
+
   /**
   /**
    * Connect socket
    * Connect socket
    */
    */
@@ -1255,8 +1260,13 @@ enum MHD_ConnectionInfoType
    * fresh for each HTTP request, while the "socket_context" is fresh
    * fresh for each HTTP request, while the "socket_context" is fresh
    * for each socket.
    * 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
 };
 };
 
 
 
 

+ 2 - 0
src/microhttpd/connection.c

@@ -3013,6 +3013,8 @@ MHD_get_connection_info (struct MHD_Connection *connection,
       return (const union MHD_ConnectionInfo *) &connection->socket_fd;
       return (const union MHD_ConnectionInfo *) &connection->socket_fd;
     case MHD_CONNECTION_INFO_SOCKET_CONTEXT:
     case MHD_CONNECTION_INFO_SOCKET_CONTEXT:
       return (const union MHD_ConnectionInfo *) &connection->socket_context;
       return (const union MHD_ConnectionInfo *) &connection->socket_context;
+    case MHD_CONNECTION_INFO_CONNECTION_SUSPENDED:
+      return (const union MHD_ConnectionInfo *) &connection->suspended;
     default:
     default:
       return NULL;
       return NULL;
     };
     };