From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsURs-00070P-Pa for qemu-devel@nongnu.org; Thu, 05 Jun 2014 05:59:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsURh-0006i4-O4 for qemu-devel@nongnu.org; Thu, 05 Jun 2014 05:59:04 -0400 Received: from mail-wg0-x22d.google.com ([2a00:1450:400c:c00::22d]:34263) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsURh-0006hu-HP for qemu-devel@nongnu.org; Thu, 05 Jun 2014 05:58:53 -0400 Received: by mail-wg0-f45.google.com with SMTP id m15so810457wgh.16 for ; Thu, 05 Jun 2014 02:58:52 -0700 (PDT) Date: Thu, 5 Jun 2014 10:58:45 +0100 From: Hani Benhabiles Message-ID: <20140605095845.GA10811@Inspiron-3521> References: <1401572382-11667-1-git-send-email-kroosec@gmail.com> <1401572382-11667-4-git-send-email-kroosec@gmail.com> <538DB295.2020508@redhat.com> <20140604222806.GA7620@Inspiron-3521> <538FCE1C.5000708@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <538FCE1C.5000708@redhat.com> Subject: Re: [Qemu-devel] [PATCH 3/3] nbd: Shutdown socket before closing. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, mreitz@redhat.com On Thu, Jun 05, 2014 at 03:55:40AM +0200, Paolo Bonzini wrote: > Il 05/06/2014 00:33, Hani Benhabiles ha scritto: > >> IIUC, what this does is ensure that the other side gets a FIN before it gets > >> a RST. Is this correct? > > > >Yes. Without shutdown(), this could be reproduced (unreliably) on multiple > >tries. This is done in nbd_client_close() too, for the same reasons AFAICT. > > Actually, nbd_client_close() is different because it's an abortive close of > the socket. nbd_client_close() doesn't care about FIN vs. RST, it does the > shutdown to force all the requests to fail (with either an error for writes, > or a short read if they're receiving). This will cause a flurry of > nbd_client_put() calls soon after nbd_clint_close() returns, until the last > reference is dropped and the socket is closed. > I see, thanks for the explanation. > I'll apply the patch. Will you apply it directly or should I resend it in v3 ?