Patchwork [RFC,v3,3/5] net: resolve race of tap backend and its peer

login
register
mail settings
Submitter pingfank@linux.vnet.ibm.com
Date April 8, 2013, 5:36 a.m.
Message ID <1365399368-26967-4-git-send-email-pingfank@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/234580/
State New
Headers show

Comments

pingfank@linux.vnet.ibm.com - April 8, 2013, 5:36 a.m.
When vhost net enabled, we should be sure that the user space
fd handler is not in flight

Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
---
 net/tap.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

Patch

diff --git a/net/tap.c b/net/tap.c
index e19bb07..a3947eb 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -324,6 +324,11 @@  static void tap_poll(NetClientState *nc, bool enable)
     /* 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)