diff options
author | Florin Coras <fcoras@cisco.com> | 2018-09-11 00:10:41 -0700 |
---|---|---|
committer | Marco Varlese <marco.varlese@suse.de> | 2018-09-12 09:13:16 +0000 |
commit | 41c9e04be0ca3a081926045e78dc969dab563532 (patch) | |
tree | 2b0e666792415ebd8fc3fed5847652321231e4a8 /src/vcl | |
parent | ffb14b9554afa1e58c3657e0c91dda3135008274 (diff) |
vcl: improve read and fifo event handling
Change-Id: Ic1c51818b8aa8dbd164e70bb3b7471868e5af6f6
Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vcl')
-rw-r--r-- | src/vcl/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/vcl/vcl_test_server.c | 6 | ||||
-rw-r--r-- | src/vcl/vppcom.c | 26 |
3 files changed, 19 insertions, 16 deletions
diff --git a/src/vcl/CMakeLists.txt b/src/vcl/CMakeLists.txt index ba19ced27a6..c86f40bb0f2 100644 --- a/src/vcl/CMakeLists.txt +++ b/src/vcl/CMakeLists.txt @@ -24,6 +24,9 @@ add_vpp_library(vppcom LINK_LIBRARIES vppinfra svm vlibmemoryclient rt pthread + + DEPENDS + api_headers ) add_vpp_library(vcl_ldpreload diff --git a/src/vcl/vcl_test_server.c b/src/vcl/vcl_test_server.c index 5c8656c9603..7c1bef62d6d 100644 --- a/src/vcl/vcl_test_server.c +++ b/src/vcl/vcl_test_server.c @@ -575,8 +575,8 @@ vts_worker_loop (void *arg) } continue; } - else if ((conn->cfg.test == SOCK_TEST_TYPE_UNI) - || (conn->cfg.test == SOCK_TEST_TYPE_BI)) + if ((conn->cfg.test == SOCK_TEST_TYPE_UNI) + || (conn->cfg.test == SOCK_TEST_TYPE_BI)) { vts_server_rx (conn, rx_bytes); if (vppcom_session_attr (conn->fd, VPPCOM_ATTR_GET_NREAD, 0, @@ -584,7 +584,7 @@ vts_worker_loop (void *arg) goto read_again; continue; } - else if (isascii (conn->buf[0])) + if (isascii (conn->buf[0])) { vts_server_echo (conn, rx_bytes); } diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c index 3acd1c41e70..6d6e7d08797 100644 --- a/src/vcl/vppcom.c +++ b/src/vcl/vppcom.c @@ -1268,7 +1268,7 @@ vppcom_session_read_internal (uint32_t session_handle, void *buf, int n, svm_msg_q_msg_t msg; session_event_t *e; svm_msg_q_t *mq; - u8 is_full; + u8 is_ct; if (PREDICT_FALSE (!buf)) return VPPCOM_EINVAL; @@ -1299,18 +1299,19 @@ vppcom_session_read_internal (uint32_t session_handle, void *buf, int n, return rv; } - mq = vcl_session_is_ct (s) ? s->our_evt_q : wrk->app_event_queue; - svm_fifo_unset_event (rx_fifo); - is_full = svm_fifo_is_full (rx_fifo); + is_ct = vcl_session_is_ct (s); + mq = is_ct ? s->our_evt_q : wrk->app_event_queue; if (svm_fifo_is_empty (rx_fifo)) { if (is_nonblocking) { + svm_fifo_unset_event (rx_fifo); return VPPCOM_OK; } - while (1) + while (svm_fifo_is_empty (rx_fifo)) { + svm_fifo_unset_event (rx_fifo); svm_msg_q_lock (mq); if (svm_msg_q_is_empty (mq)) svm_msg_q_wait (mq); @@ -1318,20 +1319,16 @@ vppcom_session_read_internal (uint32_t session_handle, void *buf, int n, svm_msg_q_sub_w_lock (mq, &msg); e = svm_msg_q_msg_data (mq, &msg); svm_msg_q_unlock (mq); - if (!vcl_is_rx_evt_for_session (e, s->session_index, - s->our_evt_q != 0)) + if (!vcl_is_rx_evt_for_session (e, s->session_index, is_ct)) { vcl_handle_mq_ctrl_event (wrk, e); svm_msg_q_free_msg (mq, &msg); continue; } - svm_fifo_unset_event (rx_fifo); svm_msg_q_free_msg (mq, &msg); + if (PREDICT_FALSE (s->session_state == STATE_CLOSE_ON_EMPTY)) return 0; - if (svm_fifo_is_empty (rx_fifo)) - continue; - break; } } @@ -1340,7 +1337,10 @@ vppcom_session_read_internal (uint32_t session_handle, void *buf, int n, else n_read = app_recv_stream_raw (rx_fifo, buf, n, 0, peek); - if (vcl_session_is_ct (s) && is_full) + if (svm_fifo_is_empty (rx_fifo)) + svm_fifo_unset_event (rx_fifo); + + if (is_ct && n_read + svm_fifo_max_dequeue (rx_fifo) == rx_fifo->nitems) { /* If the peer is not polling send notification */ if (!svm_fifo_has_event (s->rx_fifo)) @@ -1593,7 +1593,7 @@ if (PREDICT_FALSE (svm_fifo_is_empty (_fifo))) \ { \ svm_fifo_unset_event (_fifo); \ if (svm_fifo_is_empty (_fifo)) \ - break; \ + break; \ } \ static int |