[nginx] Resolver: canceled resend timer on empty resend queues.

Sergey Kandaurov pluknet at nginx.com
Wed Jun 17 15:01:09 UTC 2015


details:   http://hg.nginx.org/nginx/rev/c3ec43580a48
branches:  
changeset: 6196:c3ec43580a48
user:      Sergey Kandaurov <pluknet at nginx.com>
date:      Wed Jun 17 17:57:34 2015 +0300
description:
Resolver: canceled resend timer on empty resend queues.

This is specifically useful on graceful shutdown.

diffstat:

 src/core/ngx_resolver.c |  20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diffs (51 lines):

diff -r e69d5e9be292 -r c3ec43580a48 src/core/ngx_resolver.c
--- a/src/core/ngx_resolver.c	Wed Jun 10 19:18:19 2015 -0700
+++ b/src/core/ngx_resolver.c	Wed Jun 17 17:57:34 2015 +0300
@@ -71,6 +71,7 @@ static ngx_int_t ngx_resolver_create_add
 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);
@@ -463,6 +464,10 @@ done:
     ngx_resolver_free_locked(r, ctx);
 
     /* unlock alloc mutex */
+
+    if (r->event->timer_set && ngx_resolver_resend_empty(r)) {
+        ngx_del_timer(r->event);
+    }
 }
 
 
@@ -1016,6 +1021,10 @@ done:
     ngx_resolver_free_locked(r, ctx);
 
     /* unlock alloc mutex */
+
+    if (r->event->timer_set && ngx_resolver_resend_empty(r)) {
+        ngx_del_timer(r->event);
+    }
 }
 
 
@@ -1225,6 +1234,17 @@ ngx_resolver_resend(ngx_resolver_t *r, n
 }
 
 
+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)
 {



More information about the nginx-devel mailing list