diff options
| -rw-r--r-- | hcid/dbus-security.c | 45 | 
1 files changed, 29 insertions, 16 deletions
| diff --git a/hcid/dbus-security.c b/hcid/dbus-security.c index 1ca2d5b1..2cc4d44b 100644 --- a/hcid/dbus-security.c +++ b/hcid/dbus-security.c @@ -43,24 +43,10 @@  static struct passkey_agent *default_agent = NULL; -static void default_agent_exited(const char *name, void *data) -{ -	debug("%s exited without unregistering the default passkey agent", name); - -	if (!default_agent || strcmp(name, default_agent->name)) { -		/* This should never happen (there's a bug in the code if it does) */ -		debug("default_agent_exited: mismatch with actual default_agent"); -		return; -	} - -	free(default_agent->path); -	free(default_agent->name); -	free(default_agent); -	default_agent = NULL; -} -  static void passkey_agent_free(struct passkey_agent *agent)  { +	struct slist *l; +  	if (!agent)  		return;  	if (agent->name) @@ -69,9 +55,36 @@ static void passkey_agent_free(struct passkey_agent *agent)  		free(agent->path);  	if (agent->addr)  		free(agent->addr); + +	for (l = agent->pending_requests; l != NULL; l = l->next) { +		struct pending_agent_request *req = l->data; + +		free(req->path); +		dbus_pending_call_cancel(req->call); +		dbus_pending_call_unref(req->call); +		dbus_connection_unref(req->conn); +		free(req); +	} + +	slist_free(agent->pending_requests); +  	free(agent);  } +static void default_agent_exited(const char *name, void *data) +{ +	debug("%s exited without unregistering the default passkey agent", name); + +	if (!default_agent || strcmp(name, default_agent->name)) { +		/* This should never happen (there's a bug in the code if it does) */ +		debug("default_agent_exited: mismatch with actual default_agent"); +		return; +	} + +	passkey_agent_free(default_agent); +	default_agent = NULL; +} +  static struct passkey_agent *passkey_agent_new(const char *name,  					const char *path, const char *addr)  { | 
