schema: Rework dsdb_schema_set_indices_and_attributes() db operations
[samba.git] / source4 / dsdb / schema / schema_set.c
index cfd320b2407615b8dec18fdcd47586375d4bb4a9..8141e323e50db164e7671331f28cc17f0e0cc323 100644 (file)
@@ -175,11 +175,11 @@ int dsdb_schema_set_indices_and_attributes(struct ldb_context *ldb,
                }
                if (mod_msg->num_elements > 0) {
                        /*
-                        * Do the replace with the constructed message,
-                        * to avoid needing a lock between this search
-                        * and the replace
+                        * Do the replace with the difference, as we
+                        * are under the read lock and we wish to do a
+                        * delete of any removed/renamed attributes
                         */
-                       ret = dsdb_replace(ldb, msg, 0);
+                       ret = dsdb_modify(ldb, mod_msg, 0);
                }
                talloc_free(mod_msg);
        }
@@ -235,12 +235,13 @@ int dsdb_schema_set_indices_and_attributes(struct ldb_context *ldb,
                         * @SAMBA_FEATURES_SUPPORTED
                         */
                } else if (mod_msg->num_elements > 0) {
+
                        /*
-                        * Do the replace with the constructed message,
-                        * to avoid needing a lock between this search
-                        * and the replace
+                        * Do the replace with the difference, as we
+                        * are under the read lock and we wish to do a
+                        * delete of any removed/renamed attributes
                         */
-                       ret = dsdb_replace(ldb, msg_idx, 0);
+                       ret = dsdb_modify(ldb, mod_msg, 0);
                }
                talloc_free(mod_msg);
        }