Skip to content

Commit

Permalink
[IrDA] af_irda: irda_accept cleanup
Browse files Browse the repository at this point in the history
This patch removes a cut'n'paste copy of wait_event_interruptible
from irda_accept.

Signed-off-by: Samuel Ortiz <[email protected]>
Acked-by: Olaf Kirch <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Samuel Ortiz authored and David S. Miller committed Apr 26, 2007
1 parent 6e66aa1 commit d7f48d1
Showing 1 changed file with 8 additions and 26 deletions.
34 changes: 8 additions & 26 deletions net/irda/af_irda.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,37 +872,19 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags)
* calling us, the data is waiting for us ;-)
* Jean II
*/
skb = skb_dequeue(&sk->sk_receive_queue);
if (skb == NULL) {
int ret = 0;
DECLARE_WAITQUEUE(waitq, current);
while (1) {
skb = skb_dequeue(&sk->sk_receive_queue);
if (skb)
break;

/* Non blocking operation */
if (flags & O_NONBLOCK)
return -EWOULDBLOCK;

/* The following code is a cut'n'paste of the
* wait_event_interruptible() macro.
* We don't us the macro because the condition has
* side effects : we want to make sure that only one
* skb get dequeued - Jean II */
add_wait_queue(sk->sk_sleep, &waitq);
for (;;) {
set_current_state(TASK_INTERRUPTIBLE);
skb = skb_dequeue(&sk->sk_receive_queue);
if (skb != NULL)
break;
if (!signal_pending(current)) {
schedule();
continue;
}
ret = -ERESTARTSYS;
break;
}
current->state = TASK_RUNNING;
remove_wait_queue(sk->sk_sleep, &waitq);
if(ret)
return -ERESTARTSYS;
err = wait_event_interruptible(*(sk->sk_sleep),
skb_peek(&sk->sk_receive_queue));
if (err)
return err;
}

newsk = newsock->sk;
Expand Down

0 comments on commit d7f48d1

Please sign in to comment.