aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api/vapi
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2022-01-24 21:37:09 +0000
committerOle Tr�an <otroan@employees.org>2022-01-25 14:35:02 +0000
commit5f0106a76fbc3792781a81dedb5a7e41813430d3 (patch)
tree77191a0d46c5dfc575e923f4ca77f1d7d519ae00 /src/vpp-api/vapi
parent8d4db8bfb4b0d2ecd8bef37fa0650b779f03f1ef (diff)
api: vapi: honor non-blocking setting
Pass correct conditional based on how vapi is configured wrt blocking. Type: fix Fixes: 3fca567ff438145e28dd1318ad5b1734c1091257 Signed-off-by: Klement Sekera <ksekera@cisco.com> Change-Id: I47adca19f104d7a758cb2940e93c9fd8c7cc9bfa
Diffstat (limited to 'src/vpp-api/vapi')
-rw-r--r--src/vpp-api/vapi/vapi.c4
-rw-r--r--src/vpp-api/vapi/vapi_c_test.c33
2 files changed, 25 insertions, 12 deletions
diff --git a/src/vpp-api/vapi/vapi.c b/src/vpp-api/vapi/vapi.c
index fbe04c187f3..ca46f8d3b84 100644
--- a/src/vpp-api/vapi/vapi.c
+++ b/src/vpp-api/vapi/vapi.c
@@ -766,7 +766,9 @@ vapi_dispatch_one (vapi_ctx_t ctx)
VAPI_DBG ("vapi_dispatch_one()");
void *msg;
uword size;
- vapi_error_e rv = vapi_recv (ctx, &msg, &size, SVM_Q_WAIT, 0);
+ svm_q_conditional_wait_t cond =
+ vapi_is_nonblocking (ctx) ? SVM_Q_NOWAIT : SVM_Q_WAIT;
+ vapi_error_e rv = vapi_recv (ctx, &msg, &size, cond, 0);
if (VAPI_OK != rv)
{
VAPI_DBG ("vapi_recv failed with rv=%d", rv);
diff --git a/src/vpp-api/vapi/vapi_c_test.c b/src/vpp-api/vapi/vapi_c_test.c
index 7c7e8611731..99a93fb22fd 100644
--- a/src/vpp-api/vapi/vapi_c_test.c
+++ b/src/vpp-api/vapi/vapi_c_test.c
@@ -585,7 +585,8 @@ START_TEST (test_show_version_3)
;
ck_assert_int_eq (VAPI_OK, rv);
ck_assert_int_eq (0, called);
- rv = vapi_dispatch (ctx);
+ while (VAPI_EAGAIN == (rv = vapi_dispatch (ctx)))
+ ;
ck_assert_int_eq (VAPI_OK, rv);
ck_assert_int_eq (1, called);
called = 0;
@@ -619,14 +620,16 @@ START_TEST (test_show_version_4)
ck_assert_int_eq (0, contexts[j]);
}
}
- rv = vapi_dispatch (ctx);
+ while (VAPI_EAGAIN == (rv = vapi_dispatch (ctx)))
+ ;
ck_assert_int_eq (VAPI_OK, rv);
for (i = 0; i < num_req; ++i)
{
ck_assert_int_eq (1, contexts[i]);
}
clib_memset (contexts, 0, sizeof (contexts));
- rv = vapi_dispatch (ctx);
+ while (VAPI_EAGAIN == (rv = vapi_dispatch (ctx)))
+ ;
ck_assert_int_eq (VAPI_OK, rv);
for (i = 0; i < num_req; ++i)
{
@@ -670,7 +673,8 @@ START_TEST (test_loopbacks_2)
;
ck_assert_int_eq (VAPI_OK, rv);
}
- rv = vapi_dispatch (ctx);
+ while (VAPI_EAGAIN == (rv = vapi_dispatch (ctx)))
+ ;
ck_assert_int_eq (VAPI_OK, rv);
for (i = 0; i < num_ifs; ++i)
{
@@ -695,7 +699,8 @@ START_TEST (test_loopbacks_2)
}
clib_memset (&seen, 0, sizeof (seen));
ck_assert_int_eq (false, dctx.last_called);
- rv = vapi_dispatch (ctx);
+ while (VAPI_EAGAIN == (rv = vapi_dispatch (ctx)))
+ ;
ck_assert_int_eq (VAPI_OK, rv);
for (i = 0; i < num_ifs; ++i)
{
@@ -713,7 +718,8 @@ START_TEST (test_loopbacks_2)
;
ck_assert_int_eq (VAPI_OK, rv);
}
- rv = vapi_dispatch (ctx);
+ while (VAPI_EAGAIN == (rv = vapi_dispatch (ctx)))
+ ;
ck_assert_int_eq (VAPI_OK, rv);
for (i = 0; i < num_ifs; ++i)
{
@@ -727,7 +733,8 @@ START_TEST (test_loopbacks_2)
(rv =
vapi_sw_interface_dump (ctx, dump, sw_interface_dump_cb, &dctx)))
;
- rv = vapi_dispatch (ctx);
+ while (VAPI_EAGAIN == (rv = vapi_dispatch (ctx)))
+ ;
ck_assert_int_eq (VAPI_OK, rv);
for (i = 0; i < num_ifs; ++i)
{
@@ -766,7 +773,8 @@ START_TEST (test_show_version_5)
int called = 0;
vapi_set_generic_event_cb (ctx, generic_cb, &called);
ck_assert_int_eq (VAPI_OK, rv);
- rv = vapi_dispatch_one (ctx);
+ while (VAPI_EAGAIN == (rv = vapi_dispatch_one (ctx)))
+ ;
ck_assert_int_eq (VAPI_OK, rv);
ck_assert_int_eq (1, called);
sv = vapi_alloc_show_version (ctx);
@@ -776,7 +784,8 @@ START_TEST (test_show_version_5)
;
ck_assert_int_eq (VAPI_OK, rv);
vapi_clear_generic_event_cb (ctx);
- rv = vapi_dispatch_one (ctx);
+ while (VAPI_EAGAIN == (rv = vapi_dispatch_one (ctx)))
+ ;
ck_assert_int_eq (VAPI_OK, rv);
ck_assert_int_eq (1, called); /* needs to remain unchanged */
}
@@ -813,7 +822,8 @@ START_TEST (test_no_response_1)
(rv = vapi_show_version (ctx, sv, show_version_cb, &called)))
;
ck_assert_int_eq (VAPI_OK, rv);
- rv = vapi_dispatch (ctx);
+ while (VAPI_EAGAIN == (rv = vapi_dispatch (ctx)))
+ ;
ck_assert_int_eq (VAPI_OK, rv);
ck_assert_int_eq (2, called);
}
@@ -844,7 +854,8 @@ START_TEST (test_no_response_2)
(rv = vapi_sw_interface_dump (ctx, dump, no_msg_cb, &no_called)))
;
ck_assert_int_eq (VAPI_OK, rv);
- rv = vapi_dispatch (ctx);
+ while (VAPI_EAGAIN == (rv = vapi_dispatch (ctx)))
+ ;
ck_assert_int_eq (VAPI_OK, rv);
ck_assert_int_eq (1, no_called);
}