virtio/vsock: use 'target' in notify_poll_in callback
authorArseniy Krasnov <AVKrasnov@sberdevices.ru>
Fri, 19 Aug 2022 05:29:34 +0000 (05:29 +0000)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 23 Aug 2022 08:43:11 +0000 (10:43 +0200)
This callback controls setting of POLLIN, POLLRDNORM output bits of poll()
syscall, but in some cases, it is incorrectly to set it, when socket has
at least 1 bytes of available data. Use 'target' which is already exists.

Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/vmw_vsock/virtio_transport_common.c

index ec2c2afbf0d060b4f6335a7616c8deba0a95fde6..8f6356ebcdd1777d894bb0c9ce6646b4c8f68cb1 100644 (file)
@@ -634,10 +634,7 @@ virtio_transport_notify_poll_in(struct vsock_sock *vsk,
                                size_t target,
                                bool *data_ready_now)
 {
-       if (vsock_stream_has_data(vsk))
-               *data_ready_now = true;
-       else
-               *data_ready_now = false;
+       *data_ready_now = vsock_stream_has_data(vsk) >= target;
 
        return 0;
 }