mirror of https://github.com/getdnsapi/getdns.git
Correct the logic for upstream back off
This commit is contained in:
parent
8fa84c836a
commit
5e1575dabc
|
@ -696,11 +696,12 @@ _getdns_upstream_shutdown(getdns_upstream *upstream)
|
|||
use the same basis if we simply can't get TCP service either.*/
|
||||
|
||||
/* [TLS1]TODO: This arbitrary logic at the moment - review and improve!*/
|
||||
if (upstream->conn_setup_failed >= GETDNS_MAX_CONN_FAILS ||
|
||||
(upstream->conn_shutdowns >= GETDNS_MAX_CONN_FAILS*GETDNS_CONN_FAIL_MULT
|
||||
if (upstream->conn_setup_failed >= GETDNS_CONN_ATTEMPTS ||
|
||||
(upstream->conn_shutdowns >= GETDNS_CONN_ATTEMPTS*GETDNS_TRANSPORT_FAIL_MULT
|
||||
&& upstream->total_responses == 0) ||
|
||||
(upstream->total_timeouts > 0 &&
|
||||
upstream->total_responses*GETDNS_MAX_CONN_FAILS == 0))
|
||||
(upstream->conn_completed >= GETDNS_CONN_ATTEMPTS &&
|
||||
upstream->total_responses == 0 &&
|
||||
upstream->total_timeouts > GETDNS_TRANSPORT_FAIL_MULT))
|
||||
upstream->conn_state = GETDNS_CONN_BACKOFF;
|
||||
// Reset per connection counters
|
||||
upstream->queries_sent = 0;
|
||||
|
|
|
@ -1542,7 +1542,7 @@ upstream_working_ok(getdns_upstream *upstream)
|
|||
{
|
||||
/* [TLS1]TODO: This arbitrary logic at the moment - review and improve!*/
|
||||
return (upstream->responses_timeouts >
|
||||
upstream->responses_received*GETDNS_MAX_CONN_FAILS ? 0 : 1);
|
||||
upstream->responses_received*GETDNS_CONN_ATTEMPTS ? 0 : 1);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1564,7 +1564,7 @@ upstream_stats(getdns_upstream *upstream)
|
|||
{
|
||||
/* [TLS1]TODO: This arbitrary logic at the moment - review and improve!*/
|
||||
return (upstream->total_responses - upstream->total_timeouts
|
||||
- upstream->conn_shutdowns*GETDNS_CONN_FAIL_MULT);
|
||||
- upstream->conn_shutdowns*GETDNS_TRANSPORT_FAIL_MULT);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -120,8 +120,8 @@ struct getdns_upstream;
|
|||
|
||||
#define GETDNS_TRANSPORTS_MAX 3
|
||||
#define GETDNS_UPSTREAM_TRANSPORTS 2
|
||||
#define GETDNS_MAX_CONN_FAILS 2
|
||||
#define GETDNS_CONN_FAIL_MULT 5
|
||||
#define GETDNS_CONN_ATTEMPTS 2
|
||||
#define GETDNS_TRANSPORT_FAIL_MULT 5
|
||||
|
||||
|
||||
/* declarations */
|
||||
|
|
Loading…
Reference in New Issue