[SCM] Samba Shared Repository - branch master updated

Rusty Russell rusty at samba.org
Wed Oct 28 17:45:13 MDT 2009


The branch, master has been updated
       via  83de5c8... tdb: update README a bit
       via  71a2139... tdb: add tests for double .close() in pytdb
       via  b4424f8... tdb: reset tdb->fd to -1 in tdb_close()
       via  cfed5f9... tdb: fix typo in python's Tdb.get() docstring
       via  ecbe5eb... tdb: kill last bits from swig
      from  04161b4... Fix map readonly in smb.conf, it is a single word

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


- Log -----------------------------------------------------------------
commit 83de5c826313aa09c76131ae70550bd81b3521c5
Author: Kirill Smelkov <kirr at mns.spb.ru>
Date:   Wed Oct 21 21:18:58 2009 +0400

    tdb: update README a bit
    
    While studying tdb, I've noticed a couple of mismatches between readme
    and actual code:
    
    - tdb_open_ex changed it's log_fn argument to log_ctx
    - there is now no tdb_update(), which it seems was transformed into
      non-exported tdb_update_hash()
    
    There were other mismatches, but I don't remember them now, sorry.
    
    Signed-off-by: Kirill Smelkov <kirr at mns.spb.ru>
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit 71a21393dd1bb61bded82b1581ac6d5bd3b0153c
Author: Kirill Smelkov <kirr at mns.spb.ru>
Date:   Wed Oct 21 21:18:57 2009 +0400

    tdb: add tests for double .close() in pytdb
    
    The reason I do it is that when using older python-tdb as shipped in
    Debian Lenny, python interpreter crashes on this test:
    
        (gdb) bt
        #0  0xb7f8c424 in __kernel_vsyscall ()
        #1  0xb7df5640 in raise () from /lib/i686/cmov/libc.so.6
        #2  0xb7df7018 in abort () from /lib/i686/cmov/libc.so.6
        #3  0xb7e3234d in __libc_message () from /lib/i686/cmov/libc.so.6
        #4  0xb7e38624 in malloc_printerr () from /lib/i686/cmov/libc.so.6
        #5  0xb7e3a826 in free () from /lib/i686/cmov/libc.so.6
        #6  0xb7b39c84 in tdb_close () from /usr/lib/libtdb.so.1
        #7  0xb7b43e14 in ?? () from /var/lib/python-support/python2.5/_tdb.so
        #8  0x0a038d08 in ?? ()
        #9  0x00000000 in ?? ()
    
    master's pytdb does not (we have a check for self->closed in obj_close()),
    but still...
    
    Signed-off-by: Kirill Smelkov <kirr at mns.spb.ru>
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit b4424f8234a78a79fb2d71d46ca208b4f12e0f9e
Author: Kirill Smelkov <kirr at mns.spb.ru>
Date:   Wed Oct 21 21:18:56 2009 +0400

    tdb: reset tdb->fd to -1 in tdb_close()
    
    So that erroneous double tdb_close() calls do not try to close() same
    fd again. This is like SAFE_FREE() but for fd.
    
    Signed-off-by: Kirill Smelkov <kirr at mns.spb.ru>
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit cfed5f946de0992a594c189ee3c19cf98e59d380
Author: Kirill Smelkov <kirr at mns.spb.ru>
Date:   Wed Oct 21 21:18:55 2009 +0400

    tdb: fix typo in python's Tdb.get() docstring
    
    It's Tdb.get(), not Tdb.fetch().
    
    Signed-off-by: Kirill Smelkov <kirr at mns.spb.ru>
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit ecbe5ebd8d1c44a478c613eb1cace0521142d0d3
Author: Kirill Smelkov <kirr at mns.spb.ru>
Date:   Wed Oct 21 21:18:54 2009 +0400

    tdb: kill last bits from swig
    
    We no longer use swig for pytdb, so there is no need for swig make
    rules. Also pytdb.c header should be updated.
    
    Signed-off-by: Kirill Smelkov <kirr at mns.spb.ru>
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

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

Summary of changes:
 lib/tdb/common/open.c          |    4 +++-
 lib/tdb/docs/README            |    9 +--------
 lib/tdb/pytdb.c                |    4 ++--
 lib/tdb/python/tests/simple.py |    9 +++++++++
 lib/tdb/rules.mk               |    5 -----
 5 files changed, 15 insertions(+), 16 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c
index 1ba2e7b..64efafe 100644
--- a/lib/tdb/common/open.c
+++ b/lib/tdb/common/open.c
@@ -403,8 +403,10 @@ int tdb_close(struct tdb_context *tdb)
 			tdb_munmap(tdb);
 	}
 	SAFE_FREE(tdb->name);
-	if (tdb->fd != -1)
+	if (tdb->fd != -1) {
 		ret = close(tdb->fd);
+		tdb->fd = -1;
+	}
 	SAFE_FREE(tdb->lockrecs);
 
 	/* Remove from contexts list */
diff --git a/lib/tdb/docs/README b/lib/tdb/docs/README
index 4eb809f..7bf4854 100644
--- a/lib/tdb/docs/README
+++ b/lib/tdb/docs/README
@@ -73,7 +73,7 @@ TDB_CONTEXT *tdb_open(char *name, int hash_size, int tdb_flags,
 ----------------------------------------------------------------------
 TDB_CONTEXT *tdb_open_ex(char *name, int hash_size, int tdb_flags,
 		         int open_flags, mode_t mode,
-			 tdb_log_func log_fn,
+			 const struct tdb_logging_context *log_ctx,
 			 tdb_hash_func hash_fn)
 
 This is like tdb_open(), but allows you to pass an initial logging and
@@ -93,13 +93,6 @@ int tdb_close(TDB_CONTEXT *tdb);
    close a database
 
 ----------------------------------------------------------------------
-int tdb_update(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf);
-
-   update an entry in place - this only works if the new data size
-   is <= the old data size and the key exists.
-   on failure return -1
-
-----------------------------------------------------------------------
 TDB_DATA tdb_fetch(TDB_CONTEXT *tdb, TDB_DATA key);
 
    fetch an entry in the database given a key 
diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c
index 159bc4d..202dca1 100644
--- a/lib/tdb/pytdb.c
+++ b/lib/tdb/pytdb.c
@@ -1,7 +1,7 @@
 /* 
    Unix SMB/CIFS implementation.
 
-   Swig interface to tdb.
+   Python interface to tdb.
 
    Copyright (C) 2004-2006 Tim Potter <tpot at samba.org>
    Copyright (C) 2007-2008 Jelmer Vernooij <jelmer at samba.org>
@@ -337,7 +337,7 @@ static PyMethodDef tdb_object_methods[] = {
 	{ "read_lock_all", (PyCFunction)obj_lockall_read, METH_NOARGS, NULL },
 	{ "read_unlock_all", (PyCFunction)obj_unlockall_read, METH_NOARGS, NULL },
 	{ "close", (PyCFunction)obj_close, METH_NOARGS, NULL },
-	{ "get", (PyCFunction)obj_get, METH_VARARGS, "S.fetch(key) -> value\n"
+	{ "get", (PyCFunction)obj_get, METH_VARARGS, "S.get(key) -> value\n"
 		"Fetch a value." },
 	{ "append", (PyCFunction)obj_append, METH_VARARGS, "S.append(key, value) -> None\n"
 		"Append data to an existing key." },
diff --git a/lib/tdb/python/tests/simple.py b/lib/tdb/python/tests/simple.py
index d242e66..c7443c0 100644
--- a/lib/tdb/python/tests/simple.py
+++ b/lib/tdb/python/tests/simple.py
@@ -15,6 +15,15 @@ class OpenTdbTests(TestCase):
     def test_nonexistant_read(self):
         self.assertRaises(IOError, tdb.Tdb, "/some/nonexistant/file", 0, tdb.DEFAULT, os.O_RDWR)
 
+class CloseTdbTests(TestCase):
+    def test_double_close(self):
+        self.tdb = tdb.Tdb(tempfile.mkstemp()[1], 0, tdb.DEFAULT, os.O_CREAT|os.O_RDWR)
+        self.assertNotEqual(None, self.tdb)
+
+        # ensure that double close does not crash python
+        self.tdb.close()
+        self.tdb.close()
+
 
 class SimpleTdbTests(TestCase):
     def setUp(self):
diff --git a/lib/tdb/rules.mk b/lib/tdb/rules.mk
index 73ab771..023e0ce 100644
--- a/lib/tdb/rules.mk
+++ b/lib/tdb/rules.mk
@@ -1,8 +1,3 @@
-.SUFFIXES: .i _wrap.c
-
-.i_wrap.c: 
-	$(SWIG) -O -Wall -python -keyword $<
-
 showflags::
 	@echo 'tdb will be compiled with flags:'
 	@echo '  CFLAGS = $(CFLAGS)'


-- 
Samba Shared Repository


More information about the samba-cvs mailing list