From: Stephan Bosch Date: Tue, 13 Sep 2016 23:30:16 +0000 (+0200) Subject: lib-http: client: Added function that counts how many connections are active within... X-Git-Tag: 2.3.0.rc1~2722 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=66ea898de7face7fc9c275e01e514fa002446975;p=thirdparty%2Fdovecot%2Fcore.git lib-http: client: Added function that counts how many connections are active within a peer. --- diff --git a/src/lib-http/http-client-peer.c b/src/lib-http/http-client-peer.c index f10b2b9884..0bcaa4591d 100644 --- a/src/lib-http/http-client-peer.c +++ b/src/lib-http/http-client-peer.c @@ -782,6 +782,21 @@ http_client_peer_idle_connections(struct http_client_peer *peer) return idle; } +unsigned int +http_client_peer_active_connections(struct http_client_peer *peer) +{ + struct http_client_connection *const *conn_idx; + unsigned int active = 0; + + /* find idle connections */ + array_foreach(&peer->conns, conn_idx) { + if (http_client_connection_is_active(*conn_idx)) + active++; + } + + return active; +} + unsigned int http_client_peer_pending_connections(struct http_client_peer *peer) { diff --git a/src/lib-http/http-client-private.h b/src/lib-http/http-client-private.h index d5ad05d94b..1c1ec8aa7a 100644 --- a/src/lib-http/http-client-private.h +++ b/src/lib-http/http-client-private.h @@ -459,6 +459,8 @@ bool http_client_peer_is_connected(struct http_client_peer *peer); unsigned int http_client_peer_idle_connections(struct http_client_peer *peer); unsigned int +http_client_peer_active_connections(struct http_client_peer *peer); +unsigned int http_client_peer_pending_connections(struct http_client_peer *peer); void http_client_peer_switch_ioloop(struct http_client_peer *peer);