summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@redhat.com>2010-04-16 19:29:53 +0200
committerAndreas Schwab <schwab@redhat.com>2010-04-16 19:29:53 +0200
commit2e76ab2332a7fb9e73a4047625b915bff93bd427 (patch)
tree40ed21c34ab76442f61f77d98f8e14af96ac3086
parent8bff84622140b61a35c7def2d2baeb87a644b05f (diff)
Fix AIO when thread creation failed
-rw-r--r--rtkaio/sysdeps/unix/sysv/linux/kaio_misc.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/rtkaio/sysdeps/unix/sysv/linux/kaio_misc.c b/rtkaio/sysdeps/unix/sysv/linux/kaio_misc.c
index 76e0c430b7..1b30a9fc8e 100644
--- a/rtkaio/sysdeps/unix/sysv/linux/kaio_misc.c
+++ b/rtkaio/sysdeps/unix/sysv/linux/kaio_misc.c
@@ -1,5 +1,5 @@
/* Handle general operations.
- Copyright (C) 1997,1998,1999,2000,2001,2002,2003,2006
+ Copyright (C) 1997,1998,1999,2000,2001,2002,2003,2006,2010
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -617,7 +617,8 @@ __aio_enqueue_user_request (struct requestlist *newp)
running = newp->running = allocated;
/* Now try to start a thread. */
- if (aio_create_helper_thread (&thid, handle_fildes_io, newp) == 0)
+ result = aio_create_helper_thread (&thid, handle_fildes_io, newp);
+ if (result == 0)
/* We managed to enqueue the request. All errors which can
happen now can be recognized by calls to `aio_return' and
`aio_error'. */
@@ -628,10 +629,14 @@ __aio_enqueue_user_request (struct requestlist *newp)
running = newp->running = yes;
if (nthreads == 0)
- /* We cannot create a thread in the moment and there is
- also no thread running. This is a problem. `errno' is
- set to EAGAIN if this is only a temporary problem. */
- result = -1;
+ {
+ /* We cannot create a thread in the moment and there is
+ also no thread running. This is a problem. `errno' is
+ set to EAGAIN if this is only a temporary problem. */
+ __aio_remove_request (NULL, newp, 0);
+ }
+ else
+ result = 0;
}
}
}
@@ -658,7 +663,7 @@ struct requestlist *
internal_function
__aio_enqueue_request_ctx (aiocb_union *aiocbp, int operation, kctx_t kctx)
{
- int policy, prio;
+ int policy, prio, result;
struct sched_param param;
struct requestlist *newp;
int op = (operation & 0xffff);
@@ -793,10 +798,13 @@ __aio_enqueue_request_ctx (aiocb_union *aiocbp, int operation, kctx_t kctx)
newp->kioctx = KCTX_NONE;
}
- if (__aio_enqueue_user_request (newp))
+ result = __aio_enqueue_user_request (newp);
+ if (result)
{
/* Something went wrong. */
__aio_free_request (newp);
+ aiocbp->aiocb.__error_code = result;
+ __set_errno (result);
newp = NULL;
}