From b0116a13dcc631d5128209dec867c3fb5209629d Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Tue, 7 Feb 2023 09:11:47 -0800 Subject: vcl: handle lt events in epoll ctl Type: fix Signed-off-by: Florin Coras Change-Id: I4e176e9ada32d5f61d10aeca1c68f72114dec9b8 --- src/vcl/vppcom.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c index 1b0da450781..e3fb14fa4e5 100644 --- a/src/vcl/vppcom.c +++ b/src/vcl/vppcom.c @@ -2755,6 +2755,24 @@ vppcom_epoll_create (void) return vcl_session_handle (vep_session); } +static void +vcl_epoll_ctl_add_unhandled_event (vcl_worker_t *wrk, vcl_session_t *s, + u8 is_epollet, session_evt_type_t evt) +{ + if (!is_epollet) + { + vcl_epoll_lt_add (wrk, s); + return; + } + + session_event_t e = { 0 }; + e.session_index = s->session_index; + e.event_type = evt; + if (evt == SESSION_IO_EVT_RX) + s->flags &= ~VCL_SESSION_F_HAS_RX_EVT; + vec_add1 (wrk->unhandled_evts_vector, e); +} + int vppcom_epoll_ctl (uint32_t vep_handle, int op, uint32_t session_handle, struct epoll_event *event) @@ -2843,20 +2861,15 @@ vppcom_epoll_ctl (uint32_t vep_handle, int op, uint32_t session_handle, /* Generate EPOLLOUT if tx fifo not full */ if ((event->events & EPOLLOUT) && (vcl_session_write_ready (s) > 0)) { - session_event_t e = { 0 }; - e.event_type = SESSION_IO_EVT_TX; - e.session_index = s->session_index; - vec_add1 (wrk->unhandled_evts_vector, e); + vcl_epoll_ctl_add_unhandled_event (wrk, s, event->events & EPOLLET, + SESSION_IO_EVT_TX); add_evt = 1; } /* Generate EPOLLIN if rx fifo has data */ if ((event->events & EPOLLIN) && (vcl_session_read_ready (s) > 0)) { - session_event_t e = { 0 }; - e.event_type = SESSION_IO_EVT_RX; - e.session_index = s->session_index; - vec_add1 (wrk->unhandled_evts_vector, e); - s->flags &= ~VCL_SESSION_F_HAS_RX_EVT; + vcl_epoll_ctl_add_unhandled_event (wrk, s, event->events & EPOLLET, + SESSION_IO_EVT_RX); add_evt = 1; } if (!add_evt && vcl_session_is_closing (s)) @@ -2900,20 +2913,15 @@ vppcom_epoll_ctl (uint32_t vep_handle, int op, uint32_t session_handle, if ((event->events & EPOLLOUT) && !(s->vep.ev.events & EPOLLOUT) && (vcl_session_write_ready (s) > 0)) { - session_event_t e = { 0 }; - e.event_type = SESSION_IO_EVT_TX; - e.session_index = s->session_index; - vec_add1 (wrk->unhandled_evts_vector, e); + vcl_epoll_ctl_add_unhandled_event (wrk, s, event->events & EPOLLET, + SESSION_IO_EVT_TX); } /* Generate EPOLLIN if session read ready and event was not on */ if ((event->events & EPOLLIN) && !(s->vep.ev.events & EPOLLIN) && (vcl_session_read_ready (s) > 0)) { - session_event_t e = { 0 }; - e.event_type = SESSION_IO_EVT_RX; - e.session_index = s->session_index; - vec_add1 (wrk->unhandled_evts_vector, e); - s->flags &= ~VCL_SESSION_F_HAS_RX_EVT; + vcl_epoll_ctl_add_unhandled_event (wrk, s, event->events & EPOLLET, + SESSION_IO_EVT_RX); } s->vep.et_mask = VEP_DEFAULT_ET_MASK; s->vep.ev = *event; -- cgit 1.2.3-korg