Commit 9be4e3fbf2d3603e7a7010ede0697166738a788b
Committed by
Gustavo F. Padovan
1 parent
950e2d51e8
Exists in
master
and in
6 other branches
Bluetooth: Fix lost wakeups waiting for sock state change
Fix race conditions which can cause lost wakeups while waiting for sock state to change. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Showing 1 changed file with 3 additions and 3 deletions Side-by-side Diff
net/bluetooth/af_bluetooth.c
... | ... | @@ -494,9 +494,8 @@ |
494 | 494 | BT_DBG("sk %p", sk); |
495 | 495 | |
496 | 496 | add_wait_queue(sk_sleep(sk), &wait); |
497 | + set_current_state(TASK_INTERRUPTIBLE); | |
497 | 498 | while (sk->sk_state != state) { |
498 | - set_current_state(TASK_INTERRUPTIBLE); | |
499 | - | |
500 | 499 | if (!timeo) { |
501 | 500 | err = -EINPROGRESS; |
502 | 501 | break; |
503 | 502 | |
... | ... | @@ -510,12 +509,13 @@ |
510 | 509 | release_sock(sk); |
511 | 510 | timeo = schedule_timeout(timeo); |
512 | 511 | lock_sock(sk); |
512 | + set_current_state(TASK_INTERRUPTIBLE); | |
513 | 513 | |
514 | 514 | err = sock_error(sk); |
515 | 515 | if (err) |
516 | 516 | break; |
517 | 517 | } |
518 | - set_current_state(TASK_RUNNING); | |
518 | + __set_current_state(TASK_RUNNING); | |
519 | 519 | remove_wait_queue(sk_sleep(sk), &wait); |
520 | 520 | return err; |
521 | 521 | } |