summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-04-16 13:37:39 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-04-18 12:04:59 +1000
commit338e5a1d35574dbd96bbbcf2a74fe33adc95cb8c (patch)
tree4206afcc1354276ab3d99fce23754430a3b0264d
parent235016bcf9c332f88d3aae68d0726d8bb2a64246 (diff)
downloadsamba-338e5a1d35574dbd96bbbcf2a74fe33adc95cb8c.tar.gz
samba-338e5a1d35574dbd96bbbcf2a74fe33adc95cb8c.tar.bz2
samba-338e5a1d35574dbd96bbbcf2a74fe33adc95cb8c.zip
s3-dbwrap: push lp_ctx up another layer in the stack
This will allow db_open_tdb() to be called from common code, which may already have a loadparm context loaded. It also slowly moves the lp_ctx up the stack, as required to remove the library loop between smbconf and the registry. Andrew Bartlett
-rw-r--r--source3/lib/dbwrap/dbwrap_open.c5
-rw-r--r--source3/lib/dbwrap/dbwrap_tdb.c5
-rw-r--r--source3/lib/dbwrap/dbwrap_tdb.h1
-rw-r--r--source3/smbd/notify_internal.c5
4 files changed, 10 insertions, 6 deletions
diff --git a/source3/lib/dbwrap/dbwrap_open.c b/source3/lib/dbwrap/dbwrap_open.c
index 5491a1f56b..b7e6bd586f 100644
--- a/source3/lib/dbwrap/dbwrap_open.c
+++ b/source3/lib/dbwrap/dbwrap_open.c
@@ -24,6 +24,7 @@
#include "dbwrap/dbwrap_open.h"
#include "dbwrap/dbwrap_tdb.h"
#include "dbwrap/dbwrap_ctdb.h"
+#include "lib/param/param.h"
#include "util_tdb.h"
#ifdef CLUSTER_SUPPORT
#include "ctdb_private.h"
@@ -117,9 +118,11 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx,
#endif
if (result == NULL) {
- result = db_open_tdb(mem_ctx, name, hash_size,
+ struct loadparm_context *lp_ctx = loadparm_init_s3(mem_ctx, loadparm_s3_context());
+ result = db_open_tdb(mem_ctx, lp_ctx, name, hash_size,
tdb_flags, open_flags, mode,
lock_order);
+ talloc_unlink(mem_ctx, lp_ctx);
}
return result;
}
diff --git a/source3/lib/dbwrap/dbwrap_tdb.c b/source3/lib/dbwrap/dbwrap_tdb.c
index ffad39bed8..2041613be2 100644
--- a/source3/lib/dbwrap/dbwrap_tdb.c
+++ b/source3/lib/dbwrap/dbwrap_tdb.c
@@ -22,7 +22,6 @@
#include "dbwrap/dbwrap_private.h"
#include "dbwrap/dbwrap_tdb.h"
#include "lib/tdb_wrap/tdb_wrap.h"
-#include "lib/param/param.h"
#include "util_tdb.h"
struct db_tdb_ctx {
@@ -363,6 +362,7 @@ static int db_tdb_transaction_cancel(struct db_context *db)
}
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,
@@ -370,14 +370,12 @@ struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
{
struct db_context *result = NULL;
struct db_tdb_ctx *db_tdb;
- struct loadparm_context *lp_ctx;
result = talloc_zero(mem_ctx, struct db_context);
if (result == NULL) {
DEBUG(0, ("talloc failed\n"));
goto fail;
}
- lp_ctx = loadparm_init_s3(result, loadparm_s3_context());
result->private_data = db_tdb = talloc(result, struct db_tdb_ctx);
if (db_tdb == NULL) {
@@ -388,7 +386,6 @@ struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
db_tdb->wtdb = tdb_wrap_open(db_tdb, name, hash_size, tdb_flags,
open_flags, mode, lp_ctx);
- talloc_unlink(result, lp_ctx);
if (db_tdb->wtdb == NULL) {
DEBUG(3, ("Could not open tdb: %s\n", strerror(errno)));
goto fail;
diff --git a/source3/lib/dbwrap/dbwrap_tdb.h b/source3/lib/dbwrap/dbwrap_tdb.h
index 1f7a223c70..6a6da45a08 100644
--- a/source3/lib/dbwrap/dbwrap_tdb.h
+++ b/source3/lib/dbwrap/dbwrap_tdb.h
@@ -25,6 +25,7 @@
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,
diff --git a/source3/smbd/notify_internal.c b/source3/smbd/notify_internal.c
index 6e6bdf7b03..4d78743687 100644
--- a/source3/smbd/notify_internal.c
+++ b/source3/smbd/notify_internal.c
@@ -123,6 +123,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx,
struct messaging_context *msg,
struct event_context *ev)
{
+ struct loadparm_context *lp_ctx;
struct notify_context *notify;
notify = talloc(mem_ctx, struct notify_context);
@@ -132,10 +133,12 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx,
notify->msg = msg;
notify->list = NULL;
+ lp_ctx = loadparm_init_s3(notify, loadparm_s3_context());
notify->db_notify = db_open_tdb(
- notify, lock_path("notify.tdb"),
+ notify, lp_ctx, lock_path("notify.tdb"),
0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
O_RDWR|O_CREAT, 0644, DBWRAP_LOCK_ORDER_2);
+ talloc_unlink(notify, lp_ctx);
if (notify->db_notify == NULL) {
goto fail;
}