vapi: implement vapi_wait() for reads
Type: improvement The function vapi_wait() is intended to allow a caller to block while waiting until the API queue can be read/written. It was a stub that returned VAPI_ENOTSUP. Add code which implements the wait on being able to read an incoming message. Had to touch a few other things in vapi.h to make checkstyle.sh happy after changing the prototype of vapi_wait(). Signed-off-by: Matthew Smith <mgsmith@netgate.com> Change-Id: Ida80c1a1d34fe297ab23268087be65ea53ad7040
This commit is contained in:
@ -989,9 +989,13 @@ again:
|
|||||||
}
|
}
|
||||||
|
|
||||||
vapi_error_e
|
vapi_error_e
|
||||||
vapi_wait (vapi_ctx_t ctx, vapi_wait_mode_e mode)
|
vapi_wait (vapi_ctx_t ctx)
|
||||||
{
|
{
|
||||||
return VAPI_ENOTSUP;
|
svm_queue_lock (ctx->vl_input_queue);
|
||||||
|
svm_queue_wait (ctx->vl_input_queue);
|
||||||
|
svm_queue_unlock (ctx->vl_input_queue);
|
||||||
|
|
||||||
|
return VAPI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static vapi_error_e
|
static vapi_error_e
|
||||||
|
@ -175,7 +175,7 @@ vapi_error_e vapi_send (vapi_ctx_t ctx, void *msg);
|
|||||||
*
|
*
|
||||||
* @return VAPI_OK on success, other error code on error
|
* @return VAPI_OK on success, other error code on error
|
||||||
*/
|
*/
|
||||||
vapi_error_e vapi_send2 (vapi_ctx_t ctx, void *msg1, void *msg2);
|
vapi_error_e vapi_send2 (vapi_ctx_t ctx, void *msg1, void *msg2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief low-level api for reading messages from vpp
|
* @brief low-level api for reading messages from vpp
|
||||||
@ -191,18 +191,17 @@ vapi_error_e vapi_send (vapi_ctx_t ctx, void *msg);
|
|||||||
*
|
*
|
||||||
* @return VAPI_OK on success, other error code on error
|
* @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);
|
svm_q_conditional_wait_t cond, u32 time);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief wait for connection to become readable or writable
|
* @brief wait for connection to become readable
|
||||||
*
|
*
|
||||||
* @param ctx opaque vapi context
|
* @param ctx opaque vapi context
|
||||||
* @param mode type of property to wait for - readability, writability or both
|
|
||||||
*
|
*
|
||||||
* @return VAPI_OK on success, other error code on error
|
* @return VAPI_OK on success, other error code on error
|
||||||
*/
|
*/
|
||||||
vapi_error_e vapi_wait (vapi_ctx_t ctx, vapi_wait_mode_e mode);
|
vapi_error_e vapi_wait (vapi_ctx_t ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief pick next message sent by vpp and call the appropriate callback
|
* @brief pick next message sent by vpp and call the appropriate callback
|
||||||
|
@ -45,13 +45,6 @@ typedef enum
|
|||||||
VAPI_MODE_NONBLOCKING = 2, /**< operations never block */
|
VAPI_MODE_NONBLOCKING = 2, /**< operations never block */
|
||||||
} vapi_mode_e;
|
} vapi_mode_e;
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
VAPI_WAIT_FOR_READ, /**< wait until some message is readable */
|
|
||||||
VAPI_WAIT_FOR_WRITE, /**< wait until a message can be written */
|
|
||||||
VAPI_WAIT_FOR_READ_WRITE, /**< wait until a read or write can be done */
|
|
||||||
} vapi_wait_mode_e;
|
|
||||||
|
|
||||||
typedef unsigned int vapi_msg_id_t;
|
typedef unsigned int vapi_msg_id_t;
|
||||||
|
|
||||||
#define VAPI_INVALID_MSG_ID ((vapi_msg_id_t)(~0))
|
#define VAPI_INVALID_MSG_ID ((vapi_msg_id_t)(~0))
|
||||||
|
Reference in New Issue
Block a user