summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2013-09-06 17:43:50 +0200
committerKarolin Seeger <kseeger@samba.org>2013-09-09 10:08:21 +0200
commitec1948d3a6adec3dd659abc8ab9c49a334c1e6a7 (patch)
tree67f02bf2ce83bc008029affee5a3238dde95c2c4
parent4b8b385042ace68c4ec59fea81bf8b284b34c356 (diff)
downloadsamba-ec1948d3a6adec3dd659abc8ab9c49a334c1e6a7.tar.gz
s3-serverid: restructure serverid initialization.
Guenther Signed-off-by: Günther Deschner <gd@samba.org>
-rw-r--r--source3/lib/serverid.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/source3/lib/serverid.c b/source3/lib/serverid.c
index 00dd6c4f8d2..420633ff23e 100644
--- a/source3/lib/serverid.c
+++ b/source3/lib/serverid.c
@@ -34,37 +34,41 @@ struct serverid_data {
uint32_t msg_flags;
};
-bool serverid_parent_init(TALLOC_CTX *mem_ctx)
+static struct db_context *db_ptr = NULL;
+
+static struct db_context *serverid_init(TALLOC_CTX *mem_ctx)
{
- struct tdb_wrap *db;
+ db_ptr = db_open(mem_ctx, lock_path("serverid.tdb"),
+ 0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
+ O_RDWR | O_CREAT,
+ 0644);
+ return db_ptr;
+}
+bool serverid_parent_init(TALLOC_CTX *mem_ctx)
+{
/*
* Open the tdb in the parent process (smbd) so that our
* CLEAR_IF_FIRST optimization in tdb_reopen_all can properly
* work.
*/
- db = tdb_wrap_open(mem_ctx, lock_path("serverid.tdb"),
- 0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDWR|O_CREAT,
- 0644);
- if (db == NULL) {
+ if (serverid_init(mem_ctx) == NULL) {
DEBUG(1, ("could not open serverid.tdb: %s\n",
strerror(errno)));
return false;
}
+
return true;
}
static struct db_context *serverid_db(void)
{
- static struct db_context *db;
-
- if (db != NULL) {
- return db;
+ if (db_ptr != NULL) {
+ return db_ptr;
}
- db = db_open(NULL, lock_path("serverid.tdb"), 0,
- TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDWR|O_CREAT, 0644);
- return db;
+
+ return serverid_init(NULL);
}
static void serverid_fill_key(const struct server_id *id,