aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpp-api')
-rw-r--r--src/vpp-api/client/client.c5
-rw-r--r--src/vpp-api/vapi/vapi.c9
-rw-r--r--src/vpp-api/vapi/vapi.h6
-rw-r--r--src/vpp-api/vapi/vapi.hpp5
4 files changed, 17 insertions, 8 deletions
diff --git a/src/vpp-api/client/client.c b/src/vpp-api/client/client.c
index f1372230195..fd2c4174285 100644
--- a/src/vpp-api/client/client.c
+++ b/src/vpp-api/client/client.c
@@ -143,7 +143,7 @@ vac_rx_thread_fn (void *arg)
q = am->vl_input_queue;
while (1)
- while (!svm_queue_sub(q, (u8 *)&msg, 0))
+ while (!svm_queue_sub(q, (u8 *)&msg, SVM_Q_WAIT, 0))
{
u16 id = ntohs(*((u16 *)msg));
switch (id) {
@@ -404,7 +404,8 @@ vac_read (char **p, int *l, u16 timeout)
q = am->vl_input_queue;
again:
- rv = svm_queue_sub(q, (u8 *)&msg, 0);
+ rv = svm_queue_sub(q, (u8 *)&msg, SVM_Q_WAIT, 0);
+
if (rv == 0) {
u16 msg_id = ntohs(*((u16 *)msg));
switch (msg_id) {
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);
diff --git a/src/vpp-api/vapi/vapi.h b/src/vpp-api/vapi/vapi.h
index 245bf654e8a..fc48e7d402c 100644
--- a/src/vpp-api/vapi/vapi.h
+++ b/src/vpp-api/vapi/vapi.h
@@ -22,6 +22,7 @@
#include <stdbool.h>
#include <vppinfra/types.h>
#include <vapi/vapi_common.h>
+#include <svm/queue.h>
#ifdef __cplusplus
extern "C"
@@ -162,10 +163,13 @@ extern "C"
* @param ctx opaque vapi context
* @param[out] msg pointer to result variable containing message
* @param[out] msg_size pointer to result variable containing message size
+ * @param cond enum type for blocking, non-blocking or timed wait call
+ * @param time in sec for timed wait
*
* @return VAPI_OK on success, other error code on error
*/
- vapi_error_e vapi_recv (vapi_ctx_t ctx, void **msg, size_t * msg_size);
+ vapi_error_e vapi_recv (vapi_ctx_t ctx, void **msg, size_t * msg_size,
+ svm_q_conditional_wait_t cond, u32 time);
/**
* @brief wait for connection to become readable or writable
diff --git a/src/vpp-api/vapi/vapi.hpp b/src/vpp-api/vapi/vapi.hpp
index 893851a0dbb..28357db420c 100644
--- a/src/vpp-api/vapi/vapi.hpp
+++ b/src/vpp-api/vapi/vapi.hpp
@@ -245,7 +245,7 @@ public:
*
* @return VAPI_OK on success, other error code on error
*/
- vapi_error_e dispatch (const Common_req *limit = nullptr)
+ vapi_error_e dispatch (const Common_req *limit = nullptr, u32 time = 5)
{
std::lock_guard<std::mutex> lock (dispatch_mutex);
vapi_error_e rv = VAPI_OK;
@@ -254,7 +254,8 @@ public:
{
void *shm_data;
size_t shm_data_size;
- rv = vapi_recv (vapi_ctx, &shm_data, &shm_data_size);
+ rv = vapi_recv (vapi_ctx, &shm_data, &shm_data_size, SVM_Q_TIMEDWAIT,
+ time);
if (VAPI_OK != rv)
{
return rv;