Browse Source

Bug 725743 - Make memberOf use PRMonitor for it's operation lock

We currently use a mutex for the operation lock in the memberOf
plug-in.  This can cause a deadlock issue since the locks are not
re-entrant.  When memberOf performs an internal operation that
triggers another plug-in to perform an internal operation, a
deadlock will occur if this second internal operation triggers
memberOf again.

This patch switches memberOf to use PRMonitor instead, which is
re-entrant.
Nathan Kinder 14 years ago
parent
commit
238b74de64
1 changed files with 4 additions and 4 deletions
  1. 4 4
      ldap/servers/plugins/memberof/memberof.c

+ 4 - 4
ldap/servers/plugins/memberof/memberof.c

@@ -77,7 +77,7 @@ static Slapi_PluginDesc pdesc = { "memberof", VENDOR,
 	DS_PACKAGE_VERSION, "memberof plugin" };
 
 static void* _PluginID = NULL;
-static Slapi_Mutex *memberof_operation_lock = 0;
+static PRMonitor *memberof_operation_lock = 0;
 MemberOfConfig *qsortConfig = 0;
 static int g_plugin_started = 0;
 
@@ -278,7 +278,7 @@ int memberof_postop_start(Slapi_PBlock *pb)
 		goto bail;
 	}
 
-	memberof_operation_lock = slapi_new_mutex();
+	memberof_operation_lock = PR_NewMonitor();
 	if(0 == memberof_operation_lock)
 	{
 		rc = -1;
@@ -2147,12 +2147,12 @@ int memberof_qsort_compare(const void *a, const void *b)
 
 void memberof_lock()
 {
-	slapi_lock_mutex(memberof_operation_lock);
+	PR_EnterMonitor(memberof_operation_lock);
 }
 
 void memberof_unlock()
 {
-	slapi_unlock_mutex(memberof_operation_lock);
+	PR_ExitMonitor(memberof_operation_lock);
 }
 
 typedef struct _task_data