]> 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)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 9 Nov 2016 12:17:13 +0000 (14:17 +0200)
src/lib-http/http-client-connection.c
src/lib-http/http-client-private.h

index 80ca616d674f5b70c57196ee0d8db36c06813765..e9f181eecbe09e74b270efc33b3ba7fd00193e96 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 f5fbe257776ce463021d954914438571f0494c91..f8a0e8acd2d31f964ee5826cadcd89306dbcd0f2 100644 (file)
@@ -332,6 +332,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);