From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHbiq-0000ja-Ll for qemu-devel@nongnu.org; Fri, 08 Jan 2016 13:25:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aHbip-0001sy-RE for qemu-devel@nongnu.org; Fri, 08 Jan 2016 13:25:12 -0500 References: <1451454566-15005-1-git-send-email-famz@redhat.com> <1451454566-15005-2-git-send-email-famz@redhat.com> <20160108162428.GC24031@redhat.com> From: Paolo Bonzini Message-ID: <568FFEE9.9040303@redhat.com> Date: Fri, 8 Jan 2016 19:24:41 +0100 MIME-Version: 1.0 In-Reply-To: <20160108162428.GC24031@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/2] nbd: Interface tweak of nbd_client_new List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , Fam Zheng Cc: Kevin Wolf , qemu-devel@nongnu.org, qemu-block@nongnu.org On 08/01/2016 17:24, Daniel P. Berrange wrote: >> > if (nbd_send_negotiate(client)) { >> > + shutdown(csock, 2); >> > + close(csock); >> > g_free(client); >> > - return NULL; >> > + ret = -1; >> > + goto out; > If you simply make this failure code branch call close_fn() then I > think you can adding needing the new NBDClientNewCB entirely if.... Good idea, but note that close_fn will call nbd_client_put, so the close/g_free must be removed. It's probably cleanest to change csock to client->sock in the shutdown call, too. Paolo