]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: Fix/cleanup to handling connect failures.
authorTimo Sirainen <tss@iki.fi>
Wed, 10 Jul 2013 00:27:52 +0000 (03:27 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 10 Jul 2013 00:27:52 +0000 (03:27 +0300)
There was some kind of double-error handling which messed up things.

src/lib-http/http-client-connection.c
src/lib-http/http-client-peer.c
src/lib-http/http-client-private.h

index 3fc644f7234d6c1bcbab00a9b565c5c75ade0cc8..39085c6d4616ce557163f25d81a28cb49fc1195e 100644 (file)
@@ -694,6 +694,7 @@ http_client_connection_ready(struct http_client_connection *conn)
        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 @@ void http_client_connection_unref(struct http_client_connection **_conn)
                }
        }
 
+       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)
index d81e824fd7702173cbe30ebda6f3b2f9119d1c69..4531733522962d75c95541641fbfd93862648179 100644 (file)
@@ -329,17 +329,20 @@ void http_client_peer_connection_lost(struct http_client_peer *peer)
 {
        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);
index 44e885f60884a733242e2325c2fcc885cffffdee..35cc724f6f426d9057052461f32c1c9164699d8f 100644 (file)
@@ -159,6 +159,7 @@ struct http_client_connection {
        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 */