Skip to content

Commit

Permalink
lib-http: client: peer: Moved http_client_peer_disconnect() function.
Browse files Browse the repository at this point in the history
This is a preparation for a subsequent change.
  • Loading branch information
stephanbosch authored and cmouse committed Dec 7, 2017
1 parent 90fa7fd commit 4e62967
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions src/lib-http/http-client-peer.c
Expand Up @@ -261,6 +261,43 @@ http_client_peer_create(struct http_client *client,
return peer;
}

static void
http_client_peer_disconnect(struct http_client_peer *peer)
{
struct http_client_connection **conn;
ARRAY_TYPE(http_client_connection) conns;
struct http_client_queue *const *queue;

if (peer->disconnected)
return;
peer->disconnected = TRUE;

http_client_peer_debug(peer, "Peer disconnect");

/* make a copy of the connection array; freed connections modify it */
t_array_init(&conns, array_count(&peer->conns));
array_copy(&conns.arr, 0, &peer->conns.arr, 0, array_count(&peer->conns));
array_foreach_modifiable(&conns, conn) {
http_client_connection_peer_closed(conn);
}
i_assert(array_count(&peer->conns) == 0);

if (peer->to_req_handling != NULL)
timeout_remove(&peer->to_req_handling);
if (peer->to_backoff != NULL)
timeout_remove(&peer->to_backoff);

/* unlist in client */
hash_table_remove
(peer->client->peers, (const struct http_client_peer_addr *)&peer->addr);
DLLIST_REMOVE(&peer->client->peers_list, peer);

/* unlink all queues */
array_foreach(&peer->queues, queue)
http_client_queue_peer_disconnected(*queue, peer);
array_clear(&peer->queues);
}

static void
http_client_peer_do_connect(struct http_client_peer *peer,
unsigned int count)
Expand Down Expand Up @@ -691,43 +728,6 @@ void http_client_peer_trigger_request_handler(struct http_client_peer *peer)
}
}

static void
http_client_peer_disconnect(struct http_client_peer *peer)
{
struct http_client_connection **conn;
ARRAY_TYPE(http_client_connection) conns;
struct http_client_queue *const *queue;

if (peer->disconnected)
return;
peer->disconnected = TRUE;

http_client_peer_debug(peer, "Peer disconnect");

/* make a copy of the connection array; freed connections modify it */
t_array_init(&conns, array_count(&peer->conns));
array_copy(&conns.arr, 0, &peer->conns.arr, 0, array_count(&peer->conns));
array_foreach_modifiable(&conns, conn) {
http_client_connection_peer_closed(conn);
}
i_assert(array_count(&peer->conns) == 0);

if (peer->to_req_handling != NULL)
timeout_remove(&peer->to_req_handling);
if (peer->to_backoff != NULL)
timeout_remove(&peer->to_backoff);

/* unlist in client */
hash_table_remove
(peer->client->peers, (const struct http_client_peer_addr *)&peer->addr);
DLLIST_REMOVE(&peer->client->peers_list, peer);

/* unlink all queues */
array_foreach(&peer->queues, queue)
http_client_queue_peer_disconnected(*queue, peer);
array_clear(&peer->queues);
}

void http_client_peer_ref(struct http_client_peer *peer)
{
peer->refcount++;
Expand Down

0 comments on commit 4e62967

Please sign in to comment.