diff options
author | Florin Coras <fcoras@cisco.com> | 2018-10-13 12:20:01 -0700 |
---|---|---|
committer | Marco Varlese <marco.varlese@suse.de> | 2018-10-16 10:05:57 +0000 |
commit | d6a0d0e2063fcc93eb56fc8a542e89a8e0b53741 (patch) | |
tree | c8f10ce77fe524a6cf9f927395adff6c206e9ab0 /src/vcl | |
parent | 347c523c23277a6061a21dbca43be7498ebb41af (diff) |
vcl: fix bidirectional tests (VPP-1455)
- add epoll dequeued events beyond maxevents to unhandled
- filter multiple epoll rx events
Change-Id: I618f5f02b19581473de891b3b59bb6a0faad10b5
Signed-off-by: Florin Coras <fcoras@cisco.com>
(cherry picked from commit aa27eb95b7ee3bb69b62166d5e418e973cbbdcfa)
Diffstat (limited to 'src/vcl')
-rw-r--r-- | src/vcl/vcl_private.h | 1 | ||||
-rw-r--r-- | src/vcl/vcl_test.h | 2 | ||||
-rw-r--r-- | src/vcl/vppcom.c | 27 |
3 files changed, 17 insertions, 13 deletions
diff --git a/src/vcl/vcl_private.h b/src/vcl/vcl_private.h index 5975f15ac4f..d1a40b933a7 100644 --- a/src/vcl/vcl_private.h +++ b/src/vcl/vcl_private.h @@ -153,6 +153,7 @@ typedef struct /* Socket configuration state */ u8 is_vep; u8 is_vep_session; + u8 has_rx_evt; u32 attr; u32 wait_cont_idx; vppcom_epoll_t vep; diff --git a/src/vcl/vcl_test.h b/src/vcl/vcl_test.h index 927110f55d2..9d28b262e3a 100644 --- a/src/vcl/vcl_test.h +++ b/src/vcl/vcl_test.h @@ -438,7 +438,7 @@ vcl_test_write (int fd, uint8_t * buf, uint32_t nbytes, { if (stats) stats->tx_eagain++; - continue; + break; } else break; diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c index df4ebde72eb..fad2ac98538 100644 --- a/src/vcl/vppcom.c +++ b/src/vcl/vppcom.c @@ -1293,13 +1293,14 @@ vppcom_session_read_internal (uint32_t session_handle, void *buf, int n, is_ct = vcl_session_is_ct (s); mq = is_ct ? s->our_evt_q : wrk->app_event_queue; rx_fifo = s->rx_fifo; + s->has_rx_evt = 0; if (svm_fifo_is_empty (rx_fifo)) { if (is_nonblocking) { svm_fifo_unset_event (rx_fifo); - return VPPCOM_OK; + return VPPCOM_EWOULDBLOCK; } while (svm_fifo_is_empty (rx_fifo)) { @@ -1385,13 +1386,14 @@ vppcom_session_read_segments (uint32_t session_handle, is_ct = vcl_session_is_ct (s); mq = is_ct ? s->our_evt_q : wrk->app_event_queue; rx_fifo = s->rx_fifo; + s->has_rx_evt = 0; if (svm_fifo_is_empty (rx_fifo)) { if (is_nonblocking) { svm_fifo_unset_event (rx_fifo); - return VPPCOM_OK; + return VPPCOM_EWOULDBLOCK; } while (svm_fifo_is_empty (rx_fifo)) { @@ -1551,7 +1553,8 @@ vppcom_session_write (uint32_t session_handle, void *buf, size_t n) { svm_fifo_set_want_tx_evt (tx_fifo, 1); svm_msg_q_lock (mq); - svm_msg_q_wait (mq); + if (svm_msg_q_is_empty (mq)) + svm_msg_q_wait (mq); svm_msg_q_sub_w_lock (mq, &msg); e = svm_msg_q_msg_data (mq, &msg); @@ -2303,11 +2306,12 @@ vcl_epoll_wait_handle_mq_event (vcl_worker_t * wrk, session_event_t * e, sid = e->fifo->client_session_index; session = vcl_session_get (wrk, sid); session_events = session->vep.ev.events; - if (!(EPOLLIN & session->vep.ev.events)) + if (!(EPOLLIN & session->vep.ev.events) || session->has_rx_evt) break; add_event = 1; events[*num_ev].events |= EPOLLIN; session_evt_data = session->vep.ev.data.u64; + session->has_rx_evt = 1; break; case FIFO_EVENT_APP_TX: sid = e->fifo->client_session_index; @@ -2324,11 +2328,12 @@ vcl_epoll_wait_handle_mq_event (vcl_worker_t * wrk, session_event_t * e, session = vcl_ct_session_get_from_fifo (wrk, e->fifo, 0); sid = session->session_index; session_events = session->vep.ev.events; - if (!(EPOLLIN & session->vep.ev.events)) + if (!(EPOLLIN & session->vep.ev.events) || session->has_rx_evt) break; add_event = 1; events[*num_ev].events |= EPOLLIN; session_evt_data = session->vep.ev.data.u64; + session->has_rx_evt = 1; break; case SESSION_IO_EVT_CT_RX: session = vcl_ct_session_get_from_fifo (wrk, e->fifo, 1); @@ -2452,15 +2457,13 @@ handle_dequeued: { msg = vec_elt_at_index (wrk->mq_msg_vector, i); e = svm_msg_q_msg_data (mq, msg); - vcl_epoll_wait_handle_mq_event (wrk, e, events, num_ev); + if (*num_ev < maxevents) + vcl_epoll_wait_handle_mq_event (wrk, e, events, num_ev); + else + vec_add1 (wrk->unhandled_evts_vector, *e); svm_msg_q_free_msg (mq, msg); - if (*num_ev == maxevents) - { - i += 1; - break; - } } - vec_delete (wrk->mq_msg_vector, i, 0); + vec_reset_length (wrk->mq_msg_vector); return *num_ev; } |