[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Fri Nov 20 02:25:28 MST 2009


The branch, master has been updated
       via  5ca0a4b... tdb: change version to 1.2.0 after adding TDB_*ALLOW_NESTING
       via  3b9f19e... tdb: add TDB_DISALLOW_NESTING and make TDB_ALLOW_NESTING the default behavior
       via  436b55d... New attempt at TDB transaction nesting allow/disallow.
       via  85449b7... tdb: always set tdb->tracefd to -1 to be safe on goto fail
      from  92eff41... s4-dsdb: some more attribuutes that we should only give if asked for

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 5ca0a4bfd6fdbb515835682a12f715283b46cb3e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Nov 19 09:49:03 2009 +0100

    tdb: change version to 1.2.0 after adding TDB_*ALLOW_NESTING
    
    metze

commit 3b9f19ed919fef2e88b2f92ae541e07bc7379cd1
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Nov 19 09:34:05 2009 +0100

    tdb: add TDB_DISALLOW_NESTING and make TDB_ALLOW_NESTING the default behavior
    
    We need to keep TDB_ALLOW_NESTING as default behavior,
    so that existing code continues to work.
    
    However we may change the default together with a major version
    number change in future.
    
    metze

commit 436b55db1ff238ec467b07a74b088f6fcfaf927c
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon May 25 17:04:42 2009 +1000

    New attempt at TDB transaction nesting allow/disallow.
    
    Make the default be that transaction is not allowed and any attempt to create a nested transaction will fail with TDB_ERR_NESTING.
    
    If an application can cope with transaction nesting and the implicit
    semantics of tdb_transaction_commit(), it can enable transaction nesting
    by using the TDB_ALLOW_NESTING flag.
    (cherry picked from ctdb commit 3e49e41c21eb8c53084aa8cc7fd3557bdd8eb7b6)
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 85449b7bcc4bd7948bea38b5514a02357950a002
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Nov 19 09:38:48 2009 +0100

    tdb: always set tdb->tracefd to -1 to be safe on goto fail
    
    metze

-----------------------------------------------------------------------

Summary of changes:
 lib/tdb/common/open.c        |   24 ++++++++++++++++++++----
 lib/tdb/common/tdb.c         |   30 ++++++++++++++++++++++++++++++
 lib/tdb/common/transaction.c |   19 +++++++++++++++++++
 lib/tdb/configure.ac         |    2 +-
 lib/tdb/docs/README          |    4 ++++
 lib/tdb/include/tdb.h        |    5 ++++-
 6 files changed, 78 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c
index 64efafe..4d4f95a 100644
--- a/lib/tdb/common/open.c
+++ b/lib/tdb/common/open.c
@@ -163,6 +163,9 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
 	}
 	tdb_io_init(tdb);
 	tdb->fd = -1;
+#ifdef TDB_TRACE
+	tdb->tracefd = -1;
+#endif
 	tdb->name = NULL;
 	tdb->map_ptr = NULL;
 	tdb->flags = tdb_flags;
@@ -199,6 +202,23 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
 		tdb->flags &= ~TDB_CLEAR_IF_FIRST;
 	}
 
+	if ((tdb->flags & TDB_ALLOW_NESTING) &&
+	    (tdb->flags & TDB_DISALLOW_NESTING)) {
+		tdb->ecode = TDB_ERR_NESTING;
+		TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_open_ex: "
+			"allow_nesting and disallow_nesting are not allowed together!"));
+		errno = EINVAL;
+		goto fail;
+	}
+
+	/*
+	 * TDB_ALLOW_NESTING is the default behavior.
+	 * Note: this may change in future versions!
+	 */
+	if (!(tdb->flags & TDB_DISALLOW_NESTING)) {
+		tdb->flags |= TDB_ALLOW_NESTING;
+	}
+
 	/* internal databases don't mmap or lock, and start off cleared */
 	if (tdb->flags & TDB_INTERNAL) {
 		tdb->flags |= (TDB_NOLOCK | TDB_NOMMAP);
@@ -207,10 +227,6 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
 			TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: tdb_new_database failed!"));
 			goto fail;
 		}
-#ifdef TDB_TRACE
-		/* All tracing will fail.  That's ok. */
-		tdb->tracefd = -1;
-#endif
 		goto internal;
 	}
 
diff --git a/lib/tdb/common/tdb.c b/lib/tdb/common/tdb.c
index 564c5fe..d2688de 100644
--- a/lib/tdb/common/tdb.c
+++ b/lib/tdb/common/tdb.c
@@ -730,11 +730,41 @@ int tdb_get_flags(struct tdb_context *tdb)
 
 void tdb_add_flags(struct tdb_context *tdb, unsigned flags)
 {
+	if ((flags & TDB_ALLOW_NESTING) &&
+	    (flags & TDB_DISALLOW_NESTING)) {
+		tdb->ecode = TDB_ERR_NESTING;
+		TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_add_flags: "
+			"allow_nesting and disallow_nesting are not allowed together!"));
+		return;
+	}
+
+	if (flags & TDB_ALLOW_NESTING) {
+		tdb->flags &= ~TDB_DISALLOW_NESTING;
+	}
+	if (flags & TDB_DISALLOW_NESTING) {
+		tdb->flags &= ~TDB_ALLOW_NESTING;
+	}
+
 	tdb->flags |= flags;
 }
 
 void tdb_remove_flags(struct tdb_context *tdb, unsigned flags)
 {
+	if ((flags & TDB_ALLOW_NESTING) &&
+	    (flags & TDB_DISALLOW_NESTING)) {
+		tdb->ecode = TDB_ERR_NESTING;
+		TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_remove_flags: "
+			"allow_nesting and disallow_nesting are not allowed together!"));
+		return;
+	}
+
+	if (flags & TDB_ALLOW_NESTING) {
+		tdb->flags |= TDB_DISALLOW_NESTING;
+	}
+	if (flags & TDB_DISALLOW_NESTING) {
+		tdb->flags |= TDB_ALLOW_NESTING;
+	}
+
 	tdb->flags &= ~flags;
 }
 
diff --git a/lib/tdb/common/transaction.c b/lib/tdb/common/transaction.c
index 035b4e1..20f2bfc 100644
--- a/lib/tdb/common/transaction.c
+++ b/lib/tdb/common/transaction.c
@@ -85,6 +85,21 @@
     still available, but no transaction recovery area is used and no
     fsync/msync calls are made.
 
+  - if TDB_ALLOW_NESTING is passed to flags in tdb open, or added using
+    tdb_add_flags() transaction nesting is enabled.
+    It resets the TDB_DISALLOW_NESTING flag, as both cannot be used together.
+    The default is that transaction nesting is allowed.
+    Note: this default may change in future versions of tdb.
+
+    Beware. when transactions are nested a transaction successfully
+    completed with tdb_transaction_commit() can be silently unrolled later.
+
+  - if TDB_DISALLOW_NESTING is passed to flags in tdb open, or added using
+    tdb_add_flags() transaction nesting is disabled.
+    It resets the TDB_ALLOW_NESTING flag, as both cannot be used together.
+    An attempt create a nested transaction will fail with TDB_ERR_NESTING.
+    The default is that transaction nesting is allowed.
+    Note: this default may change in future versions of tdb.
 */
 
 
@@ -427,6 +442,10 @@ int tdb_transaction_start(struct tdb_context *tdb)
 
 	/* cope with nested tdb_transaction_start() calls */
 	if (tdb->transaction != NULL) {
+		if (!(tdb->flags & TDB_ALLOW_NESTING)) {
+			tdb->ecode = TDB_ERR_NESTING;
+			return -1;
+		}
 		tdb->transaction->nesting++;
 		TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_start: nesting %d\n", 
 			 tdb->transaction->nesting));
diff --git a/lib/tdb/configure.ac b/lib/tdb/configure.ac
index 52ecff4..779f596 100644
--- a/lib/tdb/configure.ac
+++ b/lib/tdb/configure.ac
@@ -2,7 +2,7 @@ AC_PREREQ(2.50)
 AC_DEFUN([SMB_MODULE_DEFAULT], [echo -n ""])
 AC_DEFUN([SMB_LIBRARY_ENABLE], [echo -n ""])
 AC_DEFUN([SMB_ENABLE], [echo -n ""])
-AC_INIT(tdb, 1.1.7)
+AC_INIT(tdb, 1.2.0)
 AC_CONFIG_SRCDIR([common/tdb.c])
 AC_CONFIG_HEADER(include/config.h)
 AC_LIBREPLACE_ALL_CHECKS
diff --git a/lib/tdb/docs/README b/lib/tdb/docs/README
index 7bf4854..c02ee0e 100644
--- a/lib/tdb/docs/README
+++ b/lib/tdb/docs/README
@@ -69,6 +69,10 @@ TDB_CONTEXT *tdb_open(char *name, int hash_size, int tdb_flags,
     TDB_NOLOCK - don't do any locking
     TDB_NOMMAP - don't use mmap
     TDB_NOSYNC - don't synchronise transactions to disk
+    TDB_SEQNUM - maintain a sequence number
+    TDB_VOLATILE - activate the per-hashchain freelist, default 5
+    TDB_ALLOW_NESTING - allow transactions to nest
+    TDB_DISALLOW_NESTING - disallow transactions to nest
 
 ----------------------------------------------------------------------
 TDB_CONTEXT *tdb_open_ex(char *name, int hash_size, int tdb_flags,
diff --git a/lib/tdb/include/tdb.h b/lib/tdb/include/tdb.h
index e849f20..db9ce4a 100644
--- a/lib/tdb/include/tdb.h
+++ b/lib/tdb/include/tdb.h
@@ -48,11 +48,14 @@ extern "C" {
 #define TDB_NOSYNC   64 /* don't use synchronous transactions */
 #define TDB_SEQNUM   128 /* maintain a sequence number */
 #define TDB_VOLATILE   256 /* Activate the per-hashchain freelist, default 5 */
+#define TDB_ALLOW_NESTING 512 /* Allow transactions to nest */
+#define TDB_DISALLOW_NESTING 1024 /* Disallow transactions to nest */
 
 /* error codes */
 enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK, 
 		TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOLOCK, TDB_ERR_LOCK_TIMEOUT,
-		TDB_ERR_NOEXIST, TDB_ERR_EINVAL, TDB_ERR_RDONLY};
+		TDB_ERR_NOEXIST, TDB_ERR_EINVAL, TDB_ERR_RDONLY,
+		TDB_ERR_NESTING};
 
 /* debugging uses one of the following levels */
 enum tdb_debug_level {TDB_DEBUG_FATAL = 0, TDB_DEBUG_ERROR, 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list