#include <svm/message_queue.h>
#include <vppinfra/mem.h>
+#include <vppinfra/format.h>
#include <sys/eventfd.h>
static inline svm_msg_q_ring_t *
{
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;
}
*msg = svm_msg_q_alloc_msg_w_ring (mq, ring_index);
- if (PREDICT_FALSE (svm_msg_q_msg_is_invalid (msg)))
- {
- svm_msg_q_unlock (mq);
- return -2;
- }
}
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);
}
return 0;
}
+u8 *
+format_svm_msg_q (u8 * s, va_list * args)
+{
+ svm_msg_q_t *mq = va_arg (*args, svm_msg_q_t *);
+ s = format (s, " [Q:%d/%d]", mq->q->cursize, mq->q->maxsize);
+ for (u32 i = 0; i < vec_len (mq->rings); i++)
+ {
+ s = format (s, " [R%d:%d/%d]", i, mq->rings[i].cursize,
+ mq->rings[i].nitems);
+ }
+ return s;
+}
+
/*
* fd.io coding-style-patch-verification: ON
*