From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42660) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULDut-0005qm-Bs for qemu-devel@nongnu.org; Thu, 28 Mar 2013 10:35:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ULDur-00006Z-RE for qemu-devel@nongnu.org; Thu, 28 Mar 2013 10:34:59 -0400 Received: from mail-wi0-x229.google.com ([2a00:1450:400c:c05::229]:46368) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULDur-00006T-Li for qemu-devel@nongnu.org; Thu, 28 Mar 2013 10:34:57 -0400 Received: by mail-wi0-f169.google.com with SMTP id c10so3450620wiw.2 for ; Thu, 28 Mar 2013 07:34:56 -0700 (PDT) Date: Thu, 28 Mar 2013 15:34:53 +0100 From: Stefan Hajnoczi Message-ID: <20130328143453.GI22865@stefanha-thinkpad.redhat.com> References: <1364457355-4119-1-git-send-email-qemulist@gmail.com> <1364457355-4119-3-git-send-email-qemulist@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1364457355-4119-3-git-send-email-qemulist@gmail.com> Subject: Re: [Qemu-devel] [RFC PATCH v2 2/4] net: resolve race of tap backend and its peer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liu Ping Fan Cc: Paolo Bonzini , Anthony Liguori , qemu-devel@nongnu.org, mdroth On Thu, Mar 28, 2013 at 03:55:53PM +0800, Liu Ping Fan wrote: > From: Liu Ping Fan > > Signed-off-by: Liu Ping Fan > --- > net/tap.c | 7 ++++++- > 1 files changed, 6 insertions(+), 1 deletions(-) > > diff --git a/net/tap.c b/net/tap.c > index 0b663d1..401161c 100644 > --- a/net/tap.c > +++ b/net/tap.c > @@ -321,9 +321,14 @@ static void tap_cleanup(NetClientState *nc) > static void tap_poll(NetClientState *nc, bool enable) > { > TAPState *s = DO_UPCAST(TAPState, nc, nc); > - /* fixme, when tap backend on another thread, the disable should be sync */ > + > tap_read_poll(s, enable); > tap_write_poll(s, enable); > + > + if (!enable) { > + /* need sync so vhost can take over polling */ > + g_source_remove_poll(&nc->nsrc->source, &nc->nsrc->gfd); > + } Is this necessary? Since we're in tap_poll() we are currently not in poll(2) waiting on the fd. Therefore it's safe for the caller to use the fd, the prepare function will remove it from the fd set before glib calls poll(2) again. Stefan