Resolver: fixed CNAME processing for several requests.
When several requests were waiting for a response, then after getting a CNAME response only the last request was properly processed, while others were left waiting.
This commit is contained in:
parent
1fdddd2818
commit
60334da462
1 changed files with 15 additions and 6 deletions
|
@ -478,7 +478,7 @@ ngx_resolve_name_locked(ngx_resolver_t *r, ngx_resolver_ctx_t *ctx)
|
|||
ngx_int_t rc;
|
||||
ngx_uint_t naddrs;
|
||||
ngx_addr_t *addrs;
|
||||
ngx_resolver_ctx_t *next;
|
||||
ngx_resolver_ctx_t *next, *last;
|
||||
ngx_resolver_node_t *rn;
|
||||
|
||||
ngx_strlow(ctx->name.data, ctx->name.data, ctx->name.len);
|
||||
|
@ -489,6 +489,9 @@ ngx_resolve_name_locked(ngx_resolver_t *r, ngx_resolver_ctx_t *ctx)
|
|||
|
||||
if (rn) {
|
||||
|
||||
/* ctx can be a list after NGX_RESOLVE_CNAME */
|
||||
for (last = ctx; last->next; last = last->next);
|
||||
|
||||
if (rn->valid >= ngx_time()) {
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_CORE, r->log, 0, "resolve cached");
|
||||
|
@ -516,7 +519,7 @@ ngx_resolve_name_locked(ngx_resolver_t *r, ngx_resolver_ctx_t *ctx)
|
|||
}
|
||||
}
|
||||
|
||||
ctx->next = rn->waiting;
|
||||
last->next = rn->waiting;
|
||||
rn->waiting = NULL;
|
||||
|
||||
/* unlock name mutex */
|
||||
|
@ -562,7 +565,7 @@ ngx_resolve_name_locked(ngx_resolver_t *r, ngx_resolver_ctx_t *ctx)
|
|||
return ngx_resolve_name_locked(r, ctx);
|
||||
}
|
||||
|
||||
ctx->next = rn->waiting;
|
||||
last->next = rn->waiting;
|
||||
rn->waiting = NULL;
|
||||
|
||||
/* unlock name mutex */
|
||||
|
@ -595,7 +598,7 @@ ngx_resolve_name_locked(ngx_resolver_t *r, ngx_resolver_ctx_t *ctx)
|
|||
ngx_add_timer(ctx->event, ctx->timeout);
|
||||
}
|
||||
|
||||
ctx->next = rn->waiting;
|
||||
last->next = rn->waiting;
|
||||
rn->waiting = ctx;
|
||||
ctx->state = NGX_AGAIN;
|
||||
|
||||
|
@ -666,8 +669,14 @@ ngx_resolve_name_locked(ngx_resolver_t *r, ngx_resolver_ctx_t *ctx)
|
|||
ngx_resolver_free(r, rn->name);
|
||||
ngx_resolver_free(r, rn);
|
||||
|
||||
ctx->state = NGX_RESOLVE_NXDOMAIN;
|
||||
ctx->handler(ctx);
|
||||
do {
|
||||
ctx->state = NGX_RESOLVE_NXDOMAIN;
|
||||
next = ctx->next;
|
||||
|
||||
ctx->handler(ctx);
|
||||
|
||||
ctx = next;
|
||||
} while (ctx);
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue