[nginx] Resolver: cancelable resend timer event.
Ruslan Ermilov
ru at nginx.com
Tue Jul 4 16:52:32 UTC 2017
details: http://hg.nginx.org/nginx/rev/70e65bf8dfd7
branches:
changeset: 7052:70e65bf8dfd7
user: Ruslan Ermilov <ru at nginx.com>
date: Tue Jul 04 18:50:41 2017 +0300
description:
Resolver: cancelable resend timer event.
It is safe because re-sending still works during graceful shutdown as
long as resolving takes place (and resolve tasks set their own timeouts
that are not cancelable).
Also, the new ctx->cancelable flag can be set to make resolve task's
timeout event cancelable.
diffstat:
src/core/ngx_resolver.c | 2 ++
src/core/ngx_resolver.h | 1 +
2 files changed, 3 insertions(+), 0 deletions(-)
diffs (30 lines):
diff -r 137c5be7df09 -r 70e65bf8dfd7 src/core/ngx_resolver.c
--- a/src/core/ngx_resolver.c Tue Jul 04 18:46:30 2017 +0300
+++ b/src/core/ngx_resolver.c Tue Jul 04 18:50:41 2017 +0300
@@ -191,6 +191,7 @@ ngx_resolver_create(ngx_conf_t *cf, ngx_
r->event->handler = ngx_resolver_resend_handler;
r->event->data = r;
r->event->log = &cf->cycle->new_log;
+ r->event->cancelable = 1;
r->ident = -1;
r->resend_timeout = 5;
@@ -4008,6 +4009,7 @@ ngx_resolver_set_timeout(ngx_resolver_t
ctx->event->handler = ngx_resolver_timeout_handler;
ctx->event->data = ctx;
ctx->event->log = r->log;
+ ctx->event->cancelable = ctx->cancelable;
ctx->ident = -1;
ngx_add_timer(ctx->event, ctx->timeout);
diff -r 137c5be7df09 -r 70e65bf8dfd7 src/core/ngx_resolver.h
--- a/src/core/ngx_resolver.h Tue Jul 04 18:46:30 2017 +0300
+++ b/src/core/ngx_resolver.h Tue Jul 04 18:50:41 2017 +0300
@@ -220,6 +220,7 @@ struct ngx_resolver_ctx_s {
unsigned quick:1;
unsigned async:1;
+ unsigned cancelable:1;
ngx_uint_t recursion;
ngx_event_t *event;
};
More information about the nginx-devel
mailing list