[libvirt-glib 2/3] glib: Allow to remove disabled timers and handles

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

 



Trying to remove a disabled timer or handle will cause
gvir_{event,timer}_handle_remove() to return an error
rather than removing it.
---
 libvirt-glib/libvirt-glib-event.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libvirt-glib/libvirt-glib-event.c b/libvirt-glib/libvirt-glib-event.c
index 67144fa..adcc2fe 100644
--- a/libvirt-glib/libvirt-glib-event.c
+++ b/libvirt-glib/libvirt-glib-event.c
@@ -292,12 +292,12 @@ gvir_event_handle_remove(int watch)
 
     g_debug("Remove handle %p %d %d\n", data, watch, data->fd);
 
-    if (!data->source)
-        goto cleanup;
+    if (data->source != 0) {
+        g_source_remove(data->source);
+        data->source = 0;
+        data->events = 0;
+    }
 
-    g_source_remove(data->source);
-    data->source = 0;
-    data->events = 0;
     /* since the actual watch deletion is done asynchronously, a handle_update call may
      * reschedule the watch before it's fully deleted, that's why we need to mark it as
      * 'removed' to prevent reuse
@@ -448,11 +448,11 @@ gvir_event_timeout_remove(int timer)
 
     g_debug("Remove timeout %p %d\n", data, timer);
 
-    if (!data->source)
-        goto cleanup;
+    if (data->source != 0) {
+        g_source_remove(data->source);
+        data->source = 0;
+    }
 
-    g_source_remove(data->source);
-    data->source = 0;
     /* since the actual timeout deletion is done asynchronously, a timeout_update call may
      * reschedule the timeout before it's fully deleted, that's why we need to mark it as
      * 'removed' to prevent reuse
-- 
1.8.5.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]