From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52543) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYoww-0007zW-Gq for qemu-devel@nongnu.org; Mon, 07 Sep 2015 01:26:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYowv-0004SM-Ov for qemu-devel@nongnu.org; Mon, 07 Sep 2015 01:26:38 -0400 Date: Mon, 7 Sep 2015 13:26:29 +0800 From: Fam Zheng Message-ID: <20150907052629.GB3958@ad.nay.redhat.com> References: <1438144934-23619-1-git-send-email-famz@redhat.com> <1438144934-23619-8-git-send-email-famz@redhat.com> <20150827172338.GG4917@stefanha-thinkpad.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150827172338.GG4917@stefanha-thinkpad.redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 07/11] aio-posix: introduce aio_{disable, enable}_clients List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org On Thu, 08/27 18:23, Stefan Hajnoczi wrote: > On Wed, Jul 29, 2015 at 12:42:10PM +0800, Fam Zheng wrote: > > +void aio_disable_enable_clients(AioContext *ctx, int clients_mask, > > + bool is_disable) > > +{ > > + AioHandler *node; > > + aio_context_acquire(ctx); > > + > > + QLIST_FOREACH(node, &ctx->aio_handlers, node) { > > + if (!node->deleted && node->type & clients_mask) { > > + node->disable_cnt += is_disable ? 1 : -1; > > + } > > + } > > + aio_context_release(ctx); > > +} > > If someone adds an fd of a disabled type *after* the call to > aio_disable_clients() then it won't be disabled. > > Another approach is to keep an array of counters per AioContext and > check the counters during aio_poll() when deciding which fds to monitor. Good idea, I'll change that way. > > Also, this function acquires/releases AioContext so it's worth > mentioning in the doc comments that this function is thread-safe. > OK. Fam