Thread (2 messages) flat view 2 messages, 1 author, 2011-03-22
DORMANTno replies

[PATCH] Add release all sessions when adapter is switched off

From: Dmitriy Paliy <hidden>
Date: 2011-03-22 11:46:58
Subsystem: the rest · Maintainer: Linus Torvalds

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 |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index cc4f43e..b0d1773 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2507,6 +2507,10 @@ static void set_mode_complete(struct btd_adapter *adapter)
 
 	DBG("");
 
+	if (adapter->mode == MODE_OFF)
+		g_slist_foreach(adapter->mode_sessions, (GFunc) session_free,
+									NULL);
+
 	if (adapter->pending_mode == NULL)
 		return;
 
-- 
1.7.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help