diff options
author | Ulrich Drepper <drepper@redhat.com> | 2005-11-27 23:13:21 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2005-11-27 23:13:21 +0000 |
commit | 01abbc0f7f1e0f88532664ecc3592b30b1c871d0 (patch) | |
tree | b629fc0fcd29ecc60acd1365b7c6ac4b2573d985 | |
parent | da09af7627661660b947857851f6154d2568f89f (diff) | |
download | glibc-01abbc0f7f1e0f88532664ecc3592b30b1c871d0.tar.gz glibc-01abbc0f7f1e0f88532664ecc3592b30b1c871d0.tar.xz glibc-01abbc0f7f1e0f88532664ecc3592b30b1c871d0.zip |
* sysdeps/posix/getaddrinfo.c: Avoid RFC 3484 sorting if there are
multiple return records but only one address.
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | sysdeps/posix/getaddrinfo.c | 13 |
2 files changed, 12 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog index 9bb4c72ed0..2b56ff887f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2005-11-27 Ulrich Drepper <drepper@redhat.com> + * sysdeps/posix/getaddrinfo.c: Avoid RFC 3484 sorting if there are + multiple return records but only one address. + * sysdeps/posix/getaddrinfo.c (gaih_inet): Avoid some code duplication. 2005-11-27 Roland McGrath <roland@redhat.com> diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index b85b68c925..b9819bfc0a 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -121,7 +121,8 @@ struct gaih { int family; int (*gaih)(const char *name, const struct gaih_service *service, - const struct addrinfo *req, struct addrinfo **pai); + const struct addrinfo *req, struct addrinfo **pai, + unsigned int *naddrs); }; static const struct addrinfo default_hints = @@ -363,7 +364,8 @@ extern service_user *__nss_hosts_database attribute_hidden; static int gaih_inet (const char *name, const struct gaih_service *service, - const struct addrinfo *req, struct addrinfo **pai) + const struct addrinfo *req, struct addrinfo **pai, + unsigned int *naddrs) { const struct gaih_typeproto *tp = gaih_inet_typeproto; struct gaih_servtuple *st = (struct gaih_servtuple *) &nullserv; @@ -1087,6 +1089,8 @@ gaih_inet (const char *name, const struct gaih_service *service, } *pai = NULL; + ++*naddrs; + ignore: at2 = at2->next; } @@ -1535,6 +1539,7 @@ getaddrinfo (const char *name, const char *service, else end = NULL; + unsigned int naddrs = 0; while (g->gaih) { if (hints->ai_family == g->family || hints->ai_family == AF_UNSPEC) @@ -1543,7 +1548,7 @@ getaddrinfo (const char *name, const char *service, if (pg == NULL || pg->gaih != g->gaih) { pg = g; - i = g->gaih (name, pservice, hints, end); + i = g->gaih (name, pservice, hints, end, &naddrs); if (i != 0) { /* EAI_NODATA is a more specific result as it says that @@ -1575,7 +1580,7 @@ getaddrinfo (const char *name, const char *service, if (j == 0) return EAI_FAMILY; - if (nresults > 1) + if (naddrs > 1) { /* Sort results according to RFC 3484. */ struct sort_result results[nresults]; |