summaryrefslogtreecommitdiffstats
path: root/src/svm/queue.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-11-27 09:49:10 -0800
committerDave Barach <openvpp@barachs.net>2020-11-30 16:05:59 +0000
commit2440a8a6e72a1fb156fce3f38ef3ae8cd2a527d8 (patch)
treeda054371c94e55e691458f30b2279214d25ec01d /src/svm/queue.c
parent7d8a956287e2b19059f041c77a57480f437fe2bf (diff)
svm: make svm queue mutex robust
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I256774c25b3c4105139a4728724a1a0c775e740f
Diffstat (limited to 'src/svm/queue.c')
-rw-r--r--src/svm/queue.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/svm/queue.c b/src/svm/queue.c
index 8d70dda61a3..96383d44f3d 100644
--- a/src/svm/queue.c
+++ b/src/svm/queue.c
@@ -51,6 +51,8 @@ svm_queue_init (void *base, int nels, int elsize)
clib_unix_warning ("mutexattr_init");
if (pthread_mutexattr_setpshared (&attr, PTHREAD_PROCESS_SHARED))
clib_unix_warning ("pthread_mutexattr_setpshared");
+ if (pthread_mutexattr_setrobust (&attr, PTHREAD_MUTEX_ROBUST))
+ clib_unix_warning ("setrobust");
if (pthread_mutex_init (&q->mutex, &attr))
clib_unix_warning ("mutex_init");
if (pthread_mutexattr_destroy (&attr))
@@ -96,7 +98,9 @@ svm_queue_free (svm_queue_t * q)
void
svm_queue_lock (svm_queue_t * q)
{
- pthread_mutex_lock (&q->mutex);
+ int rv = pthread_mutex_lock (&q->mutex);
+ if (PREDICT_FALSE (rv == EOWNERDEAD))
+ pthread_mutex_consistent (&q->mutex);
}
void