dovecot-2.2: lib-http: Fix/cleanup to handling connect failures.
dovecot at dovecot.org
dovecot at dovecot.org
Wed Jul 10 03:28:04 EEST 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/4707096101a4
changeset: 16580:4707096101a4
user: Timo Sirainen <tss at iki.fi>
date: Wed Jul 10 03:27:52 2013 +0300
description:
lib-http: Fix/cleanup to handling connect failures.
There was some kind of double-error handling which messed up things.
diffstat:
src/lib-http/http-client-connection.c | 5 +++--
src/lib-http/http-client-peer.c | 13 ++++++++-----
src/lib-http/http-client-private.h | 1 +
3 files changed, 12 insertions(+), 7 deletions(-)
diffs (64 lines):
diff -r 129ae6342b28 -r 4707096101a4 src/lib-http/http-client-connection.c
--- a/src/lib-http/http-client-connection.c Wed Jul 10 02:50:04 2013 +0300
+++ b/src/lib-http/http-client-connection.c Wed Jul 10 03:27:52 2013 +0300
@@ -694,6 +694,7 @@
struct stat st;
conn->connected = TRUE;
+ conn->connect_succeeded = TRUE;
if (conn->to_connect != NULL &&
(conn->ssl_iostream == NULL ||
ssl_iostream_is_handshaked(conn->ssl_iostream)))
@@ -952,10 +953,10 @@
}
}
+ if (conn->connect_succeeded)
+ http_client_peer_connection_lost(peer);
i_free(conn);
*_conn = NULL;
-
- http_client_peer_connection_lost(peer);
}
void http_client_connection_switch_ioloop(struct http_client_connection *conn)
diff -r 129ae6342b28 -r 4707096101a4 src/lib-http/http-client-peer.c
--- a/src/lib-http/http-client-peer.c Wed Jul 10 02:50:04 2013 +0300
+++ b/src/lib-http/http-client-peer.c Wed Jul 10 03:27:52 2013 +0300
@@ -329,17 +329,20 @@
{
unsigned int num_urgent;
+ /* we get here when an already connected connection fails. if the
+ connect itself fails, http_client_peer_connection_failure() is
+ called instead. */
+
if (peer->destroyed)
return;
http_client_peer_debug(peer, "Lost a connection (%d connections left)",
array_count(&peer->conns));
- if (!peer->last_connect_failed) {
- /* if there are pending requests, create a new
- connection for them. */
- http_client_peer_handle_requests(peer);
- }
+ /* if there are pending requests for this peer, create a new connection
+ for them. */
+ http_client_peer_handle_requests(peer);
+
if (array_count(&peer->conns) == 0 &&
http_client_peer_requests_pending(peer, &num_urgent) == 0)
http_client_peer_free(&peer);
diff -r 129ae6342b28 -r 4707096101a4 src/lib-http/http-client-private.h
--- a/src/lib-http/http-client-private.h Wed Jul 10 02:50:04 2013 +0300
+++ b/src/lib-http/http-client-private.h Wed Jul 10 03:27:52 2013 +0300
@@ -159,6 +159,7 @@
ARRAY_TYPE(http_client_request) request_wait_list;
unsigned int connected:1; /* connection is connected */
+ unsigned int connect_succeeded:1;
unsigned int closing:1;
unsigned int close_indicated:1;
unsigned int output_locked:1; /* output is locked; no pipelining */
More information about the dovecot-cvs
mailing list