Skip to content

Commit

Permalink
Bluetooth: Fix lost wakeups waiting for sock state change
Browse files Browse the repository at this point in the history
Fix race conditions which can cause lost wakeups while waiting
for sock state to change.

Signed-off-by: Peter Hurley <[email protected]>
Signed-off-by: Gustavo F. Padovan <[email protected]>
  • Loading branch information
peterhurley authored and Gustavo F. Padovan committed Aug 11, 2011
1 parent 950e2d5 commit 9be4e3f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net/bluetooth/af_bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,8 @@ int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo)
BT_DBG("sk %p", sk);

add_wait_queue(sk_sleep(sk), &wait);
set_current_state(TASK_INTERRUPTIBLE);
while (sk->sk_state != state) {
set_current_state(TASK_INTERRUPTIBLE);

if (!timeo) {
err = -EINPROGRESS;
break;
Expand All @@ -510,12 +509,13 @@ int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo)
release_sock(sk);
timeo = schedule_timeout(timeo);
lock_sock(sk);
set_current_state(TASK_INTERRUPTIBLE);

err = sock_error(sk);
if (err)
break;
}
set_current_state(TASK_RUNNING);
__set_current_state(TASK_RUNNING);
remove_wait_queue(sk_sleep(sk), &wait);
return err;
}
Expand Down

0 comments on commit 9be4e3f

Please sign in to comment.