Linux bluetooth development
 help / color / mirror / Atom feed
From: Dmitriy Paliy <dmitriy.paliy@nokia.com>
To: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com,
	claudio.takahasi@openbossa.org
Cc: Dmitriy Paliy <dmitriy.paliy@nokia.com>
Subject: [PATCH BlueZ] Fix release all sessions on powering adapter off
Date: Wed, 19 Oct 2011 11:19:58 +0300	[thread overview]
Message-ID: <1319012398-13859-1-git-send-email-dmitriy.paliy@nokia.com> (raw)

When adapter is powered off, all sessions should be released without
changing mode, which is contrary to what session_remove does. This
prevents from such situation when powering off leads to new mode
derived from mode_sessions.

Currently, if there are multiple mode sessions requested by different
clients, powering adapter off results in powering immediately it on.
---
 src/adapter.c |   14 ++------------
 1 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index d1ef17c..6d982a0 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2313,19 +2313,9 @@ static void set_mode_complete(struct btd_adapter *adapter)
 
 	DBG("");
 
-	/*
-	 * g_slist_free is not called after g_slist_foreach because the list is
-	 * updated using g_slist_remove in session_remove.
-	 */
 	if (adapter->mode == MODE_OFF) {
-		GSList *l;
-
-		for (l = adapter->mode_sessions; l;) {
-			struct session_req *req = l->data;
-			l = g_slist_next(l);
-			session_remove(req);
-			session_free(req);
-		}
+		g_slist_free_full(adapter->mode_sessions, session_free);
+		adapter->mode_sessions = NULL;
 	}
 
 	if (adapter->pending_mode == NULL)
-- 
1.7.4.1


             reply	other threads:[~2011-10-19  8:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-19  8:19 Dmitriy Paliy [this message]
2011-10-19  9:24 ` [PATCH BlueZ] Fix release all sessions on powering adapter off Luiz Augusto von Dentz
2011-10-19  9:37 ` 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=1319012398-13859-1-git-send-email-dmitriy.paliy@nokia.com \
    --to=dmitriy.paliy@nokia.com \
    --cc=claudio.takahasi@openbossa.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    /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