- we are no longer shareing any resources to be locked between

getaddrinfo(3) and getipnodeby*(3).
- use definitions in reentrant.h.
- remove obsolete comment.
This commit is contained in:
Hajimu UMEMOTO 2005-04-06 15:36:34 +00:00
parent 1b482912d1
commit 2424b11851
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=144715
2 changed files with 12 additions and 27 deletions

View File

@ -66,6 +66,7 @@
__FBSDID("$FreeBSD$");
#include "namespace.h"
#include "reentrant.h"
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
@ -84,7 +85,6 @@ __FBSDID("$FreeBSD$");
#include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h>
#include <netdb.h>
#include <pthread.h>
#include <resolv.h>
#include <string.h>
#include <stdlib.h>
@ -287,16 +287,12 @@ static int res_querydomainN(const char *, const char *,
struct res_target *);
/*
* XXX: Many dependencies are 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 them.
* XXX: Many dependencies are not thread-safe. Still, we cannot use
* getaddrinfo() in conjunction with other functions which call them.
*/
pthread_mutex_t __getaddrinfo_thread_lock = PTHREAD_MUTEX_INITIALIZER;
#define THREAD_LOCK() \
if (__isthreaded) _pthread_mutex_lock(&__getaddrinfo_thread_lock);
#define THREAD_UNLOCK() \
if (__isthreaded) _pthread_mutex_unlock(&__getaddrinfo_thread_lock);
static mutex_t _getaddrinfo_thread_lock = MUTEX_INITIALIZER;
#define THREAD_LOCK() mutex_lock(&_getaddrinfo_thread_lock);
#define THREAD_UNLOCK() mutex_unlock(&_getaddrinfo_thread_lock);
/* XXX macros that make external reference is BAD. */

View File

@ -87,16 +87,11 @@
* Atsushi Onoe <onoe@sm.sony.co.jp>
*/
/*
* TODO for thread safe
* use mutex for _hostconf, _hostconf_init.
* rewrite resolvers to be thread safe
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "namespace.h"
#include "reentrant.h"
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/time.h>
@ -121,7 +116,6 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <stdarg.h>
#include <nsswitch.h>
#include <pthread.h>
#include <unistd.h>
#include "un-namespace.h"
@ -238,17 +232,12 @@ static int _icmp_ghbyaddr(void *, void *, va_list);
#endif /* ICMPNL */
/*
* XXX: Many dependencies are 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 them.
* XXX: Many dependencies are not thread-safe. Still, we cannot use
* getipnodeby*() in conjunction with other functions which call them.
*/
#include "libc_private.h"
extern pthread_mutex_t __getaddrinfo_thread_lock;
#define THREAD_LOCK() \
if (__isthreaded) _pthread_mutex_lock(&__getaddrinfo_thread_lock);
#define THREAD_UNLOCK() \
if (__isthreaded) _pthread_mutex_unlock(&__getaddrinfo_thread_lock);
static mutex_t _getipnodeby_thread_lock = MUTEX_INITIALIZER;
#define THREAD_LOCK() mutex_lock(&_getipnodeby_thread_lock);
#define THREAD_UNLOCK() mutex_unlock(&_getipnodeby_thread_lock);
/* Host lookup order if nsswitch.conf is broken or nonexistant */
static const ns_src default_src[] = {