Make sure all pending coroutines are finished when closing the session. Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxx> --- block/nbd-client.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/block/nbd-client.c b/block/nbd-client.c index c0ad2c2..ad6fb01 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -32,6 +32,18 @@ #define HANDLE_TO_INDEX(bs, handle) ((handle) ^ ((uint64_t)(intptr_t)bs)) #define INDEX_TO_HANDLE(bs, index) ((index) ^ ((uint64_t)(intptr_t)bs)) +static void nbd_recv_coroutines_enter_all(NbdClientSession *s) +{ + int i; + + for (i = 0; i < MAX_NBD_REQUESTS; i++) { + if (s->recv_coroutine[i]) { + fprintf(stderr, "*nbd reply enter: %p %d\n", s, s->reply.error); + qemu_coroutine_enter(s->recv_coroutine[i], NULL); + } + } +} + static void nbd_reply_ready(void *opaque) { NbdClientSession *s = opaque; @@ -67,11 +79,7 @@ static void nbd_reply_ready(void *opaque) } fail: - for (i = 0; i < MAX_NBD_REQUESTS; i++) { - if (s->recv_coroutine[i]) { - qemu_coroutine_enter(s->recv_coroutine[i], NULL); - } - } + nbd_recv_coroutines_enter_all(s); } static void nbd_restart_write(void *opaque) @@ -332,6 +340,10 @@ static void nbd_teardown_connection(NbdClientSession *client) qemu_aio_set_fd_handler(client->sock, NULL, NULL, NULL); closesocket(client->sock); + /* finish any pending coroutines */ + client->reply.handle = 0; + client->reply.error = EIO; + nbd_recv_coroutines_enter_all(client); client->sock = -1; } -- 1.8.3.1 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel