From: Andrew Bartlett Date: Tue, 6 Jun 2017 22:44:50 +0000 (+1200) Subject: dsdb: Do not run dsdb_replace() on the calculated difference between old and new... X-Git-Tag: tevent-0.9.32~87 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec9b1e881c3eef503d6b4b311594113acf7d47d8;p=thirdparty%2Fsamba.git dsdb: Do not run dsdb_replace() on the calculated difference between old and new schema 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 Reviewed-by: Stefan Metzmacher --- diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c index 977c9e339b6..df27e19a944 100644 --- a/source4/dsdb/schema/schema_set.c +++ b/source4/dsdb/schema/schema_set.c @@ -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); }