diff options
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; } |