aboutsummaryrefslogtreecommitdiff
path: root/resolv
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
commit0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (patch)
tree2ea1f8305970753e4a657acb2ccc15ca3eec8e2c /resolv
parent7d58530341304d403a6626d7f7a1913165fe2f32 (diff)
downloadglibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.xz
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.zip
2.5-18.1
Diffstat (limited to 'resolv')
-rw-r--r--resolv/Depend1
-rw-r--r--resolv/Makefile4
-rw-r--r--resolv/Versions2
-rw-r--r--resolv/gai_cancel.c4
-rw-r--r--resolv/gai_error.c4
-rw-r--r--resolv/gai_misc.c32
-rw-r--r--resolv/gai_misc.h4
-rw-r--r--resolv/gai_notify.c53
-rw-r--r--resolv/gai_sigqueue.c36
-rw-r--r--resolv/gai_suspend.c19
-rw-r--r--resolv/getaddrinfo_a.c21
-rw-r--r--resolv/gethnamaddr.c10
-rw-r--r--resolv/herror.c5
-rw-r--r--resolv/inet_ntop.c2
-rw-r--r--resolv/nss_dns/dns-canon.c16
-rw-r--r--resolv/nss_dns/dns-host.c15
-rw-r--r--resolv/nss_dns/dns-network.c47
-rw-r--r--resolv/res-state.c45
-rw-r--r--resolv/res_data.c4
-rw-r--r--resolv/res_debug.c24
-rw-r--r--resolv/res_hconf.c221
-rw-r--r--resolv/res_hconf.h13
-rw-r--r--resolv/res_init.c36
-rw-r--r--resolv/res_libc.c16
-rw-r--r--resolv/res_mkquery.c48
-rw-r--r--resolv/res_query.c6
-rw-r--r--resolv/res_send.c123
-rw-r--r--resolv/tst-inet_ntop.c111
28 files changed, 531 insertions, 391 deletions
diff --git a/resolv/Depend b/resolv/Depend
index fe673ba5ec..8d2587bbc1 100644
--- a/resolv/Depend
+++ b/resolv/Depend
@@ -1 +1,2 @@
linuxthreads
+nptl
diff --git a/resolv/Makefile b/resolv/Makefile
index f6230da8fb..6ac226735a 100644
--- a/resolv/Makefile
+++ b/resolv/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2001,2003,2004
+# Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2001,2003,2004,2007
# Free Software Foundation, Inc.
# This file is part of the GNU C Library.
@@ -32,7 +32,7 @@ distribute := ../conf/portability.h mapv4v6addr.h mapv4v6hostent.h \
routines := herror inet_addr inet_ntop inet_pton nsap_addr res_init \
res_hconf res_libc res-state
-tests = tst-aton tst-leaks
+tests = tst-aton tst-leaks tst-inet_ntop
xtests = tst-leaks2
generate := mtrace-tst-leaks tst-leaks.mtrace tst-leaks2.mtrace
diff --git a/resolv/Versions b/resolv/Versions
index 2a67677d8e..7016365be5 100644
--- a/resolv/Versions
+++ b/resolv/Versions
@@ -39,7 +39,7 @@ libc {
h_errno; __resp;
%endif
- __res_maybe_init;
+ __res_maybe_init; __res_iclose;
}
}
diff --git a/resolv/gai_cancel.c b/resolv/gai_cancel.c
index 45432065c4..19a0a9bb87 100644
--- a/resolv/gai_cancel.c
+++ b/resolv/gai_cancel.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
@@ -20,7 +20,7 @@
#include <netdb.h>
#include <pthread.h>
-#include "gai_misc.h"
+#include <gai_misc.h>
int
diff --git a/resolv/gai_error.c b/resolv/gai_error.c
index 0620b04b9d..4c91628a62 100644
--- a/resolv/gai_error.c
+++ b/resolv/gai_error.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
@@ -19,7 +19,7 @@
#include <netdb.h>
-#include "gai_misc.h"
+#include <gai_misc.h>
int
gai_error (struct gaicb *req)
diff --git a/resolv/gai_misc.c b/resolv/gai_misc.c
index b3334f38ef..2eec0f529d 100644
--- a/resolv/gai_misc.c
+++ b/resolv/gai_misc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
@@ -23,10 +23,31 @@
#include <stdlib.h>
#include <sys/time.h>
-#include "gai_misc.h"
+#include <gai_misc.h>
+#ifndef gai_create_helper_thread
+# define gai_create_helper_thread __gai_create_helper_thread
+
+extern inline int
+__gai_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
+ void *arg)
+{
+ pthread_attr_t attr;
+
+ /* Make sure the thread is created detached. */
+ pthread_attr_init (&attr);
+ pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
+
+ int ret = pthread_create (threadp, &attr, tf, arg);
+
+ (void) pthread_attr_destroy (&attr);
+ return ret;
+}
+#endif
+
+
/* Pool of request list entries. */
static struct requestlist **pool;
@@ -229,16 +250,11 @@ __gai_enqueue_request (struct gaicb *gaicbp)
if (nthreads < optim.gai_threads && idle_thread_count == 0)
{
pthread_t thid;
- pthread_attr_t attr;
newp->running = 1;
- /* Make sure the thread is created detached. */
- pthread_attr_init (&attr);
- pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
-
/* Now try to start a thread. */
- if (pthread_create (&thid, &attr, handle_requests, newp) == 0)
+ if (gai_create_helper_thread (&thid, handle_requests, newp) == 0)
/* We managed to enqueue the request. All errors which can
happen now can be recognized by calls to `gai_error'. */
++nthreads;
diff --git a/resolv/gai_misc.h b/resolv/gai_misc.h
index 48a93977ae..94005de02c 100644
--- a/resolv/gai_misc.h
+++ b/resolv/gai_misc.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
@@ -29,7 +29,9 @@ struct waitlist
{
struct waitlist *next;
+#ifndef DONT_NEED_GAI_MISC_COND
pthread_cond_t *cond;
+#endif
volatile int *counterp;
/* The next field is used in asynchronous `lio_listio' operations. */
struct sigevent *sigevp;
diff --git a/resolv/gai_notify.c b/resolv/gai_notify.c
index 987a64c0e2..c3ce0afb45 100644
--- a/resolv/gai_notify.c
+++ b/resolv/gai_notify.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
@@ -20,15 +20,24 @@
#include <netdb.h>
#include <pthread.h>
#include <stdlib.h>
+#include <gai_misc.h>
-#include "gai_misc.h"
+struct notify_func
+ {
+ void (*func) (sigval_t);
+ sigval_t value;
+ };
static void *
notify_func_wrapper (void *arg)
{
- struct sigevent *sigev = arg;
- sigev->sigev_notify_function (sigev->sigev_value);
+ gai_start_notify_thread ();
+ struct notify_func *const n = arg;
+ void (*func) (sigval_t) = n->func;
+ sigval_t value = n->value;
+ free (n);
+ (*func) (value);
return NULL;
}
@@ -54,8 +63,26 @@ __gai_notify_only (struct sigevent *sigev, pid_t caller_pid)
pattr = &attr;
}
- if (pthread_create (&tid, pattr, notify_func_wrapper, sigev) < 0)
+ /* SIGEV may be freed as soon as we return, so we cannot let the
+ notification thread use that pointer. Even though a sigval_t is
+ only one word and the same size as a void *, we cannot just pass
+ the value through pthread_create as the argument and have the new
+ thread run the user's function directly, because on some machines
+ the calling convention for a union like sigval_t is different from
+ that for a pointer type like void *. */
+ struct notify_func *nf = malloc (sizeof *nf);
+ if (nf == NULL)
result = -1;
+ else
+ {
+ nf->func = sigev->sigev_notify_function;
+ nf->value = sigev->sigev_value;
+ if (pthread_create (&tid, pattr, notify_func_wrapper, nf) < 0)
+ {
+ free (nf);
+ result = -1;
+ }
+ }
}
else if (sigev->sigev_notify == SIGEV_SIGNAL)
/* We have to send a signal. */
@@ -79,15 +106,21 @@ __gai_notify (struct requestlist *req)
{
struct waitlist *next = waitlist->next;
- /* Decrement the counter. This is used in both cases. */
- --*waitlist->counterp;
-
if (waitlist->sigevp == NULL)
- pthread_cond_signal (waitlist->cond);
+ {
+#ifdef DONT_NEED_GAI_MISC_COND
+ GAI_MISC_NOTIFY (waitlist);
+#else
+ /* Decrement the counter. */
+ --*waitlist->counterp;
+
+ pthread_cond_signal (waitlist->cond);
+#endif
+ }
else
/* This is part of a asynchronous `getaddrinfo_a' operation. If
this request is the last one, send the signal. */
- if (*waitlist->counterp == 0)
+ if (--*waitlist->counterp == 0)
{
__gai_notify_only (waitlist->sigevp, waitlist->caller_pid);
/* This is tricky. See getaddrinfo_a.c for the reason why
diff --git a/resolv/gai_sigqueue.c b/resolv/gai_sigqueue.c
new file mode 100644
index 0000000000..278a1d8026
--- /dev/null
+++ b/resolv/gai_sigqueue.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 2001, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <aio.h>
+#include <errno.h>
+#include <signal.h>
+
+#include <gai_misc.h>
+
+int
+__gai_sigqueue (sig, val, caller_pid)
+ int sig;
+ const union sigval val;
+ pid_t caller_pid;
+{
+ __set_errno (ENOSYS);
+ return -1;
+}
+
+stub_warning (__gai_sigqueue)
+#include <stub-tag.h>
diff --git a/resolv/gai_suspend.c b/resolv/gai_suspend.c
index bb3c9c3402..4d85ac2c10 100644
--- a/resolv/gai_suspend.c
+++ b/resolv/gai_suspend.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
@@ -23,7 +23,7 @@
#include <stdlib.h>
#include <sys/time.h>
-#include "gai_misc.h"
+#include <gai_misc.h>
int
@@ -32,9 +32,11 @@ gai_suspend (const struct gaicb *const list[], int ent,
{
struct waitlist waitlist[ent];
struct requestlist *requestlist[ent];
+#ifndef DONT_NEED_GAI_MISC_COND
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+#endif
int cnt;
- int dummy;
+ int cntr = 1;
int none = 1;
int result;
@@ -50,9 +52,11 @@ gai_suspend (const struct gaicb *const list[], int ent,
if (requestlist[cnt] != NULL)
{
+#ifndef DONT_NEED_GAI_MISC_COND
waitlist[cnt].cond = &cond;
+#endif
waitlist[cnt].next = requestlist[cnt]->waiting;
- waitlist[cnt].counterp = &dummy;
+ waitlist[cnt].counterp = &cntr;
waitlist[cnt].sigevp = NULL;
waitlist[cnt].caller_pid = 0; /* Not needed. */
requestlist[cnt]->waiting = &waitlist[cnt];
@@ -78,6 +82,10 @@ gai_suspend (const struct gaicb *const list[], int ent,
which we must remove. So defer cancelation for now. */
pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &oldstate);
+#ifdef DONT_NEED_GAI_MISC_COND
+ result = 0;
+ GAI_MISC_WAIT (result, cntr, timeout, 1);
+#else
if (timeout == NULL)
result = pthread_cond_wait (&cond, &__gai_requests_mutex);
else
@@ -99,6 +107,7 @@ gai_suspend (const struct gaicb *const list[], int ent,
result = pthread_cond_timedwait (&cond, &__gai_requests_mutex,
&abstime);
}
+#endif
/* Now remove the entry in the waiting list for all requests
which didn't terminate. */
@@ -121,10 +130,12 @@ gai_suspend (const struct gaicb *const list[], int ent,
/* Now it's time to restore the cancelation state. */
pthread_setcancelstate (oldstate, NULL);
+#ifndef DONT_NEED_GAI_MISC_COND
/* Release the conditional variable. */
if (pthread_cond_destroy (&cond) != 0)
/* This must never happen. */
abort ();
+#endif
if (result != 0)
{
diff --git a/resolv/getaddrinfo_a.c b/resolv/getaddrinfo_a.c
index abac27d361..f6af3aa45a 100644
--- a/resolv/getaddrinfo_a.c
+++ b/resolv/getaddrinfo_a.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
@@ -23,7 +23,7 @@
#include <stdlib.h>
#include <unistd.h>
-#include "gai_misc.h"
+#include <gai_misc.h>
/* We need this special structure to handle asynchronous I/O. */
@@ -96,7 +96,9 @@ getaddrinfo_a (int mode, struct gaicb *list[], int ent, struct sigevent *sig)
}
else if (mode == GAI_WAIT)
{
+#ifndef DONT_NEED_GAI_MISC_COND
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+#endif
struct waitlist waitlist[ent];
int oldstate;
@@ -104,7 +106,9 @@ getaddrinfo_a (int mode, struct gaicb *list[], int ent, struct sigevent *sig)
for (cnt = 0; cnt < ent; ++cnt)
if (requests[cnt] != NULL)
{
+#ifndef DONT_NEED_GAI_MISC_COND
waitlist[cnt].cond = &cond;
+#endif
waitlist[cnt].next = requests[cnt]->waiting;
waitlist[cnt].counterp = &total;
waitlist[cnt].sigevp = NULL;
@@ -119,15 +123,24 @@ getaddrinfo_a (int mode, struct gaicb *list[], int ent, struct sigevent *sig)
pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &oldstate);
while (total > 0)
- pthread_cond_wait (&cond, &__gai_requests_mutex);
+ {
+#ifdef DONT_NEED_GAI_MISC_COND
+ int result;
+ GAI_MISC_WAIT (result, total, NULL, 1);
+#else
+ pthread_cond_wait (&cond, &__gai_requests_mutex);
+#endif
+ }
/* Now it's time to restore the cancelation state. */
pthread_setcancelstate (oldstate, NULL);
+#ifndef DONT_NEED_GAI_MISC_COND
/* Release the conditional variable. */
if (pthread_cond_destroy (&cond) != 0)
/* This must never happen. */
abort ();
+#endif
}
else
{
@@ -147,7 +160,9 @@ getaddrinfo_a (int mode, struct gaicb *list[], int ent, struct sigevent *sig)
for (cnt = 0; cnt < ent; ++cnt)
if (requests[cnt] != NULL)
{
+#ifndef DONT_NEED_GAI_MISC_COND
waitlist->list[cnt].cond = NULL;
+#endif
waitlist->list[cnt].next = requests[cnt]->waiting;
waitlist->list[cnt].counterp = &waitlist->counter;
waitlist->list[cnt].sigevp = &waitlist->sigev;
diff --git a/resolv/gethnamaddr.c b/resolv/gethnamaddr.c
index 3698e4b841..7be23158d0 100644
--- a/resolv/gethnamaddr.c
+++ b/resolv/gethnamaddr.c
@@ -51,7 +51,6 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$Id$";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -177,11 +176,7 @@ Dprintf(msg, num)
static struct hostent *
-getanswer(answer, anslen, qname, qtype)
- const querybuf *answer;
- int anslen;
- const char *qname;
- int qtype;
+getanswer (const querybuf *answer, int anslen, const char *qname, int qtype)
{
register const HEADER *hp;
register const u_char *cp;
@@ -523,7 +518,6 @@ gethostbyname2(name, af)
char *bp;
int n, size, type, len;
struct hostent *ret;
- extern struct hostent *_gethtbyname2();
if (__res_maybe_init (&_res, 0) == -1) {
__set_h_errno (NETDB_INTERNAL);
@@ -667,7 +661,6 @@ gethostbyaddr(addr, len, af)
u_long old_options;
char hname2[MAXDNAME+1];
#endif /*SUNSECURITY*/
- extern struct hostent *_gethtbyaddr();
if (__res_maybe_init (&_res, 0) == -1) {
__set_h_errno (NETDB_INTERNAL);
@@ -880,7 +873,6 @@ struct hostent *
_gethtbyname(name)
const char *name;
{
- extern struct hostent *_gethtbyname2();
struct hostent *hp;
if (_res.options & RES_USE_INET6) {
diff --git a/resolv/herror.c b/resolv/herror.c
index a61a3a9a4d..0aaf29f9db 100644
--- a/resolv/herror.c
+++ b/resolv/herror.c
@@ -64,14 +64,14 @@ static const char rcsid[] = "$BINDId: herror.c,v 8.11 1999/10/13 16:39:39 vixie
#include <libintl.h>
#include <not-cancel.h>
-const char *h_errlist[] = {
+const char *const h_errlist[] = {
N_("Resolver Error 0 (no error)"),
N_("Unknown host"), /* 1 HOST