Linux bluetooth development
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 7/7] audio/AVCTP: Do not process browsing queue until connection completes
Date: Mon, 29 Jul 2013 17:04:39 +0300	[thread overview]
Message-ID: <1375106679-14645-7-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1375106679-14645-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Any request processed before the connection completes will likely fail
in avctp_browsing_send so instead delay the processing.
---
 profiles/audio/avctp.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index 2c1aa94..845027f 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -1107,6 +1107,7 @@ static void avctp_connect_browsing_cb(GIOChannel *chan, GError *err,
 							gpointer data)
 {
 	struct avctp *session = data;
+	struct avctp_channel *browsing = session->browsing;
 	char address[18];
 	uint16_t imtu, omtu;
 	GError *gerr = NULL;
@@ -1131,18 +1132,25 @@ static void avctp_connect_browsing_cb(GIOChannel *chan, GError *err,
 
 	DBG("AVCTP Browsing: connected to %s", address);
 
-	if (session->browsing == NULL)
-		session->browsing = avctp_channel_create(session, chan,
+	if (browsing == NULL) {
+		browsing = avctp_channel_create(session, chan,
 						avctp_destroy_browsing);
+		session->browsing = browsing;
+	}
 
-	session->browsing->imtu = imtu;
-	session->browsing->omtu = omtu;
-	session->browsing->buffer = g_malloc0(MAX(imtu, omtu));
-	session->browsing->watch = g_io_add_watch(session->browsing->io,
+	browsing->imtu = imtu;
+	browsing->omtu = omtu;
+	browsing->buffer = g_malloc0(MAX(imtu, omtu));
+	browsing->watch = g_io_add_watch(session->browsing->io,
 				G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
 				(GIOFunc) session_browsing_cb, session);
 
 	avctp_set_state(session, AVCTP_STATE_BROWSING_CONNECTED);
+
+	/* Process any request that was pending the connection to complete */
+	if (browsing->process_id == 0 && !g_queue_is_empty(browsing->queue))
+		browsing->process_id = g_idle_add(process_queue, browsing);
+
 	return;
 
 fail:
@@ -1543,6 +1551,10 @@ int avctp_send_browsing_req(struct avctp *session,
 
 	g_queue_push_tail(browsing->queue, p);
 
+	/* Connection did not complete, delay process of the request */
+	if (browsing->watch == 0)
+		return 0;
+
 	if (browsing->process_id == 0)
 		browsing->process_id = g_idle_add(process_queue, browsing);
 
-- 
1.8.3.1


  parent reply	other threads:[~2013-07-29 14:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-29 14:04 [PATCH BlueZ 1/7] audio/AVRCP: Fix memory leaks Luiz Augusto von Dentz
2013-07-29 14:04 ` [PATCH BlueZ 2/7] audio/AVRCP: Fix not connecting Browsing channel when supported Luiz Augusto von Dentz
2013-07-29 14:04 ` [PATCH BlueZ 3/7] audio/AVRCP: Fix not setting browsing feature in CT record Luiz Augusto von Dentz
2013-07-29 14:04 ` [PATCH BlueZ 4/7] audio/AVRCP: Connect browsing channel when accepting the connection Luiz Augusto von Dentz
2013-07-29 14:04 ` [PATCH BlueZ 5/7] audio/AVRCP: Connect browsing channel in case of GetCapabilities response Luiz Augusto von Dentz
2013-07-29 14:04 ` [PATCH BlueZ 6/7] audio/AVCTP: Fix connecting browsing channel multiple times Luiz Augusto von Dentz
2013-07-29 14:04 ` Luiz Augusto von Dentz [this message]
2013-07-30  9:54 ` [PATCH BlueZ 1/7] audio/AVRCP: Fix memory leaks Johan Hedberg

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=1375106679-14645-7-git-send-email-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.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