]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
resolv: fix rotate option
authorAurelien Jarno <aurelien@aurel32.net>
Tue, 6 Jan 2015 16:50:23 +0000 (08:50 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 6 Jan 2015 17:00:20 +0000 (09:00 -0800)
The rotate option doesn't work correctly, and only send the query to the
same server (the second in the list). The rotation code in itself is not
broken, but the nsaddrs structure is reinitialized each time at the
beginning of __libc_res_nsend unless RES_STAYOPEN is enabled.

This is due to a call to __res_iclose from the end of __libc_res_nsend
when answers from the name server have been received. This function
closes all the sockets, but doesn't free the addresses (it can do that,
but in that case the second argument is false).

This patch change the code of __res_iclose to clear statp->_u._ext.nsinit
 only when the addresses are actually freed.

* resolv/res_init.c (__res_iclose): Only clear nsinit if the
addresses have been freed.

ChangeLog
resolv/res_init.c

index 1204575be1b722d2a5585ad2e2cfaa0133e52f6b..6ba3b8e8403e3a6bf1559f75c579e593450124aa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-06  Aurelien Jarno  <aurelien@aurel32.net>
+
+       * resolv/res_init.c (__res_iclose): Only clear nsinit if the
+       addresses have been freed.
+
 2015-01-06  Aurelien Jarno  <aurelien@aurel32.net>
 
        * resolv/res_init.c (__res_vinit): Improve comments about nserv
index 4c170be684d821ba435971d2dd210c938065b467..553ba12a5aa31ee16b504dd9b25f18364dee7df1 100644 (file)
@@ -621,7 +621,8 @@ __res_iclose(res_state statp, bool free_addr) {
                                statp->_u._ext.nsaddrs[ns] = NULL;
                        }
                }
-       statp->_u._ext.nsinit = 0;
+       if (free_addr)
+               statp->_u._ext.nsinit = 0;
 }
 libc_hidden_def (__res_iclose)