diff options
author | Daniel Orstadius <daniel.orstadius@gmail.com> | 2009-12-16 11:23:46 +0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2009-12-17 07:35:40 +0200 |
commit | 0b15d14b98393f6be6de50f0ef1c8c687054ef5d (patch) | |
tree | a6b459d43ab40e67a2fa9437b5d1946a911a6f85 /gdbus/mainloop.c | |
parent | 3faf12fdb7f9d7a043ad526e8e8d1788d4956a4b (diff) | |
download | bluez-0b15d14b98393f6be6de50f0ef1c8c687054ef5d.tar.gz |
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.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/gdbus/mainloop.c b/gdbus/mainloop.c index bd775f8bb..7abdf478a 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) |