Locking gethostbyname call, as Alexander notes that it is not thread safe

git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@2865 19bc5d8c-e614-43d4-8b26-e1612bc8e597
This commit is contained in:
kurtis.heimerl
2011-12-24 02:53:10 +00:00
parent bee9289aa0
commit 2e30767716

View File

@@ -40,9 +40,8 @@
#include <stdlib.h>
//mutex for protecting non-thread safe gethostbyname
static Mutex sgGethostbynameLock;
bool resolveAddress(struct sockaddr_in *address, const char *hostAndPort)
{
@@ -63,6 +62,8 @@ bool resolveAddress(struct sockaddr_in *address, const char *host, unsigned shor
{
assert(address);
assert(host);
//gethostbyname not thread safe
ScopedLock lock(sgGethostbynameLock);
// FIXME -- Need to ignore leading/trailing spaces in hostname.
struct hostent *hp = gethostbyname(host);
if (hp==NULL) {