dbwrap: Remove loadparm_context from db_open_tdb
authorVolker Lendecke <vl@samba.org>
Mon, 21 Sep 2015 10:28:20 +0000 (12:28 +0200)
committerRalph Böhme <slow@samba.org>
Tue, 22 Sep 2015 02:51:16 +0000 (04:51 +0200)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
lib/dbwrap/dbwrap_local_open.c
lib/dbwrap/dbwrap_tdb.c
lib/dbwrap/dbwrap_tdb.h
source4/ntvfs/posix/python/pyxattr_tdb.c

index 6509ff97871ed0c3071d42388265d66cca6771f6..c350fd3ea420dc2168d63e77e30ab4ba39e39228 100644 (file)
@@ -34,8 +34,13 @@ struct db_context *dbwrap_local_open(TALLOC_CTX *mem_ctx,
 {
        struct db_context *db = NULL;
 
-       db = db_open_tdb(mem_ctx, lp_ctx, name, hash_size,
-                        tdb_flags, open_flags, mode,
+       if (hash_size == 0) {
+               hash_size = lpcfg_tdb_hash_size(lp_ctx, name);
+       }
+
+       db = db_open_tdb(mem_ctx, name, hash_size,
+                        lpcfg_tdb_flags(lp_ctx, tdb_flags),
+                        open_flags, mode,
                         lock_order, dbwrap_flags);
 
        return db;
index 2bc123e36d3b10f415ada6fc54e328fbd1a5e5dd..574b5d93d472ee965d19d1d5008a03d8b8689e7e 100644 (file)
@@ -397,7 +397,6 @@ static void db_tdb_id(struct db_context *db, const uint8_t **id, size_t *idlen)
 }
 
 struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
-                              struct loadparm_context *lp_ctx,
                               const char *name,
                               int hash_size, int tdb_flags,
                               int open_flags, mode_t mode,
@@ -421,12 +420,7 @@ struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
        }
        result->lock_order = lock_order;
 
-       if (hash_size == 0) {
-               hash_size = lpcfg_tdb_hash_size(lp_ctx, name);
-       }
-
-       db_tdb->wtdb = tdb_wrap_open(db_tdb, name, hash_size,
-                                    lpcfg_tdb_flags(lp_ctx, tdb_flags),
+       db_tdb->wtdb = tdb_wrap_open(db_tdb, name, hash_size, tdb_flags,
                                     open_flags, mode);
        if (db_tdb->wtdb == NULL) {
                DEBUG(3, ("Could not open tdb: %s\n", strerror(errno)));
index 93ee09c60576a7bc656a5a2daa93ffe98f2fbc7d..d5f49c7d5741efd25db8bf5c5d62e86e658f1447 100644 (file)
@@ -25,7 +25,6 @@
 struct db_context;
 
 struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
-                              struct loadparm_context *lp_ctx,
                               const char *name,
                               int hash_size, int tdb_flags,
                               int open_flags, mode_t mode,
index d3390a3d906c9e796d9b9452598f2ab9ef27d8e6..84ef426ead810c87aa12147c61aab66148cfa065 100644 (file)
@@ -46,6 +46,7 @@ static PyObject *py_wrap_setxattr(PyObject *self, PyObject *args)
        int blobsize;
        int ret;
        TALLOC_CTX *mem_ctx;
+       struct loadparm_context *lp_ctx;
        struct db_context *eadb = NULL;
        struct file_id id;
        struct stat sbuf;
@@ -56,8 +57,11 @@ static PyObject *py_wrap_setxattr(PyObject *self, PyObject *args)
 
        blob.length = blobsize;
        mem_ctx = talloc_new(NULL);
-       eadb = db_open_tdb(mem_ctx, py_default_loadparm_context(mem_ctx), tdbname, 50000,
-                          TDB_DEFAULT, O_RDWR|O_CREAT, 0600, DBWRAP_LOCK_ORDER_2,
+
+       lp_ctx = py_default_loadparm_context(mem_ctx);
+       eadb = db_open_tdb(mem_ctx, tdbname, 50000,
+                          lpcfg_tdb_flags(lp_ctx, TDB_DEFAULT),
+                          O_RDWR|O_CREAT, 0600, DBWRAP_LOCK_ORDER_2,
                           DBWRAP_FLAG_NONE);
 
        if (eadb == NULL) {
@@ -91,6 +95,7 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args)
 {
        char *filename, *attribute, *tdbname;
        TALLOC_CTX *mem_ctx;
+       struct loadparm_context *lp_ctx;
        DATA_BLOB blob;
        PyObject *ret_obj;
        int ret;
@@ -104,8 +109,10 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args)
 
        mem_ctx = talloc_new(NULL);
 
-       eadb = db_open_tdb(mem_ctx, py_default_loadparm_context(mem_ctx), tdbname, 50000,
-                          TDB_DEFAULT, O_RDWR|O_CREAT, 0600, DBWRAP_LOCK_ORDER_2,
+       lp_ctx = py_default_loadparm_context(mem_ctx);
+       eadb = db_open_tdb(mem_ctx, tdbname, 50000,
+                          lpcfg_tdb_flags(lp_ctx, TDB_DEFAULT),
+                          O_RDWR|O_CREAT, 0600, DBWRAP_LOCK_ORDER_2,
                           DBWRAP_FLAG_NONE);
 
        if (eadb == NULL) {