aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-08-15 22:39:07 +0000
committerUlrich Drepper <drepper@redhat.com>2004-08-15 22:39:07 +0000
commit2d26a7173c076ff8f40c9bbdbff80166ff0c781d (patch)
tree2e4085109c65479fe0ecbc587b0dbdbbd03bf9fd
parent28977c2c1acb789660ad47e0d88e42486059c916 (diff)
downloadglibc-2d26a7173c076ff8f40c9bbdbff80166ff0c781d.tar
glibc-2d26a7173c076ff8f40c9bbdbff80166ff0c781d.tar.gz
glibc-2d26a7173c076ff8f40c9bbdbff80166ff0c781d.tar.bz2
glibc-2d26a7173c076ff8f40c9bbdbff80166ff0c781d.zip
Update.
* sysdeps/posix/getaddrinfo.c (gaih_inet): Optimize generation of v4-mapped addresses a bit. (gethosts): Move alloca out of macro, so that it is done only once.
-rw-r--r--ChangeLog4
-rw-r--r--sysdeps/posix/getaddrinfo.c21
2 files changed, 17 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index ef90c576fa..00d62964e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2004-08-15 Ulrich Drepper <drepper@redhat.com>
+ * sysdeps/posix/getaddrinfo.c (gaih_inet): Optimize generation of
+ v4-mapped addresses a bit.
+ (gethosts): Move alloca out of macro, so that it is done only once.
+
* sysdeps/posix/getaddrinfo.c (gaih_addrtuple): Change type of
addr to avoid casts.
(gethosts): Removed.
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 23b74296c1..9de2860323 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -282,18 +282,18 @@ gaih_inet_serv (const char *servicename, const struct gaih_typeproto *tp,
#define gethosts(_family, _type) \
{ \
- int i, herrno; \
- size_t tmpbuflen; \
+ int i; \
+ int herrno; \
struct hostent th; \
- char *tmpbuf = NULL; \
- tmpbuflen = 512; \
no_data = 0; \
- do { \
- tmpbuf = extend_alloca (tmpbuf, tmpbuflen, 2 * tmpbuflen); \
+ while (1) { \
rc = 0; \
status = DL_CALL_FCT (fct, (name, _family, &th, tmpbuf, \
tmpbuflen, &rc, &herrno)); \
- } while (rc == ERANGE && herrno == NETDB_INTERNAL); \
+ if (rc != ERANGE || herrno != NETDB_INTERNAL) \
+ break; \
+ tmpbuf = extend_alloca (tmpbuf, tmpbuflen, 2 * tmpbuflen); \
+ } \
if (status == NSS_STATUS_SUCCESS && rc == 0) \
h = &th; \
else \
@@ -585,6 +585,8 @@ gaih_inet (const char *name, const struct gaih_service *service,
int no_more;
nss_gethostbyname2_r fct;
int old_res_options;
+ size_t tmpbuflen = 512;
+ char *tmpbuf = alloca (tmpbuflen);
if (__nss_hosts_database != NULL)
{
@@ -622,7 +624,10 @@ gaih_inet (const char *name, const struct gaih_service *service,
if (req->ai_family == AF_INET
|| req->ai_family == AF_UNSPEC
|| (req->ai_family == AF_INET6
- && (req->ai_flags & AI_V4MAPPED)))
+ && (req->ai_flags & AI_V4MAPPED)
+ /* Avoid generating the mapped addresses if we
+ know we are not going to need them. */
+ && ((req->ai_flags & AI_ALL) || !got_ipv6)))
{
gethosts (AF_INET, struct in_addr);