diff options
author | Fabiano FidĂȘncio <fidencio@redhat.com> | 2015-07-22 04:05:45 +0200 |
---|---|---|
committer | Fabiano FidĂȘncio <fidencio@redhat.com> | 2015-07-22 14:56:57 +0200 |
commit | 4ec75ee70cbe7560ffb83e4e84ffb4f925a41390 (patch) | |
tree | dcff3f2045381ceb5f8b9f1a26138b3c7974974f | |
parent | 3281c47e8b03cd0072c5ac18e97f1a36d08ec485 (diff) | |
download | virt-viewer-4ec75ee70cbe7560ffb83e4e84ffb4f925a41390.tar.gz virt-viewer-4ec75ee70cbe7560ffb83e4e84ffb4f925a41390.tar.xz virt-viewer-4ec75ee70cbe7560ffb83e4e84ffb4f925a41390.zip |
events: allow to remove disabled timers and handles
Trying to remove a disabled timer or handle will cause
virt_viewer_events_remove_{handle,timeout}() to return an error
rather than removing it.
Based on commit 79699d73e6e1b7218e3bd8349d176752f86128b9 from
libvirt-glib.
Original author: Christophe Fergeau <cfergeau@redhat.com>
Related to: rhbz#1243228
-rw-r--r-- | src/virt-viewer-events.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/virt-viewer-events.c b/src/virt-viewer-events.c index fe3aaa6..44740c3 100644 --- a/src/virt-viewer-events.c +++ b/src/virt-viewer-events.c @@ -233,12 +233,11 @@ virt_viewer_events_remove_handle(int watch) g_debug("Remove handle %d %d", watch, data->fd); - if (!data->source) - goto cleanup; - - g_source_remove(data->source); - data->source = 0; - data->events = 0; + if (data->source != 0) { + g_source_remove(data->source); + data->source = 0; + data->events = 0; + } /* since the actual watch deletion is done asynchronously, a update_handle call may * reschedule the watch before it's fully deleted, that's why we need to mark it as @@ -409,11 +408,10 @@ virt_viewer_events_remove_timeout(int timer) g_debug("Remove timeout %p %d", data, timer); - if (!data->source) - goto cleanup; - - g_source_remove(data->source); - data->source = 0; + if (data->source != 0) { + g_source_remove(data->source); + data->source = 0; + } /* since the actual timeout deletion is done asynchronously, a update_timeout call may * reschedule the timeout before it's fully deleted, that's why we need to mark it as |