--- libaitio/src/aio.c 2012/05/14 12:49:21 1.5 +++ libaitio/src/aio.c 2012/08/01 09:37:20 1.5.14.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aio.c,v 1.5 2012/05/14 12:49:21 misho Exp $ +* $Id: aio.c,v 1.5.14.2 2012/08/01 09:37:20 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -46,6 +46,10 @@ SUCH DAMAGE. #include "global.h" +/* default AIO completion request timeout */ +struct timespec aiots = { 10, 0 }; + + /* * io_rread() - Raw VFS read function * @@ -62,7 +66,7 @@ io_rread(int fd, void * __restrict buf, size_t nbytes, int ret; #ifdef AIO_OPS off_t old = 0; - struct aiocb acb; + struct aiocb acb, *racb; #endif if (!buf) { @@ -102,13 +106,15 @@ io_rread(int fd, void * __restrict buf, size_t nbytes, return -1; } +#if 0 while (aio_error(&acb) == EINPROGRESS); ret = aio_return(&acb); +#endif + ret = aio_waitcomplete(&racb, &aiots); if (ret == -1) { LOGERR; return -1; - } else - ret = acb.aio_nbytes; + } #else ret = pread(fd, buf, nbytes, offset); if (ret == -1) { @@ -138,7 +144,7 @@ io_rwrite(int fd, void * __restrict buf, size_t nbytes { int ret; #ifdef AIO_OPS - struct aiocb acb; + struct aiocb acb, *racb; #endif if (!buf) { @@ -167,13 +173,15 @@ io_rwrite(int fd, void * __restrict buf, size_t nbytes return -1; } +#if 0 while (aio_error(&acb) == EINPROGRESS); ret = aio_return(&acb); +#endif + ret = aio_waitcomplete(&racb, &aiots); if (ret == -1) { LOGERR; return -1; - } else - ret = acb.aio_nbytes; + } #else ret = pwrite(fd, buf, nbytes, offset); if (ret == -1) {