Resolver: do not enable resolve timer if provided timeout is zero.

This commit is contained in:
Dmitry Volyntsev 2016-03-23 17:44:36 +03:00
parent 98f222c6c1
commit 2b2fe92aaa

View File

@ -611,7 +611,7 @@ ngx_resolve_name_locked(ngx_resolver_t *r, ngx_resolver_ctx_t *ctx,
if (rn->waiting) {
if (ctx->event == NULL) {
if (ctx->event == NULL && ctx->timeout) {
ctx->event = ngx_resolver_calloc(r, sizeof(ngx_event_t));
if (ctx->event == NULL) {
return NGX_ERROR;
@ -729,7 +729,7 @@ ngx_resolve_name_locked(ngx_resolver_t *r, ngx_resolver_ctx_t *ctx,
goto failed;
}
if (ctx->event == NULL) {
if (ctx->event == NULL && ctx->timeout) {
ctx->event = ngx_resolver_calloc(r, sizeof(ngx_event_t));
if (ctx->event == NULL) {
goto failed;
@ -872,6 +872,7 @@ ngx_resolve_addr(ngx_resolver_ctx_t *ctx)
if (rn->waiting) {
if (ctx->event == NULL && ctx->timeout) {
ctx->event = ngx_resolver_calloc(r, sizeof(ngx_event_t));
if (ctx->event == NULL) {
return NGX_ERROR;
@ -883,6 +884,7 @@ ngx_resolve_addr(ngx_resolver_ctx_t *ctx)
ctx->ident = -1;
ngx_add_timer(ctx->event, ctx->timeout);
}
ctx->next = rn->waiting;
rn->waiting = ctx;
@ -949,6 +951,7 @@ ngx_resolve_addr(ngx_resolver_ctx_t *ctx)
goto failed;
}
if (ctx->event == NULL && ctx->timeout) {
ctx->event = ngx_resolver_calloc(r, sizeof(ngx_event_t));
if (ctx->event == NULL) {
goto failed;
@ -960,6 +963,7 @@ ngx_resolve_addr(ngx_resolver_ctx_t *ctx)
ctx->ident = -1;
ngx_add_timer(ctx->event, ctx->timeout);
}
if (ngx_queue_empty(resend_queue)) {
ngx_add_timer(r->event, (ngx_msec_t) (r->resend_timeout * 1000));