diff options
author | Dave Wallace <dwallacelf@gmail.com> | 2018-03-08 16:39:28 -0500 |
---|---|---|
committer | Keith Burns <alagalah@gmail.com> | 2018-03-09 16:51:37 +0000 |
commit | 8d73e856ca9c62271495cef9059063d9abd8ae3c (patch) | |
tree | f5db187b5133673b68c7d31d66a959cceaf84dc0 /src/vcl | |
parent | 5e85c54d229e443d30dabe9bca39625587add8a5 (diff) |
VCL: add event registration to listen session in select()
Change-Id: Ie2e8f4ec3a7ec1018e5f9ca6f28f8cb18beaa814
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'src/vcl')
-rw-r--r-- | src/vcl/vppcom.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c index 4dea4aa3292..c0b09e833d7 100644 --- a/src/vcl/vppcom.c +++ b/src/vcl/vppcom.c @@ -460,7 +460,7 @@ vce_connect_request_handler_fn (void *arg) } /** - * @brief vce_epoll_wait_connect_request_handler_fn + * @brief vce_poll_wait_connect_request_handler_fn * - used by vppcom_epoll_xxxx() for listener sessions * - when a vl_api_accept_session_t_handler() generates an event * this callback is alerted and sets the fields that vppcom_epoll_wait() @@ -469,7 +469,7 @@ vce_connect_request_handler_fn (void *arg) * @param arg - void* to be cast to vce_event_handler_reg_t* */ void -vce_epoll_wait_connect_request_handler_fn (void *arg) +vce_poll_wait_connect_request_handler_fn (void *arg) { vce_event_handler_reg_t *reg = (vce_event_handler_reg_t *) arg; vce_event_t *ev; @@ -3462,8 +3462,30 @@ vppcom_select (unsigned long n_bits, unsigned long *read_map, bits_set = VPPCOM_EBADFD; goto select_done; } - - rv = vppcom_session_read_ready (session, session_index); + if (session->state & STATE_LISTEN) + { + vce_event_handler_reg_t *reg = 0; + vce_event_key_t evk; + + /* Check if handler already registered for this + * event. + * If not, register handler for connect_request event + * on listen_session_index + */ + evk.session_index = session_index; + evk.eid = VCL_EVENT_CONNECT_REQ_ACCEPTED; + reg = vce_get_event_handler (&vcm->event_thread, &evk); + if (!reg) + reg = vce_register_handler (&vcm->event_thread, &evk, + vce_poll_wait_connect_request_handler_fn); + rv = vppcom_session_read_ready (session, session_index); + if (rv > 0) + { + vce_unregister_handler (&vcm->event_thread, reg); + } + } + else + rv = vppcom_session_read_ready (session, session_index); clib_spinlock_unlock (&vcm->sessions_lockp); if (except_map && vcm->ex_bitmap && clib_bitmap_get (vcm->ex_bitmap, session_index) && @@ -3774,7 +3796,7 @@ vppcom_epoll_ctl (uint32_t vep_idx, int op, uint32_t session_index, evk.eid = VCL_EVENT_CONNECT_REQ_ACCEPTED; vep_session->poll_reg = vce_register_handler (&vcm->event_thread, &evk, - vce_epoll_wait_connect_request_handler_fn); + vce_poll_wait_connect_request_handler_fn); } if (VPPCOM_DEBUG > 1) clib_warning ("VCL<%d>: EPOLL_CTL_ADD: vep_idx %u, " |