summaryrefslogtreecommitdiff
path: root/libc/inet
diff options
context:
space:
mode:
Diffstat (limited to 'libc/inet')
-rw-r--r--libc/inet/resolv.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index 389263175..7ac8af805 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -647,17 +647,20 @@ int __form_query(int id, const char *name, int type, unsigned char *packet,
}
#endif
-#ifdef L_dnslookup
+#if defined(L_dnslookup) || defined(L_gethostent)
#ifdef __UCLIBC_HAS_THREADS__
-static pthread_mutex_t dns_mylock = PTHREAD_MUTEX_INITIALIZER;
-# define DNS_LOCK __pthread_mutex_lock(&dns_mylock)
-# define DNS_UNLOCK __pthread_mutex_unlock(&dns_mylock);
+static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER;
+# define LOCK __pthread_mutex_lock(&mylock)
+# define UNLOCK __pthread_mutex_unlock(&mylock);
#else
-# define DNS_LOCK
-# define DNS_UNLOCK
+# define LOCK
+# define UNLOCK
+#endif
#endif
+#ifdef L_dnslookup
+
/* Just for the record, having to lock __dns_lookup() just for these two globals
* is pretty lame. I think these two variables can probably be de-global-ized,
* which should eliminate the need for doing locking here... Needs a closer
@@ -693,10 +696,10 @@ int __dns_lookup(const char *name, int type, int nscount, char **nsip,
DPRINTF("Looking up type %d answer for '%s'\n", type, name);
/* Mess with globals while under lock */
- DNS_LOCK;
+ LOCK;
local_ns = ns % nscount;
local_id = id;
- DNS_UNLOCK;
+ UNLOCK;
while (retries < MAX_RETRIES) {
if (fd != -1)
@@ -900,10 +903,10 @@ int __dns_lookup(const char *name, int type, int nscount, char **nsip,
free(lookup);
/* Mess with globals while under lock */
- DNS_LOCK;
+ LOCK;
ns = local_ns;
id = local_id;
- DNS_UNLOCK;
+ UNLOCK;
return (len); /* success! */
@@ -951,10 +954,10 @@ fail:
h_errno = NETDB_INTERNAL;
/* Mess with globals while under lock */
if (local_ns != -1) {
- DNS_LOCK;
+ LOCK;
ns = local_ns;
id = local_id;
- DNS_UNLOCK;
+ UNLOCK;
}
return -1;
}
@@ -1576,15 +1579,6 @@ int __read_etc_hosts_r(FILE * fp, const char * name, int type,
#ifdef L_gethostent
-#ifdef __UCLIBC_HAS_THREADS__
-static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER;
-# define LOCK __pthread_mutex_lock(&mylock)
-# define UNLOCK __pthread_mutex_unlock(&mylock);
-#else
-# define LOCK
-# define UNLOCK
-#endif
-
static int __stay_open;
static FILE * __gethostent_fp;