[SCM] Samba Shared Repository - branch master updated

Rusty Russell rusty at samba.org
Wed Sep 21 01:26:02 MDT 2011


The branch, master has been updated
       via  95b2e5a tdb2: change --enable-tdb2-breaks-compat to --enable-tdb2
       via  fb41dfb tdb_compat: add "TDB_COMPAT_USE_TDB2" environment variable
       via  f08b323 tdb_compat: honour hashsize arg when using tdb2 with TDB_VERSION1 flag.
       via  10e6a32 tdb_compat: handle TDB_VOLATILE flag.
       via  36b455d9 tdb_compat: handle TDB_INCOMPATIBLE_HASH flag.
      from  ad3ac7e Try and fix bug #8472 - Crash in asn.1 parsing code.

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


- Log -----------------------------------------------------------------
commit 95b2e5aa56814e04f060403b8805c5c562805ee9
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Wed Sep 21 15:18:05 2011 +0930

    tdb2: change --enable-tdb2-breaks-compat to --enable-tdb2
    
    Since we no longer break compatibility, don't scare people.
    
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
    
    Autobuild-User: Rusty Russell <rusty at rustcorp.com.au>
    Autobuild-Date: Wed Sep 21 09:25:11 CEST 2011 on sn-devel-104

commit fb41dfb77ff8b7822befcfb877e84ccdf06ab830
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Wed Sep 21 12:58:59 2011 +0930

    tdb_compat: add "TDB_COMPAT_USE_TDB2" environment variable
    
    When BUILD_TDB2 is defined, add TDB_VERSION1 flag to all tdb_open()
    calls, unless this flag is set.  This means we use the tdb1 on-disk
    format unless the user specifically asks for tdb2.
    
    We'd love to do this using loadparm, but we need to work with both
    Samba 3 and Samba 4's loadparm, and they're not unified yet.
    
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit f08b323a88658c3e52adce4fa346bc03274e2c36
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Wed Sep 21 12:57:59 2011 +0930

    tdb_compat: honour hashsize arg when using tdb2 with TDB_VERSION1 flag.
    
    We use the TDB_ATTRIBUTE_TDB1_HASHSIZE to set the hash size.
    
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit 10e6a3282098b3d4d94e72fa27f47825ef4e7f15
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Wed Sep 21 12:56:59 2011 +0930

    tdb_compat: handle TDB_VOLATILE flag.
    
    This is only meaningful when using the TDB_VERSION1 flag: we set the
    attribute to control the maximum number of dead records (to 5, which is
    what TDB_VOLATILE did for tdb1).
    
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit 36b455d95227f8ef2f08e3134e289b2862b319f9
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Wed Sep 21 12:55:59 2011 +0930

    tdb_compat: handle TDB_INCOMPATIBLE_HASH flag.
    
    This is only meaningful when using the TDB_VERSION1 flag: it is done
    by using a magic hash value (which will fall back to the default hash
    if that works instead).
    
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

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

Summary of changes:
 lib/tdb2/wscript            |    4 ++--
 lib/tdb_compat/tdb_compat.c |   35 +++++++++++++++++++++++++++++++++--
 lib/tdb_compat/tdb_compat.h |    6 +++---
 3 files changed, 38 insertions(+), 7 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb2/wscript b/lib/tdb2/wscript
index 0311caf..be5b8e2 100644
--- a/lib/tdb2/wscript
+++ b/lib/tdb2/wscript
@@ -21,8 +21,8 @@ def set_options(opt):
     opt.BUILTIN_DEFAULT('replace')
     opt.PRIVATE_EXTENSION_DEFAULT('tdb2', noextension='tdb2')
     opt.RECURSE('lib/replace')
-    opt.add_option('--enable-tdb2-breaks-compat',
-                   help=("Build tdb2 instead of tdb1 (BREAKS TDB1!) [False]"),
+    opt.add_option('--enable-tdb2',
+                   help=("Use tdb2 API instead of tdb1 [False]"),
                    action="store_true", dest='BUILD_TDB2', default=False)
     if opt.IN_LAUNCH_DIR():
         opt.add_option('--disable-python',
diff --git a/lib/tdb_compat/tdb_compat.c b/lib/tdb_compat/tdb_compat.c
index fd3a687..b37e6cc 100644
--- a/lib/tdb_compat/tdb_compat.c
+++ b/lib/tdb_compat/tdb_compat.c
@@ -85,7 +85,7 @@ static enum TDB_ERROR clear_if_first(int fd, void *unused)
 }
 
 struct tdb_context *
-tdb_open_compat_(const char *name, int hash_size_unused,
+tdb_open_compat_(const char *name, int hash_size,
 		 int tdb_flags, int open_flags, mode_t mode,
 		 void (*log_fn)(struct tdb_context *,
 				enum tdb_log_level,
@@ -94,7 +94,11 @@ tdb_open_compat_(const char *name, int hash_size_unused,
 				void *data),
 		 void *log_data)
 {
-	union tdb_attribute cif, log, *attr = NULL;
+	union tdb_attribute cif, log, hash, max_dead, hsize, *attr = NULL;
+
+	if (!getenv("TDB_COMPAT_USE_TDB2")) {
+		tdb_flags |= TDB_VERSION1;
+	}
 
 	if (log_fn) {
 		log.log.base.attr = TDB_ATTRIBUTE_LOG;
@@ -112,6 +116,33 @@ tdb_open_compat_(const char *name, int hash_size_unused,
 		tdb_flags &= ~TDB_CLEAR_IF_FIRST;
 	}
 
+	if (tdb_flags & TDB_INCOMPATIBLE_HASH) {
+		if (tdb_flags & TDB_VERSION1) {
+			hash.hash.base.attr = TDB_ATTRIBUTE_HASH;
+			hash.hash.base.next = attr;
+			hash.hash.fn = tdb1_incompatible_hash;
+			attr = &hash;
+		}
+		tdb_flags &= ~TDB_INCOMPATIBLE_HASH;
+	}
+
+	if (tdb_flags & TDB_VOLATILE) {
+		if (tdb_flags & TDB_VERSION1) {
+			max_dead.base.attr = TDB_ATTRIBUTE_TDB1_MAX_DEAD;
+			max_dead.base.next = attr;
+			max_dead.tdb1_max_dead.max_dead = 5;
+			attr = &max_dead;
+		}
+		tdb_flags &= ~TDB_VOLATILE;
+	}
+
+	if (hash_size && (tdb_flags & TDB_VERSION1)) {
+		hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+		hsize.base.next = attr;
+		hsize.tdb1_hashsize.hsize = hash_size;
+		attr = &hsize;
+	}
+
 	/* Testsuite uses this to speed things up. */
 	if (getenv("TDB_NO_FSYNC")) {
 		tdb_flags |= TDB_NOSYNC;
diff --git a/lib/tdb_compat/tdb_compat.h b/lib/tdb_compat/tdb_compat.h
index 1f7e8a9..0d58075 100644
--- a/lib/tdb_compat/tdb_compat.h
+++ b/lib/tdb_compat/tdb_compat.h
@@ -82,8 +82,8 @@ int tdb_reopen_all(int parent_longlived);
 
 /* These no longer exist in tdb2. */
 #define TDB_CLEAR_IF_FIRST 1048576
-#define TDB_INCOMPATIBLE_HASH 0
-#define TDB_VOLATILE 0
+#define TDB_INCOMPATIBLE_HASH 2097152
+#define TDB_VOLATILE 4194304
 
 /* tdb2 does nonblocking functions via attibutes. */
 enum TDB_ERROR tdb_transaction_start_nonblock(struct tdb_context *tdb);
@@ -100,7 +100,7 @@ enum TDB_ERROR tdb_transaction_start_nonblock(struct tdb_context *tdb);
 			 (log_data))
 
 struct tdb_context *
-tdb_open_compat_(const char *name, int hash_size_unused,
+tdb_open_compat_(const char *name, int hash_size,
 		 int tdb_flags, int open_flags, mode_t mode,
 		 void (*log_fn)(struct tdb_context *,
 				enum tdb_log_level,


-- 
Samba Shared Repository


More information about the samba-cvs mailing list