Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ] Fix release all sessions on powering adapter off
@ 2011-10-19  8:19 Dmitriy Paliy
  2011-10-19  9:24 ` Luiz Augusto von Dentz
  2011-10-19  9:37 ` Johan Hedberg
  0 siblings, 2 replies; 3+ messages in thread
From: Dmitriy Paliy @ 2011-10-19  8:19 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz, claudio.takahasi; +Cc: Dmitriy Paliy

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-19  9:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-19  8:19 [PATCH BlueZ] Fix release all sessions on powering adapter off Dmitriy Paliy
2011-10-19  9:24 ` Luiz Augusto von Dentz
2011-10-19  9:37 ` Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox