From: Paolo Bonzini <pbonzini@redhat.com>
To: pyssling@ludd.ltu.se, batuzovk@ispras.ru, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3] qemu-char: Fix missed data on unix socket
Date: Fri, 17 Jul 2015 19:28:43 +0200 [thread overview]
Message-ID: <55A93B4B.4060408@redhat.com> (raw)
In-Reply-To: <1437153114-19074-1-git-send-email-pyssling@ludd.ltu.se>
On 17/07/2015 19:11, pyssling@ludd.ltu.se wrote:
> From: Nils Carlson <pyssling@ludd.ltu.se>
>
> Commit 812c1057 introduced HUP detection on unix and tcp sockets prior
> to a read in tcp_chr_read. This unfortunately broke CloudStack 4.2
> which relied on the old behaviour where data on a socket was readable
> even if a HUP was present.
>
> A working solution seems to be to simply check for a HUP after
> reading all available data, i.e. recv returns a negative value.
>
> Signed-off-by: Nils Carlson <pyssling@ludd.ltu.se>
> ---
> qemu-char.c | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/qemu-char.c b/qemu-char.c
> index 617e034..f92fcee 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -2847,12 +2847,6 @@ static gboolean tcp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)
> uint8_t buf[READ_BUF_LEN];
> int len, size;
>
> - if (cond & G_IO_HUP) {
> - /* connection closed */
> - tcp_chr_disconnect(chr);
> - return TRUE;
> - }
> -
> if (!s->connected || s->max_size <= 0) {
> return TRUE;
> }
> @@ -2860,7 +2854,7 @@ static gboolean tcp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)
> if (len > s->max_size)
> len = s->max_size;
> size = tcp_chr_recv(chr, (void *)buf, len);
> - if (size == 0) {
> + if (size == 0 || (size < 0 && (cond & G_IO_HUP))) {
> /* connection closed */
> tcp_chr_disconnect(chr);
> } else if (size > 0) {
>
This looks good, but I'll also wait for your report on testing the patch
that uses the recv return value.
Paolo
prev parent reply other threads:[~2015-07-17 17:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-17 17:11 [Qemu-devel] [PATCH v3] qemu-char: Fix missed data on unix socket pyssling
2015-07-17 17:28 ` Paolo Bonzini [this message]
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=55A93B4B.4060408@redhat.com \
--to=pbonzini@redhat.com \
--cc=batuzovk@ispras.ru \
--cc=pyssling@ludd.ltu.se \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.