Resolver: report error on CNAME restart failure

Previously, if restarting a resolve with a CNAME name failed due to a
memory allocation error, no error was reported.  The waiting requests
were left detached from any node until their timeouts expired.

Now the error is reported to the waiting requests immediately.
This commit is contained in:
Roman Arutyunyan 2026-11-06 20:02:09 +04:00 • committed by Roman Arutyunyan
parent c51ffa2d1a
commit 8492a8b8a9

View file

@ -2550,7 +2550,22 @@ ngx_resolver_process_a(ngx_resolver_t *r, u_char *buf, size_t n,
next->node = NULL;
}
(void) ngx_resolve_name_locked(r, ctx, &name);
if (ngx_resolve_name_locked(r, ctx, &name) == NGX_ERROR) {
/* unlock name mutex */
do {
ctx->state = NGX_ERROR;
ctx->valid = ngx_time() + (r->valid ? r->valid : 10);
next = ctx->next;
ctx->handler(ctx);
ctx = next;
} while (ctx);
return;
}
}
/* unlock name mutex */
@ -2935,7 +2950,22 @@ ngx_resolver_process_srv(ngx_resolver_t *r, u_char *buf, size_t n,
next->node = NULL;
}
(void) ngx_resolve_name_locked(r, ctx, &name);
if (ngx_resolve_name_locked(r, ctx, &name) == NGX_ERROR) {
/* unlock name mutex */
do {
ctx->state = NGX_ERROR;
ctx->valid = ngx_time() + (r->valid ? r->valid : 10);
next = ctx->next;
ctx->handler(ctx);
ctx = next;
} while (ctx);
return;
}
}
/* unlock name mutex */