All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] nbd: use client_close() when negotiate phase fails
@ 2016-01-19 11:50 Daniel P. Berrange
  2016-01-19 12:08 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel P. Berrange @ 2016-01-19 11:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Fam Zheng, qemu-block

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 <famz@redhat.com>
  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.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 nbd/server.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/nbd/server.c b/nbd/server.c
index eead339..c29ba5f 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -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);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] nbd: use client_close() when negotiate phase fails
  2016-01-19 11:50 [Qemu-devel] [PATCH] nbd: use client_close() when negotiate phase fails Daniel P. Berrange
@ 2016-01-19 12:08 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2016-01-19 12:08 UTC (permalink / raw)
  To: Daniel P. Berrange, qemu-devel; +Cc: Fam Zheng, qemu-block



On 19/01/2016 12:50, Daniel P. Berrange wrote:
> 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 <famz@redhat.com>
>   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.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

Good catch, thanks.

Paolo

> ---
>  nbd/server.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/nbd/server.c b/nbd/server.c
> index eead339..c29ba5f 100644
> --- a/nbd/server.c
> +++ b/nbd/server.c
> @@ -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);
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-01-19 12:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-19 11:50 [Qemu-devel] [PATCH] nbd: use client_close() when negotiate phase fails Daniel P. Berrange
2016-01-19 12:08 ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.