Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
2000-11-22  Ulrich Drepper  <drepper@redhat.com>

	* rt/aio_suspend.c (aio_suspend): Convert timeout value to
	absolute time for pthread_cond_timedwait call.
	Reported by Lawrence Chen <lchen@opentext.com> [libc/1930].

	* rt/Makefile (tests): Add tst-aio6.
	* rt/tst-aio6.c: New file.
  • Loading branch information
Ulrich Drepper committed Nov 23, 2000
1 parent a95d123 commit f14811c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
2000-11-22 Ulrich Drepper <drepper@redhat.com>

* rt/aio_suspend.c (aio_suspend): Convert timeout value to
absolute time for pthread_cond_timedwait call.
Reported by Lawrence Chen <lchen@opentext.com> [libc/1930].

* rt/Makefile (tests): Add tst-aio6.
* rt/tst-aio6.c: New file.

2000-11-23 Andreas Jaeger <aj@suse.de>

* sysdeps/s390/bits/string.h (strncat): Fix one more typo.
Expand Down
2 changes: 1 addition & 1 deletion rt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ include ../Makeconfig
ifeq ($(have-thread-library),yes)

tests := tst-aio tst-aio64 tst-clock tst-shm tst-timer tst-aio2 tst-aio3 \
tst-aio4 tst-aio5
tst-aio4 tst-aio5 tst-aio6

extra-libs := librt
extra-libs-others := $(extra-libs)
Expand Down
25 changes: 21 additions & 4 deletions rt/aio_suspend.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Suspend until termination of a requests.
Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
Expand All @@ -20,7 +20,7 @@


/* We use an UGLY hack to prevent gcc from finding us cheating. The
implementation of aio_suspend and aio_suspend64 are identical and so
implementations of aio_suspend and aio_suspend64 are identical and so
we want to avoid code duplication by using aliases. But gcc sees
the different parameter lists and prints a warning. We define here
a function so that aio_suspend64 has no prototype. */
Expand All @@ -31,6 +31,7 @@

#include <errno.h>
#include <stdlib.h>
#include <sys/time.h>

#include "aio_misc.h"

Expand Down Expand Up @@ -84,8 +85,24 @@ aio_suspend (list, nent, timeout)
if (timeout == NULL)
result = pthread_cond_wait (&cond, &__aio_requests_mutex);
else
result = pthread_cond_timedwait (&cond, &__aio_requests_mutex,
timeout);
{
/* We have to convert the relative timeout value into an
absolute time value with pthread_cond_timedwait expects. */
struct timeval now;
struct timespec abstime;

__gettimeofday (&now, NULL);
abstime.tv_nsec = timeout->tv_nsec + now.tv_usec * 1000;
abstime.tv_sec = timeout->tv_sec + now.tv_sec;
if (abstime.tv_nsec >= 1000000000)
{
abstime.tv_nsec -= 1000000000;
abstime.tv_sec += 1;
}

result = pthread_cond_timedwait (&cond, &__aio_requests_mutex,
&abstime);
}

/* Now remove the entry in the waiting list for all requests
which didn't terminate. */
Expand Down

0 comments on commit f14811c

Please sign in to comment.