summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/svm/message_queue.h5
-rw-r--r--src/svm/queue.c15
2 files changed, 16 insertions, 4 deletions
diff --git a/src/svm/message_queue.h b/src/svm/message_queue.h
index 13f4d80d215..d4c47d7f024 100644
--- a/src/svm/message_queue.h
+++ b/src/svm/message_queue.h
@@ -302,7 +302,10 @@ svm_msg_q_msg_is_invalid (svm_msg_q_msg_t * msg)
static inline int
svm_msg_q_try_lock (svm_msg_q_t * mq)
{
- return pthread_mutex_trylock (&mq->q->mutex);
+ int rv = pthread_mutex_trylock (&mq->q->mutex);
+ if (PREDICT_FALSE (rv == EOWNERDEAD))
+ rv = pthread_mutex_consistent (&mq->q->mutex);
+ return rv;
}
/**
diff --git a/src/svm/queue.c b/src/svm/queue.c
index 96383d44f3d..864d97e3de4 100644
--- a/src/svm/queue.c
+++ b/src/svm/queue.c
@@ -103,6 +103,15 @@ svm_queue_lock (svm_queue_t * q)
pthread_mutex_consistent (&q->mutex);
}
+static int
+svm_queue_trylock (svm_queue_t * q)
+{
+ int rv = pthread_mutex_trylock (&q->mutex);
+ if (PREDICT_FALSE (rv == EOWNERDEAD))
+ rv = pthread_mutex_consistent (&q->mutex);
+ return rv;
+}
+
void
svm_queue_unlock (svm_queue_t * q)
{
@@ -256,7 +265,7 @@ svm_queue_add (svm_queue_t * q, u8 * elem, int nowait)
if (nowait)
{
/* zero on success */
- if (pthread_mutex_trylock (&q->mutex))
+ if (svm_queue_trylock (q))
{
return (-1);
}
@@ -306,7 +315,7 @@ svm_queue_add2 (svm_queue_t * q, u8 * elem, u8 * elem2, int nowait)
if (nowait)
{
/* zero on success */
- if (pthread_mutex_trylock (&q->mutex))
+ if (svm_queue_trylock (q))
{
return (-1);
}
@@ -367,7 +376,7 @@ svm_queue_sub (svm_queue_t * q, u8 * elem, svm_q_conditional_wait_t cond,
if (cond == SVM_Q_NOWAIT)
{
/* zero on success */
- if (pthread_mutex_trylock (&q->mutex))
+ if (svm_queue_trylock (q))
{
return (-1);
}