dsdb: Do not run dsdb_replace() on the calculated difference between old and new...
authorAndrew Bartlett <abartlet@samba.org>
Tue, 6 Jun 2017 22:44:50 +0000 (10:44 +1200)
committerStefan Metzmacher <metze@samba.org>
Fri, 16 Jun 2017 17:34:17 +0000 (19:34 +0200)
We can set the database @INDEXLIST and @ATTRIBUTES to the full calculated
values, not the difference, and let the ldb layer work it out under the
transaction lock.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source4/dsdb/schema/schema_set.c

index 977c9e339b61983bfcb50ba52598284dd1035508..df27e19a944a72894b7285dff072fd382b0016ff 100644 (file)
@@ -174,7 +174,12 @@ int dsdb_schema_set_indices_and_attributes(struct ldb_context *ldb,
                        goto op_error;
                }
                if (mod_msg->num_elements > 0) {
-                       ret = dsdb_replace(ldb, mod_msg, 0);
+                       /*
+                        * Do the replace with the constructed message,
+                        * to avoid needing a lock between this search
+                        * and the replace
+                        */
+                       ret = dsdb_replace(ldb, msg, 0);
                }
                talloc_free(mod_msg);
        }
@@ -210,7 +215,12 @@ int dsdb_schema_set_indices_and_attributes(struct ldb_context *ldb,
                        goto op_error;
                }
                if (mod_msg->num_elements > 0) {
-                       ret = dsdb_replace(ldb, mod_msg, 0);
+                       /*
+                        * Do the replace with the constructed message,
+                        * to avoid needing a lock between this search
+                        * and the replace
+                        */
+                       ret = dsdb_replace(ldb, msg_idx, 0);
                }
                talloc_free(mod_msg);
        }