git-svn: trunk@3834
Török Edvin authored on 2008/05/05 02:28:15... | ... |
@@ -4479,6 +4479,9 @@ my_r_gethostbyname(const char *hostname, struct hostent *hp, char *buf, size_t l |
4479 | 4479 |
{ |
4480 | 4480 |
struct hostent *hp2; |
4481 | 4481 |
int ret = -1; |
4482 |
+#ifdef CL_THREAD_SAFE |
|
4483 |
+ static pthread_mutex_t hostent_mutex = PTHREAD_MUTEX_INITIALIZER; |
|
4484 |
+#endif |
|
4482 | 4485 |
|
4483 | 4486 |
if((hostname == NULL) || (hp == NULL)) |
4484 | 4487 |
return -1; |
... | ... |
@@ -4503,9 +4506,8 @@ my_r_gethostbyname(const char *hostname, struct hostent *hp, char *buf, size_t l |
4503 | 4503 |
return h_errno; |
4504 | 4504 |
#else |
4505 | 4505 |
/* Single thread the code e.g. VS2005 */ |
4506 |
-#ifdef CL_THREAD_SAFE |
|
4507 |
- static pthread_mutex_t hostent_mutex = PTHREAD_MUTEX_INITIALIZER; |
|
4508 | 4506 |
|
4507 |
+#ifdef CL_THREAD_SAFE |
|
4509 | 4508 |
pthread_mutex_lock(&hostent_mutex); |
4510 | 4509 |
#endif |
4511 | 4510 |
if((hp2 = gethostbyname(hostname)) == NULL) { |
... | ... |
@@ -62,6 +62,9 @@ int r_gethostbyname(const char *hostname, struct hostent *hp, char *buf, size_t |
62 | 62 |
{ |
63 | 63 |
struct hostent *hp2; |
64 | 64 |
int ret = -1; |
65 |
+#ifdef CL_THREAD_SAFE |
|
66 |
+ static pthread_mutex_t hostent_mutex = PTHREAD_MUTEX_INITIALIZER; |
|
67 |
+#endif |
|
65 | 68 |
|
66 | 69 |
if((hostname == NULL) || (hp == NULL)) |
67 | 70 |
return -1; |
... | ... |
@@ -81,8 +84,6 @@ int r_gethostbyname(const char *hostname, struct hostent *hp, char *buf, size_t |
81 | 81 |
#else |
82 | 82 |
/* Single thread the code e.g. VS2005 */ |
83 | 83 |
#ifdef CL_THREAD_SAFE |
84 |
- static pthread_mutex_t hostent_mutex = PTHREAD_MUTEX_INITIALIZER; |
|
85 |
- |
|
86 | 84 |
pthread_mutex_lock(&hostent_mutex); |
87 | 85 |
#endif |
88 | 86 |
if((hp2 = gethostbyname(hostname)) == NULL) { |