]> git.kaiwu.me - nginx.git/commitdiff
Upstream: limited next_upstream time and tries when resolving DNS.
authorGu Feng <flygoast@126.com>
Mon, 27 Oct 2014 11:52:03 +0000 (19:52 +0800)
committerGu Feng <flygoast@126.com>
Mon, 27 Oct 2014 11:52:03 +0000 (19:52 +0800)
When got multiple upstream IP addresses using DNS resolving, the number of
upstreams tries and the maxinum time spent for these tries were not affected.
This patch fixed it.

src/http/ngx_http_upstream.c

index c5070a07e9d66f6a6ccd43e85e3eb06e3da0ca5a..3e8ce09e1a7b89d9b369898ea22fcf23cb2b17b2 100644 (file)
@@ -981,6 +981,14 @@ ngx_http_upstream_resolve_handler(ngx_resolver_ctx_t *ctx)
     ngx_resolve_name_done(ctx);
     ur->ctx = NULL;
 
+    u->peer.start_time = ngx_current_msec;
+
+    if (u->conf->next_upstream_tries
+        && u->peer.tries > u->conf->next_upstream_tries)
+    {
+        u->peer.tries = u->conf->next_upstream_tries;
+    }
+
     ngx_http_upstream_connect(r, u);
 
 failed: