From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48442) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsMuK-0007jG-Ad for qemu-devel@nongnu.org; Wed, 04 Jun 2014 21:56:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsMuB-0007BX-A3 for qemu-devel@nongnu.org; Wed, 04 Jun 2014 21:55:56 -0400 Received: from mail-qa0-x229.google.com ([2607:f8b0:400d:c00::229]:60166) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsMuB-0007BT-5X for qemu-devel@nongnu.org; Wed, 04 Jun 2014 21:55:47 -0400 Received: by mail-qa0-f41.google.com with SMTP id dc16so487076qab.14 for ; Wed, 04 Jun 2014 18:55:46 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <538FCE1C.5000708@redhat.com> Date: Thu, 05 Jun 2014 03:55:40 +0200 From: Paolo Bonzini MIME-Version: 1.0 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> In-Reply-To: <20140604222806.GA7620@Inspiron-3521> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: Hani Benhabiles Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, mreitz@redhat.com 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'll apply the patch. Paolo