tcp: Attempt to mitigate EPOLLRDHUP storms with half-closed connections

Link: https://github.com/containers/podman/issues/23686
This commit is contained in:
David Gibson 2024-08-30 14:14:19 +10:00 committed by Stefano Brivio
parent 232e12529e
commit 026fb71d1d

12
tcp.c
View file

@ -424,23 +424,27 @@ int tcp_set_peek_offset(int s, int offset)
*/ */
static uint32_t tcp_conn_epoll_events(uint8_t events, uint8_t conn_flags) static uint32_t tcp_conn_epoll_events(uint8_t events, uint8_t conn_flags)
{ {
uint32_t rdhup;
if (!events) if (!events)
return 0; return 0;
rdhup = (events & SOCK_FIN_RCVD) ? 0 : EPOLLRDHUP;
if (events & ESTABLISHED) { if (events & ESTABLISHED) {
if (events & TAP_FIN_SENT) if (events & TAP_FIN_SENT)
return EPOLLET; return EPOLLET;
if (conn_flags & STALLED) if (conn_flags & STALLED)
return EPOLLIN | EPOLLOUT | EPOLLRDHUP | EPOLLET; return EPOLLIN | EPOLLOUT | rdhup | EPOLLET;
return EPOLLIN | EPOLLRDHUP; return EPOLLIN | rdhup;
} }
if (events == TAP_SYN_RCVD) if (events == TAP_SYN_RCVD)
return EPOLLOUT | EPOLLET | EPOLLRDHUP; return EPOLLOUT | EPOLLET | rdhup;
return EPOLLRDHUP; return rdhup;
} }
/** /**