From 3c6404cd942f3b69968a390fae2a57dd2980e21a Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Sat, 5 Aug 2006 21:36:31 +0000 Subject: fixed message reply timeout --- hcid/dbus.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'hcid/dbus.c') diff --git a/hcid/dbus.c b/hcid/dbus.c index 206d3343..3a6c8e53 100644 --- a/hcid/dbus.c +++ b/hcid/dbus.c @@ -1427,11 +1427,25 @@ static int timeout_handler_dispatch(gpointer data) { timeout_handler_t *handler = data; + /* if not enabled should not be polled by the main loop */ + if (dbus_timeout_get_enabled(handler->timeout) != TRUE) + return -1; + dbus_timeout_handle(handler->timeout); return -1; } +static void timeout_handler_free(void *data) +{ + timeout_handler_t *handler = data; + if (!handler) + return; + + g_timeout_remove(handler->id); + free(handler); +} + static dbus_bool_t add_timeout(DBusTimeout *timeout, void *data) { timeout_handler_t *handler; @@ -1446,22 +1460,14 @@ static dbus_bool_t add_timeout(DBusTimeout *timeout, void *data) handler->id = g_timeout_add(dbus_timeout_get_interval(timeout), timeout_handler_dispatch, handler); - dbus_timeout_set_data(timeout, handler, NULL); + dbus_timeout_set_data(timeout, handler, timeout_handler_free); return TRUE; } static void remove_timeout(DBusTimeout *timeout, void *data) { - timeout_handler_t *handler; - - handler = dbus_timeout_get_data(timeout); - if(handler == NULL) - return; - - g_timeout_remove(handler->id); - free(handler); } static void timeout_toggled(DBusTimeout *timeout, void *data) -- cgit