diff options
author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-04-04 22:16:00 +0000 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-04-04 22:16:00 +0000 |
commit | 5d40ae4925b2f57ee70aa7f824eee29dbf3807d7 (patch) | |
tree | ad05c018280920fd520a14f80e2decb7de6247bf /hcid/agent.c | |
parent | e83935d0bc0e4d043b4f4cd372d69b95b6f10ffc (diff) |
Fix agent double free on device removal.
Diffstat (limited to 'hcid/agent.c')
-rw-r--r-- | hcid/agent.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/hcid/agent.c b/hcid/agent.c index 318a2ed3..25079908 100644 --- a/hcid/agent.c +++ b/hcid/agent.c @@ -127,6 +127,16 @@ static void agent_request_free(struct agent_request *req) g_free(req); } +static void agent_exited(const char *name, struct agent *agent) +{ + struct adapter *adapter = agent->adapter; + + debug("Agent %s exited without calling Unregister", name); + + agent_destroy(agent, TRUE); + adapter->agent = NULL; +} + static void agent_free(struct agent *agent) { if (!agent) @@ -160,8 +170,11 @@ static void agent_free(struct agent *agent) if (agent->timeout) g_source_remove(agent->timeout); - if (!agent->exited) + if (!agent->exited) { + name_listener_remove(connection, agent->name, + (name_cb_t) agent_exited, agent); agent_release(agent); + } g_free(agent->name); g_free(agent->path); @@ -204,6 +217,8 @@ struct agent *agent_create(struct adapter *adapter, const char *name, (GSourceFunc) agent_timeout, agent); } + name_listener_add(connection, name, (name_cb_t) agent_exited, agent); + return agent; } |