Skip to contentSkip to conversation

Bluetooth: cmtp: Fix lost wakeup of session thread

PATCH In review Peter Hurley 2 participants 2 messages Jul 24, 2011 – Aug 1, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 7/7 Bluetooth: cmtp: Fix lost wakeup of session thread

Fix race condition which can result in missing the wakeup intended to stop the session thread.

---
 net/bluetooth/cmtp/core.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
net/bluetooth/cmtp/core.c +4 -2
index c5b11af..2eb854a 100644
@@ -292,9 +292,11 @@ static int cmtp_session(void *arg)
 
 	init_waitqueue_entry(&wait, current);
 	add_wait_queue(sk_sleep(sk), &wait);
-	while (!kthread_should_stop()) {
+	while (1) {
 		set_current_state(TASK_INTERRUPTIBLE);
 
+		if (kthread_should_stop())
+			break;
 		if (sk->sk_state != BT_CONNECTED)
 			break;
 
@@ -307,7 +309,7 @@ static int cmtp_session(void *arg)
 
 		schedule();
 	}
-	set_current_state(TASK_RUNNING);
+	__set_current_state(TASK_RUNNING);
 	remove_wait_queue(sk_sleep(sk), &wait);
 
 	down_write(&cmtp_session_sem);
Signature · 1 line
1.7.4.1
#1 lore raw

Hi Peter,

Quoted 7 lines · Peter Hurley

Fix race condition which can result in missing the wakeup intended to stop the session thread.

---
 net/bluetooth/cmtp/core.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

All patches applied (including the other one about l2cap). Thanks.

Gustavo