qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v1 1/1] io/channel-watch.c: Only select on what we a


From: Alistair Francis
Subject: [Qemu-devel] [PATCH v1 1/1] io/channel-watch.c: Only select on what we are actually waiting for
Date: Thu, 13 Jul 2017 03:15:49 -0700

When calling WAEventSelect() only wait on events as specified by the
condition variable. This requires that the condition variable is set
correctly for the specific events that we need to wait for.

Signed-off-by: Alistair Francis <address@hidden>
---

 io/channel-watch.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/io/channel-watch.c b/io/channel-watch.c
index 8640d1c464..d80722f496 100644
--- a/io/channel-watch.c
+++ b/io/channel-watch.c
@@ -286,9 +286,21 @@ GSource *qio_channel_create_socket_watch(QIOChannel *ioc,
     QIOChannelSocketSource *ssource;
 
 #ifdef WIN32
-    WSAEventSelect(socket, ioc->event,
-                   FD_READ | FD_ACCEPT | FD_CLOSE |
-                   FD_CONNECT | FD_WRITE | FD_OOB);
+    long bitmask = 0;
+
+    if (condition & (G_IO_IN | G_IO_PRI)) {
+        bitmask |= FD_READ | FD_ACCEPT;
+    }
+
+    if (condition & G_IO_HUP) {
+        bitmask |= FD_CLOSE;
+    }
+
+    if (condition & G_IO_OUT) {
+        bitmask |= FD_WRITE | FD_CONNECT;
+    }
+
+    WSAEventSelect(socket, ioc->event, bitmask);
 #endif
 
     source = g_source_new(&qio_channel_socket_source_funcs,
-- 
2.11.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]