diff options
author | Arnd Bergmann <arnd@arndb.de> | 2011-10-20 12:30:25 -0400 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2011-10-20 12:30:25 -0400 |
commit | 995a0605a6665858d73f9e80053414909be33f27 (patch) | |
tree | fcc66a6a77acdaae492f77c0c58c0233db74a2b4 /net/bluetooth/sco.c | |
parent | a32750c2ca6f697903b19063fc86f4272865e3a1 (diff) | |
parent | 677d3e2f07d1b3d6d2f76fd5552d16a53b9236a0 (diff) |
Merge branch 'at91/trng' into next/driver
Diffstat (limited to 'net/bluetooth/sco.c')
-rw-r--r-- | net/bluetooth/sco.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 4c3621b5e0aa..8270f05e3f1f 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c | |||
@@ -564,30 +564,26 @@ static int sco_sock_accept(struct socket *sock, struct socket *newsock, int flag | |||
564 | 564 | ||
565 | lock_sock(sk); | 565 | lock_sock(sk); |
566 | 566 | ||
567 | if (sk->sk_state != BT_LISTEN) { | ||
568 | err = -EBADFD; | ||
569 | goto done; | ||
570 | } | ||
571 | |||
572 | timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); | 567 | timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); |
573 | 568 | ||
574 | BT_DBG("sk %p timeo %ld", sk, timeo); | 569 | BT_DBG("sk %p timeo %ld", sk, timeo); |
575 | 570 | ||
576 | /* Wait for an incoming connection. (wake-one). */ | 571 | /* Wait for an incoming connection. (wake-one). */ |
577 | add_wait_queue_exclusive(sk_sleep(sk), &wait); | 572 | add_wait_queue_exclusive(sk_sleep(sk), &wait); |
578 | while (!(ch = bt_accept_dequeue(sk, newsock))) { | 573 | while (1) { |
579 | set_current_state(TASK_INTERRUPTIBLE); | 574 | set_current_state(TASK_INTERRUPTIBLE); |
580 | if (!timeo) { | 575 | |
581 | err = -EAGAIN; | 576 | if (sk->sk_state != BT_LISTEN) { |
577 | err = -EBADFD; | ||
582 | break; | 578 | break; |
583 | } | 579 | } |
584 | 580 | ||
585 | release_sock(sk); | 581 | ch = bt_accept_dequeue(sk, newsock); |
586 | timeo = schedule_timeout(timeo); | 582 | if (ch) |
587 | lock_sock(sk); | 583 | break; |
588 | 584 | ||
589 | if (sk->sk_state != BT_LISTEN) { | 585 | if (!timeo) { |
590 | err = -EBADFD; | 586 | err = -EAGAIN; |
591 | break; | 587 | break; |
592 | } | 588 | } |
593 | 589 | ||
@@ -595,8 +591,12 @@ static int sco_sock_accept(struct socket *sock, struct socket *newsock, int flag | |||
595 | err = sock_intr_errno(timeo); | 591 | err = sock_intr_errno(timeo); |
596 | break; | 592 | break; |
597 | } | 593 | } |
594 | |||
595 | release_sock(sk); | ||
596 | timeo = schedule_timeout(timeo); | ||
597 | lock_sock(sk); | ||
598 | } | 598 | } |
599 | set_current_state(TASK_RUNNING); | 599 | __set_current_state(TASK_RUNNING); |
600 | remove_wait_queue(sk_sleep(sk), &wait); | 600 | remove_wait_queue(sk_sleep(sk), &wait); |
601 | 601 | ||
602 | if (err) | 602 | if (err) |