* sysdeps/posix/getaddrinfo.c (rfc3484_sort): Store result of
authorUlrich Drepper <drepper@redhat.com>
Thu, 10 Jan 2008 22:30:58 +0000 (22:30 +0000)
committerUlrich Drepper <drepper@redhat.com>
Thu, 10 Jan 2008 22:30:58 +0000 (22:30 +0000)
native interface lookup in all the relevant places.

ChangeLog
sysdeps/posix/getaddrinfo.c

index aaa866e..d2b20c4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-01-10  Ulrich Drepper  <drepper@redhat.com>
+
+       * sysdeps/posix/getaddrinfo.c (rfc3484_sort): Store result of
+       native interface lookup in all the relevant places.
+
 2008-01-10  Jakub Jelinek  <jakub@redhat.com>
            Ulrich Drepper  <drepper@redhat.com>
 
index 23d463d..8746725 100644 (file)
@@ -1363,27 +1363,54 @@ rfc3484_sort (const void *p1, const void *p2, void *arg)
         (most?) cases.  */
       if (a1->index != a2->index)
        {
-         if (a1->native == -1 || a2->native == -1)
+         int a1_native = a1->native;
+         int a2_native = a2->native;
+
+         if (a1_native == -1 || a2_native == -1)
            {
-             /* If we do not have the information use 'native' as the
-                default.  */
-             int a1_native = 0;
-             int a2_native = 0;
-             __check_native (a1->index, &a1_native, a2->index, &a2_native);
+             uint32_t a1_index;
+             if (a1_native == -1)
+               {
+                 /* If we do not have the information use 'native' as
+                    the default.  */
+                 a1_native = 0;
+                 a1_index = a1->index;
+               }
+             else
+               a1_index = 0xffffffffu;
+
+             uint32_t a2_index;
+             if (a2_native == -1)
+               {
+                 /* If we do not have the information use 'native' as
+                    the default.  */
+                 a2_native = 0;
+                 a2_index = a2->index;
+               }
+             else
+               a2_index = 0xffffffffu;
+
+             __check_native (a1_index, &a1_native, a2_index, &a2_native);
 
              /* Fill in the results in all the records.  */
              for (int i = 0; i < src->nresults; ++i)
-               {
-                 if (a1->native == -1 && src->results[i].index == a1->index)
+               if (src->results[i].index == a1_index)
+                 {
+                   assert (src->results[i].native == -1
+                           || src->results[i].native == a1_native);
                    src->results[i].native = a1_native;
-                 if (a2->native == -1 && src->results[i].index == a2->index)
+                 }
+               else if (src->results[i].index == a2_index)
+                 {
+                   assert (src->results[i].native == -1
+                           || src->results[i].native == a2_native);
                    src->results[i].native = a2_native;
-               }
+                 }
            }
 
-         if (a1->native && !a2->native)
+         if (a1_native && !a2_native)
            return -1;
-         if (!a1->native && a2->native)
+         if (!a1_native && a2_native)
            return 1;
        }
     }