dovecot-2.2: lib-http: Fixed hang when many connections were bei...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Jun 27 18:04:17 EEST 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/af23c7a899a9
changeset: 16565:af23c7a899a9
user: Timo Sirainen <tss at iki.fi>
date: Thu Jun 27 18:04:04 2013 +0300
description:
lib-http: Fixed hang when many connections were being created and closed.
diffstat:
src/lib-http/http-client-peer.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diffs (42 lines):
diff -r 185dfd05b57a -r af23c7a899a9 src/lib-http/http-client-peer.c
--- a/src/lib-http/http-client-peer.c Thu Jun 27 18:03:38 2013 +0300
+++ b/src/lib-http/http-client-peer.c Thu Jun 27 18:04:04 2013 +0300
@@ -98,7 +98,7 @@
struct http_client_connection *const *conn_idx;
struct http_client_connection *conn = NULL;
unsigned int connecting = 0, closing = 0, min_waiting = UINT_MAX;
- unsigned int num_urgent, new_connections;
+ unsigned int num_urgent, new_connections, working_conn_count;
if (http_client_peer_requests_pending(peer, &num_urgent) == 0)
return FALSE;
@@ -124,6 +124,7 @@
else if (!(*conn_idx)->connected)
connecting++;
}
+ working_conn_count = array_count(&peer->conns) - closing;
/* did we find an idle connection? */
if (conn != NULL && min_waiting == 0) {
@@ -132,8 +133,8 @@
}
/* no, but can we create a new connection? */
- if (num_urgent == 0 && (array_count(&peer->conns) - closing) >=
- peer->client->set.max_parallel_connections) {
+ if (num_urgent == 0 &&
+ working_conn_count >= peer->client->set.max_parallel_connections) {
/* no */
if (conn == NULL)
return FALSE;
@@ -142,8 +143,8 @@
}
/* yes, determine how many connections to set up */
- if (peer->last_connect_failed && array_count(&peer->conns) > 0 &&
- array_count(&peer->conns) == connecting+closing) {
+ if (peer->last_connect_failed && working_conn_count > 0 &&
+ working_conn_count == connecting) {
/* don't create new connections until the existing ones have
finished connecting successfully. */
new_connections = 0;
More information about the dovecot-cvs
mailing list