Always call res_init() before getaddrinfo().
Unfortunately, glibc assumes that /etc/resolv.conf is a static file that never changes. Even on servers, /etc/resolv.conf might be a dynamically generated file, and we never know when it changes. So just call res_init() every time, so glibc uses up-to-date nameserver information.
This commit is contained in:
parent
268e3ffca7
commit
0b310bf406
4 changed files with 18 additions and 7 deletions
|
|
@ -663,6 +663,9 @@ static bool add_listen_address(char *address, bool bindto) {
|
|||
hint.ai_protocol = IPPROTO_TCP;
|
||||
hint.ai_flags = AI_PASSIVE;
|
||||
|
||||
#ifdef HAVE_DECL_RES_INIT
|
||||
res_init();
|
||||
#endif
|
||||
int err = getaddrinfo(address && *address ? address : NULL, port, &hint, &ai);
|
||||
free(address);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue