Skip to content

Commit

Permalink
Bluetooth: bnep: Fix lost wakeup of session thread
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Peter Hurley authored and Gustavo F. Padovan committed Aug 11, 2011
1 parent 552b0d3 commit 38d5755
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/bluetooth/bnep/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,11 @@ static int bnep_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;
/* RX */
while ((skb = skb_dequeue(&sk->sk_receive_queue))) {
skb_orphan(skb);
Expand All @@ -504,7 +506,7 @@ static int bnep_session(void *arg)

schedule();
}
set_current_state(TASK_RUNNING);
__set_current_state(TASK_RUNNING);
remove_wait_queue(sk_sleep(sk), &wait);

/* Cleanup session */
Expand Down

0 comments on commit 38d5755

Please sign in to comment.