Commit d9dc8b0f authored by WANG Cong's avatar WANG Cong Committed by David S. Miller

net: fix sleeping for sk_wait_event()

Similar to commit 14135f30 ("inet: fix sleeping inside inet_wait_for_connect()"),
sk_wait_event() needs to fix too, because release_sock() is blocking,
it changes the process state back to running after sleep, which breaks
the previous prepare_to_wait().

Switch to the new wait API.

Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7d384846
...@@ -132,28 +132,27 @@ static void aead_wmem_wakeup(struct sock *sk) ...@@ -132,28 +132,27 @@ static void aead_wmem_wakeup(struct sock *sk)
static int aead_wait_for_data(struct sock *sk, unsigned flags) static int aead_wait_for_data(struct sock *sk, unsigned flags)
{ {
DEFINE_WAIT_FUNC(wait, woken_wake_function);
struct alg_sock *ask = alg_sk(sk); struct alg_sock *ask = alg_sk(sk);
struct aead_ctx *ctx = ask->private; struct aead_ctx *ctx = ask->private;
long timeout; long timeout;
DEFINE_WAIT(wait);
int err = -ERESTARTSYS; int err = -ERESTARTSYS;
if (flags & MSG_DONTWAIT) if (flags & MSG_DONTWAIT)
return -EAGAIN; return -EAGAIN;
sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
add_wait_queue(sk_sleep(sk), &wait);
for (;;) { for (;;) {
if (signal_pending(current)) if (signal_pending(current))
break; break;
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
timeout = MAX_SCHEDULE_TIMEOUT; timeout = MAX_SCHEDULE_TIMEOUT;
if (sk_wait_event(sk, &timeout, !ctx->more)) { if (sk_wait_event(sk, &timeout, !ctx->more, &wait)) {
err = 0; err = 0;
break; break;
} }
} }
finish_wait(sk_sleep(sk), &wait); remove_wait_queue(sk_sleep(sk), &wait);
sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk); sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
......
...@@ -199,26 +199,26 @@ static void skcipher_free_sgl(struct sock *sk) ...@@ -199,26 +199,26 @@ static void skcipher_free_sgl(struct sock *sk)
static int skcipher_wait_for_wmem(struct sock *sk, unsigned flags) static int skcipher_wait_for_wmem(struct sock *sk, unsigned flags)
{ {
long timeout; DEFINE_WAIT_FUNC(wait, woken_wake_function);
DEFINE_WAIT(wait);
int err = -ERESTARTSYS; int err = -ERESTARTSYS;
long timeout;
if (flags & MSG_DONTWAIT) if (flags & MSG_DONTWAIT)
return -EAGAIN; return -EAGAIN;
sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
add_wait_queue(sk_sleep(sk), &wait);
for (;;) { for (;;) {
if (signal_pending(current)) if (signal_pending(current))
break; break;
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
timeout = MAX_SCHEDULE_TIMEOUT; timeout = MAX_SCHEDULE_TIMEOUT;
if (sk_wait_event(sk, &timeout, skcipher_writable(sk))) { if (sk_wait_event(sk, &timeout, skcipher_writable(sk), &wait)) {
err = 0; err = 0;
break; break;
} }
} }
finish_wait(sk_sleep(sk), &wait); remove_wait_queue(sk_sleep(sk), &wait);
return err; return err;
} }
...@@ -242,10 +242,10 @@ static void skcipher_wmem_wakeup(struct sock *sk) ...@@ -242,10 +242,10 @@ static void skcipher_wmem_wakeup(struct sock *sk)
static int skcipher_wait_for_data(struct sock *sk, unsigned flags) static int skcipher_wait_for_data(struct sock *sk, unsigned flags)
{ {
DEFINE_WAIT_FUNC(wait, woken_wake_function);
struct alg_sock *ask = alg_sk(sk); struct alg_sock *ask = alg_sk(sk);
struct skcipher_ctx *ctx = ask->private; struct skcipher_ctx *ctx = ask->private;
long timeout; long timeout;
DEFINE_WAIT(wait);
int err = -ERESTARTSYS; int err = -ERESTARTSYS;
if (flags & MSG_DONTWAIT) { if (flags & MSG_DONTWAIT) {
...@@ -254,17 +254,17 @@ static int skcipher_wait_for_data(struct sock *sk, unsigned flags) ...@@ -254,17 +254,17 @@ static int skcipher_wait_for_data(struct sock *sk, unsigned flags)
sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
add_wait_queue(sk_sleep(sk), &wait);
for (;;) { for (;;) {
if (signal_pending(current)) if (signal_pending(current))
break; break;
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
timeout = MAX_SCHEDULE_TIMEOUT; timeout = MAX_SCHEDULE_TIMEOUT;
if (sk_wait_event(sk, &timeout, ctx->used)) { if (sk_wait_event(sk, &timeout, ctx->used, &wait)) {
err = 0; err = 0;
break; break;
} }
} }
finish_wait(sk_sleep(sk), &wait); remove_wait_queue(sk_sleep(sk), &wait);
sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk); sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
......
...@@ -915,14 +915,16 @@ static inline void sock_rps_reset_rxhash(struct sock *sk) ...@@ -915,14 +915,16 @@ static inline void sock_rps_reset_rxhash(struct sock *sk)
#endif #endif
} }
#define sk_wait_event(__sk, __timeo, __condition) \ #define sk_wait_event(__sk, __timeo, __condition, __wait) \
({ int __rc; \ ({ int __rc; \
release_sock(__sk); \ release_sock(__sk); \
__rc = __condition; \ __rc = __condition; \
if (!__rc) { \ if (!__rc) { \
*(__timeo) = schedule_timeout(*(__timeo)); \ *(__timeo) = wait_woken(__wait, \
TASK_INTERRUPTIBLE, \
*(__timeo)); \
} \ } \
sched_annotate_sleep(); \ sched_annotate_sleep(); \
lock_sock(__sk); \ lock_sock(__sk); \
__rc = __condition; \ __rc = __condition; \
__rc; \ __rc; \
......
...@@ -2078,14 +2078,14 @@ void __sk_flush_backlog(struct sock *sk) ...@@ -2078,14 +2078,14 @@ void __sk_flush_backlog(struct sock *sk)
*/ */
int sk_wait_data(struct sock *sk, long *timeo, const struct sk_buff *skb) int sk_wait_data(struct sock *sk, long *timeo, const struct sk_buff *skb)
{ {
DEFINE_WAIT_FUNC(wait, woken_wake_function);
int rc; int rc;
DEFINE_WAIT(wait);
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); add_wait_queue(sk_sleep(sk), &wait);
sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
rc = sk_wait_event(sk, timeo, skb_peek_tail(&sk->sk_receive_queue) != skb); rc = sk_wait_event(sk, timeo, skb_peek_tail(&sk->sk_receive_queue) != skb, &wait);
sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk); sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
finish_wait(sk_sleep(sk), &wait); remove_wait_queue(sk_sleep(sk), &wait);
return rc; return rc;
} }
EXPORT_SYMBOL(sk_wait_data); EXPORT_SYMBOL(sk_wait_data);
......
...@@ -53,8 +53,8 @@ void sk_stream_write_space(struct sock *sk) ...@@ -53,8 +53,8 @@ void sk_stream_write_space(struct sock *sk)
*/ */
int sk_stream_wait_connect(struct sock *sk, long *timeo_p) int sk_stream_wait_connect(struct sock *sk, long *timeo_p)
{ {
DEFINE_WAIT_FUNC(wait, woken_wake_function);
struct task_struct *tsk = current; struct task_struct *tsk = current;
DEFINE_WAIT(wait);
int done; int done;
do { do {
...@@ -68,13 +68,13 @@ int sk_stream_wait_connect(struct sock *sk, long *timeo_p) ...@@ -68,13 +68,13 @@ int sk_stream_wait_connect(struct sock *sk, long *timeo_p)
if (signal_pending(tsk)) if (signal_pending(tsk))
return sock_intr_errno(*timeo_p); return sock_intr_errno(*timeo_p);
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); add_wait_queue(sk_sleep(sk), &wait);
sk->sk_write_pending++; sk->sk_write_pending++;
done = sk_wait_event(sk, timeo_p, done = sk_wait_event(sk, timeo_p,
!sk->sk_err && !sk->sk_err &&
!((1 << sk->sk_state) & !((1 << sk->sk_state) &
~(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT))); ~(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT)), &wait);
finish_wait(sk_sleep(sk), &wait); remove_wait_queue(sk_sleep(sk), &wait);
sk->sk_write_pending--; sk->sk_write_pending--;
} while (!done); } while (!done);
return 0; return 0;
...@@ -94,16 +94,16 @@ static inline int sk_stream_closing(struct sock *sk) ...@@ -94,16 +94,16 @@ static inline int sk_stream_closing(struct sock *sk)
void sk_stream_wait_close(struct sock *sk, long timeout) void sk_stream_wait_close(struct sock *sk, long timeout)
{ {
if (timeout) { if (timeout) {
DEFINE_WAIT(wait); DEFINE_WAIT_FUNC(wait, woken_wake_function);
add_wait_queue(sk_sleep(sk), &wait);
do { do {
prepare_to_wait(sk_sleep(sk), &wait, if (sk_wait_event(sk, &timeout, !sk_stream_closing(sk), &wait))
TASK_INTERRUPTIBLE);
if (sk_wait_event(sk, &timeout, !sk_stream_closing(sk)))
break; break;
} while (!signal_pending(current) && timeout); } while (!signal_pending(current) && timeout);
finish_wait(sk_sleep(sk), &wait); remove_wait_queue(sk_sleep(sk), &wait);
} }
} }
EXPORT_SYMBOL(sk_stream_wait_close); EXPORT_SYMBOL(sk_stream_wait_close);
...@@ -119,16 +119,16 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p) ...@@ -119,16 +119,16 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p)
long vm_wait = 0; long vm_wait = 0;
long current_timeo = *timeo_p; long current_timeo = *timeo_p;
bool noblock = (*timeo_p ? false : true); bool noblock = (*timeo_p ? false : true);
DEFINE_WAIT(wait); DEFINE_WAIT_FUNC(wait, woken_wake_function);
if (sk_stream_memory_free(sk)) if (sk_stream_memory_free(sk))
current_timeo = vm_wait = (prandom_u32() % (HZ / 5)) + 2; current_timeo = vm_wait = (prandom_u32() % (HZ / 5)) + 2;
add_wait_queue(sk_sleep(sk), &wait);
while (1) { while (1) {
sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN)) if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))
goto do_error; goto do_error;
if (!*timeo_p) { if (!*timeo_p) {
...@@ -147,7 +147,7 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p) ...@@ -147,7 +147,7 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p)
sk_wait_event(sk, &current_timeo, sk->sk_err || sk_wait_event(sk, &current_timeo, sk->sk_err ||
(sk->sk_shutdown & SEND_SHUTDOWN) || (sk->sk_shutdown & SEND_SHUTDOWN) ||
(sk_stream_memory_free(sk) && (sk_stream_memory_free(sk) &&
!vm_wait)); !vm_wait), &wait);
sk->sk_write_pending--; sk->sk_write_pending--;
if (vm_wait) { if (vm_wait) {
...@@ -161,7 +161,7 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p) ...@@ -161,7 +161,7 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p)
*timeo_p = current_timeo; *timeo_p = current_timeo;
} }
out: out:
finish_wait(sk_sleep(sk), &wait); remove_wait_queue(sk_sleep(sk), &wait);
return err; return err;
do_error: do_error:
......
...@@ -1718,7 +1718,7 @@ static int dn_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, ...@@ -1718,7 +1718,7 @@ static int dn_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
* See if there is data ready to read, sleep if there isn't * See if there is data ready to read, sleep if there isn't
*/ */
for(;;) { for(;;) {
DEFINE_WAIT(wait); DEFINE_WAIT_FUNC(wait, woken_wake_function);
if (sk->sk_err) if (sk->sk_err)
goto out; goto out;
...@@ -1749,11 +1749,11 @@ static int dn_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, ...@@ -1749,11 +1749,11 @@ static int dn_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
goto out; goto out;
} }
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); add_wait_queue(sk_sleep(sk), &wait);
sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
sk_wait_event(sk, &timeo, dn_data_ready(sk, queue, flags, target)); sk_wait_event(sk, &timeo, dn_data_ready(sk, queue, flags, target), &wait);
sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk); sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
finish_wait(sk_sleep(sk), &wait); remove_wait_queue(sk_sleep(sk), &wait);
} }
skb_queue_walk_safe(queue, skb, n) { skb_queue_walk_safe(queue, skb, n) {
...@@ -1999,19 +1999,19 @@ static int dn_sendmsg(struct socket *sock, struct msghdr *msg, size_t size) ...@@ -1999,19 +1999,19 @@ static int dn_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
* size. * size.
*/ */
if (dn_queue_too_long(scp, queue, flags)) { if (dn_queue_too_long(scp, queue, flags)) {
DEFINE_WAIT(wait); DEFINE_WAIT_FUNC(wait, woken_wake_function);
if (flags & MSG_DONTWAIT) { if (flags & MSG_DONTWAIT) {
err = -EWOULDBLOCK; err = -EWOULDBLOCK;
goto out; goto out;
} }
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); add_wait_queue(sk_sleep(sk), &wait);
sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
sk_wait_event(sk, &timeo, sk_wait_event(sk, &timeo,
!dn_queue_too_long(scp, queue, flags)); !dn_queue_too_long(scp, queue, flags), &wait);
sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk); sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
finish_wait(sk_sleep(sk), &wait); remove_wait_queue(sk_sleep(sk), &wait);
continue; continue;
} }
......
...@@ -532,12 +532,12 @@ static int llc_ui_listen(struct socket *sock, int backlog) ...@@ -532,12 +532,12 @@ static int llc_ui_listen(struct socket *sock, int backlog)
static int llc_ui_wait_for_disc(struct sock *sk, long timeout) static int llc_ui_wait_for_disc(struct sock *sk, long timeout)
{ {
DEFINE_WAIT(wait); DEFINE_WAIT_FUNC(wait, woken_wake_function);
int rc = 0; int rc = 0;
add_wait_queue(sk_sleep(sk), &wait);
while (1) { while (1) {
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); if (sk_wait_event(sk, &timeout, sk->sk_state == TCP_CLOSE, &wait))
if (sk_wait_event(sk, &timeout, sk->sk_state == TCP_CLOSE))
break; break;
rc = -ERESTARTSYS; rc = -ERESTARTSYS;
if (signal_pending(current)) if (signal_pending(current))
...@@ -547,39 +547,39 @@ static int llc_ui_wait_for_disc(struct sock *sk, long timeout) ...@@ -547,39 +547,39 @@ static int llc_ui_wait_for_disc(struct sock *sk, long timeout)
break; break;
rc = 0; rc = 0;
} }
finish_wait(sk_sleep(sk), &wait); remove_wait_queue(sk_sleep(sk), &wait);
return rc; return rc;
} }
static bool llc_ui_wait_for_conn(struct sock *sk, long timeout) static bool llc_ui_wait_for_conn(struct sock *sk, long timeout)
{ {
DEFINE_WAIT(wait); DEFINE_WAIT_FUNC(wait, woken_wake_function);
add_wait_queue(sk_sleep(sk), &wait);
while (1) { while (1) {
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); if (sk_wait_event(sk, &timeout, sk->sk_state != TCP_SYN_SENT, &wait))
if (sk_wait_event(sk, &timeout, sk->sk_state != TCP_SYN_SENT))
break; break;
if (signal_pending(current) || !timeout) if (signal_pending(current) || !timeout)
break; break;
} }
finish_wait(sk_sleep(sk), &wait); remove_wait_queue(sk_sleep(sk), &wait);
return timeout; return timeout;
} }
static int llc_ui_wait_for_busy_core(struct sock *sk, long timeout) static int llc_ui_wait_for_busy_core(struct sock *sk, long timeout)
{ {
DEFINE_WAIT(wait); DEFINE_WAIT_FUNC(wait, woken_wake_function);
struct llc_sock *llc = llc_sk(sk); struct llc_sock *llc = llc_sk(sk);
int rc; int rc;
add_wait_queue(sk_sleep(sk), &wait);
while (1) { while (1) {
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
rc = 0; rc = 0;
if (sk_wait_event(sk, &timeout, if (sk_wait_event(sk, &timeout,
(sk->sk_shutdown & RCV_SHUTDOWN) || (sk->sk_shutdown & RCV_SHUTDOWN) ||
(!llc_data_accept_state(llc->state) && (!llc_data_accept_state(llc->state) &&
!llc->remote_busy_flag && !llc->remote_busy_flag &&
!llc->p_flag))) !llc->p_flag), &wait))
break; break;
rc = -ERESTARTSYS; rc = -ERESTARTSYS;
if (signal_pending(current)) if (signal_pending(current))
...@@ -588,7 +588,7 @@ static int llc_ui_wait_for_busy_core(struct sock *sk, long timeout) ...@@ -588,7 +588,7 @@ static int llc_ui_wait_for_busy_core(struct sock *sk, long timeout)
if (!timeout) if (!timeout)
break; break;
} }
finish_wait(sk_sleep(sk), &wait); remove_wait_queue(sk_sleep(sk), &wait);
return rc; return rc;
} }
......
...@@ -1167,7 +1167,7 @@ static int pep_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) ...@@ -1167,7 +1167,7 @@ static int pep_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
/* Wait until flow control allows TX */ /* Wait until flow control allows TX */
done = atomic_read(&pn->tx_credits); done = atomic_read(&pn->tx_credits);
while (!done) { while (!done) {
DEFINE_WAIT(wait); DEFINE_WAIT_FUNC(wait, woken_wake_function);
if (!timeo) { if (!timeo) {
err = -EAGAIN; err = -EAGAIN;
...@@ -1178,10 +1178,9 @@ static int pep_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) ...@@ -1178,10 +1178,9 @@ static int pep_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
goto out; goto out;
} }
prepare_to_wait(sk_sleep(sk), &wait, add_wait_queue(sk_sleep(sk), &wait);
TASK_INTERRUPTIBLE); done = sk_wait_event(sk, &timeo, atomic_read(&pn->tx_credits), &wait);
done = sk_wait_event(sk, &timeo, atomic_read(&pn->tx_credits)); remove_wait_queue(sk_sleep(sk), &wait);
finish_wait(sk_sleep(sk), &wait);
if (sk->sk_state != TCP_ESTABLISHED) if (sk->sk_state != TCP_ESTABLISHED)
goto disabled; goto disabled;
......
...@@ -876,9 +876,9 @@ static void tipc_sk_proto_rcv(struct tipc_sock *tsk, struct sk_buff *skb, ...@@ -876,9 +876,9 @@ static void tipc_sk_proto_rcv(struct tipc_sock *tsk, struct sk_buff *skb,
static int tipc_wait_for_sndmsg(struct socket *sock, long *timeo_p) static int tipc_wait_for_sndmsg(struct socket *sock, long *timeo_p)
{ {
DEFINE_WAIT_FUNC(wait, woken_wake_function);
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct tipc_sock *tsk = tipc_sk(sk); struct tipc_sock *tsk = tipc_sk(sk);
DEFINE_WAIT(wait);
int done; int done;
do { do {
...@@ -892,9 +892,9 @@ static int tipc_wait_for_sndmsg(struct socket *sock, long *timeo_p) ...@@ -892,9 +892,9 @@ static int tipc_wait_for_sndmsg(struct socket *sock, long *timeo_p)
if (signal_pending(current)) if (signal_pending(current))
return sock_intr_errno(*timeo_p); return sock_intr_errno(*timeo_p);
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); add_wait_queue(sk_sleep(sk), &wait);
done = sk_wait_event(sk, timeo_p, !tsk->link_cong); done = sk_wait_event(sk, timeo_p, !tsk->link_cong, &wait);
finish_wait(sk_sleep(sk), &wait); remove_wait_queue(sk_sleep(sk), &wait);
} while (!done); } while (!done);
return 0; return 0;
} }
...@@ -1031,9 +1031,9 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dsz) ...@@ -1031,9 +1031,9 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dsz)
static int tipc_wait_for_sndpkt(struct socket *sock, long *timeo_p) static int tipc_wait_for_sndpkt(struct socket *sock, long *timeo_p)
{ {
DEFINE_WAIT_FUNC(wait, woken_wake_function);
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct tipc_sock *tsk = tipc_sk(sk); struct tipc_sock *tsk = tipc_sk(sk);
DEFINE_WAIT(wait);
int done; int done;
do { do {
...@@ -1049,12 +1049,12 @@ static int tipc_wait_for_sndpkt(struct socket *sock, long *timeo_p) ...@@ -1049,12 +1049,12 @@ static int tipc_wait_for_sndpkt(struct socket *sock, long *timeo_p)
if (signal_pending(current)) if (signal_pending(current))
return sock_intr_errno(*timeo_p); return sock_intr_errno(*timeo_p);
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); add_wait_queue(sk_sleep(sk), &wait);
done = sk_wait_event(sk, timeo_p, done = sk_wait_event(sk, timeo_p,
(!tsk->link_cong && (!tsk->link_cong &&
!tsk_conn_cong(tsk)) || !tsk_conn_cong(tsk)) ||
!tipc_sk_connected(sk)); !tipc_sk_connected(sk), &wait);
finish_wait(sk_sleep(sk), &wait); remove_wait_queue(sk_sleep(sk), &wait);
} while (!done); } while (!done);
return 0; return 0;
} }
...@@ -1929,8 +1929,8 @@ void tipc_sk_rcv(struct net *net, struct sk_buff_head *inputq) ...@@ -1929,8 +1929,8 @@ void tipc_sk_rcv(struct net *net, struct sk_buff_head *inputq)
static int tipc_wait_for_connect(struct socket *sock, long *timeo_p) static int tipc_wait_for_connect(struct socket *sock, long *timeo_p)
{ {
DEFINE_WAIT_FUNC(wait, woken_wake_function);
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
DEFINE_WAIT(wait);
int done; int done;
do { do {
...@@ -1942,10 +1942,10 @@ static int tipc_wait_for_connect(struct socket *sock, long *timeo_p) ...@@ -1942,10 +1942,10 @@ static int tipc_wait_for_connect(struct socket *sock, long *timeo_p)
if (signal_pending(current)) if (signal_pending(current))
return sock_intr_errno(*timeo_p); return sock_intr_errno(*timeo_p);
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); add_wait_queue(sk_sleep(sk), &wait);
done = sk_wait_event(sk, timeo_p, done = sk_wait_event(sk, timeo_p,
sk->sk_state != TIPC_CONNECTING); sk->sk_state != TIPC_CONNECTING, &wait);
finish_wait(sk_sleep(sk), &wait); remove_wait_queue(sk_sleep(sk), &wait);
} while (!done); } while (!done);
return 0; return 0;
} }
......
...@@ -619,17 +619,17 @@ static int virtio_transport_reset_no_sock(struct virtio_vsock_pkt *pkt) ...@@ -619,17 +619,17 @@ static int virtio_transport_reset_no_sock(struct virtio_vsock_pkt *pkt)
static void virtio_transport_wait_close(struct sock *sk, long timeout) static void virtio_transport_wait_close(struct sock *sk, long timeout)
{ {
if (timeout) { if (timeout) {
DEFINE_WAIT(wait); DEFINE_WAIT_FUNC(wait, woken_wake_function);
add_wait_queue(sk_sleep(sk), &wait);
do { do {
prepare_to_wait(sk_sleep(sk), &wait,
TASK_INTERRUPTIBLE);
if (sk_wait_event(sk, &timeout, if (sk_wait_event(sk, &timeout,
sock_flag(sk, SOCK_DONE))) sock_flag(sk, SOCK_DONE), &wait))
break; break;
} while (!signal_pending(current) && timeout); } while (!signal_pending(current) && timeout);
finish_wait(sk_sleep(sk), &wait); remove_wait_queue(sk_sleep(sk), &wait);
} }
} }
......
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