diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2007-04-20 19:06:45 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:29:15 -0400 |
commit | 75606dc69adcfff433bca0ff747538d8495da0ab (patch) | |
tree | c36260ce3ee94fe5f405be68b90af888c7324825 | |
parent | 80feaacb8a6400a9540a961b6743c69a5896b937 (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>
-rw-r--r-- | net/ax25/af_ax25.c | 77 | ||||
-rw-r--r-- | net/netrom/af_netrom.c | 93 | ||||
-rw-r--r-- | net/rose/af_rose.c | 54 |
3 files changed, 109 insertions, 115 deletions
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 5f28887822e9..6ded95272a53 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c | |||
@@ -1127,22 +1127,22 @@ static int __must_check ax25_connect(struct socket *sock, | |||
1127 | switch (sk->sk_state) { | 1127 | switch (sk->sk_state) { |
1128 | case TCP_SYN_SENT: /* still trying */ | 1128 | case TCP_SYN_SENT: /* still trying */ |
1129 | err = -EINPROGRESS; | 1129 | err = -EINPROGRESS; |
1130 | goto out; | 1130 | goto out_release; |
1131 | 1131 | ||
1132 | case TCP_ESTABLISHED: /* connection established */ | 1132 | case TCP_ESTABLISHED: /* connection established */ |
1133 | sock->state = SS_CONNECTED; | 1133 | sock->state = SS_CONNECTED; |
1134 | goto out; | 1134 | goto out_release; |
1135 | 1135 | ||
1136 | case TCP_CLOSE: /* connection refused */ | 1136 | case TCP_CLOSE: /* connection refused */ |
1137 | sock->state = SS_UNCONNECTED; | 1137 | sock->state = SS_UNCONNECTED; |
1138 | err = -ECONNREFUSED; | 1138 | err = -ECONNREFUSED; |
1139 | goto out; | 1139 | goto out_release; |
1140 | } | 1140 | } |
1141 | } | 1141 | } |
1142 | 1142 | ||
1143 | if (sk->sk_state == TCP_ESTABLISHED && sk->sk_type == SOCK_SEQPACKET) { | 1143 | if (sk->sk_state == TCP_ESTABLISHED && sk->sk_type == SOCK_SEQPACKET) { |
1144 | err = -EISCONN; /* No reconnect on a seqpacket socket */ | 1144 | err = -EISCONN; /* No reconnect on a seqpacket socket */ |
1145 | goto out; | 1145 | goto out_release; |
1146 | } | 1146 | } |
1147 | 1147 | ||
1148 | sk->sk_state = TCP_CLOSE; | 1148 | sk->sk_state = TCP_CLOSE; |
@@ -1159,12 +1159,12 @@ static int __must_check ax25_connect(struct socket *sock, | |||
1159 | /* Valid number of digipeaters ? */ | 1159 | /* Valid number of digipeaters ? */ |
1160 | if (fsa->fsa_ax25.sax25_ndigis < 1 || fsa->fsa_ax25.sax25_ndigis > AX25_MAX_DIGIS) { | 1160 | if (fsa->fsa_ax25.sax25_ndigis < 1 || fsa->fsa_ax25.sax25_ndigis > AX25_MAX_DIGIS) { |
1161 | err = -EINVAL; | 1161 | err = -EINVAL; |
1162 | goto out; | 1162 | goto out_release; |
1163 | } | 1163 | } |
1164 | 1164 | ||
1165 | if ((digi = kmalloc(sizeof(ax25_digi), GFP_KERNEL)) == NULL) { | 1165 | if ((digi = kmalloc(sizeof(ax25_digi), GFP_KERNEL)) == NULL) { |
1166 | err = -ENOBUFS; | 1166 | err = -ENOBUFS; |
1167 | goto out; | 1167 | goto out_release; |
1168 | } | 1168 | } |
1169 | 1169 | ||
1170 | digi->ndigi = fsa->fsa_ax25.sax25_ndigis; | 1170 | digi->ndigi = fsa->fsa_ax25.sax25_ndigis; |
@@ -1194,7 +1194,7 @@ static int __must_check ax25_connect(struct socket *sock, | |||
1194 | current->comm); | 1194 | current->comm); |
1195 | if ((err = ax25_rt_autobind(ax25, &fsa->fsa_ax25.sax25_call)) < 0) { | 1195 | if ((err = ax25_rt_autobind(ax25, &fsa->fsa_ax25.sax25_call)) < 0) { |
1196 | kfree(digi); | 1196 | kfree(digi); |
1197 | goto out; | 1197 | goto out_release; |
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | ax25_fillin_cb(ax25, ax25->ax25_dev); | 1200 | ax25_fillin_cb(ax25, ax25->ax25_dev); |
@@ -1203,7 +1203,7 @@ static int __must_check ax25_connect(struct socket *sock, | |||
1203 | if (ax25->ax25_dev == NULL) { | 1203 | if (ax25->ax25_dev == NULL) { |
1204 | kfree(digi); | 1204 | kfree(digi); |
1205 | err = -EHOSTUNREACH; | 1205 | err = -EHOSTUNREACH; |
1206 | goto out; | 1206 | goto out_release; |
1207 | } | 1207 | } |
1208 | } | 1208 | } |
1209 | 1209 | ||
@@ -1213,7 +1213,7 @@ static int __must_check ax25_connect(struct socket *sock, | |||
1213 | kfree(digi); | 1213 | kfree(digi); |
1214 | err = -EADDRINUSE; /* Already such a connection */ | 1214 | err = -EADDRINUSE; /* Already such a connection */ |
1215 | ax25_cb_put(ax25t); | 1215 | ax25_cb_put(ax25t); |
1216 | goto out; | 1216 | goto out_release; |
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | ax25->dest_addr = fsa->fsa_ax25.sax25_call; | 1219 | ax25->dest_addr = fsa->fsa_ax25.sax25_call; |
@@ -1223,7 +1223,7 @@ static int __must_check ax25_connect(struct socket *sock, | |||
1223 | if (sk->sk_type != SOCK_SEQPACKET) { | 1223 | if (sk->sk_type != SOCK_SEQPACKET) { |
1224 | sock->state = SS_CONNECTED; | 1224 | sock->state = SS_CONNECTED; |
1225 | sk->sk_state = TCP_ESTABLISHED; | 1225 | sk->sk_state = TCP_ESTABLISHED; |
1226 | goto out; | 1226 | goto out_release; |
1227 | } | 1227 | } |
1228 | 1228 | ||
1229 | /* Move to connecting socket, ax.25 lapb WAIT_UA.. */ | 1229 | /* Move to connecting socket, ax.25 lapb WAIT_UA.. */ |
@@ -1255,55 +1255,53 @@ static int __must_check ax25_connect(struct socket *sock, | |||
1255 | /* Now the loop */ | 1255 | /* Now the loop */ |
1256 | if (sk->sk_state != TCP_ESTABLISHED && (flags & O_NONBLOCK)) { | 1256 | if (sk->sk_state != TCP_ESTABLISHED && (flags & O_NONBLOCK)) { |
1257 | err = -EINPROGRESS; | 1257 | err = -EINPROGRESS; |
1258 | goto out; | 1258 | goto out_release; |
1259 | } | 1259 | } |
1260 | 1260 | ||
1261 | if (sk->sk_state == TCP_SYN_SENT) { | 1261 | if (sk->sk_state == TCP_SYN_SENT) { |
1262 | struct task_struct *tsk = current; | 1262 | DEFINE_WAIT(wait); |
1263 | DECLARE_WAITQUEUE(wait, tsk); | ||
1264 | 1263 | ||
1265 | add_wait_queue(sk->sk_sleep, &wait); | ||
1266 | for (;;) { | 1264 | for (;;) { |
1265 | prepare_to_wait(sk->sk_sleep, &wait, | ||
1266 | TASK_INTERRUPTIBLE); | ||
1267 | if (sk->sk_state != TCP_SYN_SENT) | 1267 | if (sk->sk_state != TCP_SYN_SENT) |
1268 | break; | 1268 | break; |
1269 | set_current_state(TASK_INTERRUPTIBLE); | 1269 | if (!signal_pending(current)) { |
1270 | release_sock(sk); | 1270 | release_sock(sk); |
1271 | if (!signal_pending(tsk)) { | ||
1272 | schedule(); | 1271 | schedule(); |
1273 | lock_sock(sk); | 1272 | lock_sock(sk); |
1274 | continue; | 1273 | continue; |
1275 | } | 1274 | } |
1276 | current->state = TASK_RUNNING; | 1275 | err = -ERESTARTSYS; |
1277 | remove_wait_queue(sk->sk_sleep, &wait); | 1276 | break; |
1278 | return -ERESTARTSYS; | ||
1279 | } | 1277 | } |
1280 | current->state = TASK_RUNNING; | 1278 | finish_wait(sk->sk_sleep, &wait); |
1281 | remove_wait_queue(sk->sk_sleep, &wait); | 1279 | |
1280 | if (err) | ||
1281 | goto out_release; | ||
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | if (sk->sk_state != TCP_ESTABLISHED) { | 1284 | if (sk->sk_state != TCP_ESTABLISHED) { |
1285 | /* Not in ABM, not in WAIT_UA -> failed */ | 1285 | /* Not in ABM, not in WAIT_UA -> failed */ |
1286 | sock->state = SS_UNCONNECTED; | 1286 | sock->state = SS_UNCONNECTED; |
1287 | err = sock_error(sk); /* Always set at this point */ | 1287 | err = sock_error(sk); /* Always set at this point */ |
1288 | goto out; | 1288 | goto out_release; |
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | sock->state = SS_CONNECTED; | 1291 | sock->state = SS_CONNECTED; |
1292 | 1292 | ||
1293 | err=0; | 1293 | err = 0; |
1294 | out: | 1294 | out_release: |
1295 | release_sock(sk); | 1295 | release_sock(sk); |
1296 | 1296 | ||
1297 | return err; | 1297 | return err; |
1298 | } | 1298 | } |
1299 | 1299 | ||
1300 | |||
1301 | static int ax25_accept(struct socket *sock, struct socket *newsock, int flags) | 1300 | static int ax25_accept(struct socket *sock, struct socket *newsock, int flags) |
1302 | { | 1301 | { |
1303 | struct task_struct *tsk = current; | ||
1304 | DECLARE_WAITQUEUE(wait, tsk); | ||
1305 | struct sk_buff *skb; | 1302 | struct sk_buff *skb; |
1306 | struct sock *newsk; | 1303 | struct sock *newsk; |
1304 | DEFINE_WAIT(wait); | ||
1307 | struct sock *sk; | 1305 | struct sock *sk; |
1308 | int err = 0; | 1306 | int err = 0; |
1309 | 1307 | ||
@@ -1328,30 +1326,29 @@ static int ax25_accept(struct socket *sock, struct socket *newsock, int flags) | |||
1328 | * The read queue this time is holding sockets ready to use | 1326 | * The read queue this time is holding sockets ready to use |
1329 | * hooked into the SABM we saved | 1327 | * hooked into the SABM we saved |
1330 | */ | 1328 | */ |
1331 | add_wait_queue(sk->sk_sleep, &wait); | ||
1332 | for (;;) { | 1329 | for (;;) { |
1330 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); | ||
1333 | skb = skb_dequeue(&sk->sk_receive_queue); | 1331 | skb = skb_dequeue(&sk->sk_receive_queue); |
1334 | if (skb) | 1332 | if (skb) |
1335 | break; | 1333 | break; |
1336 | 1334 | ||
1337 | release_sock(sk); | ||
1338 | current->state = TASK_INTERRUPTIBLE; | ||
1339 | if (flags & O_NONBLOCK) { | 1335 | if (flags & O_NONBLOCK) { |
1340 | current->state = TASK_RUNNING; | 1336 | err = -EWOULDBLOCK; |
1341 | remove_wait_queue(sk->sk_sleep, &wait); | 1337 | break; |
1342 | return -EWOULDBLOCK; | ||
1343 | } | 1338 | } |
1344 | if (!signal_pending(tsk)) { | 1339 | if (!signal_pending(current)) { |
1340 | release_sock(sk); | ||
1345 | schedule(); | 1341 | schedule(); |
1346 | lock_sock(sk); | 1342 | lock_sock(sk); |
1347 | continue; | 1343 | continue; |
1348 | } | 1344 | } |
1349 | current->state = TASK_RUNNING; | 1345 | err = -ERESTARTSYS; |
1350 | remove_wait_queue(sk->sk_sleep, &wait); | 1346 | break; |
1351 | return -ERESTARTSYS; | ||
1352 | } | 1347 | } |
1353 | current->state = TASK_RUNNING; | 1348 | finish_wait(sk->sk_sleep, &wait); |
1354 | remove_wait_queue(sk->sk_sleep, &wait); | 1349 | |
1350 | if (err) | ||
1351 | goto out; | ||
1355 | 1352 | ||
1356 | newsk = skb->sk; | 1353 | newsk = skb->sk; |
1357 | newsk->sk_socket = newsock; | 1354 | newsk->sk_socket = newsock; |
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index 5dc7448925db..5d4a26c2aa0c 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c | |||
@@ -625,42 +625,42 @@ static int nr_connect(struct socket *sock, struct sockaddr *uaddr, | |||
625 | ax25_address *source = NULL; | 625 | ax25_address *source = NULL; |
626 | ax25_uid_assoc *user; | 626 | ax25_uid_assoc *user; |
627 | struct net_device *dev; | 627 | struct net_device *dev; |
628 | int err = 0; | ||
628 | 629 | ||
629 | lock_sock(sk); | 630 | lock_sock(sk); |
630 | if (sk->sk_state == TCP_ESTABLISHED && sock->state == SS_CONNECTING) { | 631 | if (sk->sk_state == TCP_ESTABLISHED && sock->state == SS_CONNECTING) { |
631 | sock->state = SS_CONNECTED; | 632 | sock->state = SS_CONNECTED; |
632 | release_sock(sk); | 633 | goto out_release; /* Connect completed during a ERESTARTSYS event */ |
633 | return 0; /* Connect completed during a ERESTARTSYS event */ | ||
634 | } | 634 | } |
635 | 635 | ||
636 | if (sk->sk_state == TCP_CLOSE && sock->state == SS_CONNECTING) { | 636 | if (sk->sk_state == TCP_CLOSE && sock->state == SS_CONNECTING) { |
637 | sock->state = SS_UNCONNECTED; | 637 | sock->state = SS_UNCONNECTED; |
638 | release_sock(sk); | 638 | err = -ECONNREFUSED; |
639 | return -ECONNREFUSED; | 639 | goto out_release; |
640 | } | 640 | } |
641 | 641 | ||
642 | if (sk->sk_state == TCP_ESTABLISHED) { | 642 | if (sk->sk_state == TCP_ESTABLISHED) { |
643 | release_sock(sk); | 643 | err = -EISCONN; /* No reconnect on a seqpacket socket */ |
644 | return -EISCONN; /* No reconnect on a seqpacket socket */ | 644 | goto out_release; |
645 | } | 645 | } |
646 | 646 | ||
647 | sk->sk_state = TCP_CLOSE; | 647 | sk->sk_state = TCP_CLOSE; |
648 | sock->state = SS_UNCONNECTED; | 648 | sock->state = SS_UNCONNECTED; |
649 | 649 | ||
650 | if (addr_len != sizeof(struct sockaddr_ax25) && addr_len != sizeof(struct full_sockaddr_ax25)) { | 650 | if (addr_len != sizeof(struct sockaddr_ax25) && addr_len != sizeof(struct full_sockaddr_ax25)) { |
651 | release_sock(sk); | 651 | err = -EINVAL; |
652 | return -EINVAL; | 652 | goto out_release; |
653 | } | 653 | } |
654 | if (addr->sax25_family != AF_NETROM) { | 654 | if (addr->sax25_family != AF_NETROM) { |
655 | release_sock(sk); | 655 | err = -EINVAL; |
656 | return -EINVAL; | 656 | goto out_release; |
657 | } | 657 | } |
658 | if (sock_flag(sk, SOCK_ZAPPED)) { /* Must bind first - autobinding in this may or may not work */ | 658 | if (sock_flag(sk, SOCK_ZAPPED)) { /* Must bind first - autobinding in this may or may not work */ |
659 | sock_reset_flag(sk, SOCK_ZAPPED); | 659 | sock_reset_flag(sk, SOCK_ZAPPED); |
660 | 660 | ||
661 | if ((dev = nr_dev_first()) == NULL) { | 661 | if ((dev = nr_dev_first()) == NULL) { |
662 | release_sock(sk); | 662 | err = -ENETUNREACH; |
663 | return -ENETUNREACH; | 663 | goto out_release; |
664 | } | 664 | } |
665 | source = (ax25_address *)dev->dev_addr; | 665 | source = (ax25_address *)dev->dev_addr; |
666 | 666 | ||
@@ -671,8 +671,8 @@ static int nr_connect(struct socket *sock, struct sockaddr *uaddr, | |||
671 | } else { | 671 | } else { |
672 | if (ax25_uid_policy && !capable(CAP_NET_ADMIN)) { | 672 | if (ax25_uid_policy && !capable(CAP_NET_ADMIN)) { |
673 | dev_put(dev); | 673 | dev_put(dev); |
674 | release_sock(sk); | 674 | err = -EPERM; |
675 | return -EPERM; | 675 | goto out_release; |
676 | } | 676 | } |
677 | nr->user_addr = *source; | 677 | nr->user_addr = *source; |
678 | } | 678 | } |
@@ -707,8 +707,8 @@ static int nr_connect(struct socket *sock, struct sockaddr *uaddr, | |||
707 | 707 | ||
708 | /* Now the loop */ | 708 | /* Now the loop */ |
709 | if (sk->sk_state != TCP_ESTABLISHED && (flags & O_NONBLOCK)) { | 709 | if (sk->sk_state != TCP_ESTABLISHED && (flags & O_NONBLOCK)) { |
710 | release_sock(sk); | 710 | err = -EINPROGRESS; |
711 | return -EINPROGRESS; | 711 | goto out_release; |
712 | } | 712 | } |
713 | 713 | ||
714 | /* | 714 | /* |
@@ -716,46 +716,46 @@ static int nr_connect(struct socket *sock, struct sockaddr *uaddr, | |||
716 | * closed. | 716 | * closed. |
717 | */ | 717 | */ |
718 | if (sk->sk_state == TCP_SYN_SENT) { | 718 | if (sk->sk_state == TCP_SYN_SENT) { |
719 | struct task_struct *tsk = current; | 719 | DEFINE_WAIT(wait); |
720 | DECLARE_WAITQUEUE(wait, tsk); | ||
721 | 720 | ||
722 | add_wait_queue(sk->sk_sleep, &wait); | ||
723 | for (;;) { | 721 | for (;;) { |
724 | set_current_state(TASK_INTERRUPTIBLE); | 722 | prepare_to_wait(sk->sk_sleep, &wait, |
723 | TASK_INTERRUPTIBLE); | ||
725 | if (sk->sk_state != TCP_SYN_SENT) | 724 | if (sk->sk_state != TCP_SYN_SENT) |
726 | break; | 725 | break; |
727 | release_sock(sk); | 726 | if (!signal_pending(current)) { |
728 | if (!signal_pending(tsk)) { | 727 | release_sock(sk); |
729 | schedule(); | 728 | schedule(); |
730 | lock_sock(sk); | 729 | lock_sock(sk); |
731 | continue; | 730 | continue; |
732 | } | 731 | } |
733 | current->state = TASK_RUNNING; | 732 | err = -ERESTARTSYS; |
734 | remove_wait_queue(sk->sk_sleep, &wait); | 733 | break; |
735 | return -ERESTARTSYS; | ||
736 | } | 734 | } |
737 | current->state = TASK_RUNNING; | 735 | finish_wait(sk->sk_sleep, &wait); |
738 | remove_wait_queue(sk->sk_sleep, &wait); | 736 | if (err) |
737 | goto out_release; | ||
739 | } | 738 | } |
740 | 739 | ||
741 | if (sk->sk_state != TCP_ESTABLISHED) { | 740 | if (sk->sk_state != TCP_ESTABLISHED) { |
742 | sock->state = SS_UNCONNECTED; | 741 | sock->state = SS_UNCONNECTED; |
743 | release_sock(sk); | 742 | err = sock_error(sk); /* Always set at this point */ |
744 | return sock_error(sk); /* Always set at this point */ | 743 | goto out_release; |
745 | } | 744 | } |
746 | 745 | ||
747 | sock->state = SS_CONNECTED; | 746 | sock->state = SS_CONNECTED; |
747 | |||
748 | out_release: | ||
748 | release_sock(sk); | 749 | release_sock(sk); |
749 | 750 | ||
750 | return 0; | 751 | return err; |
751 | } | 752 | } |
752 | 753 | ||
753 | static int nr_accept(struct socket *sock, struct socket *newsock, int flags) | 754 | static int nr_accept(struct socket *sock, struct socket *newsock, int flags) |
754 | { | 755 | { |
755 | struct task_struct *tsk = current; | ||
756 | DECLARE_WAITQUEUE(wait, tsk); | ||
757 | struct sk_buff *skb; | 756 | struct sk_buff *skb; |
758 | struct sock *newsk; | 757 | struct sock *newsk; |
758 | DEFINE_WAIT(wait); | ||
759 | struct sock *sk; | 759 | struct sock *sk; |
760 | int err = 0; | 760 | int err = 0; |
761 | 761 | ||
@@ -765,42 +765,40 @@ static int nr_accept(struct socket *sock, struct socket *newsock, int flags) | |||
765 | lock_sock(sk); | 765 | lock_sock(sk); |
766 | if (sk->sk_type != SOCK_SEQPACKET) { | 766 | if (sk->sk_type != SOCK_SEQPACKET) { |
767 | err = -EOPNOTSUPP; | 767 | err = -EOPNOTSUPP; |
768 | goto out; | 768 | goto out_release; |
769 | } | 769 | } |
770 | 770 | ||
771 | if (sk->sk_state != TCP_LISTEN) { | 771 | if (sk->sk_state != TCP_LISTEN) { |
772 | err = -EINVAL; | 772 | err = -EINVAL; |
773 | goto out; | 773 | goto out_release; |
774 | } | 774 | } |
775 | 775 | ||
776 | /* | 776 | /* |
777 | * The write queue this time is holding sockets ready to use | 777 | * The write queue this time is holding sockets ready to use |
778 | * hooked into the SABM we saved | 778 | * hooked into the SABM we saved |
779 | */ | 779 | */ |
780 | add_wait_queue(sk->sk_sleep, &wait); | ||
781 | for (;;) { | 780 | for (;;) { |
781 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); | ||
782 | skb = skb_dequeue(&sk->sk_receive_queue); | 782 | skb = skb_dequeue(&sk->sk_receive_queue); |
783 | if (skb) | 783 | if (skb) |
784 | break; | 784 | break; |
785 | 785 | ||
786 | current->state = TASK_INTERRUPTIBLE; | ||
787 | release_sock(sk); | ||
788 | if (flags & O_NONBLOCK) { | 786 | if (flags & O_NONBLOCK) { |
789 | current->state = TASK_RUNNING; | 787 | err = -EWOULDBLOCK; |
790 | remove_wait_queue(sk->sk_sleep, &wait); | 788 | break; |
791 | return -EWOULDBLOCK; | ||
792 | } | 789 | } |
793 | if (!signal_pending(tsk)) { | 790 | if (!signal_pending(current)) { |
791 | release_sock(sk); | ||
794 | schedule(); | 792 | schedule(); |
795 | lock_sock(sk); | 793 | lock_sock(sk); |
796 | continue; | 794 | continue; |
797 | } | 795 | } |
798 | current->state = TASK_RUNNING; | 796 | err = -ERESTARTSYS; |
799 | remove_wait_queue(sk->sk_sleep, &wait); | 797 | break; |
800 | return -ERESTARTSYS; | ||
801 | } | 798 | } |
802 | current->state = TASK_RUNNING; | 799 | finish_wait(sk->sk_sleep, &wait); |
803 | remove_wait_queue(sk->sk_sleep, &wait); | 800 | if (err) |
801 | goto out_release; | ||
804 | 802 | ||
805 | newsk = skb->sk; | 803 | newsk = skb->sk; |
806 | newsk->sk_socket = newsock; | 804 | newsk->sk_socket = newsock; |
@@ -811,8 +809,9 @@ static int nr_accept(struct socket *sock, struct socket *newsock, int flags) | |||
811 | sk_acceptq_removed(sk); | 809 | sk_acceptq_removed(sk); |
812 | newsock->sk = newsk; | 810 | newsock->sk = newsk; |
813 | 811 | ||
814 | out: | 812 | out_release: |
815 | release_sock(sk); | 813 | release_sock(sk); |
814 | |||
816 | return err; | 815 | return err; |
817 | } | 816 | } |
818 | 817 | ||
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 | ||
857 | static int rose_accept(struct socket *sock, struct socket *newsock, int flags) | 857 | static 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 | ||
919 | out: | 917 | out_release: |
920 | release_sock(sk); | 918 | release_sock(sk); |
921 | 919 | ||
922 | return err; | 920 | return err; |