Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/net centralize res_*init() calls in __res_get_state()
details: https://anonhg.NetBSD.org/src/rev/0bcc0fc41466
branches: trunk
changeset: 566895:0bcc0fc41466
user: christos <christos%NetBSD.org@localhost>
date: Sun May 23 16:54:12 2004 +0000
description:
centralize res_*init() calls in __res_get_state()
diffstat:
lib/libc/net/getaddrinfo.c | 13 +++++--------
lib/libc/net/gethnamaddr.c | 23 ++++++++++++++++-------
lib/libc/net/getnetnamadr.c | 15 ++++-----------
lib/libc/net/hesiod.c | 13 +++++--------
4 files changed, 30 insertions(+), 34 deletions(-)
diffs (200 lines):
diff -r 8893abb0300d -r 0bcc0fc41466 lib/libc/net/getaddrinfo.c
--- a/lib/libc/net/getaddrinfo.c Sun May 23 16:53:22 2004 +0000
+++ b/lib/libc/net/getaddrinfo.c Sun May 23 16:54:12 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getaddrinfo.c,v 1.70 2004/05/21 02:30:03 christos Exp $ */
+/* $NetBSD: getaddrinfo.c,v 1.71 2004/05/23 16:54:12 christos Exp $ */
/* $KAME: getaddrinfo.c,v 1.29 2000/08/31 17:26:57 itojun Exp $ */
/*
@@ -79,7 +79,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getaddrinfo.c,v 1.70 2004/05/21 02:30:03 christos Exp $");
+__RCSID("$NetBSD: getaddrinfo.c,v 1.71 2004/05/23 16:54:12 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -1728,17 +1728,14 @@
int got_nodata = 0, got_servfail = 0, tried_as_is = 0;
res_state res = __res_get_state();
+ if (res == NULL)
+ return -1;
+
_DIAGASSERT(name != NULL);
_DIAGASSERT(target != NULL);
hp = (HEADER *)(void *)target->answer; /*XXX*/
- if ((res->options & RES_INIT) == 0 && res_ninit(res) == -1) {
- h_errno = NETDB_INTERNAL;
- __res_put_state(res);
- return (-1);
- }
-
errno = 0;
h_errno = HOST_NOT_FOUND; /* default, if we never query */
dots = 0;
diff -r 8893abb0300d -r 0bcc0fc41466 lib/libc/net/gethnamaddr.c
--- a/lib/libc/net/gethnamaddr.c Sun May 23 16:53:22 2004 +0000
+++ b/lib/libc/net/gethnamaddr.c Sun May 23 16:54:12 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gethnamaddr.c,v 1.59 2004/05/21 02:30:03 christos Exp $ */
+/* $NetBSD: gethnamaddr.c,v 1.60 2004/05/23 16:54:13 christos Exp $ */
/*
* ++Copyright++ 1985, 1988, 1993
@@ -57,7 +57,7 @@
static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
static char rcsid[] = "Id: gethnamaddr.c,v 8.21 1997/06/01 20:34:37 vixie Exp ";
#else
-__RCSID("$NetBSD: gethnamaddr.c,v 1.59 2004/05/21 02:30:03 christos Exp $");
+__RCSID("$NetBSD: gethnamaddr.c,v 1.60 2004/05/23 16:54:13 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -512,13 +512,11 @@
struct hostent *hp;
res_state res = __res_get_state();
+ if (res == NULL)
+ return NULL;
+
_DIAGASSERT(name != NULL);
- if ((res->options & RES_INIT) == 0 && res_ninit(res) == -1) {
- h_errno = NETDB_INTERNAL;
- __res_put_state(res);
- return NULL;
- }
if (res->options & RES_USE_INET6) {
hp = gethostbyname_internal(name, AF_INET6, res);
if (hp) {
@@ -536,6 +534,9 @@
{
struct hostent *hp;
res_state res = __res_get_state();
+
+ if (res == NULL)
+ return NULL;
hp = gethostbyname_internal(name, af, res);
__res_put_state(res);
return hp;
@@ -765,6 +766,8 @@
len = IN6ADDRSZ;
} else if (inet_pton(AF_INET, p, (char *)(void *)host_addr) > 0) {
res_state res = __res_get_state();
+ if (res == NULL)
+ return NULL;
if (res->options & RES_USE_INET6) {
map_v4v6_address((char *)(void *)host_addr,
(char *)(void *)host_addr);
@@ -827,6 +830,8 @@
#if 0
{
res_state res = __res_get_state();
+ if (res == NULL)
+ return NS_NOTFOUND;
if (res->options & RES_USE_INET6)
hp = _gethtbyname2(name, AF_INET6);
if (hp==NULL)
@@ -1140,6 +1145,8 @@
return NS_NOTFOUND;
}
res = __res_get_state();
+ if (res == NULL)
+ return NS_NOTFOUND;
n = res_nsearch(res, name, C_IN, type, buf->buf, sizeof(buf->buf));
if (n < 0) {
free(buf);
@@ -1217,6 +1224,8 @@
return NS_NOTFOUND;
}
res = __res_get_state();
+ if (res == NULL)
+ return NS_NOTFOUND;
n = res_nquery(res, qbuf, C_IN, T_PTR, buf->buf, sizeof(buf->buf));
if (n < 0 && af == AF_INET6) {
*qp = '\0';
diff -r 8893abb0300d -r 0bcc0fc41466 lib/libc/net/getnetnamadr.c
--- a/lib/libc/net/getnetnamadr.c Sun May 23 16:53:22 2004 +0000
+++ b/lib/libc/net/getnetnamadr.c Sun May 23 16:54:12 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getnetnamadr.c,v 1.30 2004/05/21 02:30:03 christos Exp $ */
+/* $NetBSD: getnetnamadr.c,v 1.31 2004/05/23 16:54:13 christos Exp $ */
/* Copyright (c) 1993 Carlos Leandro and Rui Salgueiro
* Dep. Matematica Universidade de Coimbra, Portugal, Europe
@@ -43,7 +43,7 @@
static char sccsid_[] = "from getnetnamadr.c 1.4 (Coimbra) 93/06/03";
static char rcsid[] = "Id: getnetnamadr.c,v 8.8 1997/06/01 20:34:37 vixie Exp ";
#else
-__RCSID("$NetBSD: getnetnamadr.c,v 1.30 2004/05/21 02:30:03 christos Exp $");
+__RCSID("$NetBSD: getnetnamadr.c,v 1.31 2004/05/23 16:54:13 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -322,11 +322,8 @@
return NS_NOTFOUND;
}
res = __res_get_state();
- if ((res->options & RES_INIT) == 0 && res_ninit(res) == -1) {
- h_errno = NETDB_INTERNAL;
- __res_put_state(res);
+ if (res == NULL)
return NS_NOTFOUND;
- }
anslen = res_nquery(res, qbuf, C_IN, T_PTR, buf->buf, sizeof(buf->buf));
if (anslen < 0) {
free(buf);
@@ -429,12 +426,8 @@
return NS_NOTFOUND;
}
res = __res_get_state();
- if ((res->options & RES_INIT) == 0 && res_ninit(res) == -1) {
- h_errno = NETDB_INTERNAL;
- __res_put_state(res);
+ if (res == NULL)
return NS_NOTFOUND;
- }
-
anslen = res_nsearch(res, qbuf, C_IN, T_PTR, buf->buf,
sizeof(buf->buf));
if (anslen < 0) {
diff -r 8893abb0300d -r 0bcc0fc41466 lib/libc/net/hesiod.c
--- a/lib/libc/net/hesiod.c Sun May 23 16:53:22 2004 +0000
+++ b/lib/libc/net/hesiod.c Sun May 23 16:54:12 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hesiod.c,v 1.21 2004/05/21 02:30:03 christos Exp $ */
+/* $NetBSD: hesiod.c,v 1.22 2004/05/23 16:54:13 christos Exp $ */
/* Copyright (c) 1996 by Internet Software Consortium.
*
@@ -51,7 +51,7 @@
"#Id: hesiod_p.h,v 1.1 1996/12/08 21:39:37 ghudson Exp #");
__IDSTRING(rcsid_hescompat_c,
"#Id: hescompat.c,v 1.1.2.1 1996/12/16 08:37:45 ghudson Exp #");
-__RCSID("$NetBSD: hesiod.c,v 1.21 2004/05/21 02:30:03 christos Exp $");
+__RCSID("$NetBSD: hesiod.c,v 1.22 2004/05/23 16:54:13 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -427,13 +427,10 @@
int ancount, qdcount, i, j, n, skip, type, class, len;
res_state res = __res_get_state();
- _DIAGASSERT(name != NULL);
+ if (res == NULL)
+ return NULL;
- /* Make sure the resolver is initialized. */
- if ((res->options & RES_INIT) == 0 && res_ninit(res) == -1) {
- __res_put_state(res);
- return NULL;
- }
+ _DIAGASSERT(name != NULL);
/* Construct the query. */
n = res_nmkquery(res, QUERY, name, qclass, T_TXT, NULL, 0,
Home |
Main Index |
Thread Index |
Old Index