mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 20:32:04 +09:00
BACKPORT: AF_VSOCK: Shrink the area influenced by prepare_to_wait
When a thread is prepared for waiting by calling prepare_to_wait, sleeping is not allowed until either the wait has taken place or finish_wait has been called. The existing code in af_vsock imposed unnecessary no-sleep assumptions to a broad list of backend functions. This patch shrinks the influence of prepare_to_wait to the area where it is strictly needed, therefore relaxing the no-sleep restriction there. Signed-off-by: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commitf7f9b5e7f8) [astrachan: Backported around stable backport3223ea1("vsock: use new wait API for vsock_stream_sendmsg()")] Bug: 121166534 Test: Ran cuttlefish with android-4.4 + VSOCKETS, VMWARE_VMCI_VSOCKETS Signed-off-by: Cody Schuffelen <schuffelen@google.com> Change-Id: Ic1d7bae4b1187ad48194bf4d0b1dd09ab0275734
This commit is contained in:
committed by
Alistair Strachan
parent
6c81476a7c
commit
4c63405330
@@ -1559,7 +1559,7 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
|
||||
while (total_written < len) {
|
||||
ssize_t written;
|
||||
|
||||
add_wait_queue(sk_sleep(sk), &wait);
|
||||
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
|
||||
while (vsock_stream_has_space(vsk) == 0 &&
|
||||
sk->sk_err == 0 &&
|
||||
!(sk->sk_shutdown & SEND_SHUTDOWN) &&
|
||||
@@ -1568,13 +1568,13 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
|
||||
/* Don't wait for non-blocking sockets. */
|
||||
if (timeout == 0) {
|
||||
err = -EAGAIN;
|
||||
remove_wait_queue(sk_sleep(sk), &wait);
|
||||
finish_wait(sk_sleep(sk), &wait);
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
err = transport->notify_send_pre_block(vsk, &send_data);
|
||||
if (err < 0) {
|
||||
remove_wait_queue(sk_sleep(sk), &wait);
|
||||
finish_wait(sk_sleep(sk), &wait);
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
@@ -1583,15 +1583,15 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
|
||||
lock_sock(sk);
|
||||
if (signal_pending(current)) {
|
||||
err = sock_intr_errno(timeout);
|
||||
remove_wait_queue(sk_sleep(sk), &wait);
|
||||
finish_wait(sk_sleep(sk), &wait);
|
||||
goto out_err;
|
||||
} else if (timeout == 0) {
|
||||
err = -EAGAIN;
|
||||
remove_wait_queue(sk_sleep(sk), &wait);
|
||||
finish_wait(sk_sleep(sk), &wait);
|
||||
goto out_err;
|
||||
}
|
||||
}
|
||||
remove_wait_queue(sk_sleep(sk), &wait);
|
||||
finish_wait(sk_sleep(sk), &wait);
|
||||
|
||||
/* These checks occur both as part of and after the loop
|
||||
* conditional since we need to check before and after
|
||||
|
||||
Reference in New Issue
Block a user