From: Hani Benhabiles <kroosec@gmail.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org,
stefanha@redhat.com, mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH 3/3] nbd: Shutdown socket before closing.
Date: Wed, 4 Jun 2014 23:33:46 +0100 [thread overview]
Message-ID: <20140604222806.GA7620@Inspiron-3521> (raw)
In-Reply-To: <538DB295.2020508@redhat.com>
On Tue, Jun 03, 2014 at 01:33:41PM +0200, Paolo Bonzini wrote:
> 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 <hani@linux.com>
> >---
> > 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?
Yes. Without shutdown(), this could be reproduced (unreliably) on multiple
tries. This is done in nbd_client_close() too, for the same reasons AFAICT.
next prev parent reply other threads:[~2014-06-04 22:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1401572382-11667-1-git-send-email-kroosec@gmail.com>
[not found] ` <1401572382-11667-2-git-send-email-kroosec@gmail.com>
2014-06-02 12:32 ` [Qemu-devel] [PATCH 1/3] nbd: Handle fixed new-style clients Stefan Hajnoczi
2014-06-02 22:09 ` Hani Benhabiles
2014-06-04 8:01 ` Stefan Hajnoczi
[not found] ` <1401572382-11667-4-git-send-email-kroosec@gmail.com>
2014-06-03 11:33 ` [Qemu-devel] [PATCH 3/3] nbd: Shutdown socket before closing Paolo Bonzini
2014-06-04 22:33 ` Hani Benhabiles [this message]
2014-06-05 1:55 ` Paolo Bonzini
2014-06-05 9:58 ` Hani Benhabiles
2014-06-05 10:31 ` Paolo Bonzini
[not found] ` <1401572382-11667-3-git-send-email-kroosec@gmail.com>
2014-06-03 11:36 ` [Qemu-devel] [PATCH 2/3] nbd: Add exports listing support Paolo Bonzini
2014-06-04 22:35 ` Hani Benhabiles
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140604222806.GA7620@Inspiron-3521 \
--to=kroosec@gmail.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).