From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34448) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrmyW-0007qw-25 for qemu-devel@nongnu.org; Tue, 03 Jun 2014 07:33:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WrmyQ-0006oT-Ui for qemu-devel@nongnu.org; Tue, 03 Jun 2014 07:33:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49136) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrmyQ-0006oK-N1 for qemu-devel@nongnu.org; Tue, 03 Jun 2014 07:33:46 -0400 Message-ID: <538DB295.2020508@redhat.com> Date: Tue, 03 Jun 2014 13:33:41 +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> In-Reply-To: <1401572382-11667-4-git-send-email-kroosec@gmail.com> Content-Type: text/plain; charset=ISO-8859-15; 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 , qemu-devel@nongnu.org Cc: kwolf@redhat.com, famz@redhat.com, stefanha@redhat.com, mreitz@redhat.com Il 31/05/2014 23:39, Hani Benhabiles ha scritto: > This forces finishing data sending to client before closing the socket like in > exports listing or replying with NBD_REP_ERR_UNSUP cases. > > Signed-off-by: Hani Benhabiles > --- > blockdev-nbd.c | 1 + > qemu-nbd.c | 1 + > 2 files changed, 2 insertions(+) > > diff --git a/blockdev-nbd.c b/blockdev-nbd.c > index b60b66d..e609f66 100644 > --- a/blockdev-nbd.c > +++ b/blockdev-nbd.c > @@ -28,6 +28,7 @@ static void nbd_accept(void *opaque) > > int fd = accept(server_fd, (struct sockaddr *)&addr, &addr_len); > if (fd >= 0 && !nbd_client_new(NULL, fd, nbd_client_put)) { > + shutdown(fd, SHUT_RDWR); > close(fd); > } > } > diff --git a/qemu-nbd.c b/qemu-nbd.c > index ba60436..bf42861 100644 > --- a/qemu-nbd.c > +++ b/qemu-nbd.c > @@ -372,6 +372,7 @@ static void nbd_accept(void *opaque) > if (nbd_client_new(exp, fd, nbd_client_closed)) { > nb_fds++; > } else { > + shutdown(fd, SHUT_RDWR); > close(fd); > } > } > IIUC, what this does is ensure that the other side gets a FIN before it gets a RST. Is this correct? Paolo