mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-05 12:56:08 +00:00
Now, our getservbyname(3) is thread-safe. So, we don't need
to protect it with mutex lock.
This commit is contained in:
parent
96f79dca76
commit
62e8b17d72
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=145118
@ -66,7 +66,6 @@
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "namespace.h"
|
||||
#include "reentrant.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
@ -286,14 +285,6 @@ static int res_searchN(const char *, struct res_target *);
|
||||
static int res_querydomainN(const char *, const char *,
|
||||
struct res_target *);
|
||||
|
||||
/*
|
||||
* XXX: Many dependencies are not thread-safe. Still, we cannot use
|
||||
* getaddrinfo() in conjunction with other functions which call them.
|
||||
*/
|
||||
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. */
|
||||
|
||||
#define GET_AI(ai, afd, addr) \
|
||||
@ -1441,13 +1432,9 @@ get_port(ai, servname, matchonly)
|
||||
break;
|
||||
}
|
||||
|
||||
THREAD_LOCK();
|
||||
if ((sp = getservbyname(servname, proto)) == NULL) {
|
||||
THREAD_UNLOCK();
|
||||
if ((sp = getservbyname(servname, proto)) == NULL)
|
||||
return EAI_SERVICE;
|
||||
}
|
||||
port = sp->s_port;
|
||||
THREAD_UNLOCK();
|
||||
}
|
||||
|
||||
if (!matchonly) {
|
||||
|
Loading…
Reference in New Issue
Block a user