summaryrefslogtreecommitdiffstats
path: root/src/svm/message_queue.h
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2022-04-19 18:57:24 -0700
committerDave Barach <openvpp@barachs.net>2022-04-21 16:48:15 +0000
commit80d100cd59015d91c4f0abfaf07b6876088ecbf1 (patch)
tree5b0d949fcf012b359c0af8b4371afbe6d10c7a29 /src/svm/message_queue.h
parent5297447bd64ab253ab3ab3e144605dd39f995f12 (diff)
session svm: fix mq producer wait on q and ring
Make sure producer drops lock when it waits for empty ring slot. Type: fix Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Id77d54ee8c01bed20c9eaf5ad372ed4b1e9fa712
Diffstat (limited to 'src/svm/message_queue.h')
-rw-r--r--src/svm/message_queue.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/svm/message_queue.h b/src/svm/message_queue.h
index bd76eda5d88..0780cca1c32 100644
--- a/src/svm/message_queue.h
+++ b/src/svm/message_queue.h
@@ -328,6 +328,12 @@ svm_msg_q_ring_is_full (svm_msg_q_t * mq, u32 ring_index)
return (clib_atomic_load_relax_n (&ring->shr->cursize) >= ring->nitems);
}
+static inline u8
+svm_msg_q_or_ring_is_full (svm_msg_q_t *mq, u32 ring_index)
+{
+ return (svm_msg_q_is_full (mq) || svm_msg_q_ring_is_full (mq, ring_index));
+}
+
/**
* Check if message queue is empty
*/
@@ -418,6 +424,14 @@ int svm_msg_q_wait (svm_msg_q_t *mq, svm_msg_q_wait_type_t type);
int svm_msg_q_wait_prod (svm_msg_q_t *mq);
/**
+ * Wait for message queue or ring event as producer
+ *
+ * Similar to @ref svm_msg_q_wait but lock (mutex or spinlock) must
+ * be held. Should only be called by producers.
+ */
+int svm_msg_q_or_ring_wait_prod (svm_msg_q_t *mq, u32 ring_index);
+
+/**
* Timed wait for message queue event
*
* Must be called with mutex held.