X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvcl%2Fvppcom.c;h=5423bb62f9ecb4c6c8c0c7a47a7086d072165fe9;hb=539663c401b087e4576e41af35144e73e1907c9d;hp=cf3a770f045747b600a9df224ee743e170b68852;hpb=86f04500ae027dc66e91519a006388e56df4ceff;p=vpp.git diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c index cf3a770f045..5423bb62f9e 100644 --- a/src/vcl/vppcom.c +++ b/src/vcl/vppcom.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -1511,6 +1510,7 @@ vppcom_session_write (uint32_t session_handle, void *buf, size_t n) svm_msg_q_msg_t msg; session_event_t *e; svm_msg_q_t *mq; + u8 is_ct; if (PREDICT_FALSE (!buf)) return VPPCOM_EINVAL; @@ -1519,9 +1519,6 @@ vppcom_session_write (uint32_t session_handle, void *buf, size_t n) if (PREDICT_FALSE (!s)) return VPPCOM_EBADFD; - tx_fifo = s->tx_fifo; - is_nonblocking = VCL_SESS_ATTR_TEST (s->attr, VCL_SESS_ATTR_NONBLOCK); - if (PREDICT_FALSE (s->is_vep)) { clib_warning ("VCL<%d>: ERROR: vpp handle 0x%llx, sid %u: " @@ -1531,18 +1528,20 @@ vppcom_session_write (uint32_t session_handle, void *buf, size_t n) return VPPCOM_EBADFD; } - if (!(s->session_state & STATE_OPEN)) + if (PREDICT_FALSE (!(s->session_state & STATE_OPEN))) { session_state_t state = s->session_state; rv = ((state & STATE_DISCONNECT) ? VPPCOM_ECONNRESET : VPPCOM_ENOTCONN); VDBG (1, "VCL<%d>: vpp handle 0x%llx, sid %u: session is not open! " - "state 0x%x (%s)", - getpid (), s->vpp_handle, session_handle, + "state 0x%x (%s)", getpid (), s->vpp_handle, session_handle, state, vppcom_session_state_str (state)); return rv; } - mq = vcl_session_is_ct (s) ? s->our_evt_q : wrk->app_event_queue; + tx_fifo = s->tx_fifo; + is_ct = vcl_session_is_ct (s); + is_nonblocking = VCL_SESS_ATTR_TEST (s->attr, VCL_SESS_ATTR_NONBLOCK); + mq = is_ct ? s->our_evt_q : wrk->app_event_queue; if (svm_fifo_is_full (tx_fifo)) { if (is_nonblocking) @@ -1551,15 +1550,15 @@ vppcom_session_write (uint32_t session_handle, void *buf, size_t n) } while (svm_fifo_is_full (tx_fifo)) { + svm_fifo_set_want_tx_evt (tx_fifo, 1); svm_msg_q_lock (mq); - while (svm_msg_q_is_empty (mq) && svm_msg_q_timedwait (mq, 10e-6)) - ; + svm_msg_q_wait (mq); + svm_msg_q_sub_w_lock (mq, &msg); e = svm_msg_q_msg_data (mq, &msg); svm_msg_q_unlock (mq); - if (!vcl_is_tx_evt_for_session (e, s->session_index, - s->our_evt_q != 0)) + if (!vcl_is_tx_evt_for_session (e, s->session_index, is_ct)) vcl_handle_mq_event (wrk, e); svm_msg_q_free_msg (mq, &msg); } @@ -1576,17 +1575,9 @@ vppcom_session_write (uint32_t session_handle, void *buf, size_t n) ASSERT (n_write > 0); - if (VPPCOM_DEBUG > 2) - { - if (n_write <= 0) - clib_warning ("VCL<%d>: vpp handle 0x%llx, sid %u: " - "FIFO-FULL (%p)", getpid (), s->vpp_handle, - session_handle, tx_fifo); - else - clib_warning ("VCL<%d>: vpp handle 0x%llx, sid %u: " - "wrote %d bytes tx-fifo: (%p)", getpid (), - s->vpp_handle, session_handle, n_write, tx_fifo); - } + VDBG (2, "VCL<%d>: vpp handle 0x%llx, sid %u: wrote %d bytes", getpid (), + s->vpp_handle, session_handle, n_write); + return n_write; } @@ -2430,6 +2421,9 @@ vcl_epoll_wait_handle_mq (vcl_worker_t * wrk, svm_msg_q_t * mq, session_event_t *e; int i; + if (vec_len (wrk->mq_msg_vector) && svm_msg_q_is_empty (mq)) + goto handle_dequeued; + svm_msg_q_lock (mq); if (svm_msg_q_is_empty (mq)) { @@ -2454,6 +2448,7 @@ vcl_epoll_wait_handle_mq (vcl_worker_t * wrk, svm_msg_q_t * mq, vcl_mq_dequeue_batch (wrk, mq); svm_msg_q_unlock (mq); +handle_dequeued: for (i = 0; i < vec_len (wrk->mq_msg_vector); i++) { msg = vec_elt_at_index (wrk->mq_msg_vector, i); @@ -2466,7 +2461,6 @@ vcl_epoll_wait_handle_mq (vcl_worker_t * wrk, svm_msg_q_t * mq, break; } } - vec_delete (wrk->mq_msg_vector, i, 0); return *num_ev;