[nginx] Resolver: fixed handling of partially resolved SRV.

Dmitry Volyntsev xeioex at nginx.com
Fri Dec 16 15:22:18 UTC 2016


details:   http://hg.nginx.org/nginx/rev/d72b38376092
branches:  
changeset: 6847:d72b38376092
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Fri Dec 16 18:21:55 2016 +0300
description:
Resolver: fixed handling of partially resolved SRV.

The resolver handles SRV requests in two stages.  In the first
stage it gets all SRV RRs, and in the second stage it resolves
the names from SRV RRs into addresses.

Previously, if a response to an SRV request was cached, the
queries to resolve names were not limited by a timeout.  If a
response to any of these queries was not received, the SRV
request could never complete.

If a response to an SRV request was not cached, and some of the
queries to resolve names timed out, NGX_RESOLVE_TIMEDOUT was
returned instead of successfully resolved addresses.

To fix both issues, resolving of names is now always limited by
a timeout.

diffstat:

 src/core/ngx_resolver.c |  6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diffs (23 lines):

diff -r c3a895b94d3f -r d72b38376092 src/core/ngx_resolver.c
--- a/src/core/ngx_resolver.c	Fri Dec 16 18:21:55 2016 +0300
+++ b/src/core/ngx_resolver.c	Fri Dec 16 18:21:55 2016 +0300
@@ -2955,6 +2955,10 @@ ngx_resolver_resolve_srv_names(ngx_resol
     ctx->srvs = srvs;
     ctx->nsrvs = rn->nsrvs;
 
+    if (ctx->event && ctx->event->timer_set) {
+        ngx_del_timer(ctx->event);
+    }
+
     for (i = 0; i < rn->nsrvs; i++) {
         srvs[i].name.data = ngx_resolver_alloc(r, rn->u.srvs[i].name.len);
         if (srvs[i].name.data == NULL) {
@@ -2974,7 +2978,7 @@ ngx_resolver_resolve_srv_names(ngx_resol
         cctx->handler = ngx_resolver_srv_names_handler;
         cctx->data = ctx;
         cctx->srvs = &srvs[i];
-        cctx->timeout = 0;
+        cctx->timeout = ctx->timeout;
 
         srvs[i].priority = rn->u.srvs[i].priority;
         srvs[i].weight = rn->u.srvs[i].weight;


More information about the nginx-devel mailing list