Skip to content

Commit

Permalink
Resolver: canceled resend timer on empty resend queues.
Browse files Browse the repository at this point in the history
This is specifically useful on graceful shutdown.
  • Loading branch information
pluknet committed Jun 17, 2015
1 parent 58957fa commit f470cd2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/core/ngx_resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ static ngx_int_t ngx_resolver_create_addr_query(ngx_resolver_node_t *rn,
static void ngx_resolver_resend_handler(ngx_event_t *ev);
static time_t ngx_resolver_resend(ngx_resolver_t *r, ngx_rbtree_t *tree,
ngx_queue_t *queue);
static ngx_uint_t ngx_resolver_resend_empty(ngx_resolver_t *r);
static void ngx_resolver_read_response(ngx_event_t *rev);
static void ngx_resolver_process_response(ngx_resolver_t *r, u_char *buf,
size_t n);
Expand Down Expand Up @@ -463,6 +464,10 @@ ngx_resolve_name_done(ngx_resolver_ctx_t *ctx)
ngx_resolver_free_locked(r, ctx);

/* unlock alloc mutex */

if (r->event->timer_set && ngx_resolver_resend_empty(r)) {
ngx_del_timer(r->event);
}
}


Expand Down Expand Up @@ -1016,6 +1021,10 @@ ngx_resolve_addr_done(ngx_resolver_ctx_t *ctx)
ngx_resolver_free_locked(r, ctx);

/* unlock alloc mutex */

if (r->event->timer_set && ngx_resolver_resend_empty(r)) {
ngx_del_timer(r->event);
}
}


Expand Down Expand Up @@ -1225,6 +1234,17 @@ ngx_resolver_resend(ngx_resolver_t *r, ngx_rbtree_t *tree, ngx_queue_t *queue)
}


static ngx_uint_t
ngx_resolver_resend_empty(ngx_resolver_t *r)
{
return ngx_queue_empty(&r->name_resend_queue)
#if (NGX_HAVE_INET6)
&& ngx_queue_empty(&r->addr6_resend_queue)
#endif
&& ngx_queue_empty(&r->addr_resend_queue);
}


static void
ngx_resolver_read_response(ngx_event_t *rev)
{
Expand Down

0 comments on commit f470cd2

Please sign in to comment.