Jelajahi Sumber

Ticket #17 - Replication optimizations

Bug Description:  looks for processes to skip if we are dealing with a replicated
                  operation.

Fix Description:  Syntax and schema checking is already covered, but there are a few things
                  in add.c and modify.c that can be skipped:

			- Reverse Password storage scheme plugins
			- Other misc userpassword stuff
			- objectclass expansion

Reviewed by: rmeggins (Thanks Rich!)

https://fedorahosted.org/389/ticket/17
Mark Reynolds 14 tahun lalu
induk
melakukan
6f3f03665c
2 mengubah file dengan 19 tambahan dan 18 penghapusan
  1. 17 16
      ldap/servers/slapd/add.c
  2. 2 2
      ldap/servers/slapd/modify.c

+ 17 - 16
ldap/servers/slapd/add.c

@@ -580,7 +580,7 @@ static void op_shared_add (Slapi_PBlock *pb)
 		}
 
        /* look for multiple backend local credentials or replication local credentials */
-        for ( p = get_plugin_list(PLUGIN_LIST_REVER_PWD_STORAGE_SCHEME); p != NULL;
+        for ( p = get_plugin_list(PLUGIN_LIST_REVER_PWD_STORAGE_SCHEME); p != NULL && !repl_op;
             p = p->plg_next )
         {
             char *L_attr = NULL;
@@ -626,30 +626,31 @@ static void op_shared_add (Slapi_PBlock *pb)
 							   !slapdFrontendConfig->pw_policy.pw_must_change);
 	}
 
-	/* can get lastmod only after backend is selected */
-	slapi_pblock_get(pb, SLAPI_BE_LASTMOD, &lastmod);
-	if (!repl_op && lastmod)
+
+	if (!repl_op)
 	{
-		if (add_created_attrs(operation, e) != 0)
+		/* can get lastmod only after backend is selected */
+		slapi_pblock_get(pb, SLAPI_BE_LASTMOD, &lastmod);
+
+		if (lastmod && add_created_attrs(operation, e) != 0)
 		{
 			send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, NULL,
 				"cannot insert computed attributes", 0, NULL);
 			goto done;
 		}
+		/* expand objectClass values to reflect the inheritance hierarchy */
+		slapi_schema_expand_objectclasses( e );
 	}
 
-	/* expand objectClass values to reflect the inheritance hierarchy */
-	slapi_schema_expand_objectclasses( e );
-
-
     /* uniqueid needs to be generated for entries added during legacy replication */
-    if (legacy_op)
-	if (add_uniqueid(e) != UID_SUCCESS)
-	{
-		send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, NULL,
-			"cannot insert computed attributes", 0, NULL);
-		goto done;
-	}
+    if (legacy_op){
+    	if (add_uniqueid(e) != UID_SUCCESS)
+    	{
+    		send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, NULL,
+    				"cannot insert computed attributes", 0, NULL);
+    		goto done;
+    	}
+    }
 
 	/*
 	 * call the pre-add plugins. if they succeed, call

+ 2 - 2
ldap/servers/slapd/modify.c

@@ -825,7 +825,7 @@ static void op_shared_modify (Slapi_PBlock *pb, int pw_change, char *old_pw)
 	 * calling the preop plugins
 	 */
 
-	if (pw_change)
+	if (pw_change && !repl_op)
 	{
 		Slapi_Value **va= NULL;
 
@@ -856,7 +856,7 @@ static void op_shared_modify (Slapi_PBlock *pb, int pw_change, char *old_pw)
 			valuearray_free(&va);
 		}
 	}
-	for ( p = get_plugin_list(PLUGIN_LIST_REVER_PWD_STORAGE_SCHEME); p != NULL; p = p->plg_next )
+	for ( p = get_plugin_list(PLUGIN_LIST_REVER_PWD_STORAGE_SCHEME); p != NULL && !repl_op; p = p->plg_next )
     {
         char *L_attr = NULL;
         int i = 0;