summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2009-02-03 11:18:22 -0800
committerJohan Hedberg <johan.hedberg@nokia.com>2009-02-03 11:20:01 -0800
commitf7d1ee361e410e096929bd3918178af356c50bbd (patch)
treeb6360e73aea8397c0e06120a2306c2bd7278d671 /src
parent38ca09be34dbb514fa1194b9a164d1b63a74069b (diff)
Fix authentication replies when disconnected
This patch makes sure that we don't reply to the authentiction requests if we get disconnected before authentication has completed.
Diffstat (limited to 'src')
-rw-r--r--src/adapter.c2
-rw-r--r--src/device.c10
-rw-r--r--src/device.h2
3 files changed, 8 insertions, 6 deletions
diff --git a/src/adapter.c b/src/adapter.c
index ca41be7f..3239e9a1 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2683,7 +2683,7 @@ void adapter_remove_connection(struct btd_adapter *adapter,
hci_req_queue_remove(adapter->dev_id, &bdaddr);
if (device_is_authenticating(device))
- device_cancel_authentication(device);
+ device_cancel_authentication(device, TRUE);
if (device_is_temporary(device)) {
const char *path = device_get_path(device);
diff --git a/src/device.c b/src/device.c
index 9c647f39..926d9591 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1678,7 +1678,7 @@ static void create_bond_req_exit(DBusConnection *conn, void *user_data)
debug("%s: requestor exited before bonding was completed", device->path);
if (device->authr)
- device_cancel_authentication(device);
+ device_cancel_authentication(device, FALSE);
if (device->bonding) {
device->bonding->listener_id = 0;
@@ -1890,7 +1890,7 @@ void device_cancel_bonding(struct btd_device *device, uint8_t status)
debug("%s: canceling bonding request", device->path);
if (device->authr)
- device_cancel_authentication(device);
+ device_cancel_authentication(device, FALSE);
reply = new_authentication_return(bonding->msg, status);
g_dbus_send_message(bonding->conn, reply);
@@ -2032,7 +2032,7 @@ static void cancel_authentication(struct authentication_req *auth)
auth->cb = NULL;
}
-void device_cancel_authentication(struct btd_device *device)
+void device_cancel_authentication(struct btd_device *device, gboolean aborted)
{
struct authentication_req *auth = device->authr;
@@ -2044,7 +2044,9 @@ void device_cancel_authentication(struct btd_device *device)
if (auth->agent)
agent_cancel(auth->agent);
- cancel_authentication(auth);
+ if (!aborted)
+ cancel_authentication(auth);
+
device->authr = NULL;
g_free(auth);
}
diff --git a/src/device.h b/src/device.h
index f3a5cea0..6b750a82 100644
--- a/src/device.h
+++ b/src/device.h
@@ -68,7 +68,7 @@ gboolean device_is_bonding(struct btd_device *device, const char *sender);
void device_cancel_bonding(struct btd_device *device, uint8_t status);
int device_request_authentication(struct btd_device *device, auth_type_t type,
uint32_t passkey, void *cb);
-void device_cancel_authentication(struct btd_device *device);
+void device_cancel_authentication(struct btd_device *device, gboolean aborted);
gboolean device_is_authenticating(struct btd_device *device);
void device_set_renewed_key(struct btd_device *device, gboolean renewed);
void device_add_connection(struct btd_device *device, DBusConnection *conn,