[nginx] Resolver: introduced valid field in resolver responses.

Dmitry Volyntsev xeioex at nginx.com
Wed Mar 23 14:50:17 UTC 2016


details:   http://hg.nginx.org/nginx/rev/c94aba230a5a
branches:  
changeset: 6456:c94aba230a5a
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Wed Mar 23 17:44:36 2016 +0300
description:
Resolver: introduced valid field in resolver responses.

It hints the amount of time a response could be considered
as valid.

diffstat:

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

diffs (70 lines):

diff -r ad2360782ecd -r c94aba230a5a src/core/ngx_resolver.c
--- a/src/core/ngx_resolver.c	Wed Mar 23 17:44:04 2016 +0300
+++ b/src/core/ngx_resolver.c	Wed Mar 23 17:44:36 2016 +0300
@@ -551,6 +551,7 @@ ngx_resolve_name_locked(ngx_resolver_t *
 
                 do {
                     ctx->state = NGX_OK;
+                    ctx->valid = rn->valid;
                     ctx->naddrs = naddrs;
 
                     if (addrs == NULL) {
@@ -597,6 +598,7 @@ ngx_resolve_name_locked(ngx_resolver_t *
 
             do {
                 ctx->state = NGX_RESOLVE_NXDOMAIN;
+                ctx->valid = ngx_time() + (r->valid ? r->valid : 10);
                 next = ctx->next;
 
                 ctx->handler(ctx);
@@ -859,6 +861,7 @@ ngx_resolve_addr(ngx_resolver_ctx_t *ctx
             /* unlock addr mutex */
 
             ctx->state = NGX_OK;
+            ctx->valid = rn->valid;
 
             ctx->handler(ctx);
 
@@ -1948,6 +1951,7 @@ ngx_resolver_process_a(ngx_resolver_t *r
         while (next) {
             ctx = next;
             ctx->state = code;
+            ctx->valid = ngx_time() + (r->valid ? r->valid : 10);
             next = ctx->next;
 
             ctx->handler(ctx);
@@ -2262,6 +2266,7 @@ ngx_resolver_process_a(ngx_resolver_t *r
         while (next) {
             ctx = next;
             ctx->state = NGX_OK;
+            ctx->valid = rn->valid;
             ctx->naddrs = naddrs;
 
             if (addrs == NULL) {
@@ -2541,6 +2546,7 @@ valid:
         while (next) {
             ctx = next;
             ctx->state = code;
+            ctx->valid = ngx_time() + (r->valid ? r->valid : 10);
             next = ctx->next;
 
             ctx->handler(ctx);
@@ -2675,6 +2681,7 @@ ptr:
     while (next) {
         ctx = next;
         ctx->state = NGX_OK;
+        ctx->valid = rn->valid;
         ctx->name = name;
         next = ctx->next;
 
diff -r ad2360782ecd -r c94aba230a5a src/core/ngx_resolver.h
--- a/src/core/ngx_resolver.h	Wed Mar 23 17:44:04 2016 +0300
+++ b/src/core/ngx_resolver.h	Wed Mar 23 17:44:36 2016 +0300
@@ -164,6 +164,7 @@ struct ngx_resolver_ctx_s {
     ngx_int_t                 state;
     ngx_str_t                 name;
 
+    time_t                    valid;
     ngx_uint_t                naddrs;
     ngx_addr_t               *addrs;
     ngx_addr_t                addr;



More information about the nginx-devel mailing list