summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabiano FidĂȘncio <fidencio@redhat.com>2015-07-22 03:57:18 +0200
committerFabiano FidĂȘncio <fidencio@redhat.com>2015-07-22 14:56:57 +0200
commit3281c47e8b03cd0072c5ac18e97f1a36d08ec485 (patch)
tree6ade70b8615c494780ec7b752bc10ad75a92ff8a
parent0e0f021dec03bc7a8ef776c258b886d616e65eb2 (diff)
events: don't create glib IO watch for disabled handles
It's possible to create a handle to watch for file events which do not watch for any file event. Such a handle can be enabled later with virt_viewer_events_update_handle() by setting some conditions to watch for. When a handle is disabled after it has been created, virt_viewer_events_update_handle() makes sure it removes the corresponding virt_viewer_events_handle::source IO watch if any was set. virt_viewer_events_add_handle() will always create a virt_viewer_events_handle::source IO watch even if the handle is not watching for any events. This commit makes consistent by only creating a watch with g_io_add_watch() when the caller asked to watch for some events. Based on commit d71c143936a35cd6c3f23ae0cbf7f3215d944051 from libvirt-glib. Original author: Christophe Fergeau <cfergeau@redhat.com> Related to: rhbz#1243228
-rw-r--r--src/virt-viewer-events.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/virt-viewer-events.c b/src/virt-viewer-events.c
index f68791f..fe3aaa6 100644
--- a/src/virt-viewer-events.c
+++ b/src/virt-viewer-events.c
@@ -113,10 +113,12 @@ int virt_viewer_events_add_handle(int fd,
g_debug("Add handle %d %d %p", data->fd, events, data->opaque);
- data->source = g_io_add_watch(data->channel,
- cond,
- virt_viewer_events_dispatch_handle,
- data);
+ if (events != 0) {
+ data->source = g_io_add_watch(data->channel,
+ cond,
+ virt_viewer_events_dispatch_handle,
+ data);
+ }
g_ptr_array_add(handles, data);