Skip to content

Commit

Permalink
Resolver: do not enable resolve timer if provided timeout is zero.
Browse files Browse the repository at this point in the history
  • Loading branch information
xeioex committed Mar 23, 2016
1 parent 98f222c commit 2b2fe92
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions src/core/ngx_resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -872,17 +872,19 @@ ngx_resolve_addr(ngx_resolver_ctx_t *ctx)

if (rn->waiting) {

ctx->event = ngx_resolver_calloc(r, sizeof(ngx_event_t));
if (ctx->event == NULL) {
return NGX_ERROR;
}
if (ctx->event == NULL && ctx->timeout) {
ctx->event = ngx_resolver_calloc(r, sizeof(ngx_event_t));
if (ctx->event == NULL) {
return NGX_ERROR;
}

ctx->event->handler = ngx_resolver_timeout_handler;
ctx->event->data = ctx;
ctx->event->log = r->log;
ctx->ident = -1;
ctx->event->handler = ngx_resolver_timeout_handler;
ctx->event->data = ctx;
ctx->event->log = r->log;
ctx->ident = -1;

ngx_add_timer(ctx->event, ctx->timeout);
ngx_add_timer(ctx->event, ctx->timeout);
}

ctx->next = rn->waiting;
rn->waiting = ctx;
Expand Down Expand Up @@ -949,17 +951,19 @@ ngx_resolve_addr(ngx_resolver_ctx_t *ctx)
goto failed;
}

ctx->event = ngx_resolver_calloc(r, sizeof(ngx_event_t));
if (ctx->event == NULL) {
goto failed;
}
if (ctx->event == NULL && ctx->timeout) {
ctx->event = ngx_resolver_calloc(r, sizeof(ngx_event_t));
if (ctx->event == NULL) {
goto failed;
}

ctx->event->handler = ngx_resolver_timeout_handler;
ctx->event->data = ctx;
ctx->event->log = r->log;
ctx->ident = -1;
ctx->event->handler = ngx_resolver_timeout_handler;
ctx->event->data = ctx;
ctx->event->log = r->log;
ctx->ident = -1;

ngx_add_timer(ctx->event, ctx->timeout);
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));
Expand Down

0 comments on commit 2b2fe92

Please sign in to comment.