summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2011-08-15 13:20:33 -0400
committerMartin Kosek <mkosek@redhat.com>2011-08-24 13:59:27 +0200
commitae06f7b68e04000b748f702d553a5b691eb6cb3c (patch)
tree93f38a779b096a3c63d9999122000a93541bbc0d
parent5767c293c788e733b771da72a4dbb1ba4747d79c (diff)
downloadfreeipa-ae06f7b68e04000b748f702d553a5b691eb6cb3c.zip
freeipa-ae06f7b68e04000b748f702d553a5b691eb6cb3c.tar.gz
freeipa-ae06f7b68e04000b748f702d553a5b691eb6cb3c.tar.xz
Fix thread deadlock by using pthreads library instead of NSPR.
The 389-ds team is in the process of exposing slapi_rwlock which we will switch to when it is available. https://fedorahosted.org/freeipa/ticket/1630
-rw-r--r--daemons/ipa-slapi-plugins/ipa-modrdn/ipa_modrdn.c13
-rw-r--r--daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c13
2 files changed, 12 insertions, 14 deletions
diff --git a/daemons/ipa-slapi-plugins/ipa-modrdn/ipa_modrdn.c b/daemons/ipa-slapi-plugins/ipa-modrdn/ipa_modrdn.c
index 45a29a5..91cc2cc 100644
--- a/daemons/ipa-slapi-plugins/ipa-modrdn/ipa_modrdn.c
+++ b/daemons/ipa-slapi-plugins/ipa-modrdn/ipa_modrdn.c
@@ -42,6 +42,7 @@
#include "slapi-plugin.h"
#include "nspr.h"
#include "prclist.h"
+#include <pthread.h>
#include "util.h"
@@ -88,7 +89,7 @@ struct configEntry {
};
static PRCList *ipamodrdn_global_config = NULL;
-static PRRWLock *g_ipamodrdn_cache_lock;
+static pthread_rwlock_t g_ipamodrdn_cache_lock;
static void *_PluginID = NULL;
static char *_PluginDN = NULL;
@@ -144,17 +145,17 @@ void ipamodrdn_dump_config_entry(struct configEntry *);
*/
void ipamodrdn_read_lock(void)
{
- PR_RWLock_Rlock(g_ipamodrdn_cache_lock);
+ pthread_rwlock_rdlock(&g_ipamodrdn_cache_lock);
}
void ipamodrdn_write_lock(void)
{
- PR_RWLock_Wlock(g_ipamodrdn_cache_lock);
+ pthread_rwlock_wrlock(&g_ipamodrdn_cache_lock);
}
void ipamodrdn_unlock(void)
{
- PR_RWLock_Unlock(g_ipamodrdn_cache_lock);
+ pthread_rwlock_unlock(&g_ipamodrdn_cache_lock);
}
/**
@@ -255,9 +256,7 @@ ipamodrdn_start(Slapi_PBlock * pb)
goto done;
}
- g_ipamodrdn_cache_lock = PR_NewRWLock(PR_RWLOCK_RANK_NONE, "ipaModRDN");
-
- if (!g_ipamodrdn_cache_lock) {
+ if (pthread_rwlock_init(&g_ipamodrdn_cache_lock, NULL) != 0) {
LOG_FATAL("lock creation failed\n");
return EFAIL;
diff --git a/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c b/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
index 3249ce4..77eec6b 100644
--- a/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
+++ b/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
@@ -43,6 +43,7 @@
#include "nspr.h"
#include "prclist.h"
#include "uuid/uuid.h"
+#include <pthread.h>
#include "util.h"
@@ -94,7 +95,7 @@ struct configEntry {
};
static PRCList *ipauuid_global_config = NULL;
-static PRRWLock *g_ipauuid_cache_lock;
+static pthread_rwlock_t g_ipauuid_cache_lock;
static void *_PluginID = NULL;
static char *_PluginDN = NULL;
@@ -155,17 +156,17 @@ void ipauuid_dump_config_entry(struct configEntry *);
*/
void ipauuid_read_lock(void)
{
- PR_RWLock_Rlock(g_ipauuid_cache_lock);
+ pthread_rwlock_rdlock(&g_ipauuid_cache_lock);
}
void ipauuid_write_lock(void)
{
- PR_RWLock_Wlock(g_ipauuid_cache_lock);
+ pthread_rwlock_wrlock(&g_ipauuid_cache_lock);
}
void ipauuid_unlock(void)
{
- PR_RWLock_Unlock(g_ipauuid_cache_lock);
+ pthread_rwlock_unlock(&g_ipauuid_cache_lock);
}
/**
@@ -324,9 +325,7 @@ ipauuid_start(Slapi_PBlock * pb)
goto done;
}
- g_ipauuid_cache_lock = PR_NewRWLock(PR_RWLOCK_RANK_NONE, "ipaUuid");
-
- if (!g_ipauuid_cache_lock) {
+ if (pthread_rwlock_init(&g_ipauuid_cache_lock, NULL) != 0) {
LOG_FATAL("lock creation failed\n");
return EFAIL;