Skip to contentSkip to conversation

nbd: use client_close() when negotiate phase fails

PATCH In review Daniel P. Berrange 2 participants 2 messages Jan 19, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nbd: use client_close() when negotiate phase fails

When nbd_negotiate() fails, nbd_co_client_start() is directly calling client->close(). This eventually ends up calling nbd_client_put(), which does an assert(client->closing). Unfortunately we have not set the 'closing' flag, so the code now aborts. This bug was accidentally introduced in

commit ee7d7aabdaea4484e069cb99c9fc54e8cb24b56f
Author: Fam Zheng <[email protected]>
Date: Thu Jan 14 16:41:01 2016 +0800

nbd: Always call "close_fn" in nbd_client_new

The simple fix is to not directly call client->close() but instead call the client_close() method, which takes care todo the right sequence of steps to close the client.

---
 nbd/server.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
nbd/server.c +1 -2
index eead339..c29ba5f 100644
@@ -1080,8 +1080,7 @@ static coroutine_fn void nbd_co_client_start(void *opaque)
         nbd_export_get(exp);
     }
     if (nbd_negotiate(data)) {
-        shutdown(client->sock, 2);
-        client->close(client);
+        client_close(client);
         goto out;
     }
     qemu_co_mutex_init(&client->send_lock);
Signature · 1 line
2.5.0
#1 lore raw
Quoted 11 lines · Daniel P. Berrange

When nbd_negotiate() fails, nbd_co_client_start() is directly calling client->close(). This eventually ends up calling nbd_client_put(), which does an assert(client->closing). Unfortunately we have not set the 'closing' flag, so the code now aborts. This bug was accidentally introduced in

commit ee7d7aabdaea4484e069cb99c9fc54e8cb24b56f
Author: Fam Zheng <[email protected]>
Date: Thu Jan 14 16:41:01 2016 +0800

Quoted 8 lines

nbd: Always call "close_fn" in nbd_client_new

The simple fix is to not directly call client->close() but instead call the client_close() method, which takes care todo the right sequence of steps to close the client.

Good catch, thanks.

Paolo

Quoted 19 lines
---
 nbd/server.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
nbd/server.c +1 -2
index eead339..c29ba5f 100644
@@ -1080,8 +1080,7 @@ static coroutine_fn void nbd_co_client_start(void *opaque)
         nbd_export_get(exp);
     }
     if (nbd_negotiate(data)) {
-        shutdown(client->sock, 2);
-        client->close(client);
+        client_close(client);
         goto out;
     }
     qemu_co_mutex_init(&client->send_lock);