Resolver: fixed debug event logging.

In 954867a2f0a6, we switched to using resolver node as the timer event data.
This broke debug event logging.

Replaced now unused ngx_resolver_ctx_t.ident with ngx_resolver_node_t.ident
so that ngx_event_ident() extracts something sensible when accessing
ngx_resolver_node_t as ngx_connection_t.
This commit is contained in:
Ruslan Ermilov 2014-11-20 15:24:42 +03:00
parent d4b7b74686
commit ef563debf1
2 changed files with 23 additions and 17 deletions

View File

@ -48,6 +48,11 @@ typedef struct {
} ngx_resolver_an_t;
#define ngx_resolver_node(n) \
(ngx_resolver_node_t *) \
((u_char *) (n) - offsetof(ngx_resolver_node_t, node))
ngx_int_t ngx_udp_connect(ngx_udp_connection_t *uc);
@ -288,7 +293,7 @@ ngx_resolver_cleanup_tree(ngx_resolver_t *r, ngx_rbtree_t *tree)
while (tree->root != tree->sentinel) {
rn = (ngx_resolver_node_t *) ngx_rbtree_min(tree->root, tree->sentinel);
rn = ngx_resolver_node(ngx_rbtree_min(tree->root, tree->sentinel));
ngx_queue_remove(&rn->queue);
@ -666,7 +671,7 @@ ngx_resolve_name_locked(ngx_resolver_t *r, ngx_resolver_ctx_t *ctx)
ctx->event->handler = ngx_resolver_timeout_handler;
ctx->event->data = rn;
ctx->event->log = r->log;
ctx->ident = -1;
rn->ident = -1;
ngx_add_timer(ctx->event, ctx->timeout);
}
@ -859,7 +864,7 @@ ngx_resolve_addr(ngx_resolver_ctx_t *ctx)
ctx->event->handler = ngx_resolver_timeout_handler;
ctx->event->data = rn;
ctx->event->log = r->log;
ctx->ident = -1;
rn->ident = -1;
ngx_add_timer(ctx->event, ctx->timeout);
@ -2290,7 +2295,7 @@ ngx_resolver_lookup_name(ngx_resolver_t *r, ngx_str_t *name, uint32_t hash)
/* hash == node->key */
rn = (ngx_resolver_node_t *) node;
rn = ngx_resolver_node(node);
rc = ngx_memn2cmp(name->data, rn->name, name->len, rn->nlen);
@ -2329,7 +2334,7 @@ ngx_resolver_lookup_addr(ngx_resolver_t *r, in_addr_t addr)
/* addr == node->key */
return (ngx_resolver_node_t *) node;
return ngx_resolver_node(node);
}
/* not found */
@ -2365,7 +2370,7 @@ ngx_resolver_lookup_addr6(ngx_resolver_t *r, struct in6_addr *addr,
/* hash == node->key */
rn = (ngx_resolver_node_t *) node;
rn = ngx_resolver_node(node);
rc = ngx_memcmp(addr, &rn->addr6, 16);
@ -2403,8 +2408,8 @@ ngx_resolver_rbtree_insert_value(ngx_rbtree_node_t *temp,
} else { /* node->key == temp->key */
rn = (ngx_resolver_node_t *) node;
rn_temp = (ngx_resolver_node_t *) temp;
rn = ngx_resolver_node(node);
rn_temp = ngx_resolver_node(temp);
p = (ngx_memn2cmp(rn->name, rn_temp->name, rn->nlen, rn_temp->nlen)
< 0) ? &temp->left : &temp->right;
@ -2446,8 +2451,8 @@ ngx_resolver_rbtree_insert_addr6_value(ngx_rbtree_node_t *temp,
} else { /* node->key == temp->key */
rn = (ngx_resolver_node_t *) node;
rn_temp = (ngx_resolver_node_t *) temp;
rn = ngx_resolver_node(node);
rn_temp = ngx_resolver_node(temp);
p = (ngx_memcmp(&rn->addr6, &rn_temp->addr6, 16)
< 0) ? &temp->left : &temp->right;

View File

@ -51,12 +51,16 @@ typedef void (*ngx_resolver_handler_pt)(ngx_resolver_ctx_t *ctx);
typedef struct {
ngx_rbtree_node_t node;
ngx_queue_t queue;
/* PTR: resolved name, A: name to resolve */
u_char *name;
ngx_queue_t queue;
/* event ident must be after 3 pointers as in ngx_connection_t */
ngx_int_t ident;
ngx_rbtree_node_t node;
#if (NGX_HAVE_INET6)
/* PTR: IPv6 address to resolve (IPv4 address is in rbtree node key) */
struct in6_addr addr6;
@ -103,7 +107,7 @@ typedef struct {
void *dummy;
ngx_log_t *log;
/* ident must be after 3 pointers */
/* event ident must be after 3 pointers as in ngx_connection_t */
ngx_int_t ident;
/* simple round robin DNS peers balancer */
@ -143,9 +147,6 @@ struct ngx_resolver_ctx_s {
ngx_resolver_t *resolver;
ngx_udp_connection_t *udp_connection;
/* ident must be after 3 pointers */
ngx_int_t ident;
ngx_int_t state;
ngx_str_t name;