Welcome! Log In Create A New Profile

Advanced

[nginx] Resolver: make TCP write timer event cancelable.

Aleksei Bavshin via nginx-devel
June 10, 2022 07:36AM
details: https://hg.nginx.org/nginx/rev/aa28c802409f
branches:
changeset: 8045:aa28c802409f
user: Aleksei Bavshin <a.bavshin@f5.com>
date: Wed Jun 01 20:17:23 2022 -0700
description:
Resolver: make TCP write timer event cancelable.

Similar to 70e65bf8dfd7, the change is made to ensure that the ability to
cancel resolver tasks is fully controlled by the caller. As mentioned in the
referenced commit, it is safe to make this timer cancelable because resolve
tasks can have their own timeouts that are not cancelable.

The scenario where this may become a problem is a periodic background resolve
task (not tied to a specific request or a client connection), which receives a
response with short TTL, large enough to warrant fallback to a TCP query.
With each event loop wakeup, we either have a previously set write timer
instance or schedule a new one. The non-cancelable write timer can delay or
block graceful shutdown of a worker even if the ngx_resolver_ctx_t->cancelable
flag is set by the API user, and there are no other tasks or connections.

We use the resolver API in this way to maintain the list of upstream server
addresses specified with the 'resolve' parameter, and there could be third-party
modules implementing similar logic.

diffstat:

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

diffs (11 lines):

diff -r 457afc332c67 -r aa28c802409f src/core/ngx_resolver.c
--- a/src/core/ngx_resolver.c Mon May 23 11:29:44 2022 -0700
+++ b/src/core/ngx_resolver.c Wed Jun 01 20:17:23 2022 -0700
@@ -1389,6 +1389,7 @@ ngx_resolver_send_tcp_query(ngx_resolver

rec->tcp->data = rec;
rec->tcp->write->handler = ngx_resolver_tcp_write;
+ rec->tcp->write->cancelable = 1;
rec->tcp->read->handler = ngx_resolver_tcp_read;
rec->tcp->read->resolver = 1;

_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[nginx] Resolver: make TCP write timer event cancelable.

Aleksei Bavshin via nginx-devel 320 June 10, 2022 07:36AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 178
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready