diff options
author | ume <ume@FreeBSD.org> | 2002-10-06 08:43:35 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2002-10-06 08:43:35 +0000 |
commit | 7e81d9c8895c5a191873642d607ff2af18d95efb (patch) | |
tree | c6f531613d00c8ce1b12a87a76fa19988dc234d4 /lib/libc/net/name6.c | |
parent | 6b6614504c30f1641eea24a76e72a1dc37912ef1 (diff) | |
download | FreeBSD-src-7e81d9c8895c5a191873642d607ff2af18d95efb.zip FreeBSD-src-7e81d9c8895c5a191873642d607ff2af18d95efb.tar.gz |
Put giant locks due to make getaddrinfo(), getnameinfo()
and getipnodeby*() thread-safe.
Our res_*() is not thread-safe. So, we share lock between
getaddrinfo() and getipnodeby*(). Still, we cannot use
getaddrinfo() and getipnodeby*() in conjunction with other
functions which call res_*().
Requested by: many people
Diffstat (limited to 'lib/libc/net/name6.c')
-rw-r--r-- | lib/libc/net/name6.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/libc/net/name6.c b/lib/libc/net/name6.c index 26008d0..3840052 100644 --- a/lib/libc/net/name6.c +++ b/lib/libc/net/name6.c @@ -191,6 +191,21 @@ static void _dns_ehent(void); static int _icmp_ghbyaddr(void *, void *, va_list); #endif /* ICMPNL */ +/* Make getipnodeby*() thread-safe in libc for use with kernel threads. */ +#include "libc_private.h" +#include "spinlock.h" +/* + * XXX: Our res_*() is not thread-safe. So, we share lock between + * getaddrinfo() and getipnodeby*(). Still, we cannot use + * getaddrinfo() and getipnodeby*() in conjunction with other + * functions which call res_*(). + */ +extern spinlock_t __getaddrinfo_thread_lock; +#define THREAD_LOCK() \ + if (__isthreaded) _SPINLOCK(&__getaddrinfo_thread_lock); +#define THREAD_UNLOCK() \ + if (__isthreaded) _SPINUNLOCK(&__getaddrinfo_thread_lock); + /* Host lookup order if nsswitch.conf is broken or nonexistant */ static const ns_src default_src[] = { { NSSRC_FILES, NS_SUCCESS }, @@ -277,8 +292,10 @@ _ghbyname(const char *name, int af, int flags, int *errp) } } + THREAD_LOCK(); rval = nsdispatch(&hp, dtab, NSDB_HOSTS, "ghbyname", default_src, name, af, errp); + THREAD_UNLOCK(); return (rval == NS_SUCCESS) ? hp : NULL; } @@ -422,8 +439,10 @@ getipnodebyaddr(const void *src, size_t len, int af, int *errp) return NULL; } + THREAD_LOCK(); rval = nsdispatch(&hp, dtab, NSDB_HOSTS, "ghbyaddr", default_src, src, len, af, errp); + THREAD_UNLOCK(); return (rval == NS_SUCCESS) ? hp : NULL; } |