[nginx] Resolver: added the "async" flag to resolver context.

Roman Arutyunyan arut at nginx.com
Thu Jun 22 08:53:35 UTC 2017


details:   http://hg.nginx.org/nginx/rev/d49b74a683b1
branches:  
changeset: 7040:d49b74a683b1
user:      Roman Arutyunyan <arut at nginx.com>
date:      Wed Jun 14 18:13:31 2017 +0300
description:
Resolver: added the "async" flag to resolver context.

The flag indicates that the resolve handler is called asynchronously after the
resolve function ngx_resolve_name()/ngx_resolve_addr() exited.

diffstat:

 src/core/ngx_resolver.c |  5 +++++
 src/core/ngx_resolver.h |  3 ++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diffs (56 lines):

diff -r a39bc74873fa -r d49b74a683b1 src/core/ngx_resolver.c
--- a/src/core/ngx_resolver.c	Mon Jun 19 14:25:42 2017 +0300
+++ b/src/core/ngx_resolver.c	Wed Jun 14 18:13:31 2017 +0300
@@ -746,6 +746,7 @@ ngx_resolve_name_locked(ngx_resolver_t *
             last->next = rn->waiting;
             rn->waiting = ctx;
             ctx->state = NGX_AGAIN;
+            ctx->async = 1;
 
             do {
                 ctx->node = rn;
@@ -892,6 +893,7 @@ ngx_resolve_name_locked(ngx_resolver_t *
     rn->waiting = ctx;
 
     ctx->state = NGX_AGAIN;
+    ctx->async = 1;
 
     do {
         ctx->node = rn;
@@ -1023,6 +1025,7 @@ ngx_resolve_addr(ngx_resolver_ctx_t *ctx
             ctx->next = rn->waiting;
             rn->waiting = ctx;
             ctx->state = NGX_AGAIN;
+            ctx->async = 1;
             ctx->node = rn;
 
             /* unlock addr mutex */
@@ -1119,6 +1122,7 @@ ngx_resolve_addr(ngx_resolver_ctx_t *ctx
     /* unlock addr mutex */
 
     ctx->state = NGX_AGAIN;
+    ctx->async = 1;
     ctx->node = rn;
 
     return NGX_OK;
@@ -3019,6 +3023,7 @@ ngx_resolver_srv_names_handler(ngx_resol
     srv = cctx->srvs;
 
     ctx->count--;
+    ctx->async |= cctx->async;
 
     srv->ctx = NULL;
     srv->state = cctx->state;
diff -r a39bc74873fa -r d49b74a683b1 src/core/ngx_resolver.h
--- a/src/core/ngx_resolver.h	Mon Jun 19 14:25:42 2017 +0300
+++ b/src/core/ngx_resolver.h	Wed Jun 14 18:13:31 2017 +0300
@@ -218,7 +218,8 @@ struct ngx_resolver_ctx_s {
     void                     *data;
     ngx_msec_t                timeout;
 
-    ngx_uint_t                quick;  /* unsigned  quick:1; */
+    unsigned                  quick:1;
+    unsigned                  async:1;
     ngx_uint_t                recursion;
     ngx_event_t              *event;
 };


More information about the nginx-devel mailing list