From f1762c0c4b3ba91073f82da02a16d8ee29ed7444 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 3 Aug 2006 08:17:20 +0000 Subject: [BZ #2978] 2006-08-03 Ulrich Drepper * rt/Makefile (tests): Add tst-clock2. * rt/tst-clock2.c: New file. [BZ #2978] * resolv/gai_notify.c (__gai_notify_only): Copy memory for thread function and its parameters and pass it to new thread. (__gai_notify): Add support for alternative waiting for completion. * resolv/gai_suspend.c (gai_suspend): Add support for alternative waiting for completion. * resolv/getaddrinfo_a.c: Likewise. * resolv/gai_misc.h (struct waitlist): Don't add cond if alternative waiting for completion is used. * resolv/gai_misc.c: Allow overwriting code to start helper thread. * resolv/gai_cancel.c: Include not "gai_misc.h". * resolv/gai_error.c: Likewise. * resolv/gai_sigqueue.c: Likewise. * hurd/getdport.c (__detdport): Don't return EBADF; instead set errno to EBADF and return MACH_PORT_NULL. * posix/Makefile (CFLAGS-waitid.c): Add -fasynchronous-unwind-tables. --- resolv/gai_suspend.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'resolv/gai_suspend.c') diff --git a/resolv/gai_suspend.c b/resolv/gai_suspend.c index bb3c9c3402..c2095124b7 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 , 2001. @@ -23,7 +23,7 @@ #include #include -#include "gai_misc.h" +#include 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,9 @@ 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 + GAI_MISC_WAIT (result, cntr, timeout, 1); +#else if (timeout == NULL) result = pthread_cond_wait (&cond, &__gai_requests_mutex); else @@ -99,6 +106,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 +129,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) { -- cgit v1.2.3