vcl: handle EINTR in epoll_wait calls

Type: improvement

Change-Id: I71a987b8871988d38e4a752c7f93f52a27bce6a3
Signed-off-by: Aritra Basu <aritrbas@cisco.com>
This commit is contained in:
Aritra Basu
2024-07-30 16:03:59 -07:00
committed by Florin Coras
parent 80a16d134e
commit 119cbf2651

View File

@ -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;
}
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 (n_mq_evts == 0)
return 0;
return (n_mq_evts > 0 ? (int) *bits_set : 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);
}
if (*bits_set || !time_to_wait)
return (int) *bits_set;
}
while (end == -1 || clib_time_now (&wrk->clib_time) < end);
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;
}