Skip to content

Commit 06cd170

Browse files
committed
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: David S. Miller <davem@davemloft.net>
2 parents 3c963a3 + 48766a5 commit 06cd170

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

net/tipc/socket.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ static int tipc_sk_sock_err(struct socket *sock, long *timeout)
388388
rc_ = tipc_sk_sock_err((sock_), timeo_); \
389389
if (rc_) \
390390
break; \
391-
prepare_to_wait(sk_sleep(sk_), &wait_, TASK_INTERRUPTIBLE); \
391+
add_wait_queue(sk_sleep(sk_), &wait_); \
392392
release_sock(sk_); \
393393
*(timeo_) = wait_woken(&wait_, TASK_INTERRUPTIBLE, *(timeo_)); \
394394
sched_annotate_sleep(); \
@@ -1677,23 +1677,25 @@ static void tipc_sk_send_ack(struct tipc_sock *tsk)
16771677
static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop)
16781678
{
16791679
struct sock *sk = sock->sk;
1680-
DEFINE_WAIT(wait);
1680+
DEFINE_WAIT_FUNC(wait, woken_wake_function);
16811681
long timeo = *timeop;
16821682
int err = sock_error(sk);
16831683

16841684
if (err)
16851685
return err;
16861686

16871687
for (;;) {
1688-
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
16891688
if (timeo && skb_queue_empty(&sk->sk_receive_queue)) {
16901689
if (sk->sk_shutdown & RCV_SHUTDOWN) {
16911690
err = -ENOTCONN;
16921691
break;
16931692
}
1693+
add_wait_queue(sk_sleep(sk), &wait);
16941694
release_sock(sk);
1695-
timeo = schedule_timeout(timeo);
1695+
timeo = wait_woken(&wait, TASK_INTERRUPTIBLE, timeo);
1696+
sched_annotate_sleep();
16961697
lock_sock(sk);
1698+
remove_wait_queue(sk_sleep(sk), &wait);
16971699
}
16981700
err = 0;
16991701
if (!skb_queue_empty(&sk->sk_receive_queue))
@@ -1709,7 +1711,6 @@ static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop)
17091711
if (err)
17101712
break;
17111713
}
1712-
finish_wait(sk_sleep(sk), &wait);
17131714
*timeop = timeo;
17141715
return err;
17151716
}

0 commit comments

Comments
 (0)