D
danu
I'm trying to read asynchronously from a file using aio_read:
/* async I/O structures */
struct aiocb cb;
const struct aiocb* list[1] = { &cb };
int aioRet;
/* set appropriate values in control buffer */
cb.aio_fildes = fromfd;
cb.aio_buf = buffer0;
cb.aio_nbytes = BUFSIZE;
cb.aio_sigevent.sigev_notify = SIGEV_NONE;
while(1) {
/* copy one block asynchronously */
aioRet = aio_read(&cb);
if (aioRet == -1) {
fprintf(stderr, "%s", " aio_read failed:: ");
perror("");
exit(EXIT_FAILURE);
};
count++;
if(count == 5) break;
}
But when I tried to do this I'm getting an error message saying:
aio_read failed:: Invalid argument
I can't move on further in my program because of this read failure.
what's the reason for this?
I highly suspect it's because I'm trying to do aio_read in a while
loop. (when I remove the while loop it seem works) How do I fix this.
Do I have to use aio_suspend ? I tried that but it didn't resolve the
issue. may be I'm using it in a wrong way.
any help would be highly appreciated. Thanks in advance guys.
/* async I/O structures */
struct aiocb cb;
const struct aiocb* list[1] = { &cb };
int aioRet;
/* set appropriate values in control buffer */
cb.aio_fildes = fromfd;
cb.aio_buf = buffer0;
cb.aio_nbytes = BUFSIZE;
cb.aio_sigevent.sigev_notify = SIGEV_NONE;
while(1) {
/* copy one block asynchronously */
aioRet = aio_read(&cb);
if (aioRet == -1) {
fprintf(stderr, "%s", " aio_read failed:: ");
perror("");
exit(EXIT_FAILURE);
};
count++;
if(count == 5) break;
}
But when I tried to do this I'm getting an error message saying:
aio_read failed:: Invalid argument
I can't move on further in my program because of this read failure.
what's the reason for this?
I highly suspect it's because I'm trying to do aio_read in a while
loop. (when I remove the while loop it seem works) How do I fix this.
Do I have to use aio_suspend ? I tried that but it didn't resolve the
issue. may be I'm using it in a wrong way.
any help would be highly appreciated. Thanks in advance guys.