All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: linzhecheng <linzhecheng@huawei.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, wangxinxin.wang@huawei.com
Subject: Re: [Qemu-devel] [PATCH] socket: dont't free msgfds if error equals EAGAIN
Date: Wed, 30 May 2018 10:56:37 +0800	[thread overview]
Message-ID: <20180530025637.GB25245@xz-mi> (raw)
In-Reply-To: <20180529025240.520-1-linzhecheng@huawei.com>

On Tue, May 29, 2018 at 10:52:40AM +0800, linzhecheng wrote:
> Signed-off-by: linzhecheng <linzhecheng@huawei.com>
> 
> diff --git a/chardev/char-socket.c b/chardev/char-socket.c
> index 159e69c3b1..17519ec589 100644
> --- a/chardev/char-socket.c
> +++ b/chardev/char-socket.c
> @@ -134,8 +134,8 @@ static int tcp_chr_write(Chardev *chr, const uint8_t *buf, int len)
>                                          s->write_msgfds,
>                                          s->write_msgfds_num);
>  
> -        /* free the written msgfds, no matter what */
> -        if (s->write_msgfds_num) {
> +        /* free the written msgfds in any cases other than errno==EAGAIN */
> +        if (EAGAIN != errno && s->write_msgfds_num) {

This makes sense to me.

Meanwhile this reminds me that we didn't release the fds in
tcp_chr_disconnect().  I'm thinking whether we should do that no
matter what.  E.g., what if we set_msgfds() then another operation
instead of write() failed?

Then here we can only release the msgfds when write succeeded...

  if (ret >= 0 && s->write_msgfds_num) {
 
...as long as we'll also cleanup the msgfds in tcp_chr_disconnect()
always.

I'll see how Marc-Andre and Paolo see this though.

Thanks,

>              g_free(s->write_msgfds);
>              s->write_msgfds = 0;
>              s->write_msgfds_num = 0;
> -- 
> 2.12.2.windows.2
> 
> 
> 

-- 
Peter Xu

  parent reply	other threads:[~2018-05-30  2:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-29  2:52 [Qemu-devel] [PATCH] socket: dont't free msgfds if error equals EAGAIN linzhecheng
2018-05-29  9:11 ` Marc-André Lureau
2018-05-30  2:56 ` Peter Xu [this message]
2018-06-01 11:46 ` Daniel P. Berrangé
2018-05-29  8:20 linzhecheng
2018-05-29  8:41 ` Gonglei (Arei)
2018-05-29  9:33 linzhecheng
2018-05-29 19:33 ` Eric Blake
2018-05-30  9:05   ` Gonglei (Arei)

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=20180530025637.GB25245@xz-mi \
    --to=peterx@redhat.com \
    --cc=linzhecheng@huawei.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wangxinxin.wang@huawei.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 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.