dragonball: vsock: properly handle EPOLLHUP/EPOLLERR events

When one end of the connection close, the epoll event will be triggered
forever. We should close the connection and kill the connection.

Fixes: #6714

Signed-off-by: Zixuan Tan <tanzixuan.me@gmail.com>
This commit is contained in:
Zixuan Tan
2023-10-04 16:39:14 +08:00
parent 442df71fe5
commit b8632b4034

View File

@@ -487,6 +487,31 @@ impl VsockEpollListener for VsockConnection {
self.pending_rx.insert(PendingRx::CreditUpdate);
}
}
if evset.contains(epoll::Events::EPOLLHUP)
&& !evset.contains(epoll::Events::EPOLLIN)
&& !evset.contains(epoll::Events::EPOLLOUT)
{
// The host stream has been hung up. We'll kill this connection.
warn!(
"vsock: connection received EPOLLHUP event: lp={}, pp={}",
self.local_port, self.peer_port
);
self.kill();
}
if evset.contains(epoll::Events::EPOLLERR)
&& !evset.contains(epoll::Events::EPOLLIN)
&& !evset.contains(epoll::Events::EPOLLOUT)
{
// The host stream has encountered an error. We'll kill this
// connection.
warn!(
"vsock: connection received EPOLLERR event: lp={}, pp={}",
self.local_port, self.peer_port
);
self.kill();
}
}
}