summaryrefslogtreecommitdiffstats
path: root/gdbus/mainloop.c
diff options
context:
space:
mode:
authorDaniel Orstadius <daniel.orstadius@gmail.com>2009-12-16 11:23:46 +0200
committerMarcel Holtmann <marcel@holtmann.org>2009-12-16 22:34:33 -0800
commit9c688fff68db3faea93f2da2fb6751cb509ee364 (patch)
tree1ab28d57644b3aff97fc4bcabc29d04daf068921 /gdbus/mainloop.c
parent8e1c3fe2bcd4d3f0cfa1fc7bb6caec70095a9798 (diff)
downloadofono-9c688fff68db3faea93f2da2fb6751cb509ee364.tar.bz2
Fix D-Bus timeout handling
Timeouts should also be removed in the remove_timeout callback in addition to the timeout_handler_free function. This is how dbus-glib does it and it seems to prevent crashes in certain situations.
Diffstat (limited to 'gdbus/mainloop.c')
-rw-r--r--gdbus/mainloop.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/gdbus/mainloop.c b/gdbus/mainloop.c
index bd775f8b..7abdf478 100644
--- a/gdbus/mainloop.c
+++ b/gdbus/mainloop.c
@@ -183,7 +183,11 @@ static void timeout_handler_free(void *data)
if (!handler)
return;
- g_source_remove(handler->id);
+ if (handler->id > 0) {
+ g_source_remove(handler->id);
+ handler->id = 0;
+ }
+
g_free(handler);
}
@@ -207,6 +211,17 @@ static dbus_bool_t add_timeout(DBusTimeout *timeout, void *data)
static void remove_timeout(DBusTimeout *timeout, void *data)
{
+ timeout_handler_t *handler;
+
+ handler = dbus_timeout_get_data(timeout);
+
+ if (!handler)
+ return;
+
+ if (handler->id > 0) {
+ g_source_remove(handler->id);
+ handler->id = 0;
+ }
}
static void timeout_toggled(DBusTimeout *timeout, void *data)