When tcp_epoll_ctl() handles a CLOSED connection, it removes the timer
from epoll but leaves the fd open until tcp_flow_defer() eventually
closes it.
Close the timer fd immediately when removing it from epoll, since
there's no reason to keep an fd around that's no longer monitored.
Set conn->timer to -1 to prevent a double-close in tcp_flow_defer().
Signed-off-by: Laurent Vivier
---
tcp.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tcp.c b/tcp.c
index 1db861705ddb..62064efcc1ef 100644
--- a/tcp.c
+++ b/tcp.c
@@ -535,8 +535,11 @@ static int tcp_epoll_ctl(struct tcp_tap_conn *conn)
int epollfd = flow_epollfd(&conn->f);
epoll_del(epollfd, conn->sock);
- if (conn->timer != -1)
+ if (conn->timer != -1) {
epoll_del(epollfd, conn->timer);
+ close(conn->timer);
+ conn->timer = -1;
+ }
}
return 0;
--
2.52.0