From 1d3b102d7403f13e6efa05daee7b38c3309b409d Mon Sep 17 00:00:00 2001 From: Stephan Bosch Date: Thu, 6 Sep 2018 01:57:43 +0200 Subject: [PATCH] lib-http: client: connection: Remove the connection from the peer pool pending list in a separate function. --- src/lib-http/http-client-connection.c | 31 +++++++++++++++++---------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/lib-http/http-client-connection.c b/src/lib-http/http-client-connection.c index 74f2d84614..c13430af4a 100644 --- a/src/lib-http/http-client-connection.c +++ b/src/lib-http/http-client-connection.c @@ -45,6 +45,25 @@ http_client_connection_unref_request(struct http_client_connection *conn, return http_client_request_unref(_req); } +static void +http_client_connection_unlist_pending(struct http_client_connection *conn) +{ + struct http_client_peer_pool *ppool = conn->ppool; + ARRAY_TYPE(http_client_connection) *conn_arr; + struct http_client_connection *const *conn_idx; + + /* remove from pending list */ + + conn_arr = &ppool->pending_conns; + array_foreach(conn_arr, conn_idx) { + if (*conn_idx == conn) { + array_delete(conn_arr, + array_foreach_idx(conn_arr, conn_idx), 1); + break; + } + } +} + static inline void http_client_connection_failure(struct http_client_connection *conn, const char *reason) @@ -1310,8 +1329,6 @@ http_client_connection_ready(struct http_client_connection *conn) struct http_client_peer *peer = conn->peer; struct http_client_peer_pool *ppool = conn->ppool; struct http_client_peer_shared *pshared = ppool->peer; - ARRAY_TYPE(http_client_connection) *conn_arr; - struct http_client_connection *const *conn_idx; const struct http_client_settings *set = &peer->client->set; e_debug(conn->event, "Ready for requests"); @@ -1321,17 +1338,9 @@ http_client_connection_ready(struct http_client_connection *conn) conn->last_ioloop = current_ioloop; timeout_remove(&conn->to_connect); - /* remove from pending list */ - conn_arr = &ppool->pending_conns; - array_foreach(conn_arr, conn_idx) { - if (*conn_idx == conn) { - array_delete(conn_arr, array_foreach_idx(conn_arr, conn_idx), 1); - break; - } - } - /* indicate connection success */ conn->connect_succeeded = TRUE; + http_client_connection_unlist_pending(conn); http_client_peer_connection_success(peer); /* start raw log */ -- 2.47.3