Linux bluetooth development
 help / color / mirror / Atom feed
From: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
To: <linux-bluetooth@vger.kernel.org>
Cc: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
Subject: [PATCH v2 2/3] android: Cancel all pending confirm name before stop discovery
Date: Mon, 10 Mar 2014 00:06:36 +0100	[thread overview]
Message-ID: <1394406397-6843-3-git-send-email-lukasz.rymanowski@tieto.com> (raw)
In-Reply-To: <1394406397-6843-1-git-send-email-lukasz.rymanowski@tieto.com>

If user wants to cancel discovery we should remove all the confirm name 
requests from mgmt queues.

It is in order to make sure that stop discovery have a free way to
reach kernel.

This improves scenario when there is a big inflow of device found events and
mgmt queues become full of confirm name requests. In such case stop discovery 
might stack in the queue.
---
 android/bluetooth.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index 60ca17d..9286c67 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -2467,6 +2467,14 @@ static bool start_discovery(void)
 	return false;
 }
 
+static void cancel_pending_confirm_name(gpointer data, gpointer user_data)
+{
+	struct device *dev = data;
+
+	mgmt_cancel(mgmt_if, dev->confirm_id);
+	dev->confirm_id = 0;
+}
+
 static bool stop_discovery(void)
 {
 	struct mgmt_cp_stop_discovery cp;
@@ -2481,6 +2489,9 @@ static bool stop_discovery(void)
 
 	DBG("type=0x%x", cp.type);
 
+	/* Lets drop all confirm name request as we don't need it anymore */
+	g_slist_foreach(cached_devices, cancel_pending_confirm_name, NULL);
+
 	if (mgmt_send(mgmt_if, MGMT_OP_STOP_DISCOVERY, adapter.index,
 					sizeof(cp), &cp, NULL, NULL, NULL) > 0)
 		return true;
-- 
1.8.4


  parent reply	other threads:[~2014-03-09 23:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-09 23:06 [PATCH v2 0/3] android: Improve of handling stop discovery Lukasz Rymanowski
2014-03-09 23:06 ` [PATCH v2 1/3] android: Add tracking for pending confirm name command Lukasz Rymanowski
2014-03-09 23:06 ` Lukasz Rymanowski [this message]
2014-03-09 23:06 ` [PATCH v2 3/3] android: Send confirm name request with mgmt_send Lukasz Rymanowski
2014-03-13 14:25 ` [PATCH v2 0/3] android: Improve of handling stop discovery Szymon Janc

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=1394406397-6843-3-git-send-email-lukasz.rymanowski@tieto.com \
    --to=lukasz.rymanowski@tieto.com \
    --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