]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Mon, 23 Feb 2004 19:54:06 +0000 (19:54 +0000)
committerUlrich Drepper <drepper@redhat.com>
Mon, 23 Feb 2004 19:54:06 +0000 (19:54 +0000)
2004-02-23  Jakub Jelinek  <jakub@redhat.com>

* sysdeps/posix/getaddrinfo.c (gaih_inet): If _res has not been
inited yet, try to init it before saving old _res.options.
* posix/Makefile (xtests): Add bug-ga2.
(generated): Add bug-ga2.mtrace and bug-ga2-mem.
(xtests): Depend on bug-ga2-mem.
($(objpfx)bug-ga2-mem, bug-ga2-ENV): New.
* posix/bug-ga2.c: New test.

ChangeLog
posix/Makefile
posix/bug-ga2.c [new file with mode: 0644]
sysdeps/posix/getaddrinfo.c

index 93eae38c9c224cd21601d798afd1cd8d4af67cdd..8c365b9781a64ba946b3101b8fa07da3428159b5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2004-02-23  Jakub Jelinek  <jakub@redhat.com>
+
+       * sysdeps/posix/getaddrinfo.c (gaih_inet): If _res has not been
+       inited yet, try to init it before saving old _res.options.
+       * posix/Makefile (xtests): Add bug-ga2.
+       (generated): Add bug-ga2.mtrace and bug-ga2-mem.
+       (xtests): Depend on bug-ga2-mem.
+       ($(objpfx)bug-ga2-mem, bug-ga2-ENV): New.
+       * posix/bug-ga2.c: New test.
+
 2004-02-22  Ulrich Drepper  <drepper@redhat.com>
 
        * sysdeps/unix/sysv/linux/i386/posix_fadvise64.S: Pop register
index 97e0325d08f68dbd946b337e2e52322511d32f45..815c15ab244141374bd04ba419dfcb1a1a1a8e51 100644 (file)
@@ -82,6 +82,7 @@ tests         := tstgetopt testfnm runtests runptests      \
                   bug-regex21 bug-regex22 bug-regex23 tst-nice tst-nanosleep \
                   transbug tst-rxspencer tst-pcre tst-boost \
                   bug-ga1
+xtests         := bug-ga2
 ifeq (yes,$(build-shared))
 test-srcs      := globtest
 tests           += wordexp-test tst-exec tst-spawn
@@ -98,7 +99,8 @@ generated := $(addprefix wordexp-test-result, 1 2 3 4 5 6 7 8 9 10) \
             bug-regex2.mtrace bug-regex14-mem bug-regex14.mtrace \
             bug-regex21-mem bug-regex21.mtrace \
             tst-rxspencer-mem tst-rxspencer.mtrace tst-getconf.out \
-            tst-pcre-mem tst-pcre.mtrace tst-boost-mem tst-boost.mtrace
+            tst-pcre-mem tst-pcre.mtrace tst-boost-mem tst-boost.mtrace \
+            bug-ga2.mtrace bug-ga2-mem
 
 include ../Rules
 
@@ -191,6 +193,7 @@ ifeq (no,$(cross-compiling))
 tests: $(objpfx)bug-regex2-mem $(objpfx)bug-regex14-mem \
   $(objpfx)bug-regex21-mem $(objpfx)tst-rxspencer-mem \
   $(objpfx)tst-pcre-mem $(objpfx)tst-boost-mem $(objpfx)tst-getconf.out
+xtests: $(objpfx)bug-ga2-mem
 endif
 
 $(objpfx)annexc.out: $(objpfx)annexc
@@ -241,3 +244,8 @@ $(objpfx)tst-regex: $(common-objpfx)rt/librt.so
 else
 $(objpfx)tst-regex: $(common-objpfx)rt/librt.a
 endif
+
+$(objpfx)bug-ga2-mem: $(objpfx)bug-ga2.out
+       $(common-objpfx)malloc/mtrace $(objpfx)bug-ga2.mtrace > $@
+
+bug-ga2-ENV = MALLOC_TRACE=$(objpfx)bug-ga2.mtrace
diff --git a/posix/bug-ga2.c b/posix/bug-ga2.c
new file mode 100644 (file)
index 0000000..5ea759b
--- /dev/null
@@ -0,0 +1,30 @@
+/* Test case by Sam Varshavchik <mrsam@courier-mta.com>.  */
+#include <mcheck.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <string.h>
+
+int
+main (void)
+{
+  struct addrinfo hints, *res;
+  int i, ret;
+
+  mtrace ();
+  for (i = 0; i < 100; i++)
+    {
+      memset (&hints, 0, sizeof (hints));
+      hints.ai_family = PF_UNSPEC;
+      hints.ai_socktype = SOCK_STREAM;
+
+      ret = getaddrinfo ("www.gnu.org", "http", &hints, &res);
+
+      if (ret)
+       {
+         printf ("%s\n", gai_strerror (ret));
+         return 1;
+       }
+      freeaddrinfo (res);
+    }
+  return 0;
+}
index 7c192bf2ebde85b06de2026f56cdeffdfdde1893..afdefdfb52cfbf5f33703a14922b6c3e08c785d9 100644 (file)
@@ -604,8 +604,6 @@ gaih_inet (const char *name, const struct gaih_service *service,
          struct gaih_addrtuple **pat = &at;
          int no_data = 0;
          int no_inet6_data = 0;
-         int old_res_options = _res.options;
-
          /* If we are looking for both IPv4 and IPv6 address we don't
             want the lookup functions to automatically promote IPv4
             addresses to IPv6 addresses.  Currently this is decided
@@ -616,6 +614,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
              enum nss_status inet6_status, status = NSS_STATUS_UNAVAIL;
              int no_more;
              nss_gethostbyname2_r fct;
+             int old_res_options;
 
              if (__nss_hosts_database != NULL)
                {
@@ -626,6 +625,9 @@ gaih_inet (const char *name, const struct gaih_service *service,
                no_more = __nss_database_lookup ("hosts", NULL,
                                                 "dns [!UNAVAIL=return] files", &nip);
 
+             if ((_res.options & RES_INIT) == 0 && __res_ninit(&_res) == -1)
+               no_more = 1;
+             old_res_options = _res.options;
              _res.options &= ~RES_USE_INET6;
 
              while (!no_more)