mirror of
				https://github.com/fairwaves/openbts-2.8.git
				synced 2025-11-03 21:43:16 +00:00 
			
		
		
		
	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:
		@@ -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) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user