summaryrefslogtreecommitdiffstats
path: root/src/vlibmemory
diff options
context:
space:
mode:
Diffstat (limited to 'src/vlibmemory')
-rw-r--r--src/vlibmemory/api.h9
-rw-r--r--src/vlibmemory/memory_shared.c6
-rw-r--r--src/vlibmemory/memory_shared.h1
3 files changed, 16 insertions, 0 deletions
diff --git a/src/vlibmemory/api.h b/src/vlibmemory/api.h
index 4f869a64be3..e86b88cdf9e 100644
--- a/src/vlibmemory/api.h
+++ b/src/vlibmemory/api.h
@@ -43,6 +43,15 @@ vl_api_send_msg (vl_api_registration_t * rp, u8 * elem)
}
}
+always_inline int
+vl_api_can_send_msg (vl_api_registration_t * rp)
+{
+ if (PREDICT_FALSE (rp->registration_type > REGISTRATION_TYPE_SHMEM))
+ return 1;
+ else
+ return vl_mem_api_can_send (rp->vl_input_queue);
+}
+
always_inline vl_api_registration_t *
vl_api_client_index_to_registration (u32 index)
{
diff --git a/src/vlibmemory/memory_shared.c b/src/vlibmemory/memory_shared.c
index 19285df9efe..c9ace1b141d 100644
--- a/src/vlibmemory/memory_shared.c
+++ b/src/vlibmemory/memory_shared.c
@@ -681,6 +681,12 @@ vl_msg_api_send_shmem (svm_queue_t * q, u8 * elem)
(void) svm_queue_add (q, elem, 0 /* nowait */ );
}
+int
+vl_mem_api_can_send (svm_queue_t * q)
+{
+ return (q->cursize < q->maxsize);
+}
+
void
vl_msg_api_send_shmem_nolock (svm_queue_t * q, u8 * elem)
{
diff --git a/src/vlibmemory/memory_shared.h b/src/vlibmemory/memory_shared.h
index f60224a1815..8a7667c14d3 100644
--- a/src/vlibmemory/memory_shared.h
+++ b/src/vlibmemory/memory_shared.h
@@ -115,6 +115,7 @@ void vl_unmap_shmem (void);
void vl_register_mapped_shmem_region (svm_region_t * rp);
void vl_msg_api_send_shmem (svm_queue_t * q, u8 * elem);
void vl_msg_api_send_shmem_nolock (svm_queue_t * q, u8 * elem);
+int vl_mem_api_can_send (svm_queue_t * q);
void vl_set_memory_region_name (const char *name);
void vl_set_memory_root_path (const char *root_path);
void vl_set_memory_uid (int uid);