svn commit: samba r6560 - in
branches/SAMBA_4_0/source/lib/ldb/ldb_tdb: .
tridge at samba.org
tridge at samba.org
Sun May 1 12:34:13 GMT 2005
Author: tridge
Date: 2005-05-01 12:34:12 +0000 (Sun, 01 May 2005)
New Revision: 6560
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=6560
Log:
added a tdb_chainlock_read() call in ldb_search(). This guarantees
that ldb_search() sees a single consistent view of the database (by
blocking writes during a ldb_search)
Modified:
branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_search.c
branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c
branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.h
Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_search.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_search.c 2005-05-01 11:46:28 UTC (rev 6559)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_search.c 2005-05-01 12:34:12 UTC (rev 6560)
@@ -472,9 +472,14 @@
struct ldb_parse_tree *tree;
int ret;
+ if (ltdb_lock_read(module) != 0) {
+ return -1;
+ }
+
ltdb->last_err_string = NULL;
if (ltdb_cache_load(module) != 0) {
+ ltdb_unlock_read(module);
return -1;
}
@@ -484,6 +489,7 @@
tree = ldb_parse_tree(ldb, expression);
if (!tree) {
ltdb->last_err_string = "expression parse failed";
+ ltdb_unlock_read(module);
return -1;
}
@@ -501,6 +507,7 @@
}
ldb_parse_tree_free(ldb, tree);
+ ltdb_unlock_read(module);
return ret;
}
Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c 2005-05-01 11:46:28 UTC (rev 6559)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c 2005-05-01 12:34:12 UTC (rev 6560)
@@ -249,6 +249,40 @@
/*
+ lock the database for read - use by ltdb_search
+*/
+int ltdb_lock_read(struct ldb_module *module)
+{
+ struct ltdb_private *ltdb = module->private_data;
+ TDB_DATA key;
+ int ret;
+ key = ltdb_key(module, LDBLOCK);
+ if (!key.dptr) {
+ return -1;
+ }
+ ret = tdb_chainlock_read(ltdb->tdb, key);
+ talloc_free(key.dptr);
+ return ret;
+}
+
+/*
+ unlock the database after a ltdb_lock_read()
+*/
+int ltdb_unlock_read(struct ldb_module *module)
+{
+ struct ltdb_private *ltdb = module->private_data;
+ TDB_DATA key;
+ key = ltdb_key(module, LDBLOCK);
+ if (!key.dptr) {
+ return -1;
+ }
+ tdb_chainunlock_read(ltdb->tdb, key);
+ talloc_free(key.dptr);
+ return 0;
+}
+
+
+/*
we've made a modification to a dn - possibly reindex and
update sequence number
*/
Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.h
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.h 2005-05-01 11:46:28 UTC (rev 6559)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.h 2005-05-01 12:34:12 UTC (rev 6560)
@@ -104,6 +104,8 @@
int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs);
int ltdb_delete_noindex(struct ldb_module *module, const char *dn);
int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *msg);
+int ltdb_lock_read(struct ldb_module *module);
+int ltdb_unlock_read(struct ldb_module *module);
/* The following definitions come from lib/ldb/ldb_tdb/ldb_match.c */
int ltdb_val_equal(struct ldb_module *module,
More information about the samba-cvs
mailing list