aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-10-12 16:55:14 -0700
committerFlorin Coras <fcoras@cisco.com>2018-10-12 17:01:10 -0700
commit02a60e01a71660d17a6578e8f35f468d5b6532cb (patch)
tree2bd1542e7c6e2518e928572380d1c01a3653c472
parent9a5f9c9a43ae6057fe760a59d40443a12af37f90 (diff)
session: don't wait indefinitely for apps to consume evts (VPP-1454)
Change-Id: I544b24d2b2c4a09829773cf180d1747f4b087d4c Signed-off-by: Florin Coras <fcoras@cisco.com>
-rwxr-xr-xsrc/vnet/session/session_api.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index fc63428277e..e82be560b1f 100755
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -422,6 +422,23 @@ static session_cb_vft_t session_cb_vft = {
};
static int
+mq_try_lock_and_alloc_msg (svm_msg_q_t * app_mq, svm_msg_q_msg_t * msg)
+{
+ int rv;
+ u8 try = 0;
+ while (try < 100)
+ {
+ rv = svm_msg_q_lock_and_alloc_msg_w_ring (app_mq,
+ SESSION_MQ_CTRL_EVT_RING,
+ SVM_Q_NOWAIT, msg);
+ if (!rv)
+ return 0;
+ try++;
+ }
+ return -1;
+}
+
+static int
mq_send_session_accepted_cb (stream_session_t * s)
{
app_worker_t *app_wrk = app_worker_get (s->app_wrk_index);
@@ -436,8 +453,8 @@ mq_send_session_accepted_cb (stream_session_t * s)
app = application_get (app_wrk->app_index);
app_mq = app_wrk->event_queue;
- svm_msg_q_lock_and_alloc_msg_w_ring (app_mq, SESSION_MQ_CTRL_EVT_RING,
- SVM_Q_WAIT, msg);
+ if (mq_try_lock_and_alloc_msg (app_mq, msg))
+ return -1;
evt = svm_msg_q_msg_data (app_mq, msg);
memset (evt, 0, sizeof (*evt));
@@ -523,8 +540,8 @@ mq_send_session_disconnected_cb (stream_session_t * s)
app = application_get (app_wrk->app_index);
app_mq = app_wrk->event_queue;
- svm_msg_q_lock_and_alloc_msg_w_ring (app_mq, SESSION_MQ_CTRL_EVT_RING,
- SVM_Q_WAIT, msg);
+ if (mq_try_lock_and_alloc_msg (app_mq, msg))
+ return;
evt = svm_msg_q_msg_data (app_mq, msg);
memset (evt, 0, sizeof (*evt));
evt->event_type = SESSION_CTRL_EVT_DISCONNECTED;
@@ -544,8 +561,8 @@ mq_send_session_reset_cb (stream_session_t * s)
session_event_t *evt;
app_mq = app->event_queue;
- svm_msg_q_lock_and_alloc_msg_w_ring (app_mq, SESSION_MQ_CTRL_EVT_RING,
- SVM_Q_WAIT, msg);
+ if (mq_try_lock_and_alloc_msg (app_mq, msg))
+ return;
evt = svm_msg_q_msg_data (app_mq, msg);
memset (evt, 0, sizeof (*evt));
evt->event_type = SESSION_CTRL_EVT_RESET;
@@ -576,8 +593,8 @@ mq_send_session_connected_cb (u32 app_wrk_index, u32 api_context,
return -1;
}
- svm_msg_q_lock_and_alloc_msg_w_ring (app_mq, SESSION_MQ_CTRL_EVT_RING,
- SVM_Q_WAIT, msg);
+ if (mq_try_lock_and_alloc_msg (app_mq, msg))
+ return -1;
evt = svm_msg_q_msg_data (app_mq, msg);
memset (evt, 0, sizeof (*evt));
evt->event_type = SESSION_CTRL_EVT_CONNECTED;
@@ -656,8 +673,9 @@ mq_send_session_bound_cb (u32 app_wrk_index, u32 api_context,
return -1;
}
- svm_msg_q_lock_and_alloc_msg_w_ring (app_mq, SESSION_MQ_CTRL_EVT_RING,
- SVM_Q_WAIT, msg);
+ if (mq_try_lock_and_alloc_msg (app_mq, msg))
+ return -1;
+
evt = svm_msg_q_msg_data (app_mq, msg);
memset (evt, 0, sizeof (*evt));
evt->event_type = SESSION_CTRL_EVT_BOUND;