aboutsummaryrefslogtreecommitdiffstats
path: root/src/vcl/vcl_private.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-01-18 08:37:13 -0800
committerDamjan Marion <dmarion@me.com>2019-01-29 16:36:06 +0000
commit0ef8ef2b474473b13de2cee0165b424e79e4e363 (patch)
treebce10bafb40e25844d25604a33095c376e135b0e /src/vcl/vcl_private.c
parentcac8cfaba977d3822c06452817e43d7f0bdaa189 (diff)
vls: multi-process and multi-threaded apps improvements
- More fine tuning for multi-process applications. - Experimental support for multi-thread apps. This is meant for app whose threads are not vcl workers and the sessions are shared between them. Change-Id: Ie07651da5f2cdcf39f5dead5431f50ad39cf3f74 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vcl/vcl_private.c')
-rw-r--r--src/vcl/vcl_private.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/vcl/vcl_private.c b/src/vcl/vcl_private.c
index df602b3ce87..5f9ce270508 100644
--- a/src/vcl/vcl_private.c
+++ b/src/vcl/vcl_private.c
@@ -391,6 +391,70 @@ vcl_cleanup_bapi (void)
vl_client_api_unmap ();
}
+int
+vcl_session_read_ready (vcl_session_t * session)
+{
+ /* Assumes caller has acquired spinlock: vcm->sessions_lockp */
+ if (PREDICT_FALSE (session->is_vep))
+ {
+ VDBG (0, "ERROR: session %u: cannot read from an epoll session!",
+ session->session_index);
+ return VPPCOM_EBADFD;
+ }
+
+ if (PREDICT_FALSE (!(session->session_state & (STATE_OPEN | STATE_LISTEN))))
+ {
+ session_state_t state = session->session_state;
+ int rv;
+
+ rv = ((state & STATE_DISCONNECT) ? VPPCOM_ECONNRESET : VPPCOM_ENOTCONN);
+
+ VDBG (1, "session %u [0x%llx]: not open! state 0x%x (%s), ret %d (%s)",
+ session->session_index, session->vpp_handle, state,
+ vppcom_session_state_str (state), rv, vppcom_retval_str (rv));
+ return rv;
+ }
+
+ if (session->session_state & STATE_LISTEN)
+ return clib_fifo_elts (session->accept_evts_fifo);
+
+ return svm_fifo_max_dequeue (session->rx_fifo);
+}
+
+int
+vcl_session_write_ready (vcl_session_t * session)
+{
+ /* Assumes caller has acquired spinlock: vcm->sessions_lockp */
+ if (PREDICT_FALSE (session->is_vep))
+ {
+ VDBG (0, "session %u [0x%llx]: cannot write to an epoll session!",
+ session->session_index, session->vpp_handle);
+ return VPPCOM_EBADFD;
+ }
+
+ if (PREDICT_FALSE (session->session_state & STATE_LISTEN))
+ {
+ if (session->tx_fifo)
+ return svm_fifo_max_enqueue (session->tx_fifo);
+ else
+ return VPPCOM_EBADFD;
+ }
+
+ if (PREDICT_FALSE (!(session->session_state & STATE_OPEN)))
+ {
+ session_state_t state = session->session_state;
+ int rv;
+
+ rv = ((state & STATE_DISCONNECT) ? VPPCOM_ECONNRESET : VPPCOM_ENOTCONN);
+ VDBG (0, "session %u [0x%llx]: not open! state 0x%x (%s), ret %d (%s)",
+ session->session_index, session->vpp_handle, state,
+ vppcom_session_state_str (state), rv, vppcom_retval_str (rv));
+ return rv;
+ }
+
+ return svm_fifo_max_enqueue (session->tx_fifo);
+}
+
/*
* fd.io coding-style-patch-verification: ON
*