Replace use of a spinlock with a mutex.
This commit is contained in:
parent
c72cd7c9e2
commit
e8baaa7062
@ -77,6 +77,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <rpcsvc/yp_prot.h>
|
#include <rpcsvc/yp_prot.h>
|
||||||
#include <rpcsvc/ypclnt.h>
|
#include <rpcsvc/ypclnt.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
#include <pthread.h>
|
||||||
#include <resolv.h>
|
#include <resolv.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -256,20 +257,17 @@ static char *ai_errlist[] = {
|
|||||||
"Unknown error", /* EAI_MAX */
|
"Unknown error", /* EAI_MAX */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Make getaddrinfo() 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
|
* XXX: Our res_*() is not thread-safe. So, we share lock between
|
||||||
* getaddrinfo() and getipnodeby*(). Still, we cannot use
|
* getaddrinfo() and getipnodeby*(). Still, we cannot use
|
||||||
* getaddrinfo() and getipnodeby*() in conjunction with other
|
* getaddrinfo() and getipnodeby*() in conjunction with other
|
||||||
* functions which call res_*().
|
* functions which call res_*().
|
||||||
*/
|
*/
|
||||||
spinlock_t __getaddrinfo_thread_lock = _SPINLOCK_INITIALIZER;
|
pthread_mutex_t __getaddrinfo_thread_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
#define THREAD_LOCK() \
|
#define THREAD_LOCK() \
|
||||||
if (__isthreaded) _SPINLOCK(&__getaddrinfo_thread_lock);
|
if (__isthreaded) _pthread_mutex_lock(&__getaddrinfo_thread_lock);
|
||||||
#define THREAD_UNLOCK() \
|
#define THREAD_UNLOCK() \
|
||||||
if (__isthreaded) _SPINUNLOCK(&__getaddrinfo_thread_lock);
|
if (__isthreaded) _pthread_mutex_unlock(&__getaddrinfo_thread_lock);
|
||||||
|
|
||||||
/* XXX macros that make external reference is BAD. */
|
/* XXX macros that make external reference is BAD. */
|
||||||
|
|
||||||
|
@ -114,6 +114,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <nsswitch.h>
|
#include <nsswitch.h>
|
||||||
|
#include <pthread.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "un-namespace.h"
|
#include "un-namespace.h"
|
||||||
|
|
||||||
@ -189,20 +190,18 @@ static void _dns_ehent(void) __unused;
|
|||||||
static int _icmp_ghbyaddr(void *, void *, va_list);
|
static int _icmp_ghbyaddr(void *, void *, va_list);
|
||||||
#endif /* ICMPNL */
|
#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
|
* XXX: Our res_*() is not thread-safe. So, we share lock between
|
||||||
* getaddrinfo() and getipnodeby*(). Still, we cannot use
|
* getaddrinfo() and getipnodeby*(). Still, we cannot use
|
||||||
* getaddrinfo() and getipnodeby*() in conjunction with other
|
* getaddrinfo() and getipnodeby*() in conjunction with other
|
||||||
* functions which call res_*().
|
* functions which call res_*().
|
||||||
*/
|
*/
|
||||||
extern spinlock_t __getaddrinfo_thread_lock;
|
#include "libc_private.h"
|
||||||
|
extern pthread_mutex_t __getaddrinfo_thread_lock;
|
||||||
#define THREAD_LOCK() \
|
#define THREAD_LOCK() \
|
||||||
if (__isthreaded) _SPINLOCK(&__getaddrinfo_thread_lock);
|
if (__isthreaded) _pthread_mutex_lock(&__getaddrinfo_thread_lock);
|
||||||
#define THREAD_UNLOCK() \
|
#define THREAD_UNLOCK() \
|
||||||
if (__isthreaded) _SPINUNLOCK(&__getaddrinfo_thread_lock);
|
if (__isthreaded) _pthread_mutex_unlock(&__getaddrinfo_thread_lock);
|
||||||
|
|
||||||
/* Host lookup order if nsswitch.conf is broken or nonexistant */
|
/* Host lookup order if nsswitch.conf is broken or nonexistant */
|
||||||
static const ns_src default_src[] = {
|
static const ns_src default_src[] = {
|
||||||
|
Loading…
Reference in New Issue
Block a user