aboutsummaryrefslogtreecommitdiffstats
path: root/net/rose
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2007-04-20 19:06:45 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:29:15 -0400
commit75606dc69adcfff433bca0ff747538d8495da0ab (patch)
treec36260ce3ee94fe5f405be68b90af888c7324825 /net/rose
parent80feaacb8a6400a9540a961b6743c69a5896b937 (diff)
[AX25/NETROM/ROSE]: Convert to use modern wait queue API
Signed-off-by: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/rose')
-rw-r--r--net/rose/af_rose.c54
1 files changed, 26 insertions, 28 deletions
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index 806bf6f5dc6d..d476c43d5216 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -812,26 +812,26 @@ rose_try_next_neigh:
812 * closed. 812 * closed.
813 */ 813 */
814 if (sk->sk_state == TCP_SYN_SENT) { 814 if (sk->sk_state == TCP_SYN_SENT) {
815 struct task_struct *tsk = current; 815 DEFINE_WAIT(wait);
816 DECLARE_WAITQUEUE(wait, tsk);
817 816
818 add_wait_queue(sk->sk_sleep, &wait);
819 for (;;) { 817 for (;;) {
820 set_current_state(TASK_INTERRUPTIBLE); 818 prepare_to_wait(sk->sk_sleep, &wait,
819 TASK_INTERRUPTIBLE);
821 if (sk->sk_state != TCP_SYN_SENT) 820 if (sk->sk_state != TCP_SYN_SENT)
822 break; 821 break;
823 release_sock(sk); 822 if (!signal_pending(current)) {
824 if (!signal_pending(tsk)) { 823 release_sock(sk);
825 schedule(); 824 schedule();
826 lock_sock(sk); 825 lock_sock(sk);
827 continue; 826 continue;
828 } 827 }
829 current->state = TASK_RUNNING; 828 err = -ERESTARTSYS;
830 remove_wait_queue(sk->sk_sleep, &wait); 829 break;
831 return -ERESTARTSYS;
832 } 830 }
833 current->state = TASK_RUNNING; 831 finish_wait(sk->sk_sleep, &wait);
834 remove_wait_queue(sk->sk_sleep, &wait); 832
833 if (err)
834 goto out_release;
835 } 835 }
836 836
837 if (sk->sk_state != TCP_ESTABLISHED) { 837 if (sk->sk_state != TCP_ESTABLISHED) {
@@ -856,10 +856,9 @@ out_release:
856 856
857static int rose_accept(struct socket *sock, struct socket *newsock, int flags) 857static int rose_accept(struct socket *sock, struct socket *newsock, int flags)
858{ 858{
859 struct task_struct *tsk = current;
860 DECLARE_WAITQUEUE(wait, tsk);
861 struct sk_buff *skb; 859 struct sk_buff *skb;
862 struct sock *newsk; 860 struct sock *newsk;
861 DEFINE_WAIT(wait);
863 struct sock *sk; 862 struct sock *sk;
864 int err = 0; 863 int err = 0;
865 864
@@ -869,42 +868,41 @@ static int rose_accept(struct socket *sock, struct socket *newsock, int flags)
869 lock_sock(sk); 868 lock_sock(sk);
870 if (sk->sk_type != SOCK_SEQPACKET) { 869 if (sk->sk_type != SOCK_SEQPACKET) {
871 err = -EOPNOTSUPP; 870 err = -EOPNOTSUPP;
872 goto out; 871 goto out_release;
873 } 872 }
874 873
875 if (sk->sk_state != TCP_LISTEN) { 874 if (sk->sk_state != TCP_LISTEN) {
876 err = -EINVAL; 875 err = -EINVAL;
877 goto out; 876 goto out_release;
878 } 877 }
879 878
880 /* 879 /*
881 * The write queue this time is holding sockets ready to use 880 * The write queue this time is holding sockets ready to use
882 * hooked into the SABM we saved 881 * hooked into the SABM we saved
883 */ 882 */
884 add_wait_queue(sk->sk_sleep, &wait);
885 for (;;) { 883 for (;;) {
884 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
885
886 skb = skb_dequeue(&sk->sk_receive_queue); 886 skb = skb_dequeue(&sk->sk_receive_queue);
887 if (skb) 887 if (skb)
888 break; 888 break;
889 889
890 current->state = TASK_INTERRUPTIBLE;
891 release_sock(sk);
892 if (flags & O_NONBLOCK) { 890 if (flags & O_NONBLOCK) {
893 current->state = TASK_RUNNING; 891 err = -EWOULDBLOCK;
894 remove_wait_queue(sk->sk_sleep, &wait); 892 break;
895 return -EWOULDBLOCK;
896 } 893 }
897 if (!signal_pending(tsk)) { 894 if (!signal_pending(current)) {
895 release_sock(sk);
898 schedule(); 896 schedule();
899 lock_sock(sk); 897 lock_sock(sk);
900 continue; 898 continue;
901 } 899 }
902 current->state = TASK_RUNNING; 900 err = -ERESTARTSYS;
903 remove_wait_queue(sk->sk_sleep, &wait); 901 break;
904 return -ERESTARTSYS;
905 } 902 }
906 current->state = TASK_RUNNING; 903 finish_wait(sk->sk_sleep, &wait);
907 remove_wait_queue(sk->sk_sleep, &wait); 904 if (err)
905 goto out_release;
908 906
909 newsk = skb->sk; 907 newsk = skb->sk;
910 newsk->sk_socket = newsock; 908 newsk->sk_socket = newsock;
@@ -916,7 +914,7 @@ static int rose_accept(struct socket *sock, struct socket *newsock, int flags)
916 sk->sk_ack_backlog--; 914 sk->sk_ack_backlog--;
917 newsock->sk = newsk; 915 newsock->sk = newsk;
918 916
919out: 917out_release:
920 release_sock(sk); 918 release_sock(sk);
921 919
922 return err; 920 return err;