diff options
author | Aritra Basu <aritrbas@cisco.com> | 2024-07-30 16:03:59 -0700 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2024-08-01 22:06:37 +0000 |
commit | 119cbf2651c7bfdd1a1b4455784c83a487ee81d3 (patch) | |
tree | f4abb6fe4621adf7e1da34aa77cd393ae768f364 /src | |
parent | 80a16d134ef9c8a41149c4842d7a3f4eb62425d9 (diff) |
vcl: handle EINTR in epoll_wait calls
Type: improvement
Change-Id: I71a987b8871988d38e4a752c7f93f52a27bce6a3
Signed-off-by: Aritra Basu <aritrbas@cisco.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/vcl/vppcom.c | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c index a557093e897..56f650438a4 100644 --- a/src/vcl/vppcom.c +++ b/src/vcl/vppcom.c @@ -2619,6 +2619,7 @@ vppcom_select_eventfd (vcl_worker_t * wrk, int n_bits, vcl_mq_evt_conn_t *mqc; int __clib_unused n_read; int n_mq_evts, i; + double end = -1; u64 buf; if (PREDICT_FALSE (wrk->api_client_handle == ~0)) @@ -2628,23 +2629,45 @@ vppcom_select_eventfd (vcl_worker_t * wrk, int n_bits, } vec_validate (wrk->mq_events, pool_elts (wrk->mq_evt_conns)); - n_mq_evts = epoll_wait (wrk->mqs_epfd, wrk->mq_events, - vec_len (wrk->mq_events), time_to_wait); - for (i = 0; i < n_mq_evts; i++) + if (time_to_wait > 0) + end = clib_time_now (&wrk->clib_time) + (time_to_wait / 1e3); + + do { - if (PREDICT_FALSE (wrk->mq_events[i].data.u32 == ~0)) + n_mq_evts = epoll_wait (wrk->mqs_epfd, wrk->mq_events, + vec_len (wrk->mq_events), time_to_wait); + if (n_mq_evts < 0) { - vcl_api_handle_disconnect (wrk); - continue; + if (errno == EINTR) + continue; + + VDBG (0, "epoll_wait error %u", errno); + return 0; + } + + if (n_mq_evts == 0) + return 0; + + for (i = 0; i < n_mq_evts; i++) + { + if (PREDICT_FALSE (wrk->mq_events[i].data.u32 == ~0)) + { + vcl_api_handle_disconnect (wrk); + continue; + } + + mqc = vcl_mq_evt_conn_get (wrk, wrk->mq_events[i].data.u32); + n_read = read (mqc->mq_fd, &buf, sizeof (buf)); + vcl_select_handle_mq (wrk, mqc->mq, n_bits, read_map, write_map, + except_map, 0, bits_set); } - mqc = vcl_mq_evt_conn_get (wrk, wrk->mq_events[i].data.u32); - n_read = read (mqc->mq_fd, &buf, sizeof (buf)); - vcl_select_handle_mq (wrk, mqc->mq, n_bits, read_map, write_map, - except_map, 0, bits_set); + if (*bits_set || !time_to_wait) + return (int) *bits_set; } + while (end == -1 || clib_time_now (&wrk->clib_time) < end); - return (n_mq_evts > 0 ? (int) *bits_set : 0); + return 0; } int @@ -3407,6 +3430,9 @@ vppcom_epoll_wait_eventfd (vcl_worker_t *wrk, struct epoll_event *events, vec_len (wrk->mq_events), timeout_ms); if (n_mq_evts < 0) { + if (errno == EINTR) + continue; + VDBG (0, "epoll_wait error %u", errno); return n_evts; } |