aboutsummaryrefslogtreecommitdiff
path: root/resolv
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2003-02-22 01:58:06 +0000
committerRoland McGrath <roland@gnu.org>2003-02-22 01:58:06 +0000
commit2a3d906e217757e3cbb4f3c089a09a4cb9cb8f75 (patch)
tree967a444f29bb65b4c4b36b66f1b6a36c81b5359e /resolv
parente8783fd53d5d673eab4500d2cac82601f2f802e0 (diff)
downloadglibc-2a3d906e217757e3cbb4f3c089a09a4cb9cb8f75.tar
glibc-2a3d906e217757e3cbb4f3c089a09a4cb9cb8f75.tar.gz
glibc-2a3d906e217757e3cbb4f3c089a09a4cb9cb8f75.tar.bz2
glibc-2a3d906e217757e3cbb4f3c089a09a4cb9cb8f75.zip
* malloc/thread-freeres.c: Conditionalize on _LIBC_REENTRANT.
* sunrpc/rpc_thread.c: Likewise for text_set_element use. (__rpc_thread_destroy): Add it to __libc_subfreeres too. * include/resolv.h: Add libc_hidden_proto for __res_nclose. * resolv/res_init.c (__res_nclose): Add libc_hidden_def. (res_thread_freeres): New function, on __libc_thread_subfreeres and __libc_subfreeres. * malloc/Versions (libc: GLIBC_PRIVATE): Add __libc_thread_freeres. * sunrpc/Versions (libc: GLIBC_PRIVATE): Removed.
Diffstat (limited to 'resolv')
-rw-r--r--resolv/res_init.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/resolv/res_init.c b/resolv/res_init.c
index 764e571029..459694fbd4 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -528,6 +528,7 @@ res_randomid(void) {
libc_hidden_def (__res_randomid)
#endif
+
/*
* This routine is for closing the socket if a virtual circuit is used and
* the program wants to close it. This provides support for endhostent()
@@ -556,3 +557,26 @@ res_nclose(res_state statp) {
}
statp->_u._ext.nsinit = 0;
}
+#ifdef _LIBC
+libc_hidden_def (__res_nclose)
+#endif
+
+#ifdef _LIBC
+# ifdef _LIBC_REENTRANT
+/* This is called when a thread is exiting to free resources held in _res. */
+static void __attribute__ ((section ("__libc_thread_freeres_fn")))
+res_thread_freeres (void)
+{
+ __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;
+ }
+}
+text_set_element (__libc_thread_subfreeres, res_thread_freeres);
+text_set_element (__libc_subfreeres, res_thread_freeres);
+# endif
+#endif