summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb_tdb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-10-23 22:42:26 +1100
committerAndrew Tridgell <tridge@samba.org>2009-10-25 13:15:18 +1100
commit5002cddcb0d9e539ded949bcc805c035e038362d (patch)
tree06d190299b557d0106340759b471e58a963cc0b7 /source4/lib/ldb/ldb_tdb
parente7d9f5eea52403f576b636a35fb9889ed82cbf0b (diff)
downloadsamba-5002cddcb0d9e539ded949bcc805c035e038362d.tar.gz
samba-5002cddcb0d9e539ded949bcc805c035e038362d.tar.bz2
samba-5002cddcb0d9e539ded949bcc805c035e038362d.zip
s4-ldb: fixed re-index during a complex transaction
We may have modified index objects in the in-memory index tdb
Diffstat (limited to 'source4/lib/ldb/ldb_tdb')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_index.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c
index 0d560fea5e..9faba397d0 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_index.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_index.c
@@ -40,7 +40,6 @@ struct dn_list {
struct ltdb_idxptr {
struct tdb_context *itdb;
- bool repack;
int error;
};
@@ -1402,10 +1401,34 @@ int ltdb_index_delete(struct ldb_module *module, const struct ldb_message *msg)
*/
static int delete_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *state)
{
- const char *dn = "DN=" LTDB_INDEX ":";
- if (strncmp((char *)key.dptr, dn, strlen(dn)) == 0) {
- return tdb_delete(tdb, key);
+ struct ldb_module *module = state;
+ struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(module), struct ltdb_private);
+ const char *dnstr = "DN=" LTDB_INDEX ":";
+ struct dn_list list;
+ struct ldb_dn *dn;
+ struct ldb_val v;
+ int ret;
+
+ if (strncmp((char *)key.dptr, dnstr, strlen(dnstr)) != 0) {
+ return 0;
}
+ /* we need to put a empty list in the internal tdb for this
+ * index entry */
+ list.dn = NULL;
+ list.count = 0;
+ v.data = key.dptr;
+ v.length = strlen((char *)key.dptr);
+
+ dn = ldb_dn_from_ldb_val(ltdb, ldb_module_get_ctx(module), &v);
+ ret = ltdb_dn_list_store(module, dn, &list);
+ if (ret != LDB_SUCCESS) {
+ ldb_asprintf_errstring(ldb_module_get_ctx(module),
+ "Unable to store null index for %s\n",
+ ldb_dn_get_linearized(dn));
+ talloc_free(dn);
+ return -1;
+ }
+ talloc_free(dn);
return 0;
}
@@ -1493,8 +1516,10 @@ int ltdb_reindex(struct ldb_module *module)
return LDB_ERR_OPERATIONS_ERROR;
}
- /* first traverse the database deleting any @INDEX records */
- ret = tdb_traverse(ltdb->tdb, delete_index, NULL);
+ /* first traverse the database deleting any @INDEX records by
+ * putting NULL entries in the in-memory tdb
+ */
+ ret = tdb_traverse(ltdb->tdb, delete_index, module);
if (ret == -1) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -1510,9 +1535,5 @@ int ltdb_reindex(struct ldb_module *module)
return LDB_ERR_OPERATIONS_ERROR;
}
- if (ltdb->idxptr) {
- ltdb->idxptr->repack = true;
- }
-
return LDB_SUCCESS;
}