[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3] yield_until_fd_readable: make it work with any AioContect
From: |
Stefan Hajnoczi |
Subject: |
Re: [PATCH v3] yield_until_fd_readable: make it work with any AioContect |
Date: |
Wed, 23 Oct 2019 15:22:58 +0100 |
User-agent: |
Mutt/1.12.1 (2019-06-15) |
On Mon, Oct 21, 2019 at 10:50:55AM +0200, Dietmar Maurer wrote:
> -static void fd_coroutine_enter(void *opaque)
> -{
> - FDYieldUntilData *data = opaque;
> - qemu_set_fd_handler(data->fd, NULL, NULL, NULL);
> - qemu_coroutine_enter(data->co);
> -}
> -
> void coroutine_fn yield_until_fd_readable(int fd)
> {
> - FDYieldUntilData data;
> -
> assert(qemu_in_coroutine());
> - data.co = qemu_coroutine_self();
> - data.fd = fd;
> - qemu_set_fd_handler(fd, fd_coroutine_enter, NULL, &data);
> + AioContext *ctx = qemu_get_current_aio_context();
> + aio_set_fd_handler(ctx, fd, false, (IOHandler *)qemu_coroutine_enter,
> + NULL, NULL, qemu_coroutine_self());
This cast is unsafe. If qemu_coroutine_enter()'s prototype is changed
there will be no compiler warning that the prototypes are now
incompatible.
Please keep fd_coroutine_enter() so the code is type-safe.
signature.asc
Description: PGP signature