changeset 5885:5a042519bfe7

Upstream: limited next_upstream time and tries when resolving DNS. 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.
author Gu Feng <flygoast@126.com>
date Mon, 27 Oct 2014 19:52:03 +0800
parents 8486205d10db
children 5d4e4619982f
files src/http/ngx_http_upstream.c
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -981,6 +981,14 @@ ngx_http_upstream_resolve_handler(ngx_re
     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: