summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/vapi/vapi.c
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2018-01-04 18:57:26 +0100
committerDave Barach <openvpp@barachs.net>2018-01-22 18:17:23 +0000
commit3fca567ff438145e28dd1318ad5b1734c1091257 (patch)
tree7101b4ae130f2731e549f82ab98af8bfbabc6571 /src/vpp-api/vapi/vapi.c
parente82488f10f20f464961c5c7b381b4a419bca0bbc (diff)
svm: queue sub: Add conditional timed wait
On reviece side svm queue only permits blocking and non-blocking calls. This patch adds timed wait blocking functionality which returns either on signal/event or on given time out. It also preserves the original behavior, so it will not hurt client applications which are using svm queue. Change-Id: Ic10632170330a80afb8bc781d4ccddfe4da2c69a Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src/vpp-api/vapi/vapi.c')
-rw-r--r--src/vpp-api/vapi/vapi.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/vpp-api/vapi/vapi.c b/src/vpp-api/vapi/vapi.c
index 7aa346bf083..754c89cf561 100644
--- a/src/vpp-api/vapi/vapi.c
+++ b/src/vpp-api/vapi/vapi.c
@@ -502,7 +502,8 @@ out:
}
vapi_error_e
-vapi_recv (vapi_ctx_t ctx, void **msg, size_t * msg_size)
+vapi_recv (vapi_ctx_t ctx, void **msg, size_t * msg_size,
+ svm_q_conditional_wait_t cond, u32 time)
{
if (!ctx || !ctx->connected || !msg || !msg_size)
{
@@ -519,7 +520,9 @@ vapi_recv (vapi_ctx_t ctx, void **msg, size_t * msg_size)
svm_queue_t *q = am->vl_input_queue;
VAPI_DBG ("doing shm queue sub");
- int tmp = svm_queue_sub (q, (u8 *) & data, 0);
+
+ int tmp = svm_queue_sub (q, (u8 *) & data, cond, time);
+
if (tmp == 0)
{
#if VAPI_DEBUG_ALLOC
@@ -700,7 +703,7 @@ vapi_dispatch_one (vapi_ctx_t ctx)
VAPI_DBG ("vapi_dispatch_one()");
void *msg;
size_t size;
- vapi_error_e rv = vapi_recv (ctx, &msg, &size);
+ vapi_error_e rv = vapi_recv (ctx, &msg, &size, SVM_Q_WAIT, 0);
if (VAPI_OK != rv)
{
VAPI_DBG ("vapi_recv failed with rv=%d", rv);