From: Milan Straka <fox@ucw.cz>

Date: Wed, 29 Oct 2014 09:59:09 +0100
Subject: [PATCH 2/2] Add MHD_DAEMON_INFO_CURRENT_CONNECTIONS to
 MHD_DaemonInfoType.

The MHD_DAEMON_INFO_CURRENT_CONNECTIONS returns number of current
connections handled by the daemon.

Useful after MHD_quiesce_daemon to find out whether all connections
have been served.
This commit is contained in:
Christian Grothoff
2014-10-29 15:29:31 +00:00
parent e38d4e283e
commit d50980a765
5 changed files with 50 additions and 8 deletions
+1
View File
@@ -25,6 +25,7 @@ David Carvalho <andaris@gmail.com>
David Reiss <dreiss@facebook.com>
Matt Holiday
Michael Cronenworth <mike@cchtml.com>
Milan Straka <straka@ufal.mff.cuni.cz>
Mika Raento <mikie@iki.fi>
Mike Crowe <mac@mcrowe.com>
John Muth <muth@parascale.com>
+4
View File
@@ -1,3 +1,7 @@
Wed Oct 29 16:27:05 CET 2014
Adding MHD_DAEMON_INFO_CURRENT_CONNECTIONS to allow clients
to query the number of active connections. -MS
Fri Oct 3 14:28:58 CEST 2014
Releasing 0.9.38. -CG
+18 -4
View File
@@ -2394,13 +2394,13 @@ information about a daemon is desired.
Request information about the key size for a particular cipher
algorithm. The cipher algorithm should be passed as an extra argument
(of type 'enum MHD_GNUTLS_CipherAlgorithm'). No longer supported,
using this value will cause MHD_get_daemon_info to return NULL.
using this value will cause @code{MHD_get_daemon_info} to return NULL.
@item MHD_DAEMON_INFO_MAC_KEY_SIZE
Request information about the key size for a particular cipher
algorithm. The cipher algorithm should be passed as an extra argument
(of type 'enum MHD_GNUTLS_HashAlgorithm'). No longer supported,
using this value will cause MHD_get_daemon_info to return NULL.
using this value will cause @code{MHD_get_daemon_info} to return NULL.
@item MHD_DAEMON_INFO_LISTEN_FD
@cindex listen
@@ -2415,12 +2415,26 @@ No extra arguments should be passed.
Request the file-descriptor number that MHD is using for epoll. If
the build is not supporting epoll, NULL is returned; if we are using a
thread pool or this daemon was not started with
MHD_USE_EPOLL_LINUX_ONLY, (a pointer to) -1 is returned. If we are
using MHD_USE_SELECT_INTERNALLY or are in 'external' select mode, the
@code{MHD_USE_EPOLL_LINUX_ONLY}, (a pointer to) -1 is returned. If we are
using @code{MHD_USE_SELECT_INTERNALLY} or are in 'external' select mode, the
internal epoll FD is returned. This function must be used in external
select mode with epoll to obtain the FD to call epoll on. No extra
arguments should be passed.
@item MHD_DAEMON_INFO_CURRENT_CONNECTIONS
@cindex connection, limiting number of connections
Request the number of current connections handled by the daemon. No
extra arguments should be passed and a pointer to a @code{union
MHD_DaemonInfo} value is returned, with the @code{num_connections}
member of type @code{unsigned int} set to the number of active
connections.
Note that in multi-threaded or internal-select mode, the real number of current
connections may already be different when @code{MHD_get_daemon_info} returns.
The number of current connections can be used (even in multi-threaded and
internal-select mode) after @code{MHD_quiesce_daemon} to detect whether all
connections have been handled.
@end table
@end deftp
+16 -4
View File
@@ -1111,7 +1111,13 @@ enum MHD_DaemonInfoType
* Request the file descriptor for the external epoll.
* No extra arguments should be passed.
*/
MHD_DAEMON_INFO_EPOLL_FD_LINUX_ONLY
MHD_DAEMON_INFO_EPOLL_FD_LINUX_ONLY,
/**
* Request the number of current connections handled by the daemon.
* No extra arguments should be passed.
*/
MHD_DAEMON_INFO_CURRENT_CONNECTIONS,
};
@@ -2369,21 +2375,27 @@ MHD_set_connection_option (struct MHD_Connection *connection,
union MHD_DaemonInfo
{
/**
* Size of the key.
* Size of the key, no longer supported.
* @deprecated
*/
size_t key_size;
/**
* Size of the mac key.
* Size of the mac key, no longer supported.
* @deprecated
*/
size_t mac_key_size;
/**
* Listen socket file descriptor
* Listen socket file descriptor, for #MHD_DAEMON_INFO_EPOLL_FD_LINUX_ONLY
* and #MHD_DAEMON_INFO_LISTEN_FD.
*/
MHD_socket listen_fd;
/**
* Number of active connections, for #MHD_DAEMON_INFO_CURRENT_CONNECTIONS.
*/
unsigned int num_connections;
};
+11
View File
@@ -4232,6 +4232,17 @@ MHD_get_daemon_info (struct MHD_Daemon *daemon,
case MHD_DAEMON_INFO_EPOLL_FD_LINUX_ONLY:
return (const union MHD_DaemonInfo *) &daemon->epoll_fd;
#endif
case MHD_DAEMON_INFO_CURRENT_CONNECTIONS:
if (daemon->worker_pool)
{
/* Collect the connection information stored in the workers. */
unsigned int i;
daemon->connections = 0;
for (i=0;i<daemon->worker_pool_size;i++)
daemon->connections += daemon->worker_pool[i].connections;
}
return (const union MHD_DaemonInfo *) &daemon->connections;
default:
return NULL;
};