[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 12/13] nbd: finish any pending coroutine
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH 12/13] nbd: finish any pending coroutine |
Date: |
Fri, 29 Nov 2013 15:58:43 +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.4.2
- [Qemu-devel] [PATCH 06/13] char: add qemu_chr_fe_event(), (continued)
- [Qemu-devel] [PATCH 06/13] char: add qemu_chr_fe_event(), Marc-André Lureau, 2013/11/29
- [Qemu-devel] [PATCH 07/13] spice-char: implement chardev port event, Marc-André Lureau, 2013/11/29
- [Qemu-devel] [PATCH 08/13] Split nbd block client code, Marc-André Lureau, 2013/11/29
- [Qemu-devel] [PATCH 09/13] nbd: don't change socket block during negotiate, Marc-André Lureau, 2013/11/29
- [Qemu-devel] [PATCH 10/13] nbd: pass export name as init argument, Marc-André Lureau, 2013/11/29
- [Qemu-devel] [PATCH 11/13] nbd: make session_close() idempotent, Marc-André Lureau, 2013/11/29
- [Qemu-devel] [PATCH 12/13] nbd: finish any pending coroutine,
Marc-André Lureau <=
- [Qemu-devel] [PATCH 13/13] nbd: avoid uninitialized warnings, Marc-André Lureau, 2013/11/29
- Re: [Qemu-devel] [PATCH 00/13] Spice block device, ready-to-go patches, Paolo Bonzini, 2013/11/29