Browse Source

Uninitialized mutex in Retro Changelog Plugin. https://bugzilla.redhat.com/show_bug.cgi?id=554841 Resolves: bug 554841 Bug Description: Enabling Retro Changelog Plugin on a DS instance provisioned by Samba will crash slapd during startup. Branch: HEAD Fix Description: Apparently the retrocl_internal_lock is still NULL when it's used in retrocl_get_first_changenumber(). The solution is to initialize the lock in the retrocl_plugin_init(). Platforms tested: F12 i386

Endi S. Dewata 16 years ago
parent
commit
51fab34954
2 changed files with 4 additions and 17 deletions
  1. 4 0
      ldap/servers/plugins/retrocl/retrocl.c
  2. 0 17
      ldap/servers/plugins/retrocl/retrocl_cn.c

+ 4 - 0
ldap/servers/plugins/retrocl/retrocl.c

@@ -76,6 +76,7 @@ void plugin_init_debug_level(int *level_ptr)
 void* g_plg_identity [PLUGIN_MAX];
 
 Slapi_Backend *retrocl_be_changelog = NULL;
+PRLock *retrocl_internal_lock = NULL;
 int retrocl_nattributes = 0;
 char **retrocl_attributes = NULL;
 
@@ -392,6 +393,9 @@ retrocl_plugin_init(Slapi_PBlock *pb)
 
 	  rc= slapi_register_plugin_ext("postoperation", 1 /* Enabled */, "retrocl_postop_init", retrocl_postop_init, "Retrocl postoperation plugin", NULL, identity, precedence);
 	  rc= slapi_register_plugin_ext("internalpostoperation", 1 /* Enabled */, "retrocl_internalpostop_init", retrocl_internalpostop_init, "Retrocl internal postoperation plugin", NULL, identity, precedence);
+
+	  retrocl_internal_lock = PR_NewLock();
+	  if (retrocl_internal_lock == NULL) return -1;
 	}
 	
     legacy_initialised = 1;

+ 0 - 17
ldap/servers/plugins/retrocl/retrocl_cn.c

@@ -45,7 +45,6 @@
 
 static changeNumber retrocl_internal_cn = 0;
 static changeNumber retrocl_first_cn = 0;
-PRLock *retrocl_internal_lock = NULL;
 
 /*
  * Function: a2changeNumber
@@ -154,12 +153,6 @@ int retrocl_get_changenumbers(void)
 { 
     cnumRet cr;
 
-    if (retrocl_internal_lock == NULL) {
-      retrocl_internal_lock = PR_NewLock();
-      
-      if (retrocl_internal_lock == NULL) return -1;
-    }
-    
     if (retrocl_be_changelog == NULL) return -1;
     
     cr.cr_cnum = 0;
@@ -245,8 +238,6 @@ time_t retrocl_getchangetime( int type, int *err )
 
 void retrocl_forget_changenumbers(void) 
 { 
-    if (retrocl_internal_lock == NULL) return;
-
     PR_Lock(retrocl_internal_lock);
     retrocl_first_cn = 0;
     retrocl_internal_cn = 0;
@@ -362,12 +353,6 @@ int retrocl_update_lastchangenumber(void)
 {
     cnumRet cr;
 
-    if (retrocl_internal_lock == NULL) {
-      retrocl_internal_lock = PR_NewLock();
-
-      if (retrocl_internal_lock == NULL) return -1;
-    }
-
     if (retrocl_be_changelog == NULL) return -1;
 
     cr.cr_cnum = 0;
@@ -405,8 +390,6 @@ changeNumber retrocl_assign_changenumber(void)
 {
     changeNumber cn;
  
-    if (retrocl_internal_lock == NULL) return 0;
-
     /* Before we assign the changenumber; we should check for the
      * validity of the internal assignment of retrocl_internal_cn 
      * we had from the startup */