Mercurial > hg > nginx
comparison src/core/ngx_resolver.c @ 6847:d72b38376092
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.
author | Dmitry Volyntsev <xeioex@nginx.com> |
---|---|
date | Fri, 16 Dec 2016 18:21:55 +0300 |
parents | c3a895b94d3f |
children | f18c285c2e59 |
comparison
equal
deleted
inserted
replaced
6846:c3a895b94d3f | 6847:d72b38376092 |
---|---|
2953 } | 2953 } |
2954 | 2954 |
2955 ctx->srvs = srvs; | 2955 ctx->srvs = srvs; |
2956 ctx->nsrvs = rn->nsrvs; | 2956 ctx->nsrvs = rn->nsrvs; |
2957 | 2957 |
2958 if (ctx->event && ctx->event->timer_set) { | |
2959 ngx_del_timer(ctx->event); | |
2960 } | |
2961 | |
2958 for (i = 0; i < rn->nsrvs; i++) { | 2962 for (i = 0; i < rn->nsrvs; i++) { |
2959 srvs[i].name.data = ngx_resolver_alloc(r, rn->u.srvs[i].name.len); | 2963 srvs[i].name.data = ngx_resolver_alloc(r, rn->u.srvs[i].name.len); |
2960 if (srvs[i].name.data == NULL) { | 2964 if (srvs[i].name.data == NULL) { |
2961 goto failed; | 2965 goto failed; |
2962 } | 2966 } |
2972 | 2976 |
2973 cctx->name = srvs[i].name; | 2977 cctx->name = srvs[i].name; |
2974 cctx->handler = ngx_resolver_srv_names_handler; | 2978 cctx->handler = ngx_resolver_srv_names_handler; |
2975 cctx->data = ctx; | 2979 cctx->data = ctx; |
2976 cctx->srvs = &srvs[i]; | 2980 cctx->srvs = &srvs[i]; |
2977 cctx->timeout = 0; | 2981 cctx->timeout = ctx->timeout; |
2978 | 2982 |
2979 srvs[i].priority = rn->u.srvs[i].priority; | 2983 srvs[i].priority = rn->u.srvs[i].priority; |
2980 srvs[i].weight = rn->u.srvs[i].weight; | 2984 srvs[i].weight = rn->u.srvs[i].weight; |
2981 srvs[i].port = rn->u.srvs[i].port; | 2985 srvs[i].port = rn->u.srvs[i].port; |
2982 srvs[i].ctx = cctx; | 2986 srvs[i].ctx = cctx; |