return FALSE;
}
+static void
+http_client_peer_increase_backoff_timer(struct http_client_peer *peer)
+{
+ const struct http_client_settings *set = &peer->client->set;
+
+ if (peer->backoff_time_msecs == 0)
+ peer->backoff_time_msecs = set->connect_backoff_time_msecs;
+ else
+ peer->backoff_time_msecs *= 2;
+ if (peer->backoff_time_msecs > set->connect_backoff_max_time_msecs)
+ peer->backoff_time_msecs = set->connect_backoff_max_time_msecs;
+}
+
+static void
+http_client_peer_reset_backoff_timer(struct http_client_peer *peer)
+{
+ peer->backoff_time_msecs = 0;
+
+ if (peer->to_backoff != NULL)
+ timeout_remove(&peer->to_backoff);
+}
+
static void
http_client_peer_connect(struct http_client_peer *peer, unsigned int count)
{
array_count(&peer->conns));
peer->last_failure.tv_sec = peer->last_failure.tv_usec = 0;
- peer->backoff_time_msecs = 0;
-
- if (peer->to_backoff != NULL)
- timeout_remove(&peer->to_backoff);
+ http_client_peer_reset_backoff_timer(peer);
array_foreach(&peer->queues, queue) {
http_client_queue_connection_success(*queue, &peer->addr);
void http_client_peer_connection_failure(struct http_client_peer *peer,
const char *reason)
{
- const struct http_client_settings *set = &peer->client->set;
struct http_client_queue *const *queue;
unsigned int pending;
array_count(&peer->conns), pending);
/* manage backoff timer only when this was the only attempt */
- if (pending == 1) {
- if (peer->backoff_time_msecs == 0)
- peer->backoff_time_msecs = set->connect_backoff_time_msecs;
- else
- peer->backoff_time_msecs *= 2;
- if (peer->backoff_time_msecs > set->connect_backoff_max_time_msecs)
- peer->backoff_time_msecs = set->connect_backoff_max_time_msecs;
- }
+ if (pending == 1)
+ http_client_peer_increase_backoff_timer(peer);
if (pending > 1) {
/* if there are other connections attempting to connect, wait