]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: client: Register client objects in the associated client shared context.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Thu, 28 Dec 2017 23:48:32 +0000 (00:48 +0100)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 12 Mar 2018 07:09:09 +0000 (09:09 +0200)
src/lib-http/http-client-private.h
src/lib-http/http-client.c

index 425ce3c1eda393fd77e563ad8dc9593888534681..09d99a8b90702a94a625858975e348ede40c20c3 100644 (file)
@@ -364,6 +364,8 @@ struct http_client {
        struct http_client_context *cctx;
        struct http_client_settings set;
 
+       struct http_client *prev, *next;
+
        struct event *event;
        struct ioloop *ioloop;
        struct ssl_iostream_context *ssl_ctx;
@@ -388,6 +390,7 @@ struct http_client_context {
 
        struct http_client_settings set;
 
+       struct http_client *clients_list;
        struct connection_list *conn_list;
 
        HASH_TABLE_TYPE(http_client_peer_shared) peers;
index 5a99c91f526415e3105f9e6fc6fe152bb31fff51..8b3ed5083d180c33c0a809abb3de876920e8e65e 100644 (file)
@@ -4,6 +4,7 @@
 #include "net.h"
 #include "str.h"
 #include "hash.h"
+#include "llist.h"
 #include "array.h"
 #include "ioloop.h"
 #include "istream.h"
 
 static struct http_client_context *http_client_global_context = NULL;
 
+static void
+http_client_context_add_client(struct http_client_context *cctx,
+                              struct http_client *client);
+static void
+http_client_context_remove_client(struct http_client_context *cctx,
+                                 struct http_client *client);
+
 /*
  * Client
  */
@@ -209,6 +217,8 @@ http_client_init_shared(struct http_client_context *cctx,
 
        i_array_init(&client->delayed_failing_requests, 1);
 
+       http_client_context_add_client(cctx, client);
+
        return client;
 }
 
@@ -259,6 +269,7 @@ void http_client_deinit(struct http_client **_client)
 
        if (client->ssl_ctx != NULL)
                ssl_iostream_context_unref(&client->ssl_ctx);
+       http_client_context_remove_client(client->cctx, client);
        http_client_context_unref(&client->cctx);
        event_unref(&client->event);
        pool_unref(&client->pool);
@@ -526,6 +537,20 @@ void http_client_context_unref(struct http_client_context **_cctx)
        pool_unref(&cctx->pool);
 }
 
+static void
+http_client_context_add_client(struct http_client_context *cctx,
+                              struct http_client *client)
+{
+       DLLIST_PREPEND(&cctx->clients_list, client);
+}
+
+static void
+http_client_context_remove_client(struct http_client_context *cctx,
+                                 struct http_client *client)
+{
+       DLLIST_REMOVE(&cctx->clients_list, client);
+}
+
 void http_client_context_switch_ioloop(struct http_client_context *cctx)
 {
        struct connection *_conn = cctx->conn_list->connections;