summaryrefslogtreecommitdiff
path: root/libc/inet/resolv.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2005-04-28 18:57:25 +0000
committerEric Andersen <andersen@codepoet.org>2005-04-28 18:57:25 +0000
commit5aa1733024895911ef4e94ed47f81c8df15fef0a (patch)
treeb1256f92274ba7e6a3dcbaf4dda58ad133790b6e /libc/inet/resolv.c
parenta4294fd5e12eeb0ec81e06244096d4a00bae01f3 (diff)
Cleanup error case a bit
Diffstat (limited to 'libc/inet/resolv.c')
-rw-r--r--libc/inet/resolv.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index 752bf7fc1..6ceb07796 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -674,7 +674,7 @@ int __dns_lookup(const char *name, int type, int nscount, char **nsip,
char *dns, *lookup = malloc(MAXDNAME);
int variant = -1;
struct sockaddr_in sa;
- int local_ns, local_id;
+ int local_ns = -1, local_id = -1;
#ifdef __UCLIBC_HAS_IPV6__
int v6;
struct sockaddr_in6 sa6;
@@ -689,12 +689,10 @@ int __dns_lookup(const char *name, int type, int nscount, char **nsip,
/* Mess with globals while under lock */
LOCK;
- local_ns = ns;
+ local_ns = ns % nscount;
local_id = id;
UNLOCK;
- local_ns %= nscount;
-
while (retries < MAX_RETRIES) {
if (fd != -1)
close(fd);
@@ -912,10 +910,12 @@ fail:
free(packet);
h_errno = NETDB_INTERNAL;
/* Mess with globals while under lock */
- LOCK;
- ns = local_ns;
- id = local_id;
- UNLOCK;
+ if (local_ns != -1) {
+ LOCK;
+ ns = local_ns;
+ id = local_id;
+ UNLOCK;
+ }
return -1;
}
#endif