Commit f2fdcf67 authored by Arseniy Krasnov's avatar Arseniy Krasnov Committed by Paolo Abeni

vsock: add API call for data ready

This adds 'vsock_data_ready()' which must be called by transport to kick
sleeping data readers. It checks for SO_RCVLOWAT value before waking
user, thus preventing spurious wake ups. Based on 'tcp_data_ready()' logic.
Signed-off-by: default avatarArseniy Krasnov <AVKrasnov@sberdevices.ru>
Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent ee0b3843
...@@ -78,6 +78,7 @@ struct vsock_sock { ...@@ -78,6 +78,7 @@ struct vsock_sock {
s64 vsock_stream_has_data(struct vsock_sock *vsk); s64 vsock_stream_has_data(struct vsock_sock *vsk);
s64 vsock_stream_has_space(struct vsock_sock *vsk); s64 vsock_stream_has_space(struct vsock_sock *vsk);
struct sock *vsock_create_connected(struct sock *parent); struct sock *vsock_create_connected(struct sock *parent);
void vsock_data_ready(struct sock *sk);
/**** TRANSPORT ****/ /**** TRANSPORT ****/
......
...@@ -882,6 +882,16 @@ s64 vsock_stream_has_space(struct vsock_sock *vsk) ...@@ -882,6 +882,16 @@ s64 vsock_stream_has_space(struct vsock_sock *vsk)
} }
EXPORT_SYMBOL_GPL(vsock_stream_has_space); EXPORT_SYMBOL_GPL(vsock_stream_has_space);
void vsock_data_ready(struct sock *sk)
{
struct vsock_sock *vsk = vsock_sk(sk);
if (vsock_stream_has_data(vsk) >= sk->sk_rcvlowat ||
sock_flag(sk, SOCK_DONE))
sk->sk_data_ready(sk);
}
EXPORT_SYMBOL_GPL(vsock_data_ready);
static int vsock_release(struct socket *sock) static int vsock_release(struct socket *sock)
{ {
__vsock_release(sock->sk, 0); __vsock_release(sock->sk, 0);
......
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