Browse Source

glibc's aio_error is not currently threadsafe...

Samuel Thibault 10 years ago
parent
commit
43d8f35416
1 changed files with 11 additions and 4 deletions
  1. 11 4
      src/core/disk_ops/unistd/disk_unistd_global.c

+ 11 - 4
src/core/disk_ops/unistd/disk_unistd_global.c

@@ -424,16 +424,23 @@ starpu_unistd_global_wait_request(void * async_channel)
 int
 starpu_unistd_global_test_request(void * async_channel)
 {
-        struct aiocb * aiocb = async_channel;
-        int ret;
+        const struct aiocb * aiocb = async_channel;
+        int ret, error;
 
+#ifdef __GLIBC__
+        /* glibc's aio_error was not threadsafe at some point */
+        struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 };
+        ret = aio_suspend(&aiocb, 1, &ts);
+        error = errno;
+#else
         /* Test the answer of the request */
         ret = aio_error(aiocb);
-
+        error = ret;
+#endif
         if (ret == 0)
                 /* request is finished */
                 return 1;
-        if (ret == EINPROGRESS || ret == EAGAIN)
+        if (error == EINPROGRESS || error == EAGAIN)
                 return 0;
         /* an error occured */
         STARPU_ABORT_MSG("aio_error returned %d", errno);