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)
{
if (nowait)
{
/* zero on success */
- if (pthread_mutex_trylock (&q->mutex))
+ if (svm_queue_trylock (q))
{
return (-1);
}
if (nowait)
{
/* zero on success */
- if (pthread_mutex_trylock (&q->mutex))
+ if (svm_queue_trylock (q))
{
return (-1);
}
else
svm_queue_lock (q);
- if (PREDICT_FALSE (q->cursize + 1 == q->maxsize))
+ if (PREDICT_FALSE (q->cursize + 1 >= q->maxsize))
{
if (nowait)
{
svm_queue_unlock (q);
return (-2);
}
- while (q->cursize + 1 == q->maxsize)
+ while (q->cursize + 1 >= q->maxsize)
svm_queue_wait_inline (q);
}
if (cond == SVM_Q_NOWAIT)
{
/* zero on success */
- if (pthread_mutex_trylock (&q->mutex))
+ if (svm_queue_trylock (q))
{
return (-1);
}