[nginx] Resolver: fixed debug event logging.
Ruslan Ermilov
ru at nginx.com
Thu Nov 20 12:38:18 UTC 2014
details: http://hg.nginx.org/nginx/rev/5004210e8c78
branches:
changeset: 5921:5004210e8c78
user: Ruslan Ermilov <ru at nginx.com>
date: Thu Nov 20 15:24:42 2014 +0300
description:
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.
diffstat:
src/core/ngx_resolver.c | 25 +++++++++++++++----------
src/core/ngx_resolver.h | 15 ++++++++-------
2 files changed, 23 insertions(+), 17 deletions(-)
diffs (132 lines):
diff -r 7420068c4d4b -r 5004210e8c78 src/core/ngx_resolver.c
--- a/src/core/ngx_resolver.c Thu Nov 20 15:24:40 2014 +0300
+++ b/src/core/ngx_resolver.c Thu Nov 20 15:24:42 2014 +0300
@@ -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
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 *
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
/* 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
/* 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
/* 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_rbt
} 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(n
} 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;
diff -r 7420068c4d4b -r 5004210e8c78 src/core/ngx_resolver.h
--- a/src/core/ngx_resolver.h Thu Nov 20 15:24:40 2014 +0300
+++ b/src/core/ngx_resolver.h Thu Nov 20 15:24:42 2014 +0300
@@ -51,11 +51,15 @@ typedef void (*ngx_resolver_handler_pt)(
typedef struct {
- ngx_rbtree_node_t node;
+ /* PTR: resolved name, A: name to resolve */
+ u_char *name;
+
ngx_queue_t queue;
- /* PTR: resolved name, A: name to resolve */
- u_char *name;
+ /* 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) */
@@ -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;
More information about the nginx-devel
mailing list