limit CNAME recursion

This commit is contained in:
Igor Sysoev 2008-04-12 07:29:20 +00:00
parent 523e09ee1a
commit a8372d8a84
2 changed files with 25 additions and 3 deletions

View File

@ -435,10 +435,29 @@ ngx_resolve_name_locked(ngx_resolver_t *r, ngx_resolver_ctx_t *ctx)
/* NGX_RESOLVE_CNAME */
ctx->name.len = rn->cnlen;
ctx->name.data = rn->u.cname;
if (ctx->recursion++ < NGX_RESOLVER_MAX_RECURSION) {
return ngx_resolve_name_locked(r, ctx);
ctx->name.len = rn->cnlen;
ctx->name.data = rn->u.cname;
return ngx_resolve_name_locked(r, ctx);
}
ctx->next = rn->waiting;
rn->waiting = NULL;
/* unlock name mutex */
do {
ctx->state = NGX_RESOLVE_NXDOMAIN;
next = ctx->next;
ctx->handler(ctx);
ctx = next;
} while (ctx);
return NGX_OK;
}
if (rn->waiting) {

View File

@ -29,6 +29,8 @@
#define NGX_NO_RESOLVER (void *) -1
#define NGX_RESOLVER_MAX_RECURSION 50
typedef struct {
ngx_connection_t *connection;
@ -128,6 +130,7 @@ struct ngx_resolver_ctx_s {
ngx_msec_t timeout;
ngx_uint_t quick; /* unsigned quick:1; */
ngx_uint_t recursion;
ngx_event_t *event;
};