[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 10/21] nbd: finish any pending coroutine
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH 10/21] nbd: finish any pending coroutine |
Date: |
Mon, 18 Nov 2013 13:25:20 +0100 |
Make sure all pending coroutines are finished when closing the session.
Signed-off-by: Marc-André Lureau <address@hidden>
---
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
- [Qemu-devel] [PATCH 01/21] vscclient: do not add a socket watch if there is not data to send, (continued)
- [Qemu-devel] [PATCH 01/21] vscclient: do not add a socket watch if there is not data to send, Marc-André Lureau, 2013/11/18
- [Qemu-devel] [PATCH 02/21] spice-char: remove unused field, Marc-André Lureau, 2013/11/18
- [Qemu-devel] [PATCH 03/21] qmp_change_blockdev() remove unused has_format, Marc-André Lureau, 2013/11/18
- [Qemu-devel] [PATCH 04/21] include: add missing config-host.h include, Marc-André Lureau, 2013/11/18
- [Qemu-devel] [PATCH 05/21] char: add qemu_chr_fe_event(), Marc-André Lureau, 2013/11/18
- [Qemu-devel] [PATCH 06/21] Split nbd block client code, Marc-André Lureau, 2013/11/18
- [Qemu-devel] [PATCH 07/21] nbd: don't change socket block during negotiate, Marc-André Lureau, 2013/11/18
- [Qemu-devel] [PATCH 08/21] nbd: pass export name as init argument, Marc-André Lureau, 2013/11/18
- [Qemu-devel] [PATCH 09/21] nbd: make session_close() idempotent, Marc-André Lureau, 2013/11/18
- [Qemu-devel] [PATCH 10/21] nbd: finish any pending coroutine,
Marc-André Lureau <=
- [Qemu-devel] [PATCH 11/21] nbd: avoid uninitialized warnings, Marc-André Lureau, 2013/11/18
- [Qemu-devel] [PATCH 12/21] block: save the associated child name in BlockDriverState, Marc-André Lureau, 2013/11/18
- [Qemu-devel] [PATCH 13/21] blockdev: add qmp_change_blockdev_int(), Marc-André Lureau, 2013/11/18
- [Qemu-devel] [PATCH 14/21] block: extract make_snapshot() from bdrv_open(), Marc-André Lureau, 2013/11/18
- [Qemu-devel] [PATCH 15/21] block: add "snapshot.size" option to avoid extra bdrv_open(), Marc-André Lureau, 2013/11/18
- [Qemu-devel] [PATCH 16/21] block: learn to open a driver with a given opaque, Marc-André Lureau, 2013/11/18
- [Qemu-devel] [PATCH 17/21] block: allow to call bdrv_open() with an opaque, Marc-André Lureau, 2013/11/18
- [Qemu-devel] [PATCH 18/21] block: do not notify change during migration, Marc-André Lureau, 2013/11/18
- [Qemu-devel] [PATCH 19/21] sysemu: add vm_start_hold/release, Marc-André Lureau, 2013/11/18