From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:52544) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UL7hJ-0006KL-QO for qemu-devel@nongnu.org; Thu, 28 Mar 2013 03:56:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UL7hI-0007TJ-Ub for qemu-devel@nongnu.org; Thu, 28 Mar 2013 03:56:33 -0400 Received: from mail-ia0-x22d.google.com ([2607:f8b0:4001:c02::22d]:61987) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UL7hI-0007T5-Pl for qemu-devel@nongnu.org; Thu, 28 Mar 2013 03:56:32 -0400 Received: by mail-ia0-f173.google.com with SMTP id h37so8084911iak.4 for ; Thu, 28 Mar 2013 00:56:32 -0700 (PDT) From: Liu Ping Fan Date: Thu, 28 Mar 2013 15:55:53 +0800 Message-Id: <1364457355-4119-3-git-send-email-qemulist@gmail.com> In-Reply-To: <1364457355-4119-1-git-send-email-qemulist@gmail.com> References: <1364457355-4119-1-git-send-email-qemulist@gmail.com> Subject: [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: qemu-devel@nongnu.org Cc: Paolo Bonzini , Anthony Liguori , mdroth , Stefan Hajnoczi 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); + } } int tap_get_fd(NetClientState *nc) -- 1.7.4.4