From b64e1566263764ddc1173cfa3f94d0ef92ae2883 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 31 May 2002 07:54:02 +0000 Subject: Update. 2002-05-21 Jakub Jelinek * resolv/resolv.h (struct __res_state): Remove unused nstimes. Add nsmap. * resolv/res_init.c (__res_vinit): Initialize nsmap array. Remove nstimes setting. (res_nclose): Check all MAXNS nameservers with non-NULL nsaddrs. * resolv/res_send.c (res_nsend): Don't close unconditionally if there is mix of IPv6 and IPv4 nameservers. Use nsmap array to find free slots and preserve nameserver ordering. Fix RES_ROTATE. --- resolv/res_init.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'resolv/res_init.c') diff --git a/resolv/res_init.c b/resolv/res_init.c index bb66b02b6c..f5613825bf 100644 --- a/resolv/res_init.c +++ b/resolv/res_init.c @@ -182,8 +182,10 @@ __res_vinit(res_state statp, int preinit) { statp->_u._ext.nscount = 0; #ifdef _LIBC statp->_u._ext.nscount6 = 0; - for (n = 0; n < MAXNS; n++) - statp->_u._ext.nsaddrs[n] = NULL; + for (n = 0; n < MAXNS; n++) { + statp->_u._ext.nsaddrs[n] = NULL; + statp->_u._ext.nsmap[n] = MAXNS; + } #endif /* Allow user to override the local domain definition */ @@ -323,8 +325,8 @@ __res_vinit(res_state statp, int preinit) { sa6->sin6_family = AF_INET6; sa6->sin6_port = htons(NAMESERVER_PORT); statp->_u._ext.nsaddrs[nservall] = sa6; - statp->_u._ext.nstimes[nservall] = RES_MAXTIME; statp->_u._ext.nssocks[nservall] = -1; + statp->_u._ext.nsmap[nservall] = MAXNS + 1; nservall++; } } @@ -537,16 +539,14 @@ res_nclose(res_state statp) { statp->_flags &= ~(RES_F_VC | RES_F_CONN); } #ifdef _LIBC - for (ns = 0; ns < statp->_u._ext.nscount + statp->_u._ext.nscount6; - ns++) + for (ns = 0; ns < MAXNS; ns++) #else for (ns = 0; ns < statp->_u._ext.nscount; ns++) #endif - { - if (statp->_u._ext.nssocks[ns] != -1) { + if (statp->_u._ext.nsaddrs[ns] + && statp->_u._ext.nssocks[ns] != -1) { (void) __close(statp->_u._ext.nssocks[ns]); statp->_u._ext.nssocks[ns] = -1; } - } statp->_u._ext.nsinit = 0; } -- cgit v1.2.3