]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: client: peer: Notify definitive connection failure only within a peer pool.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Thu, 6 Sep 2018 12:49:59 +0000 (14:49 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 6 Sep 2018 17:03:46 +0000 (17:03 +0000)
Other peer pools have different configuration, which may actually succeed and
will arrive at this point when their own connections fail anyway.

src/lib-http/http-client-peer.c

index 40f4c5210e785fd5c619240c6338cc29260a94c4..09bb87e44829bdcdecf1a28a92854438c00e36c6 100644 (file)
@@ -22,8 +22,7 @@ http_client_peer_shared_connection_success(
        struct http_client_peer_shared *pshared);
 static void
 http_client_peer_shared_connection_failure(
-       struct http_client_peer_shared *pshared, const char *reason,
-       unsigned int pending);
+       struct http_client_peer_shared *pshared, unsigned int pending);
 static void
 http_client_peer_connection_failed_any(struct http_client_peer *peer,
                                         const char *reason);
@@ -237,8 +236,27 @@ http_client_peer_pool_connection_failure(
                "(connections=%u, connecting=%u)",
                array_count(&ppool->conns), pending);
 
-       http_client_peer_shared_connection_failure(ppool->peer,
-               reason, pending);
+       http_client_peer_shared_connection_failure(ppool->peer, pending);
+
+       if (pending > 1) {
+               /* if there are other connections attempting to connect, wait
+                  for them before failing the requests. remember that we had
+                  trouble with connecting so in future we don't try to create
+                  more than one connection until connects work again. */
+       } else {
+               struct http_client_peer *peer;
+
+               /* this was the only/last connection and connecting to it
+                  failed. notify all interested peers in this pool about the
+                  failure */
+               peer = ppool->peer->peers_list;
+               while (peer != NULL) {
+                       struct http_client_peer *peer_next = peer->shared_next;
+                       if (peer->ppool == ppool)
+                               http_client_peer_connection_failed_any(peer, reason);
+                       peer = peer_next;
+               }
+       }
 }
 
 /*
@@ -453,32 +471,13 @@ http_client_peer_shared_connection_success(
 
 static void
 http_client_peer_shared_connection_failure(
-       struct http_client_peer_shared *pshared, const char *reason,
-       unsigned int pending)
+       struct http_client_peer_shared *pshared, unsigned int pending)
 {
        pshared->last_failure = ioloop_timeval;
 
        /* manage backoff timer only when this was the only attempt */
        if (pending == 1)
                http_client_peer_shared_increase_backoff_timer(pshared);
-
-       if (pending > 1) {
-               /* if there are other connections attempting to connect, wait
-                  for them before failing the requests. remember that we had
-                  trouble with connecting so in future we don't try to create
-                  more than one connection until connects work again. */
-       } else {
-               struct http_client_peer *peer;
-
-               /* this was the only/last connection and connecting to it
-                  failed. notify all interested peers about the failure */
-               peer = pshared->peers_list;
-               while (peer != NULL) {
-                       struct http_client_peer *peer_next = peer->shared_next;
-                       http_client_peer_connection_failed_any(peer, reason);
-                       peer = peer_next;
-               }
-       }
 }
 
 static void