|
From: | Paolo Bonzini |
Subject: | Re: [Qemu-devel] [RFC 3/5] nbd: Use aio_set_fd_handler2() |
Date: | Fri, 06 Jun 2014 09:44:51 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 |
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. 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.
Paolo
[Prev in Thread] | Current Thread | [Next in Thread] |