Linux bluetooth development
 help / color / mirror / Atom feed
From: Dmitriy Paliy <dmitriy.paliy@nokia.com>
To: linux-bluetooth@vger.kernel.org, johan.hedberg@nokia.com
Cc: Dmitriy Paliy <dmitriy.paliy@nokia.com>
Subject: [PATCH v3] Add release all sessions when adapter is switched off
Date: Tue, 22 Mar 2011 14:29:07 +0200	[thread overview]
Message-ID: <1300796947-1518-2-git-send-email-dmitriy.paliy@nokia.com> (raw)
In-Reply-To: <1300796947-1518-1-git-send-email-dmitriy.paliy@nokia.com>

All sessions should be released when adapter is switched off. Then a new
RequestSession method call always results in change from power off to power
on such ensuring operational mode. Otherwise, it is possible to end up in
adapter state being powered off after RequestSession succeded.

g_slist_free is not called after g_slist_foreach because the list is updated
using g_slist_remove inside of session_free, which is called for each element
by g_slist_foreach.
---
 src/adapter.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index cc4f43e..691b963 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2507,6 +2507,15 @@ 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 which is called by
+         * session_free, which is called for each element by g_slist_foreach.
+	 */
+	if (adapter->mode == MODE_OFF)
+		g_slist_foreach(adapter->mode_sessions, (GFunc) session_free,
+									NULL);
+
 	if (adapter->pending_mode == NULL)
 		return;
 
-- 
1.7.1


  reply	other threads:[~2011-03-22 12:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-22 12:29 [PATCH 0/1 v3] Add release all sessions when adapter is switched off Dmitriy Paliy
2011-03-22 12:29 ` Dmitriy Paliy [this message]
2011-03-23 13:09   ` [PATCH " 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=1300796947-1518-2-git-send-email-dmitriy.paliy@nokia.com \
    --to=dmitriy.paliy@nokia.com \
    --cc=johan.hedberg@nokia.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