summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author"Steven J. Hill" <sjhill@realitydiluted.com>2005-06-03 03:19:48 +0000
committer"Steven J. Hill" <sjhill@realitydiluted.com>2005-06-03 03:19:48 +0000
commitb972f78f0d58d9babfd27074a7207c42bf58df6c (patch)
treed48715202719c1255f8197292b0c2e6e1a9a5ad2
parent26d0cf034b04c3a4f14ae6ead92006b1391af835 (diff)
downloaduClibc-alpine-b972f78f0d58d9babfd27074a7207c42bf58df6c.tar.bz2
uClibc-alpine-b972f78f0d58d9babfd27074a7207c42bf58df6c.tar.xz
Update structures and defines necessary to make resolver code thread
safe for TLS and NPTL. Our name resolver code is so out of date, we made not be able to correctly utilize it in multi-threaded programs compiled with NPTL.
-rw-r--r--include/resolv.h18
-rw-r--r--libc/inet/resolv.c25
2 files changed, 43 insertions, 0 deletions
diff --git a/include/resolv.h b/include/resolv.h
index 815b3a92a..e94247f91 100644
--- a/include/resolv.h
+++ b/include/resolv.h
@@ -217,7 +217,25 @@ typedef struct __res_state *res_state;
/* 0x00008000 */
/* Internal (static) resolver context. */
+/*
+ * NPTL - This code was taken from 'include/resolve.h'
+ * and makes the assumption that our libraries
+ * are reentrant.
+ */
+#ifdef IS_IN_libpthread
+#include <libc-symbols.h>
+#include <tls.h>
+#if USE___THREAD
+# undef _res
+# ifndef NOT_IN_libc
+# define __resp __libc_resp
+# endif
+# define _res (*__resp)
+extern __thread struct __res_state *__resp attribute_tls_model_ie;
+#endif
+#else
extern struct __res_state _res;
+#endif
#ifndef __BIND_NOSTATIC
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index 27b60efea..695ee048b 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -1149,6 +1149,31 @@ void res_close( void )
return;
}
+/*
+ * NPTL - This code was taken from 'resolve/res_libc.c' and
+ * may still be incorrect. Our name resolver code is
+ * so out of date, we made not be able to correctly
+ * utilize it in multi-threaded programs.
+ */
+#ifdef IS_IN_libpthread
+
+/* This needs to be after the use of _res in res_init, above. */
+#undef _res
+
+/* The resolver state for use by single-threaded programs.
+ This differs from plain `struct __res_state _res;' in that it doesn't
+ create a common definition, but a plain symbol that resides in .bss,
+ which can have an alias. */
+struct __res_state _res __attribute__((section (".bss")));
+
+#if USE___THREAD
+#undef __resp
+__thread struct __res_state *__resp = &_res;
+extern __thread struct __res_state *__libc_resp
+ __attribute__ ((alias ("__resp"))) attribute_hidden;
+#endif
+#endif
+
#endif