diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2006-04-10 17:28:47 +0000 |
---|---|---|
committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2006-04-10 17:28:47 +0000 |
commit | 1f98ca9b57ecd36d032449972b7b9f006ad1e06f (patch) | |
tree | 93902fb3eb844f7cc70107f78423b294ec9ed9cf /hcid/dbus.c | |
parent | 99ab0e609a4590d0027ae42d95ed1ca0b6c2e86f (diff) |
Fixed discoverable timeout and timeout list data memory leak
Diffstat (limited to 'hcid/dbus.c')
-rw-r--r-- | hcid/dbus.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/hcid/dbus.c b/hcid/dbus.c index 3fed5397..b5928367 100644 --- a/hcid/dbus.c +++ b/hcid/dbus.c @@ -388,6 +388,8 @@ static gboolean unregister_dbus_path(const char *path) slist_free(pdata->active_conn); pdata->active_conn = NULL; } + + free (pdata); } if (!dbus_connection_unregister_object_path (connection, path)) { @@ -1397,9 +1399,9 @@ done: * *****************************************************************/ -static int discoverable_timeout_handler(void *data) +int discoverable_timeout_handler(void *data) { - const struct hci_dbus_data *dbus_data = data; + struct hci_dbus_data *dbus_data = data; struct hci_request rq; int dd = -1; uint8_t hci_mode = dbus_data->mode; @@ -1432,6 +1434,7 @@ static int discoverable_timeout_handler(void *data) goto failed; } + dbus_data->timeout_id = 0; retval = -1; failed: if (dd >= 0) @@ -1642,10 +1645,14 @@ void hcid_dbus_setscan_enable_complete(bdaddr_t *local) error("Getting %s path data failed!", path); goto failed; } - + /* update the current scan mode value */ pdata->mode = rp.enable; + if (pdata->timeout_id) { + g_timeout_remove(pdata->timeout_id); + pdata->timeout_id = 0; + } switch (rp.enable) { case SCAN_DISABLED: scan_mode = MODE_OFF; @@ -1655,11 +1662,15 @@ void hcid_dbus_setscan_enable_complete(bdaddr_t *local) break; case (SCAN_PAGE | SCAN_INQUIRY): scan_mode = MODE_DISCOVERABLE; - g_timeout_add(pdata->discoverable_timeout, discoverable_timeout_handler, pdata); + if (pdata->discoverable_timeout != 0) + pdata->timeout_id = g_timeout_add(pdata->discoverable_timeout, + discoverable_timeout_handler, pdata); break; case SCAN_INQUIRY: /* Address the scenario where another app changed the scan mode */ - g_timeout_add(pdata->discoverable_timeout, discoverable_timeout_handler, pdata); + if (pdata->discoverable_timeout != 0) + pdata->timeout_id = g_timeout_add(pdata->discoverable_timeout, + discoverable_timeout_handler, pdata); /* ignore, this event should not be sent*/ default: /* ignore, reserved */ |