aboutsummaryrefslogtreecommitdiff
path: root/io/channel.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2016-03-07 12:12:36 +0100
committerDaniel P. Berrange <berrange@redhat.com>2016-03-10 17:19:07 +0000
commita58972056776e2f2588aed5a2dc0db7cc28f80b1 (patch)
treec0dd41eda6b2fb73dd1b477b17723c695aa0a6a1 /io/channel.c
parent30fd3e27907dfd1c0c66cc1339657af1a2ce1d4b (diff)
io: implement socket watch for win32 using WSAEventSelect+select
On Win32 we cannot directly poll on socket handles. Instead we create a Win32 event object and associate the socket handle with the event. When the event signals readyness we then have to use select to determine which events are ready. Creating Win32 events is moderately heavyweight, so we don't want todo it every time we create a GSource, so this associates a single event with a QIOChannel. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'io/channel.c')
-rw-r--r--io/channel.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/io/channel.c b/io/channel.c
index 3fc09f887c..dd6fc0eb28 100644
--- a/io/channel.c
+++ b/io/channel.c
@@ -274,10 +274,24 @@ void qio_channel_wait(QIOChannel *ioc,
}
+#ifdef _WIN32
+static void qio_channel_finalize(Object *obj)
+{
+ QIOChannel *ioc = QIO_CHANNEL(obj);
+
+ if (ioc->event) {
+ CloseHandle(ioc->event);
+ }
+}
+#endif
+
static const TypeInfo qio_channel_info = {
.parent = TYPE_OBJECT,
.name = TYPE_QIO_CHANNEL,
.instance_size = sizeof(QIOChannel),
+#ifdef _WIN32
+ .instance_finalize = qio_channel_finalize,
+#endif
.abstract = true,
.class_size = sizeof(QIOChannelClass),
};