]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: client: Added function that checks whether a connection is currently active.
authorStephan Bosch <stephan@dovecot.fi>
Tue, 13 Sep 2016 23:26:10 +0000 (01:26 +0200)
committerGitLab <gitlab@git.dovecot.net>
Wed, 2 Nov 2016 11:42:18 +0000 (13:42 +0200)
src/lib-http/http-client-connection.c
src/lib-http/http-client-private.h

index d11d104d3b5c3550cf75a18f79932cfc2ecd28d8..1ee59f6ac6e76c03bfbd26ace9dd502282f088a1 100644 (file)
@@ -72,6 +72,18 @@ bool http_client_connection_is_idle(struct http_client_connection *conn)
        return (conn->to_idle != NULL);
 }
 
+bool http_client_connection_is_active(struct http_client_connection *conn)
+{
+       if (!conn->connected)
+               return FALSE;
+
+       if (conn->in_req_callback || conn->pending_request != NULL)
+               return TRUE;
+
+       return (array_is_created(&conn->request_wait_list) &&
+               array_count(&conn->request_wait_list) > 0);
+}
+
 static void
 http_client_connection_retry_requests(struct http_client_connection *conn,
        unsigned int status, const char *error)
index 94162879b2924d967474193eac96c1a5087aeaf9..d5ad05d94b8bc4dc822797cc76e77475f5348e27 100644 (file)
@@ -414,6 +414,7 @@ unsigned int
 http_client_connection_count_pending(struct http_client_connection *conn);
 int http_client_connection_check_ready(struct http_client_connection *conn);
 bool http_client_connection_is_idle(struct http_client_connection *conn);
+bool http_client_connection_is_active(struct http_client_connection *conn);
 int http_client_connection_next_request(struct http_client_connection *conn);
 void http_client_connection_check_idle(struct http_client_connection *conn);
 void http_client_connection_switch_ioloop(struct http_client_connection *conn);