diff options
-rw-r--r-- | net/irda/af_irda.c | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index e9aa1626ea89..4eda10d79141 100644 --- a/net/irda/af_irda.c +++ b/net/irda/af_irda.c | |||
@@ -872,37 +872,19 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags) | |||
872 | * calling us, the data is waiting for us ;-) | 872 | * calling us, the data is waiting for us ;-) |
873 | * Jean II | 873 | * Jean II |
874 | */ | 874 | */ |
875 | skb = skb_dequeue(&sk->sk_receive_queue); | 875 | while (1) { |
876 | if (skb == NULL) { | 876 | skb = skb_dequeue(&sk->sk_receive_queue); |
877 | int ret = 0; | 877 | if (skb) |
878 | DECLARE_WAITQUEUE(waitq, current); | 878 | break; |
879 | 879 | ||
880 | /* Non blocking operation */ | 880 | /* Non blocking operation */ |
881 | if (flags & O_NONBLOCK) | 881 | if (flags & O_NONBLOCK) |
882 | return -EWOULDBLOCK; | 882 | return -EWOULDBLOCK; |
883 | 883 | ||
884 | /* The following code is a cut'n'paste of the | 884 | err = wait_event_interruptible(*(sk->sk_sleep), |
885 | * wait_event_interruptible() macro. | 885 | skb_peek(&sk->sk_receive_queue)); |
886 | * We don't us the macro because the condition has | 886 | if (err) |
887 | * side effects : we want to make sure that only one | 887 | return err; |
888 | * skb get dequeued - Jean II */ | ||
889 | add_wait_queue(sk->sk_sleep, &waitq); | ||
890 | for (;;) { | ||
891 | set_current_state(TASK_INTERRUPTIBLE); | ||
892 | skb = skb_dequeue(&sk->sk_receive_queue); | ||
893 | if (skb != NULL) | ||
894 | break; | ||
895 | if (!signal_pending(current)) { | ||
896 | schedule(); | ||
897 | continue; | ||
898 | } | ||
899 | ret = -ERESTARTSYS; | ||
900 | break; | ||
901 | } | ||
902 | current->state = TASK_RUNNING; | ||
903 | remove_wait_queue(sk->sk_sleep, &waitq); | ||
904 | if(ret) | ||
905 | return -ERESTARTSYS; | ||
906 | } | 888 | } |
907 | 889 | ||
908 | newsk = newsock->sk; | 890 | newsk = newsock->sk; |