linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Scott James Remnant <scott@netsplit.com>
To: linux-bluetooth@vger.kernel.org
Cc: keybuk@chromium.org, Scott James Remnant <scott@netsplit.com>
Subject: [PATCHv2 1/4] Add support for retrying a bonding
Date: Tue, 24 Jan 2012 10:47:55 -0800	[thread overview]
Message-ID: <1327430878-23913-2-git-send-email-scott@netsplit.com> (raw)
In-Reply-To: <1327430878-23913-1-git-send-email-scott@netsplit.com>

In order to retry a bonding we need a timer that will perform the
retry, we need to stash the status and capability of the bonding
request so it can use them again, and in the case of a retrying
bonding attempt we need to not tear down the temporary D-Bus device
object on the adapter.
---
 src/adapter.c |    2 +-
 src/device.c  |   14 ++++++++++++++
 src/device.h  |    1 +
 3 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index d5075db..a606174 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3072,7 +3072,7 @@ void adapter_remove_connection(struct btd_adapter *adapter,
 	if (device_is_authenticating(device))
 		device_cancel_authentication(device, TRUE);
 
-	if (device_is_temporary(device)) {
+	if (device_is_temporary(device) && !device_is_retrying(device)) {
 		const char *path = device_get_path(device);
 
 		DBG("Removing temporary device %s", path);
diff --git a/src/device.c b/src/device.c
index c19acd4..278ad4b 100644
--- a/src/device.c
+++ b/src/device.c
@@ -86,6 +86,9 @@ struct bonding_req {
 	GIOChannel *io;
 	guint listener_id;
 	struct btd_device *device;
+	uint8_t capability;
+	uint8_t status;
+	guint retry_timer;
 };
 
 struct authentication_req {
@@ -2176,6 +2179,9 @@ static void bonding_request_free(struct bonding_req *bonding)
 	if (bonding->io)
 		g_io_channel_unref(bonding->io);
 
+	if (bonding->retry_timer)
+		g_source_remove(bonding->retry_timer);
+
 	device = bonding->device;
 	g_free(bonding);
 
@@ -2247,6 +2253,7 @@ proceed:
 
 	bonding->conn = dbus_connection_ref(conn);
 	bonding->msg = dbus_message_ref(msg);
+	bonding->capability = capability;
 
 	return bonding;
 }
@@ -2330,6 +2337,13 @@ static void device_auth_req_free(struct btd_device *device)
 	device->authr = NULL;
 }
 
+gboolean device_is_retrying(struct btd_device *device)
+{
+	struct bonding_req *bonding = device->bonding;
+
+	return bonding && bonding->retry_timer != 0;
+}
+
 void device_bonding_complete(struct btd_device *device, uint8_t status)
 {
 	struct bonding_req *bonding = device->bonding;
diff --git a/src/device.h b/src/device.h
index 13005ae..5b1152b 100644
--- a/src/device.h
+++ b/src/device.h
@@ -73,6 +73,7 @@ void device_set_temporary(struct btd_device *device, gboolean temporary);
 void device_set_bonded(struct btd_device *device, gboolean bonded);
 void device_set_auto_connect(struct btd_device *device, gboolean enable);
 gboolean device_is_connected(struct btd_device *device);
+gboolean device_is_retrying(struct btd_device *device);
 DBusMessage *device_create_bonding(struct btd_device *device,
 				DBusConnection *conn, DBusMessage *msg,
 				const char *agent_path, uint8_t capability);
-- 
1.7.7.3


  reply	other threads:[~2012-01-24 18:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-24 18:47 [PATCHv2 0/4] Add support for bonding callbacks and retrying Scott James Remnant
2012-01-24 18:47 ` Scott James Remnant [this message]
2012-01-24 18:47 ` [PATCHv2 2/4] plugin: Add bonding callback support for plugins Scott James Remnant
2012-01-24 18:47 ` [PATCHv2 3/4] bonding: retry if callback returns TRUE Scott James Remnant
2012-01-24 18:47 ` [PATCHv2 4/4] bonding: call plugin callback on cancellation Scott James Remnant
2012-01-30 19:41 ` [PATCHv2 0/4] Add support for bonding callbacks and retrying Marcel Holtmann
2012-01-30 21:38   ` Scott James Remnant
2012-01-30 21:51     ` Marcel Holtmann
2012-01-30 21:57       ` Scott James Remnant
2012-01-30 22:08         ` Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1327430878-23913-2-git-send-email-scott@netsplit.com \
    --to=scott@netsplit.com \
    --cc=keybuk@chromium.org \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).