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>
{
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 =
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;
}
*pai = NULL;
+ ++*naddrs;
+
ignore:
at2 = at2->next;
}
else
end = NULL;
+ unsigned int naddrs = 0;
while (g->gaih)
{
if (hints->ai_family == g->family || hints->ai_family == AF_UNSPEC)
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
if (j == 0)
return EAI_FAMILY;
- if (nresults > 1)
+ if (naddrs > 1)
{
/* Sort results according to RFC 3484. */
struct sort_result results[nresults];