]> git.kaiwu.me - nginx.git/commitdiff
Resolver: added the "async" flag to resolver context.
authorRoman Arutyunyan <arut@nginx.com>
Wed, 14 Jun 2017 15:13:31 +0000 (18:13 +0300)
committerRoman Arutyunyan <arut@nginx.com>
Wed, 14 Jun 2017 15:13:31 +0000 (18:13 +0300)
The flag indicates that the resolve handler is called asynchronously after the
resolve function ngx_resolve_name()/ngx_resolve_addr() exited.

src/core/ngx_resolver.c
src/core/ngx_resolver.h

index a18fd1fde7ffee46e5352a2ce9f9715016779ccd..91f8a5ef30163034040cd686887a8474ba9302ea 100644 (file)
@@ -746,6 +746,7 @@ ngx_resolve_name_locked(ngx_resolver_t *r, ngx_resolver_ctx_t *ctx,
             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 *r, ngx_resolver_ctx_t *ctx,
     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_resolver_ctx_t *cctx)
     srv = cctx->srvs;
 
     ctx->count--;
+    ctx->async |= cctx->async;
 
     srv->ctx = NULL;
     srv->state = cctx->state;
index a0d6fc341aeccc58726a4904f23e946635720341..6f099b70fb9b0c002defe09a6332497edb88a6db 100644 (file)
@@ -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;
 };