[libxml2] Use non-recursive mutex in dict.c
- From: Nick Wellnhofer <nwellnhof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml2] Use non-recursive mutex in dict.c
- Date: Sun, 6 Mar 2022 18:19:16 +0000 (UTC)
commit 3241c47c1fe64af9f629a22911eb99ba576f7b00
Author: Nick Wellnhofer <wellnhofer aevum de>
Date: Sun Mar 6 14:58:04 2022 +0100
Use non-recursive mutex in dict.c
The mutex is never locked recursively.
dict.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/dict.c b/dict.c
index 0e4c87b9..c29d2af7 100644
--- a/dict.c
+++ b/dict.c
@@ -127,7 +127,7 @@ struct _xmlDict {
* A mutex for modifying the reference counter for shared
* dictionaries.
*/
-static xmlRMutexPtr xmlDictMutex = NULL;
+static xmlMutexPtr xmlDictMutex = NULL;
/*
* Whether the dictionary mutex was initialized.
@@ -174,9 +174,9 @@ int __xmlInitializeDict(void) {
if (xmlDictInitialized)
return(1);
- if ((xmlDictMutex = xmlNewRMutex()) == NULL)
+ if ((xmlDictMutex = xmlNewMutex()) == NULL)
return(0);
- xmlRMutexLock(xmlDictMutex);
+ xmlMutexLock(xmlDictMutex);
#ifdef DICT_RANDOMIZATION
#ifdef HAVE_RAND_R
@@ -187,7 +187,7 @@ int __xmlInitializeDict(void) {
#endif
#endif
xmlDictInitialized = 1;
- xmlRMutexUnlock(xmlDictMutex);
+ xmlMutexUnlock(xmlDictMutex);
return(1);
}
@@ -198,13 +198,13 @@ int __xmlRandom(void) {
if (xmlDictInitialized == 0)
__xmlInitializeDict();
- xmlRMutexLock(xmlDictMutex);
+ xmlMutexLock(xmlDictMutex);
#ifdef HAVE_RAND_R
ret = rand_r(& rand_seed);
#else
ret = rand();
#endif
- xmlRMutexUnlock(xmlDictMutex);
+ xmlMutexUnlock(xmlDictMutex);
return(ret);
}
#endif
@@ -225,7 +225,7 @@ xmlDictCleanup(void) {
if (!xmlDictInitialized)
return;
- xmlFreeRMutex(xmlDictMutex);
+ xmlFreeMutex(xmlDictMutex);
xmlDictInitialized = 0;
}
@@ -650,9 +650,9 @@ xmlDictReference(xmlDictPtr dict) {
return(-1);
if (dict == NULL) return -1;
- xmlRMutexLock(xmlDictMutex);
+ xmlMutexLock(xmlDictMutex);
dict->ref_counter++;
- xmlRMutexUnlock(xmlDictMutex);
+ xmlMutexUnlock(xmlDictMutex);
return(0);
}
@@ -814,14 +814,14 @@ xmlDictFree(xmlDictPtr dict) {
return;
/* decrement the counter, it may be shared by a parser and docs */
- xmlRMutexLock(xmlDictMutex);
+ xmlMutexLock(xmlDictMutex);
dict->ref_counter--;
if (dict->ref_counter > 0) {
- xmlRMutexUnlock(xmlDictMutex);
+ xmlMutexUnlock(xmlDictMutex);
return;
}
- xmlRMutexUnlock(xmlDictMutex);
+ xmlMutexUnlock(xmlDictMutex);
if (dict->subdict != NULL) {
xmlDictFree(dict->subdict);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]