svn commit: samba r25690 - in branches/SAMBA_4_0/source/lib/ldb/ldb_tdb: .

tridge at samba.org tridge at samba.org
Thu Oct 18 02:03:22 GMT 2007


Author: tridge
Date: 2007-10-18 02:03:21 +0000 (Thu, 18 Oct 2007)
New Revision: 25690

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25690

Log:

- only use a readonly traverse in ldb_search when not in a
  transaction. When we are in a transaction then we could be in a top
  level modify operation (such as rename), so we must use a writeable
  traverse so that the async callbacks can do the modifies while the
  search is progressing.

- don't do the lockall operation on the tdb during a ldb search if in
  a transaction, as this would prevent modifies by callbacks as well

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	2007-10-18 01:37:46 UTC (rev 25689)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_search.c	2007-10-18 02:03:21 UTC (rev 25690)
@@ -253,7 +253,10 @@
 static int ltdb_lock_read(struct ldb_module *module)
 {
 	struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
-	return tdb_lockall_read(ltdb->tdb);
+	if (ltdb->in_transaction == 0) {
+		return tdb_lockall_read(ltdb->tdb);
+	}
+	return 0;
 }
 
 /*
@@ -262,7 +265,10 @@
 static int ltdb_unlock_read(struct ldb_module *module)
 {
 	struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
-	return tdb_unlockall_read(ltdb->tdb);
+	if (ltdb->in_transaction == 0) {
+		return tdb_unlockall_read(ltdb->tdb);
+	}
+	return 0;
 }
 
 /*
@@ -442,7 +448,11 @@
 	struct ltdb_private *ltdb = talloc_get_type(ac->module->private_data, struct ltdb_private);
 	int ret;
 
-	ret = tdb_traverse_read(ltdb->tdb, search_func, handle);
+	if (ltdb->in_transaction != 0) {
+		ret = tdb_traverse(ltdb->tdb, search_func, handle);
+	} else {
+		ret = tdb_traverse_read(ltdb->tdb, search_func, handle);
+	}
 
 	if (ret == -1) {
 		handle->status = LDB_ERR_OPERATIONS_ERROR;

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	2007-10-18 01:37:46 UTC (rev 25689)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c	2007-10-18 02:03:21 UTC (rev 25690)
@@ -907,6 +907,8 @@
 		return ltdb_err_map(tdb_error(ltdb->tdb));
 	}
 
+	ltdb->in_transaction++;
+
 	return LDB_SUCCESS;
 }
 
@@ -915,6 +917,8 @@
 	struct ltdb_private *ltdb =
 		talloc_get_type(module->private_data, struct ltdb_private);
 
+	ltdb->in_transaction--;
+
 	if (tdb_transaction_commit(ltdb->tdb) != 0) {
 		return ltdb_err_map(tdb_error(ltdb->tdb));
 	}
@@ -927,6 +931,8 @@
 	struct ltdb_private *ltdb =
 		talloc_get_type(module->private_data, struct ltdb_private);
 
+	ltdb->in_transaction--;
+
 	if (tdb_transaction_cancel(ltdb->tdb) != 0) {
 		return ltdb_err_map(tdb_error(ltdb->tdb));
 	}

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	2007-10-18 01:37:46 UTC (rev 25689)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.h	2007-10-18 02:03:21 UTC (rev 25690)
@@ -27,6 +27,8 @@
 			int flags;
 		} last_attribute;
 	} *cache;
+
+	int in_transaction;
 };
 
 /*



More information about the samba-cvs mailing list