about summary refs log tree commit diff
path: root/sysdeps/posix
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-06-22 15:00:54 -0400
committerUlrich Drepper <drepper@gmail.com>2011-06-22 15:00:54 -0400
commitfa3fc0fe5f452d0aa7e435d8f32e992958683819 (patch)
tree37203438a7bfb2a347803415289aacc6fdf8c82e /sysdeps/posix
parente12df166d37522c2ed434c2d70a1b04640d2d7c6 (diff)
downloadglibc-fa3fc0fe5f452d0aa7e435d8f32e992958683819.tar.gz
glibc-fa3fc0fe5f452d0aa7e435d8f32e992958683819.tar.xz
glibc-fa3fc0fe5f452d0aa7e435d8f32e992958683819.zip
Avoid __check_pf calls in getaddrinfo unless really needed
Diffstat (limited to 'sysdeps/posix')
-rw-r--r--sysdeps/posix/getaddrinfo.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 14e9270b1b..05c883d850 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -2352,14 +2352,17 @@ getaddrinfo (const char *name, const char *service,
   size_t in6ailen = 0;
   bool seen_ipv4 = false;
   bool seen_ipv6 = false;
-  /* We might need information about what interfaces are available.
-     Also determine whether we have IPv4 or IPv6 interfaces or both.  We
-     cannot cache the results since new interfaces could be added at
-     any time.  */
-  __check_pf (&seen_ipv4, &seen_ipv6, &in6ai, &in6ailen);
+  bool check_pf_called = false;
 
   if (hints->ai_flags & AI_ADDRCONFIG)
     {
+      /* We might need information about what interfaces are available.
+	 Also determine whether we have IPv4 or IPv6 interfaces or both.  We
+	 cannot cache the results since new interfaces could be added at
+	 any time.  */
+      __check_pf (&seen_ipv4, &seen_ipv6, &in6ai, &in6ailen);
+      check_pf_called = true;
+
       /* Now make a decision on what we return, if anything.  */
       if (hints->ai_family == PF_UNSPEC && (seen_ipv4 || seen_ipv6))
 	{
@@ -2441,6 +2444,10 @@ getaddrinfo (const char *name, const char *service,
       struct addrinfo *last = NULL;
       char *canonname = NULL;
 
+      /* Now we definitely need the interface information.  */
+      if (! check_pf_called)
+	__check_pf (&seen_ipv4, &seen_ipv6, &in6ai, &in6ailen);
+
       /* If we have information about deprecated and temporary addresses
 	 sort the array now.  */
       if (in6ai != NULL)