summaryrefslogtreecommitdiffstats
path: root/lib/libc/include
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>2004-02-25 21:03:46 +0000
committergreen <green@FreeBSD.org>2004-02-25 21:03:46 +0000
commit40452493ee2a89d18609e7a71f114981ff6a315a (patch)
tree9638e0bc7f96f243bb180d862cc5f1093a53454c /lib/libc/include
parent821b77eba39a417a7e8283015b0d7dcf52875715 (diff)
downloadFreeBSD-src-40452493ee2a89d18609e7a71f114981ff6a315a.zip
FreeBSD-src-40452493ee2a89d18609e7a71f114981ff6a315a.tar.gz
Make the resolver(3) and many associated interfaces much more reentrant.
The getaddrinfo(3), getipnodebyname(3) and resolver(3) can coincide now with what should be totally reentrant, and h_errno values will now be preserved correctly, but this does not affect interfaces such as gethostbyname(3) which are still mostly non-reentrant. In all of these relevant functions, the thread-safety has been pushed down as far as it seems possible right now. This means that operations that are selected via nsdispatch(3) (i.e. files, yp, dns) are protected still under global locks that getaddrinfo(3) defines, but where possible the locking is greatly reduced. The most noticeable improvement is that multiple DNS lookups can now be run at the same time, and this shows major improvement in performance of DNS-lookup threaded programs, and solves the "Mozilla tab serialization" problem. No single-threaded applications need to be recompiled. Multi-threaded applications that reference "_res" to change resolver(3) options will need to be recompiled, and ones which reference "h_errno" will also if they desire the correct h_errno values. If the applications already understood that _res and h_errno were not thread-safe and had their own locking, they will see no performance improvement but will not actually break in any way. Please note that when NSS modules are used, or when nsdispatch(3) defaults to adding any lookups of its own to the individual libc _nsdispatch() calls, those MUST be reentrant as well.
Diffstat (limited to 'lib/libc/include')
-rw-r--r--lib/libc/include/reentrant.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/libc/include/reentrant.h b/lib/libc/include/reentrant.h
index 8ce3af6..8ab328b 100644
--- a/lib/libc/include/reentrant.h
+++ b/lib/libc/include/reentrant.h
@@ -94,10 +94,12 @@
#define mutex_t pthread_mutex_t
#define cond_t pthread_cond_t
#define rwlock_t pthread_rwlock_t
+#define once_t pthread_once_t
#define thread_key_t pthread_key_t
#define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
#define RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER
+#define ONCE_INITIALIZER PTHREAD_ONCE_INIT
#define mutex_init(m, a) _pthread_mutex_init(m, a)
#define mutex_lock(m) if (__isthreaded) \
@@ -127,6 +129,7 @@
#define thr_getspecific(k) _pthread_getspecific(k)
#define thr_sigsetmask(f, n, o) _pthread_sigmask(f, n, o)
+#define thr_once(o, i) _pthread_once(o, i)
#define thr_self() _pthread_self()
#define thr_exit(x) _pthread_exit(x)
#define thr_main() _pthread_main_np()
OpenPOWER on IntegriCloud