diff options
author | Roman Arutyunyan <arut@nginx.com> | 2018-12-11 19:41:22 +0300 |
---|---|---|
committer | Roman Arutyunyan <arut@nginx.com> | 2018-12-11 19:41:22 +0300 |
commit | 8e2949e56a13405a157e05b21aa4c4a5fa468335 (patch) | |
tree | 9bbdafc1a1104465b3cd428d554338d71dfff68c /src/core/ngx_resolver.c | |
parent | 746fba0d79c6909e9e09b4d1cb9ddbf052ab545e (diff) |
Resolver: report SRV resolve failure if all A resolves failed.
Previously, if an SRV record was successfully resolved, but all of its A
records failed to resolve, NXDOMAIN was returned to the caller, which is
considered a successful resolve rather than an error. This could result in
losing the result of a previous successful resolve by the caller.
Now NXDOMAIN is only returned if at least one A resolve completed with this
code. Otherwise the error state of the first A resolve is returned.
Diffstat (limited to 'src/core/ngx_resolver.c')
-rw-r--r-- | src/core/ngx_resolver.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/core/ngx_resolver.c b/src/core/ngx_resolver.c index 5d7fe312d..593645d5d 100644 --- a/src/core/ngx_resolver.c +++ b/src/core/ngx_resolver.c @@ -4266,7 +4266,15 @@ ngx_resolver_report_srv(ngx_resolver_t *r, ngx_resolver_ctx_t *ctx) } if (naddrs == 0) { - ctx->state = NGX_RESOLVE_NXDOMAIN; + ctx->state = srvs[0].state; + + for (i = 0; i < nsrvs; i++) { + if (srvs[i].state == NGX_RESOLVE_NXDOMAIN) { + ctx->state = NGX_RESOLVE_NXDOMAIN; + break; + } + } + ctx->valid = ngx_time() + (r->valid ? r->valid : 10); ctx->handler(ctx); |