From db3fbfca514e1fdc1530ed7ffe430fe26acdbb49 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Mon, 22 May 2023 09:19:57 -0700 Subject: vcl: avoid reusing user provided events in lt mode Epoll events might not have been cleared by user so always compute event flags locally and assign to user provided epoll event. Type: fix Signed-off-by: Ping Yu Signed-off-by: Florin Coras Change-Id: I3b594a0fd7be345a0e0ad81d1d3636e9354cc15d --- src/vcl/vppcom.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c index 0b4d75765ea..ecbbf7a7d5f 100644 --- a/src/vcl/vppcom.c +++ b/src/vcl/vppcom.c @@ -3369,7 +3369,7 @@ static void vcl_epoll_wait_handle_lt (vcl_worker_t *wrk, struct epoll_event *events, int maxevents, u32 *n_evts) { - u32 add_event = 0, next, *to_remove = 0, *si; + u32 add_event = 0, evt_flags = 0, next, *to_remove = 0, *si; vcl_session_t *s; u64 evt_data; int rv; @@ -3387,26 +3387,28 @@ vcl_epoll_wait_handle_lt (vcl_worker_t *wrk, struct epoll_event *events, if ((s->vep.ev.events & EPOLLIN) && (rv = vcl_session_read_ready (s))) { add_event = 1; - events[*n_evts].events |= rv > 0 ? EPOLLIN : EPOLLHUP | EPOLLRDHUP; + evt_flags |= rv > 0 ? EPOLLIN : EPOLLHUP | EPOLLRDHUP; evt_data = s->vep.ev.data.u64; } if ((s->vep.ev.events & EPOLLOUT) && (rv = vcl_session_write_ready (s))) { add_event = 1; - events[*n_evts].events |= rv > 0 ? EPOLLOUT : EPOLLHUP | EPOLLRDHUP; + evt_flags |= rv > 0 ? EPOLLOUT : EPOLLHUP | EPOLLRDHUP; evt_data = s->vep.ev.data.u64; } if (!add_event && s->session_state > VCL_STATE_READY) { add_event = 1; - events[*n_evts].events |= EPOLLHUP | EPOLLRDHUP; + evt_flags |= EPOLLHUP | EPOLLRDHUP; evt_data = s->vep.ev.data.u64; } if (add_event) { + events[*n_evts].events = evt_flags; events[*n_evts].data.u64 = evt_data; *n_evts += 1; add_event = 0; + evt_flags = 0; if (EPOLLONESHOT & s->vep.ev.events) s->vep.ev.events = 0; if (*n_evts == maxevents) -- cgit 1.2.3-korg