]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: client: peer: Moved http_client_peer_start_backoff_timer() function.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sun, 18 Dec 2016 18:15:04 +0000 (19:15 +0100)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 7 Dec 2017 16:40:45 +0000 (18:40 +0200)
This is a preparation for a subsequent change.

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

index 081ed90fa5c86fb459bc922a176dbb4e193d6ad6..4c60b11e07cc4ba325d24fb0c0ab30f9a6ec890b 100644 (file)
@@ -197,8 +197,6 @@ void http_client_peer_pool_unref(struct http_client_peer_pool **_ppool)
  * Peer
  */
 
-static bool
-http_client_peer_start_backoff_timer(struct http_client_peer *peer);
 static void
 http_client_peer_do_connect(struct http_client_peer *peer,
        unsigned int count);
@@ -238,6 +236,33 @@ http_client_peer_connect_backoff(struct http_client_peer *peer)
        http_client_peer_do_connect(peer, 1);
 }
 
+static bool
+http_client_peer_start_backoff_timer(struct http_client_peer *peer)
+{
+       if (peer->to_backoff != NULL)
+               return TRUE;
+
+       if (peer->last_failure.tv_sec > 0) {
+               int backoff_time_spent =
+                       timeval_diff_msecs(&ioloop_timeval, &peer->last_failure);
+
+               if (backoff_time_spent < (int)peer->backoff_time_msecs) {
+                       http_client_peer_debug(peer,
+                               "Starting backoff timer for %d msecs",
+                               peer->backoff_time_msecs - backoff_time_spent);
+                       peer->to_backoff = timeout_add
+                               ((unsigned int)(peer->backoff_time_msecs - backoff_time_spent),
+                                       http_client_peer_connect_backoff, peer);
+                       return TRUE;
+               }
+
+               http_client_peer_debug(peer,
+                       "Backoff time already exceeded by %d msecs",
+                       backoff_time_spent - peer->backoff_time_msecs);
+       }
+       return FALSE;
+}
+
 static struct http_client_peer *
 http_client_peer_create(struct http_client *client,
                              const struct http_client_peer_addr *addr)
@@ -432,33 +457,6 @@ http_client_peer_do_connect(struct http_client_peer *peer,
        }
 }
 
-static bool
-http_client_peer_start_backoff_timer(struct http_client_peer *peer)
-{
-       if (peer->to_backoff != NULL)
-               return TRUE;
-
-       if (peer->last_failure.tv_sec > 0) {
-               int backoff_time_spent =
-                       timeval_diff_msecs(&ioloop_timeval, &peer->last_failure);
-
-               if (backoff_time_spent < (int)peer->backoff_time_msecs) {
-                       http_client_peer_debug(peer,
-                               "Starting backoff timer for %d msecs",
-                               peer->backoff_time_msecs - backoff_time_spent);
-                       peer->to_backoff = timeout_add
-                               ((unsigned int)(peer->backoff_time_msecs - backoff_time_spent),
-                                       http_client_peer_connect_backoff, peer);
-                       return TRUE;
-               }
-
-               http_client_peer_debug(peer,
-                       "Backoff time already exceeded by %d msecs",
-                       backoff_time_spent - peer->backoff_time_msecs);
-       }
-       return FALSE;
-}
-
 static void
 http_client_peer_increase_backoff_timer(struct http_client_peer *peer)
 {