提交 f895e611 编写于 作者: S Stefan Berger 提交者: Daniel P. Berrange

Add recursive locks

This patch adds recursive locks necessary due to the processing of
network filter XML that can reference other network filters, including
references that cause looks. Loops in the XML are prevented but their
detection requires recursive locks.
Signed-off-by: NStefan Berger <stefanb@us.ibm.com>
上级 67253251
......@@ -46,6 +46,19 @@ int virMutexInit(virMutexPtr m)
return 0;
}
int virMutexInitRecursive(virMutexPtr m)
{
int ret;
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
if ((ret = pthread_mutex_init(&m->lock, &attr)) != 0) {
errno = ret;
return -1;
}
return 0;
}
void virMutexDestroy(virMutexPtr m)
{
pthread_mutex_destroy(&m->lock);
......
......@@ -68,6 +68,11 @@ void virThreadOnExit(void)
int virMutexInit(virMutexPtr m)
{
virMutexInitRecursive(m);
}
int virMutexInitRecursive(virMutexPtr m)
{
if (!(m->lock = CreateMutex(NULL, FALSE, NULL))) {
errno = ESRCH;
......
......@@ -38,6 +38,7 @@ int virThreadInitialize(void) ATTRIBUTE_RETURN_CHECK;
void virThreadOnExit(void);
int virMutexInit(virMutexPtr m) ATTRIBUTE_RETURN_CHECK;
int virMutexInitRecursive(virMutexPtr m) ATTRIBUTE_RETURN_CHECK;
void virMutexDestroy(virMutexPtr m);
void virMutexLock(virMutexPtr m);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册