svm: fix producer deadlock in svm_msg_q_wait()
1. When producer invokes svm_msg_q_wait() in svm_msg_q_lock_and_alloc_msg_w_ring(), queue mutex is held by itself. 2. Sometimes, svm msg queue is not full and ring is full, svm_msg_q_wait() do nothing with mutex held, consumer will blocking at svm_msg_q_send_signal(). Type: fix Signed-off-by: nandfan <fanyufei521@outlook.com> Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Ib90b87ab76534cd42e9a4c3e11703e80d93ca678
This commit is contained in:
@ -498,17 +498,21 @@ svm_msg_q_wait (svm_msg_q_t *mq, svm_msg_q_wait_type_t type)
|
||||
|
||||
if (mq->q.evtfd == -1)
|
||||
{
|
||||
rv = pthread_mutex_lock (&mq->q.shr->mutex);
|
||||
if (PREDICT_FALSE (rv == EOWNERDEAD))
|
||||
if (type == SVM_MQ_WAIT_EMPTY)
|
||||
{
|
||||
rv = pthread_mutex_consistent (&mq->q.shr->mutex);
|
||||
return rv;
|
||||
rv = pthread_mutex_lock (&mq->q.shr->mutex);
|
||||
if (PREDICT_FALSE (rv == EOWNERDEAD))
|
||||
{
|
||||
rv = pthread_mutex_consistent (&mq->q.shr->mutex);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
while (fn (mq))
|
||||
pthread_cond_wait (&mq->q.shr->condvar, &mq->q.shr->mutex);
|
||||
|
||||
pthread_mutex_unlock (&mq->q.shr->mutex);
|
||||
if (type == SVM_MQ_WAIT_EMPTY)
|
||||
pthread_mutex_unlock (&mq->q.shr->mutex);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user