From 62bace390b34c00e37323fdddb05b3c79eaa4242 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Thu, 16 Sep 2021 08:41:19 +0200 Subject: [PATCH] pasta, tcp: Mask EPOLLIN and EPOLLRDHUP after sending FIN Now that we dropped EPOLLET, we'll keep getting EPOLLRDHUP, and possibly EPOLLIN, even if there's nothing to read anymore. Signed-off-by: Stefano Brivio --- tcp.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tcp.c b/tcp.c index eab5c13..526032e 100644 --- a/tcp.c +++ b/tcp.c @@ -2735,8 +2735,14 @@ eintr: if (move_from == conn->from && conn->from_read == conn->from_written) { if (!conn->from_fin_sent) { - shutdown(move_to, SHUT_WR); + shutdown(conn->to, SHUT_WR); conn->from_fin_sent = 1; + + ev.events = 0; + ref.s = move_from; + ev.data.u64 = ref.u64, + epoll_ctl(c->epollfd, EPOLL_CTL_MOD, + move_from, &ev); } if (conn->to_fin_sent) @@ -2744,8 +2750,14 @@ eintr: } else if (move_from == conn->to && conn->to_read == conn->to_written) { if (!conn->to_fin_sent) { - shutdown(move_to, SHUT_WR); + shutdown(conn->from, SHUT_WR); conn->to_fin_sent = 1; + + ev.events = 0; + ref.s = move_from; + ev.data.u64 = ref.u64, + epoll_ctl(c->epollfd, EPOLL_CTL_MOD, + move_from, &ev); } if (conn->from_fin_sent)