static void posix_aio_read(void *opaque)

{

    PosixAioState *s = opaque;

    RawAIOCB *acb, **pacb;

    int ret;

    ssize_t len;



    /* read all bytes from signal pipe */

    for (;;) {

        char bytes[16];



        len = read(s->rfd, bytes, sizeof(bytes));

        if (len == -1 && errno == EINTR)

            continue; /* try again */

        if (len == sizeof(bytes))

            continue; /* more to read */

        break;

    }



    for(;;) {

        pacb = &s->first_aio;

        for(;;) {

            acb = *pacb;

            if (!acb)

                goto the_end;

            ret = aio_error(&acb->aiocb);

            if (ret == ECANCELED) {

                /* remove the request */

                *pacb = acb->next;

                raw_fd_pool_put(acb);

                qemu_aio_release(acb);

            } else if (ret != EINPROGRESS) {

                /* end of aio */

                if (ret == 0) {

                    ret = aio_return(&acb->aiocb);

                    if (ret == acb->aiocb.aio_nbytes)

                        ret = 0;

                    else

                        ret = -EINVAL;

                } else {

                    ret = -ret;

                }

                /* remove the request */

                *pacb = acb->next;

                /* call the callback */

                acb->common.cb(acb->common.opaque, ret);

                raw_fd_pool_put(acb);

                qemu_aio_release(acb);

                break;

            } else {

                pacb = &acb->next;

            }

        }

    }

 the_end: ;

}

static void posix_aio_read(void *opaque)

{

    PosixAioState *s = opaque;

    RawAIOCB *acb, **pacb;

    int ret;

    ssize_t len;



    

    for (;;) {

        char bytes[16];



        len = read(s->rfd, bytes, sizeof(bytes));

        if (len == -1 && errno == EINTR)

            continue; 

        if (len == sizeof(bytes))

            continue; 

        break;

    }



    for(;;) {

        pacb = &s->first_aio;

        for(;;) {

            acb = *pacb;

            if (!acb)

                goto the_end;

            ret = aio_error(&acb->aiocb);

            if (ret == ECANCELED) {

                

                *pacb = acb->next;

                raw_fd_pool_put(acb);

                qemu_aio_release(acb);

            } else if (ret != EINPROGRESS) {

                

                if (ret == 0) {

                    ret = aio_return(&acb->aiocb);

                    if (ret == acb->aiocb.aio_nbytes)

                        ret = 0;

                    else

                        ret = -EINVAL;

                } else {

                    ret = -ret;

                }

                

                *pacb = acb->next;

                

                acb->common.cb(acb->common.opaque, ret);

                raw_fd_pool_put(acb);

                qemu_aio_release(acb);

                break;

            } else {

                pacb = &acb->next;

            }

        }

    }

 the_end: ;

}

static void FUNC_0(void *VAR_0)

{

    PosixAioState *s = VAR_0;

    RawAIOCB *acb, **pacb;

    int VAR_1;

    ssize_t len;



    

    for (;;) {

        char VAR_2[16];



        len = read(s->rfd, VAR_2, sizeof(VAR_2));

        if (len == -1 && errno == EINTR)

            continue; 

        if (len == sizeof(VAR_2))

            continue; 

        break;

    }



    for(;;) {

        pacb = &s->first_aio;

        for(;;) {

            acb = *pacb;

            if (!acb)

                goto the_end;

            VAR_1 = aio_error(&acb->aiocb);

            if (VAR_1 == ECANCELED) {

                

                *pacb = acb->next;

                raw_fd_pool_put(acb);

                qemu_aio_release(acb);

            } else if (VAR_1 != EINPROGRESS) {

                

                if (VAR_1 == 0) {

                    VAR_1 = aio_return(&acb->aiocb);

                    if (VAR_1 == acb->aiocb.aio_nbytes)

                        VAR_1 = 0;

                    else

                        VAR_1 = -EINVAL;

                } else {

                    VAR_1 = -VAR_1;

                }

                

                *pacb = acb->next;

                

                acb->common.cb(acb->common.VAR_0, VAR_1);

                raw_fd_pool_put(acb);

                qemu_aio_release(acb);

                break;

            } else {

                pacb = &acb->next;

            }

        }

    }

 the_end: ;

}

static void FUNC_0(void *VAR_0)
{ PosixAioState *s = VAR_0; RawAIOCB *acb, **pacb; int VAR_1; ssize_t len; for (;;) { char VAR_2[16]; len = read(s->rfd, VAR_2, sizeof(VAR_2)); if (len == -1 && errno == EINTR)
continue; if (len == sizeof(VAR_2))
continue; break; } for(;;) { pacb = &s->first_aio; for(;;) { acb = *pacb; if (!acb)
goto the_end; VAR_1 = aio_error(&acb->aiocb); if (VAR_1 == ECANCELED) { *pacb = acb->next; raw_fd_pool_put(acb); qemu_aio_release(acb); } else if (VAR_1 != EINPROGRESS) { if (VAR_1 == 0) { VAR_1 = aio_return(&acb->aiocb); if (VAR_1 == acb->aiocb.aio_nbytes)
VAR_1 = 0; else
VAR_1 = -EINVAL; } else { VAR_1 = -VAR_1; } *pacb = acb->next; acb->common.cb(acb->common.VAR_0, VAR_1); raw_fd_pool_put(acb); qemu_aio_release(acb); break; } else { pacb = &acb->next; } } } the_end: ; }