X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvcl%2Fvppcom.c;h=645550812b1dfe4c759b0cb6d17ec413d563ce79;hb=de9f08b0302d5b4cdc8fbfeb9a9585f46e8314f2;hp=1991e3e72774ea05bcf0cb290f50793e0b54d04d;hpb=145987776f57de20e9724d58fe28796d40ffebfa;p=vpp.git diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c index 1991e3e7277..645550812b1 100644 --- a/src/vcl/vppcom.c +++ b/src/vcl/vppcom.c @@ -700,6 +700,7 @@ vppcom_app_create (char *app_name) svm_fifo_segment_main_init (vcl_cfg->segment_baseva, 20 /* timeout in secs */ ); pool_init_fixed (vcm->workers, vcl_cfg->max_workers); + clib_spinlock_init (&vcm->workers_lock); vcl_worker_alloc_and_init (); } @@ -1580,6 +1581,14 @@ vcl_mq_dequeue_batch (vcl_worker_t * wrk, svm_msg_q_t * mq) return n_msgs; } +#define vcl_fifo_rx_evt_valid_or_break(_fifo) \ +if (PREDICT_FALSE (svm_fifo_is_empty (_fifo))) \ + { \ + svm_fifo_unset_event (_fifo); \ + if (svm_fifo_is_empty (_fifo)) \ + break; \ + } \ + static int vcl_select_handle_mq (vcl_worker_t * wrk, svm_msg_q_t * mq, unsigned long n_bits, unsigned long *read_map, @@ -1633,6 +1642,7 @@ vcl_select_handle_mq (vcl_worker_t * wrk, svm_msg_q_t * mq, switch (e->event_type) { case FIFO_EVENT_APP_RX: + vcl_fifo_rx_evt_valid_or_break (e->fifo); sid = e->fifo->client_session_index; session = vcl_session_get (wrk, sid); if (!session) @@ -1655,12 +1665,7 @@ vcl_select_handle_mq (vcl_worker_t * wrk, svm_msg_q_t * mq, } break; case SESSION_IO_EVT_CT_TX: - if (svm_fifo_is_empty (e->fifo)) - { - svm_fifo_unset_event (e->fifo); - if (svm_fifo_is_empty (e->fifo)) - break; - } + vcl_fifo_rx_evt_valid_or_break (e->fifo); session = vcl_ct_session_get_from_fifo (wrk, e->fifo, 0); if (!session) break; @@ -2228,6 +2233,7 @@ vcl_epoll_wait_handle_mq (vcl_worker_t * wrk, svm_msg_q_t * mq, switch (e->event_type) { case FIFO_EVENT_APP_RX: + vcl_fifo_rx_evt_valid_or_break (e->fifo); sid = e->fifo->client_session_index; session = vcl_session_get (wrk, sid); session_events = session->vep.ev.events; @@ -2248,6 +2254,7 @@ vcl_epoll_wait_handle_mq (vcl_worker_t * wrk, svm_msg_q_t * mq, session_evt_data = session->vep.ev.data.u64; break; case SESSION_IO_EVT_CT_TX: + vcl_fifo_rx_evt_valid_or_break (e->fifo); session = vcl_ct_session_get_from_fifo (wrk, e->fifo, 0); sid = session->session_index; session_events = session->vep.ev.events; @@ -3156,7 +3163,7 @@ vppcom_session_index (uint32_t session_handle) int vppcom_worker_register (void) { - if (!vcl_worker_alloc_and_init ()) + if (vcl_worker_alloc_and_init ()) return VPPCOM_OK; return VPPCOM_EEXIST; }