qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC 3/5] nbd: Use aio_set_fd_handler2()


From: Max Reitz
Subject: Re: [Qemu-devel] [RFC 3/5] nbd: Use aio_set_fd_handler2()
Date: Sat, 07 Jun 2014 21:27:26 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

On 06.06.2014 09:44, Paolo Bonzini wrote:
Il 05/06/2014 20:18, Max Reitz ha scritto:

Why is this design cleaner?  Because NBD code doesn't have to worry
about fd handlers.  It uses straightforward coroutine send/recv for
socket I/O inside nbd_read_req() and nbd_write_resp(). It's easy to see
that only one coroutine receives from the socket and that only one
coroutine writes to the socket.

Yes, this sounds better. I'll take a look into it and see how far I can
get.

But it doesn't solve any problem, and requires rethinking the aio_set_fd_handler API.

It might clean things up. :-)

On the other hand, you are right, it's probably too complicated right now.

I suggest you just refactor all calls to qemu_set_fd_handler2 into a function like

    qemu_set_fd_handler2(fd, NULL,
                 nbd_can_read(client) ? nbd_read : NULL,
                 client->send_coroutine ?
                    nbd_restart_write : NULL,
                 opaque);

and call this function every time the result of nbd_can_read() changes. Then you can switch to aio_set_fd_handler easily.

Seems good, I'll do that.

Max



reply via email to

[Prev in Thread] Current Thread [Next in Thread]