Hey Ben,

Looks good to me, thanks,

few inline questions below,


+static bool
> +async_append_is_full(const struct async_append *ap)
> +{
> +    return (ap->aiocb_head - ap->aiocb_tail >= MAX_CBS
> +            || byteq_is_full(&ap->byteq));
> +}
>


Just make sure, "ap->aiocb_head - ap->aiocb_tail > MAX_CBS" won't happen,
right?



> +void

+async_append_write(struct async_append *ap, const void *data_, size_t size)
> +{
> +    const uint8_t *data = data_;
> +
> +    if (!async_append_enabled) {
> +        ignore(write(ap->fd, data, size));
> +        return;
> +    }
> +
> +    while (size > 0) {
> +        struct aiocb *aiocb;
> +        size_t chunk_size;
> +        void *chunk;
> +
> +        while (async_append_is_full(ap)) {
> +            async_append_wait(ap);
> +        }
> +
> +        chunk = byteq_head(&ap->byteq);
> +        chunk_size = byteq_headroom(&ap->byteq);
> +        if (chunk_size > size) {
> +            chunk_size = size;
> +        }
> +        memcpy(chunk, data, chunk_size);
> +
> +        aiocb = &ap->aiocbs[ap->aiocb_head & (MAX_CBS - 1)];
> +        memset(aiocb, 0, sizeof *aiocb);
> +        aiocb->aio_fildes = ap->fd;
> +        aiocb->aio_offset = 0;
> +        aiocb->aio_buf = chunk;
> +        aiocb->aio_nbytes = chunk_size;
> +        aiocb->aio_sigevent.sigev_notify = SIGEV_NONE;
> +        if (aio_write(aiocb) == -1) {
> +            async_append_flush(ap);
> +            ignore(write(ap->fd, data, size));
> +            return;
> +        }
> +
> +        data += chunk_size;
> +        size -= chunk_size;
> +        byteq_advance_head(&ap->byteq, chunk_size);
> +        ap->aiocb_head++;
> +    }
> +}
>


Is there requirement that the "* data_" must not be free'ed before
asynchronously written to 'fd'?



> --
> 1.7.2.5
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to