diff options
author | kurtis.heimerl <kurtis.heimerl@19bc5d8c-e614-43d4-8b26-e1612bc8e597> | 2011-12-24 02:53:10 +0000 |
---|---|---|
committer | kurtis.heimerl <kurtis.heimerl@19bc5d8c-e614-43d4-8b26-e1612bc8e597> | 2011-12-24 02:53:10 +0000 |
commit | d0093191d0eaed29b1bacb834f0922b95cb0fd6e (patch) | |
tree | 47f48e4b19536b08dc4cfc42e15c78af305c0ead /CommonLibs | |
parent | f041e257770658e378fd3384366681a970aedc3a (diff) |
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
Diffstat (limited to 'CommonLibs')
-rw-r--r-- | CommonLibs/Sockets.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/CommonLibs/Sockets.cpp b/CommonLibs/Sockets.cpp index f24b495..992a486 100644 --- a/CommonLibs/Sockets.cpp +++ b/CommonLibs/Sockets.cpp @@ -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) { |