mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
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: Stefan Berger <stefanb@us.ibm.com>
This commit is contained in:
parent
67253251c5
commit
f895e611df
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user