Skip to content

Commit

Permalink
decnet: Remove SOCK_SLEEP_{PRE,POST} usage.
Browse files Browse the repository at this point in the history
Just expand the wait sequence.  And as a nice side-effect
the timeout is respected now.

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jun 17, 2008
1 parent 8ce9c6e commit 22196d3
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions net/decnet/af_decnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1719,6 +1719,8 @@ static int dn_recvmsg(struct kiocb *iocb, struct socket *sock,
* See if there is data ready to read, sleep if there isn't
*/
for(;;) {
DEFINE_WAIT(wait);

if (sk->sk_err)
goto out;

Expand Down Expand Up @@ -1748,14 +1750,11 @@ static int dn_recvmsg(struct kiocb *iocb, struct socket *sock,
goto out;
}

set_bit(SOCK_ASYNC_WAITDATA, &sock->flags);
SOCK_SLEEP_PRE(sk)

if (!dn_data_ready(sk, queue, flags, target))
schedule();

SOCK_SLEEP_POST(sk)
clear_bit(SOCK_ASYNC_WAITDATA, &sock->flags);
prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags);
sk_wait_event(sk, &timeo, dn_data_ready(sk, queue, flags, target));
clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags);
finish_wait(sk->sk_sleep, &wait);
}

for(skb = queue->next; skb != (struct sk_buff *)queue; skb = nskb) {
Expand Down Expand Up @@ -2002,18 +2001,19 @@ static int dn_sendmsg(struct kiocb *iocb, struct socket *sock,
* size.
*/
if (dn_queue_too_long(scp, queue, flags)) {
DEFINE_WAIT(wait);

if (flags & MSG_DONTWAIT) {
err = -EWOULDBLOCK;
goto out;
}

SOCK_SLEEP_PRE(sk)

if (dn_queue_too_long(scp, queue, flags))
schedule();

SOCK_SLEEP_POST(sk)

prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags);
sk_wait_event(sk, &timeo,
!dn_queue_too_long(scp, queue, flags));
clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags);
finish_wait(sk->sk_sleep, &wait);
continue;
}

Expand Down

0 comments on commit 22196d3

Please sign in to comment.