qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: "WangJie (Pluto)" <wangjie88@huawei.com>
Cc: stefanha@redhat.com, famz@redhat.com, eblake@redhat.com,
	qemu-devel@nongnu.org, qemu-block@nongnu.org,
	eric.fangyi@huawei.com, wu.wubin@huawei.com
Subject: Re: [Qemu-devel] [PATCH v4] iothread: fix epollfd leak in the process of delIOThread
Date: Wed, 16 May 2018 19:43:50 +0800	[thread overview]
Message-ID: <20180516114350.GJ9089@xz-mi> (raw)
In-Reply-To: <05498b0c-f729-0a2d-685a-7e81c3550ae4@huawei.com>

On Wed, May 16, 2018 at 07:14:53PM +0800, WangJie (Pluto) wrote:
> Hi, Peter Xu:
> 	If call aio_epoll_disable() here, aio_epoll_disable() will return before close ctx->epollfd,
>     Because the ctx->epoll_enabled is false in the moment.
> 	In the process of addIOThread, aio_context_setup created epoll without call aio_epoll_try_enable,
>     so ctx->epoll_enabled have no chance to set true.

I see that epoll_available will only be set if epollfd != -1, so it
seems to me to make more sense if we swap the two variables in
aio_epoll_disable(), from current version:

static void aio_epoll_disable(AioContext *ctx)
{
    ctx->epoll_available = false;
    if (!ctx->epoll_enabled) {
        return;
    }
    ctx->epoll_enabled = false;
    close(ctx->epollfd);
}

To:

static void aio_epoll_disable(AioContext *ctx)
{
    ctx->epoll_enabled = false;
    if (!ctx->epoll_available) {
        return;
    }
    ctx->epoll_available = false;
    close(ctx->epollfd);
}

What do you think?  And Fam?

> 
> On 2018/5/16 16:36, Jie Wang wrote:
> > +void aio_context_destroy(AioContext *ctx)
> > +{
> > +#ifdef CONFIG_EPOLL_CREATE1
> > +    if (ctx->epollfd >= 0) {
> > +        close(ctx->epollfd);
> > +    }
> > +#endif
> > +}
> > +
> >  void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns,
> >                                   int64_t grow, int64_t shrink, Error **errp)
> 

-- 
Peter Xu

  reply	other threads:[~2018-05-16 11:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-16  8:36 [Qemu-devel] [PATCH v4] iothread: fix epollfd leak in the process of delIOThread Jie Wang
2018-05-16 11:14 ` WangJie (Pluto)
2018-05-16 11:43   ` Peter Xu [this message]
2018-05-17  1:42     ` WangJie (Pluto)
2018-05-17  2:26     ` Fam Zheng
2018-05-16 11:18 ` WangJie (Pluto)

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=20180516114350.GJ9089@xz-mi \
    --to=peterx@redhat.com \
    --cc=eblake@redhat.com \
    --cc=eric.fangyi@huawei.com \
    --cc=famz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=wangjie88@huawei.com \
    --cc=wu.wubin@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 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).