]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Bluetooth: cmtp: Fix lost wakeup of session thread
authorPeter Hurley <peter@hurleysoftware.com>
Sun, 24 Jul 2011 04:11:10 +0000 (00:11 -0400)
committerGustavo F. Padovan <padovan@profusion.mobi>
Mon, 1 Aug 2011 17:55:56 +0000 (14:55 -0300)
Fix race condition which can result in missing the wakeup intended
to stop the session thread.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
net/bluetooth/cmtp/core.c

index 2487b84e815fe06ef947512ff41420c374a14fd3..c237499d1aa70fc9ea433a9587f27263d60af463 100644 (file)
@@ -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;
 
@@ -310,7 +312,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);