Просмотр исходного кода

add MHD_CONNECTION_INFO_CONNECTION_SUSPENDED

Christian Grothoff 9 лет назад
Родитель
Сommit
8a4e48c6f4
4 измененных файлов с 26 добавлено и 1 удалено
  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
 	Fix handling system or process resource limit exhaustion upon
 	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
 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

+ 11 - 1
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
 };
 
 

+ 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;
     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;
     };