summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2006-08-19 00:30:46 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2006-08-19 00:30:46 +0000
commit5c2f4ca97418ad12a764790a3b3d4023c987dd7f (patch)
treee198b85c1137c6f7e60a34b80a33bc1bd60c5a68 /hcid
parent37726232053804e18cb5c34e6dec42a8427240a2 (diff)
Cancel bonding if requestor exits
Diffstat (limited to 'hcid')
-rw-r--r--hcid/dbus-adapter.c3
-rw-r--r--hcid/dbus-security.c6
-rw-r--r--hcid/dbus.c24
-rw-r--r--hcid/dbus.h2
4 files changed, 29 insertions, 6 deletions
diff --git a/hcid/dbus-adapter.c b/hcid/dbus-adapter.c
index 3c4ce652..0feccf0b 100644
--- a/hcid/dbus-adapter.c
+++ b/hcid/dbus-adapter.c
@@ -1812,6 +1812,9 @@ static DBusHandlerResult handle_dev_create_bonding_req(DBusConnection *conn, DBu
dbus_data->requestor_name = strdup(dbus_message_get_sender(msg));
+ name_listener_add(conn, dbus_data->requestor_name,
+ (name_cb_t)create_bond_req_exit, dbus_data);
+
hci_close_dev(dd);
return DBUS_HANDLER_RESULT_HANDLED;
diff --git a/hcid/dbus-security.c b/hcid/dbus-security.c
index f7b409e6..c4ef5931 100644
--- a/hcid/dbus-security.c
+++ b/hcid/dbus-security.c
@@ -562,11 +562,8 @@ void cancel_passkey_agent_requests(struct slist *agents, const char *path, bdadd
{
struct slist *l, *next;
- if (!default_agent)
- return;
-
/* First check the default agent */
- for (l = default_agent->pending_requests; l != NULL; l = next) {
+ for (l = default_agent ? default_agent->pending_requests : NULL; l != NULL; l = next) {
struct pending_agent_request *req = l->data;
next = l->next;
if (!strcmp(path, req->path) && (!addr || !bacmp(addr, &req->bda))) {
@@ -588,5 +585,4 @@ void cancel_passkey_agent_requests(struct slist *agents, const char *path, bdadd
}
}
}
-
}
diff --git a/hcid/dbus.c b/hcid/dbus.c
index 6e174ab3..7f72d7cc 100644
--- a/hcid/dbus.c
+++ b/hcid/dbus.c
@@ -394,8 +394,13 @@ static int unregister_dbus_path(const char *path)
/* check pending requests */
reply_pending_requests(path, pdata);
- if (pdata->requestor_name)
+ cancel_passkey_agent_requests(pdata->passkey_agents, path, NULL);
+
+ if (pdata->requestor_name) {
+ name_listener_remove(connection, pdata->requestor_name,
+ (name_cb_t)create_bond_req_exit, pdata);
free(pdata->requestor_name);
+ }
if (pdata->disc_devices) {
slist_foreach(pdata->disc_devices, (slist_func_t)free, NULL);
@@ -638,6 +643,8 @@ int hcid_dbus_stop_device(uint16_t id)
cancel_passkey_agent_requests(pdata->passkey_agents, path, NULL);
if (pdata->requestor_name) {
+ name_listener_remove(connection, pdata->requestor_name,
+ (name_cb_t)create_bond_req_exit, pdata);
free(pdata->requestor_name);
pdata->requestor_name = NULL;
}
@@ -796,6 +803,8 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer, const u
bonding_request_free(pdata->bonding);
pdata->bonding = NULL;
+ name_listener_remove(connection, pdata->requestor_name,
+ (name_cb_t)create_bond_req_exit, pdata);
free(pdata->requestor_name);
pdata->requestor_name = NULL;
@@ -1331,6 +1340,8 @@ bonding_failed:
/* free bonding request if the HCI pairing request was not sent */
bonding_request_free(pdata->bonding);
pdata->bonding = NULL;
+ name_listener_remove(connection, pdata->requestor_name,
+ (name_cb_t)create_bond_req_exit, pdata);
free(pdata->requestor_name);
pdata->requestor_name = NULL;
@@ -1962,3 +1973,14 @@ failed:
bt_free(local_addr);
}
+
+void create_bond_req_exit(const char *name, struct hci_dbus_data *pdata)
+{
+ char path[MAX_PATH_LENGTH];
+
+ snprintf(path, sizeof(path), "%s/hci%d", BASE_PATH, pdata->dev_id);
+
+ debug("PasskeyAgent at %s exited before bonding was completed", name);
+
+ cancel_passkey_agent_requests(pdata->passkey_agents, path, &pdata->bonding->bdaddr);
+}
diff --git a/hcid/dbus.h b/hcid/dbus.h
index 4671c482..1399bf92 100644
--- a/hcid/dbus.h
+++ b/hcid/dbus.h
@@ -191,6 +191,8 @@ DBusHandlerResult simple_introspect(DBusConnection *conn, DBusMessage *msg, void
service_handler_func_t find_service_handler(struct service_data *services, DBusMessage *msg);
+void create_bond_req_exit(const char *name, struct hci_dbus_data *pdata);
+
int handle_passkey_request(DBusConnection *conn, int dev, const char *path, bdaddr_t *sba, bdaddr_t *dba);
void cancel_passkey_agent_requests(struct slist *agents, const char *path, bdaddr_t *dba);