Skip to content

Commit

Permalink
Resolver: limited CNAME recursion.
Browse files Browse the repository at this point in the history
Previously, the recursion was only limited for cached responses.
  • Loading branch information
mdocguard committed Jan 26, 2016
1 parent 70f485c commit 13b6b5b
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/core/ngx_resolver.c
Original file line number Diff line number Diff line change
@@ -1981,24 +1981,40 @@ ngx_resolver_process_a(ngx_resolver_t *r, u_char *buf, size_t last,

ngx_queue_insert_head(&r->name_expire_queue, &rn->queue);

ngx_resolver_free(r, rn->query);
rn->query = NULL;
#if (NGX_HAVE_INET6)
rn->query6 = NULL;
#endif

ctx = rn->waiting;
rn->waiting = NULL;

if (ctx) {

if (ctx->recursion++ >= NGX_RESOLVER_MAX_RECURSION) {

/* unlock name mutex */

do {
ctx->state = NGX_RESOLVE_NXDOMAIN;
next = ctx->next;

ctx->handler(ctx);

ctx = next;
} while (ctx);

return;
}

for (next = ctx; next; next = next->next) {
next->node = NULL;
}

(void) ngx_resolve_name_locked(r, ctx, &name);
}

ngx_resolver_free(r, rn->query);
rn->query = NULL;
#if (NGX_HAVE_INET6)
rn->query6 = NULL;
#endif

/* unlock name mutex */

return;

0 comments on commit 13b6b5b

Please sign in to comment.