summary refs log tree commit diff
path: root/resolv/res_init.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-11-01 00:08:54 +0000
committerUlrich Drepper <drepper@redhat.com>2005-11-01 00:08:54 +0000
commitcb07f6f67db0ef4ccbf3bedfb7c9c4f140773d2c (patch)
tree2524b26825fbddf3868e2e8a976f030d4e1dd626 /resolv/res_init.c
parent6ff8f07aba531a7f8641562889898b1a657d7d54 (diff)
downloadglibc-cb07f6f67db0ef4ccbf3bedfb7c9c4f140773d2c.tar.gz
glibc-cb07f6f67db0ef4ccbf3bedfb7c9c4f140773d2c.tar.xz
glibc-cb07f6f67db0ef4ccbf3bedfb7c9c4f140773d2c.zip
* resolv/res_init.c (__res_iclose): New function. Broken out of
	res_nclose.  Take addition parameter which determines whether
	addresses should be freed.
	(res_nclose): Call __res_iclose.
	(res_thread_freeres): Likewise.
	* resolv/res_data.c (res_close): Call __res_iclose.
	* resolv/res_libc.c (res_init): No need to separately free the
	addresses.
	(__res_maybe_init): Likewise.
	* resolv/res_send.c: Use __res_iclose instead of res_nclose.
	* resolv/Versions [GLIBC_PRIVATE]: Add __res_iclose.
	* include/resolv.h: Declare __res_iclose.
	Add libc_hidden_proto for __res_iclose.
	* hesiod/hesiod.c (__hesiod_res_set): No need to free name server
	addresses here again.
Diffstat (limited to 'resolv/res_init.c')
-rw-r--r--resolv/res_init.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/resolv/res_init.c b/resolv/res_init.c
index 731c784e17..f881060d58 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -555,7 +555,7 @@ libc_hidden_def (__res_randomid)
  * This routine is not expected to be user visible.
  */
 void
-res_nclose(res_state statp) {
+__res_iclose(res_state statp, bool free_addr) {
 	int ns;
 
 	if (statp->_vcsock >= 0) {
@@ -568,13 +568,25 @@ res_nclose(res_state statp) {
 #else
 	for (ns = 0; ns < statp->_u._ext.nscount; ns++)
 #endif
-		if (statp->_u._ext.nsaddrs[ns]
-		    && statp->_u._ext.nssocks[ns] != -1) {
-			close_not_cancel_no_status(statp->_u._ext.nssocks[ns]);
-			statp->_u._ext.nssocks[ns] = -1;
+		if (statp->_u._ext.nsaddrs[ns]) {
+			if (statp->_u._ext.nssocks[ns] != -1) {
+				close_not_cancel_no_status(statp->_u._ext.nssocks[ns]);
+				statp->_u._ext.nssocks[ns] = -1;
+			}
+			if (free_addr) {
+				free (statp->_u._ext.nsaddrs[ns]);
+				statp->_u._ext.nsaddrs[ns] = NULL;
+			}
 		}
 	statp->_u._ext.nsinit = 0;
 }
+libc_hidden_def (__res_iclose)
+
+void
+res_nclose(res_state statp)
+{
+  __res_iclose (statp, true);
+}
 #ifdef _LIBC
 libc_hidden_def (__res_nclose)
 #endif
@@ -589,14 +601,7 @@ res_thread_freeres (void)
     /* Never called res_ninit.  */
     return;
 
-  __res_nclose (&_res);		/* Close any VC sockets.  */
-
-  for (int ns = 0; ns < MAXNS; ns++)
-    if (_res._u._ext.nsaddrs[ns] != NULL)
-      {
-	free (_res._u._ext.nsaddrs[ns]);
-	_res._u._ext.nsaddrs[ns] = NULL;
-      }
+  __res_iclose (&_res, true);		/* Close any VC sockets.  */
 
   /* Make sure we do a full re-initialization the next time.  */
   _res.options = 0;