summaryrefslogtreecommitdiffstats
path: root/src/svm/message_queue.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-07-25 14:51:09 -0700
committerDave Barach <openvpp@barachs.net>2019-07-29 20:46:46 +0000
commit2b5fed8696ce2a9b67e63cf5b5dbf49505172c9a (patch)
treee737297817caba79e3657b1c101d41b9802a7bf9 /src/svm/message_queue.c
parent1a3d2370b53bcdb13581d8be0d9410974b9966c3 (diff)
session: fix vpp to app msg generation
Type:fix Freeing mq messages in vpp (producer), if enqueueing fails, invalidates consumer assumption that messages can be freed without a lock. Change-Id: I748a33b8846597bdad865945d8e899346d482434 Signed-off-by: Florin Coras <fcoras@cisco.com> Signed-off-by: Tal Saiag <tal.saiag@gmail.com>
Diffstat (limited to 'src/svm/message_queue.c')
-rw-r--r--src/svm/message_queue.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/svm/message_queue.c b/src/svm/message_queue.c
index 630442064f8..a40c4a46a39 100644
--- a/src/svm/message_queue.c
+++ b/src/svm/message_queue.c
@@ -120,7 +120,8 @@ svm_msg_q_lock_and_alloc_msg_w_ring (svm_msg_q_t * mq, u32 ring_index,
{
if (svm_msg_q_try_lock (mq))
return -1;
- if (PREDICT_FALSE (svm_msg_q_ring_is_full (mq, ring_index)))
+ if (PREDICT_FALSE (svm_msg_q_is_full (mq)
+ || svm_msg_q_ring_is_full (mq, ring_index)))
{
svm_msg_q_unlock (mq);
return -2;
@@ -135,7 +136,8 @@ svm_msg_q_lock_and_alloc_msg_w_ring (svm_msg_q_t * mq, u32 ring_index,
else
{
svm_msg_q_lock (mq);
- while (svm_msg_q_ring_is_full (mq, ring_index))
+ while (svm_msg_q_is_full (mq)
+ || svm_msg_q_ring_is_full (mq, ring_index))
svm_msg_q_wait (mq);
*msg = svm_msg_q_alloc_msg_w_ring (mq, ring_index);
}