From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLV5r-0003tG-9f for qemu-devel@nongnu.org; Tue, 19 Jan 2016 07:09:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLV5q-0008BW-74 for qemu-devel@nongnu.org; Tue, 19 Jan 2016 07:09:03 -0500 Sender: Paolo Bonzini References: <1453204208-10776-1-git-send-email-berrange@redhat.com> From: Paolo Bonzini Message-ID: <569E2753.8020607@redhat.com> Date: Tue, 19 Jan 2016 13:08:51 +0100 MIME-Version: 1.0 In-Reply-To: <1453204208-10776-1-git-send-email-berrange@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] nbd: use client_close() when negotiate phase fails List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , qemu-devel@nongnu.org Cc: Fam Zheng , qemu-block@nongnu.org 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 > 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 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); >