Commit 06cd1702 authored by David S. Miller's avatar David S. Miller

Merge branch 'tipc-improvement-for-wait-and-wakeup'

Tung Nguyen says:

====================
tipc: improvement for wait and wakeup

Some improvements for tipc_wait_for_xzy().
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 3c963a33 48766a58
...@@ -388,7 +388,7 @@ static int tipc_sk_sock_err(struct socket *sock, long *timeout) ...@@ -388,7 +388,7 @@ static int tipc_sk_sock_err(struct socket *sock, long *timeout)
rc_ = tipc_sk_sock_err((sock_), timeo_); \ rc_ = tipc_sk_sock_err((sock_), timeo_); \
if (rc_) \ if (rc_) \
break; \ break; \
prepare_to_wait(sk_sleep(sk_), &wait_, TASK_INTERRUPTIBLE); \ add_wait_queue(sk_sleep(sk_), &wait_); \
release_sock(sk_); \ release_sock(sk_); \
*(timeo_) = wait_woken(&wait_, TASK_INTERRUPTIBLE, *(timeo_)); \ *(timeo_) = wait_woken(&wait_, TASK_INTERRUPTIBLE, *(timeo_)); \
sched_annotate_sleep(); \ sched_annotate_sleep(); \
...@@ -1677,7 +1677,7 @@ static void tipc_sk_send_ack(struct tipc_sock *tsk) ...@@ -1677,7 +1677,7 @@ static void tipc_sk_send_ack(struct tipc_sock *tsk)
static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop) static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
DEFINE_WAIT(wait); DEFINE_WAIT_FUNC(wait, woken_wake_function);
long timeo = *timeop; long timeo = *timeop;
int err = sock_error(sk); int err = sock_error(sk);
...@@ -1685,15 +1685,17 @@ static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop) ...@@ -1685,15 +1685,17 @@ static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop)
return err; return err;
for (;;) { for (;;) {
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
if (timeo && skb_queue_empty(&sk->sk_receive_queue)) { if (timeo && skb_queue_empty(&sk->sk_receive_queue)) {
if (sk->sk_shutdown & RCV_SHUTDOWN) { if (sk->sk_shutdown & RCV_SHUTDOWN) {
err = -ENOTCONN; err = -ENOTCONN;
break; break;
} }
add_wait_queue(sk_sleep(sk), &wait);
release_sock(sk); release_sock(sk);
timeo = schedule_timeout(timeo); timeo = wait_woken(&wait, TASK_INTERRUPTIBLE, timeo);
sched_annotate_sleep();
lock_sock(sk); lock_sock(sk);
remove_wait_queue(sk_sleep(sk), &wait);
} }
err = 0; err = 0;
if (!skb_queue_empty(&sk->sk_receive_queue)) if (!skb_queue_empty(&sk->sk_receive_queue))
...@@ -1709,7 +1711,6 @@ static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop) ...@@ -1709,7 +1711,6 @@ static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop)
if (err) if (err)
break; break;
} }
finish_wait(sk_sleep(sk), &wait);
*timeop = timeo; *timeop = timeo;
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment