Skip to content

Commit

Permalink
tdns: strerror() -> strerror_r()
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelortmann committed Jun 16, 2024
1 parent 4c42116 commit af0afc0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,12 @@ void *thread_dns_ipbyhost(void *arg)
}
else if (error == EAI_NONAME)
snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): not known");
else if (error == EAI_SYSTEM)
snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): %s: %s", gai_strerror(error), strerror(errno));
else
else if (error == EAI_SYSTEM) {
char ebuf[2048];
if (strerror_r(errno, ebuf, sizeof ebuf))
strcpy(ebuf, "strerror_r()");
snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): %s: %s", gai_strerror(error), ebuf);
} else
snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): %s", gai_strerror(error));
pthread_mutex_lock(&dtn->mutex);
close(dtn->fildes[1]);
Expand Down

0 comments on commit af0afc0

Please sign in to comment.