Skip to content

Commit

Permalink
be more descriptive about dns failures in the logs
Browse files Browse the repository at this point in the history
  • Loading branch information
postwait committed Sep 11, 2012
1 parent 84c90ce commit c8df5e1
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/modules/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,28 @@ static dns_ctx_handle_t *dns_ctx_alloc(const char *ns, int port) {
h = calloc(1, sizeof(*h));
h->ns = ns ? strdup(ns) : NULL;
h->ctx = dns_new(NULL);
if(dns_init(h->ctx, 0) != 0) failed++;
if(dns_init(h->ctx, 0) != 0) {
noitL(nlerr, "dns_init failed\n");
failed++;
}
if(ns) {
if(dns_add_serv(h->ctx, NULL) < 0) failed++;
if(dns_add_serv(h->ctx, ns) < 0) failed++;
if(dns_add_serv(h->ctx, NULL) < 0) {
noitL(nlerr, "dns_add_serv(NULL) failed\n");
failed++;
}
if(dns_add_serv(h->ctx, ns) < 0) {
noitL(nlerr, "dns_add_serv(%s) failed\n", ns);
failed++;
}
}
if(port && port != DNS_PORT) {
dns_set_opt(h->ctx, DNS_OPT_PORT, port);
}
if(dns_open(h->ctx) < 0) failed++;
if(failed) {
if(dns_open(h->ctx) < 0) {
noitL(nlerr, "dns_open failed\n");
failed++;
}
if(failed) {
free(h->ns);
free(h);
free(hk);
Expand Down

0 comments on commit c8df5e1

Please sign in to comment.