diff options
Diffstat (limited to 'sysdeps/pthread')
-rw-r--r-- | sysdeps/pthread/aio_misc.h | 5 | ||||
-rw-r--r-- | sysdeps/pthread/aio_notify.c | 10 | ||||
-rw-r--r-- | sysdeps/pthread/aio_suspend.c | 4 | ||||
-rw-r--r-- | sysdeps/pthread/lio_listio.c | 12 |
4 files changed, 22 insertions, 9 deletions
diff --git a/sysdeps/pthread/aio_misc.h b/sysdeps/pthread/aio_misc.h index 44d53b078f..d9aa6e8dd3 100644 --- a/sysdeps/pthread/aio_misc.h +++ b/sysdeps/pthread/aio_misc.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 1999, 2000, 2001, 2003 Free Software Foundation, Inc. +/* Copyright (C) 1997,1999,2000,2001,2003,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 @@ -46,7 +46,10 @@ struct waitlist { struct waitlist *next; + /* The next two fields is used in synchronous `lio_listio' operations. */ pthread_cond_t *cond; + int *result; + volatile int *counterp; /* The next field is used in asynchronous `lio_listio' operations. */ struct sigevent *sigevp; diff --git a/sysdeps/pthread/aio_notify.c b/sysdeps/pthread/aio_notify.c index 877e8d9363..4d2611f0a1 100644 --- a/sysdeps/pthread/aio_notify.c +++ b/sysdeps/pthread/aio_notify.c @@ -1,6 +1,5 @@ /* Notify initiator of AIO request. - Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004 - Free Software Foundation, Inc. + Copyright (C) 1997-2001, 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -148,7 +147,12 @@ __aio_notify (struct requestlist *req) --*waitlist->counterp; if (waitlist->sigevp == NULL) - pthread_cond_signal (waitlist->cond); + { + if (waitlist->result != NULL && aiocbp->__return_value == -1) + *waitlist->result = -1; + + pthread_cond_signal (waitlist->cond); + } else /* This is part of a asynchronous `lio_listio' operation. If this request is the last one, send the signal. */ diff --git a/sysdeps/pthread/aio_suspend.c b/sysdeps/pthread/aio_suspend.c index 8f8e33a7dc..9e3a1ee46e 100644 --- a/sysdeps/pthread/aio_suspend.c +++ b/sysdeps/pthread/aio_suspend.c @@ -1,6 +1,5 @@ /* Suspend until termination of a requests. - Copyright (C) 1997,1998,1999,2000,2002,2003,2005 - Free Software Foundation, Inc. + Copyright (C) 1997-2000,2002,2003,2005,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -113,6 +112,7 @@ aio_suspend (list, nent, timeout) if (requestlist[cnt] != NULL) { waitlist[cnt].cond = &cond; + waitlist[cnt].result = NULL; waitlist[cnt].next = requestlist[cnt]->waiting; waitlist[cnt].counterp = &dummy; waitlist[cnt].sigevp = NULL; diff --git a/sysdeps/pthread/lio_listio.c b/sysdeps/pthread/lio_listio.c index 815840397e..d6ad5a2b48 100644 --- a/sysdeps/pthread/lio_listio.c +++ b/sysdeps/pthread/lio_listio.c @@ -134,6 +134,7 @@ lio_listio_internal (int mode, struct aiocb *const list[], int nent, if (requests[cnt] != NULL && list[cnt]->aio_lio_opcode != LIO_NOP) { waitlist[cnt].cond = &cond; + waitlist[cnt].result = &result; waitlist[cnt].next = requests[cnt]->waiting; waitlist[cnt].counterp = &total; waitlist[cnt].sigevp = NULL; @@ -145,21 +146,25 @@ lio_listio_internal (int mode, struct aiocb *const list[], int nent, } } - /* Since `pthread_cond_wait'/`pthread_cond_timedwait' are cancelation + /* Since `pthread_cond_wait'/`pthread_cond_timedwait' are cancellation points we must be careful. We added entries to the waiting lists - which we must remove. So defer cancelation for now. */ + which we must remove. So defer cancellation for now. */ pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &oldstate); while (total > 0) pthread_cond_wait (&cond, &__aio_requests_mutex); - /* Now it's time to restore the cancelation state. */ + /* Now it's time to restore the cancellation state. */ pthread_setcancelstate (oldstate, NULL); /* Release the conditional variable. */ if (pthread_cond_destroy (&cond) != 0) /* This must never happen. */ abort (); + + /* If any of the I/O requests failed, return -1 and set errno. */ + if (result != 0) + __set_errno (EIO); } else { @@ -189,6 +194,7 @@ lio_listio_internal (int mode, struct aiocb *const list[], int nent, && list[cnt]->aio_lio_opcode != LIO_NOP) { waitlist->list[cnt].cond = NULL; + waitlist->list[cnt].result = NULL; waitlist->list[cnt].next = requests[cnt]->waiting; waitlist->list[cnt].counterp = &waitlist->counter; waitlist->list[cnt].sigevp = &waitlist->sigev; |