MINOR: resolvers: replace nameserver's resolver ref by generic parent pointer
This will allow to use nameservers in something else than a resolver
section (load balancing for instance).
diff --git a/include/haproxy/dns-t.h b/include/haproxy/dns-t.h
index a542d45..237c756 100644
--- a/include/haproxy/dns-t.h
+++ b/include/haproxy/dns-t.h
@@ -201,12 +201,12 @@
*/
struct dns_nameserver {
char *id; /* nameserver unique identifier */
+ void *parent;
struct {
const char *file; /* file where the section appears */
int line; /* line where the section appears */
} conf; /* config information */
- struct resolvers *resolvers;
struct dgram_conn *dgram; /* transport layer */
struct sockaddr_storage addr; /* IP address */
diff --git a/src/dns.c b/src/dns.c
index 34546ac..72436a6 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -275,13 +275,13 @@
if ((fd = socket(ns->addr.ss_family, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
send_log(NULL, LOG_WARNING,
"DNS : resolvers '%s': can't create socket for nameserver '%s'.\n",
- ns->resolvers->id, ns->id);
+ ns->counters->pid, ns->id);
return -1;
}
if (connect(fd, (struct sockaddr*)&ns->addr, get_addr_len(&ns->addr)) == -1) {
send_log(NULL, LOG_WARNING,
"DNS : resolvers '%s': can't connect socket for nameserver '%s'.\n",
- ns->resolvers->id, ns->id);
+ ns->counters->id, ns->id);
close(fd);
return -1;
}
@@ -1901,7 +1901,7 @@
return;
}
- resolvers = ns->resolvers;
+ resolvers = ns->parent;
HA_SPIN_LOCK(DNS_LOCK, &resolvers->lock);
/* process all pending input messages */
@@ -2092,7 +2092,7 @@
if ((ns = dgram->owner) == NULL)
return;
- resolvers = ns->resolvers;
+ resolvers = ns->parent;
HA_SPIN_LOCK(DNS_LOCK, &resolvers->lock);
list_for_each_entry(res, &resolvers->resolutions.curr, list) {
@@ -2318,12 +2318,6 @@
dgram->t.sock.fd = -1;
ns->dgram = dgram;
- /* Store the ns counters pointer */
- if (ns->extra_counters) {
- ns->counters = EXTRA_COUNTERS_GET(ns->extra_counters, &dns_stats_module);
- ns->counters->id = ns->id;
- ns->counters->pid = ns->resolvers->id;
- }
}
/* Create the task associated to the resolvers section */
@@ -2512,7 +2506,7 @@
if (strcmp(mod->name, "dns") == 0) {
ns->counters = (struct dns_counters *)ns->extra_counters->data + mod->counters_off[COUNTERS_DNS];
ns->counters->id = ns->id;
- ns->counters->pid = ns->resolvers->id;
+ ns->counters->pid = resolvers->id;
}
}
}
@@ -3042,7 +3036,7 @@
/* the nameservers are linked backward first */
LIST_ADDQ(&curr_resolvers->nameservers, &newnameserver->list);
- newnameserver->resolvers = curr_resolvers;
+ newnameserver->parent = curr_resolvers;
newnameserver->conf.file = strdup(file);
newnameserver->conf.line = linenum;
newnameserver->id = strdup(args[1]);
@@ -3160,7 +3154,7 @@
goto resolv_out;
}
- newnameserver->resolvers = curr_resolvers;
+ newnameserver->parent = curr_resolvers;
newnameserver->conf.line = resolv_linenum;
newnameserver->addr = *sk;