Skip to content

Commit ba3169f

Browse files
stefanhaRHdavem330
authored andcommitted
VSOCK: set POLLOUT | POLLWRNORM for TCP_CLOSING
select(2) with wfds but no rfds must return when the socket is shut down by the peer. This way userspace notices socket activity and gets -EPIPE from the next write(2). Currently select(2) does not return for virtio-vsock when a SEND+RCV shutdown packet is received. This is because vsock_poll() only sets POLLOUT | POLLWRNORM for TCP_CLOSE, not the TCP_CLOSING state that the socket is in when the shutdown is received. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent dd5684e commit ba3169f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/vmw_vsock/af_vsock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ static unsigned int vsock_poll(struct file *file, struct socket *sock,
951951
* POLLOUT|POLLWRNORM when peer is closed and nothing to read,
952952
* but local send is not shutdown.
953953
*/
954-
if (sk->sk_state == TCP_CLOSE) {
954+
if (sk->sk_state == TCP_CLOSE || sk->sk_state == TCP_CLOSING) {
955955
if (!(sk->sk_shutdown & SEND_SHUTDOWN))
956956
mask |= POLLOUT | POLLWRNORM;
957957

0 commit comments

Comments
 (0)