Skip to content

Commit

Permalink
Resolver: introduced valid field in resolver responses.
Browse files Browse the repository at this point in the history
It hints the amount of time a response could be considered
as valid.
  • Loading branch information
xeioex committed Mar 23, 2016
1 parent 0f4315f commit 98f222c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/core/ngx_resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ ngx_resolve_name_locked(ngx_resolver_t *r, ngx_resolver_ctx_t *ctx,

do {
ctx->state = NGX_OK;
ctx->valid = rn->valid;
ctx->naddrs = naddrs;

if (addrs == NULL) {
Expand Down Expand Up @@ -597,6 +598,7 @@ ngx_resolve_name_locked(ngx_resolver_t *r, ngx_resolver_ctx_t *ctx,

do {
ctx->state = NGX_RESOLVE_NXDOMAIN;
ctx->valid = ngx_time() + (r->valid ? r->valid : 10);
next = ctx->next;

ctx->handler(ctx);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -1948,6 +1951,7 @@ ngx_resolver_process_a(ngx_resolver_t *r, u_char *buf, size_t n,
while (next) {
ctx = next;
ctx->state = code;
ctx->valid = ngx_time() + (r->valid ? r->valid : 10);
next = ctx->next;

ctx->handler(ctx);
Expand Down Expand Up @@ -2262,6 +2266,7 @@ ngx_resolver_process_a(ngx_resolver_t *r, u_char *buf, size_t n,
while (next) {
ctx = next;
ctx->state = NGX_OK;
ctx->valid = rn->valid;
ctx->naddrs = naddrs;

if (addrs == NULL) {
Expand Down Expand Up @@ -2541,6 +2546,7 @@ ngx_resolver_process_ptr(ngx_resolver_t *r, u_char *buf, size_t n,
while (next) {
ctx = next;
ctx->state = code;
ctx->valid = ngx_time() + (r->valid ? r->valid : 10);
next = ctx->next;

ctx->handler(ctx);
Expand Down Expand Up @@ -2675,6 +2681,7 @@ ngx_resolver_process_ptr(ngx_resolver_t *r, u_char *buf, size_t n,
while (next) {
ctx = next;
ctx->state = NGX_OK;
ctx->valid = rn->valid;
ctx->name = name;
next = ctx->next;

Expand Down
1 change: 1 addition & 0 deletions src/core/ngx_resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 98f222c

Please sign in to comment.