aio_read Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • danu

    #1

    aio_read Help

    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_FAILU RE);
    };
    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.

  • Keith Thompson

    #2
    Re: aio_read Help

    "danu" <danu82@gmail.c omwrites:
    I'm trying to read asynchronously from a file using aio_read:
    [snip]

    aio_read is not standard C. Try asking in a newsgroup that's specific
    to your system.

    --
    Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.

    Comment

    • Flash Gordon

      #3
      Re: aio_read Help

      danu wrote:
      I'm trying to read asynchronously from a file using aio_read:
      Good luck, aio_read is not part of the C standard so we don't know
      anything about it.
      >
      /* async I/O structures */
      struct aiocb cb;
      Perhaps you should do:
      struct aiocb cb = { 0 };
      to ensure all fields are initialised.

      <snip>
      /* copy one block asynchronously */
      aioRet = aio_read(&cb);
      >
      <snip>
      But when I tried to do this I'm getting an error message saying:
      aio_read failed:: Invalid argument
      <snip>
      any help would be highly appreciated. Thanks in advance guys.
      Try asking in a group dedicated to your system. There you might find
      someone who knows about aio_read.
      --
      Flash Gordon
      Still sigless on this computer.

      Comment

      • William Ahern

        #4
        Re: aio_read Help

        On Mon, 31 Jul 2006 23:17:13 -0700, danu wrote:
        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_FAILU RE);
        };
        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.
        It would indeed look like you're using aio_read improperly. Nothing you're
        doing is asynchronous.
        any help would be highly appreciated. Thanks in advance guys.
        Try comp.unix.progr ammer. The POSIX AIO interface is newish, so you might
        have to exercise some patience.

        Comment

        Working...