[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Wed Sep 12 23:35:03 UTC 2018
The branch, master has been updated
via f84e372 dbwrap_ctdb: return correct record count for a persistent db read-only traverse
via 7c0607e dbwrap_ctdb: increment record count in traverse_callback()
via eaaee00 dbwrap_ctdb: use struct initializer in db_ctdb_traverse()
via fce54bf dbwrap_ctdb: use struct initializer in db_ctdb_traverse_read()
via dcc50d6 dbwrap_ctdb: README.Coding fixes in traverse_callback()
via daea965 dbwrap_ctdb: simplify if condition
via 7cafbc5 dbwrap_ctdb: add error checking to ctdbd_dbpath()
via 382620d dbwrap_tdb: use struct initializer
via 9a9620b dbwrap_tdb: move a function call out of an if condition
via 6617b2d dbwrap: early return, removes an indentation level
via b1838b1 dbwrap: move sockname variable and call to lp_ctdbd_socket into context
from e52abc8 ctdb-doc: Remove PIDFILE option from ctdbd_wrapper man page
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit f84e372a5ba154c524c63a2da07410c036fd0222
Author: Ralph Boehme <slow at samba.org>
Date: Mon Sep 10 12:50:01 2018 +0200
dbwrap_ctdb: return correct record count for a persistent db read-only traverse
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Thu Sep 13 01:34:30 CEST 2018 on sn-devel-144
commit 7c0607e96d9bb77522d7d8f4f452dc14880a5b0d
Author: Ralph Boehme <slow at samba.org>
Date: Sun Sep 9 18:51:43 2018 +0200
dbwrap_ctdb: increment record count in traverse_callback()
state->count wasn't incremented and is returned at the end of a
dbwrap_traverse().
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit eaaee00a068257b6d130518a2a228fab07df259e
Author: Ralph Boehme <slow at samba.org>
Date: Sun Sep 9 18:50:14 2018 +0200
dbwrap_ctdb: use struct initializer in db_ctdb_traverse()
This ensures all struct members are implicitly initialized.
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit fce54bf071a7cf86dfdec7b858a0c5254542e6d4
Author: Ralph Boehme <slow at samba.org>
Date: Sun Sep 9 18:48:13 2018 +0200
dbwrap_ctdb: use struct initializer in db_ctdb_traverse_read()
This ensures all struct members are implicitly initialized.
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit dcc50d670702ccbd14f9e58857499911fa215e0b
Author: Ralph Boehme <slow at samba.org>
Date: Sun Sep 9 18:35:26 2018 +0200
dbwrap_ctdb: README.Coding fixes in traverse_callback()
NULL initialize pointers, check function return values, explicit
variable check against NULL.
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit daea9655ef9fc5a0b7b9389f9c4a4b4114261933
Author: Ralph Boehme <slow at samba.org>
Date: Tue Sep 4 12:47:42 2018 +0200
dbwrap_ctdb: simplify if condition
This just moves the talloc_memdup() out of the if condition as per
README.Coding.
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 7cafbc50d9cc4c1b3b985cc1398d184e0a1a75b7
Author: Ralph Boehme <slow at samba.org>
Date: Sun Mar 4 23:39:05 2018 +0100
dbwrap_ctdb: add error checking to ctdbd_dbpath()
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 382620d42dd12fc9bb946b15044ae09a569abca7
Author: Ralph Boehme <slow at samba.org>
Date: Sat Aug 18 08:35:27 2018 +0200
dbwrap_tdb: use struct initializer
This ensures all struct members are implicitly initialized.
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 9a9620bb4252a76385284092a1497920e86b34eb
Author: Ralph Boehme <slow at samba.org>
Date: Sat Aug 18 09:12:21 2018 +0200
dbwrap_tdb: move a function call out of an if condition
At least for me this improves readability somewhat. No change in
behaviour.
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 6617b2db35ec6f5f5acb979bf672414a1f9e5657
Author: Ralph Boehme <slow at samba.org>
Date: Sat Nov 18 12:13:15 2017 +0100
dbwrap: early return, removes an indentation level
No change in behaviour.
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit b1838b15750da7b5d2627f7f8093e19000ddbb3c
Author: Ralph Boehme <slow at samba.org>
Date: Sat Nov 18 08:56:09 2017 +0100
dbwrap: move sockname variable and call to lp_ctdbd_socket into context
sockname is only needed in a cluster.
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/dbwrap/dbwrap_tdb.c | 14 +++++----
source3/lib/dbwrap/dbwrap_ctdb.c | 61 ++++++++++++++++++++++++++++------------
source3/lib/dbwrap/dbwrap_open.c | 40 +++++++++++++-------------
3 files changed, 72 insertions(+), 43 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/dbwrap/dbwrap_tdb.c b/lib/dbwrap/dbwrap_tdb.c
index f597645..d695f3b 100644
--- a/lib/dbwrap/dbwrap_tdb.c
+++ b/lib/dbwrap/dbwrap_tdb.c
@@ -116,13 +116,17 @@ static struct db_record *db_tdb_fetch_locked_internal(
struct db_tdb_ctx *ctx = talloc_get_type_abort(db->private_data,
struct db_tdb_ctx);
struct tdb_fetch_locked_state state;
+ int ret;
- state.mem_ctx = mem_ctx;
- state.result = NULL;
+ state = (struct tdb_fetch_locked_state) {
+ .mem_ctx = mem_ctx,
+ };
- if ((tdb_parse_record(ctx->wtdb->tdb, key, db_tdb_fetchlock_parse,
- &state) < 0) &&
- (tdb_error(ctx->wtdb->tdb) != TDB_ERR_NOEXIST)) {
+ ret = tdb_parse_record(ctx->wtdb->tdb,
+ key,
+ db_tdb_fetchlock_parse,
+ &state);
+ if ((ret < 0) && (tdb_error(ctx->wtdb->tdb) != TDB_ERR_NOEXIST)) {
tdb_chainunlock(ctx->wtdb->tdb, key);
return NULL;
}
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index 2885f4e..b487d10 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -1232,12 +1232,14 @@ again:
result->value.dsize = ctdb_data.dsize - sizeof(crec->header);
result->value.dptr = NULL;
- if ((result->value.dsize != 0)
- && !(result->value.dptr = (uint8_t *)talloc_memdup(
- result, ctdb_data.dptr + sizeof(crec->header),
- result->value.dsize))) {
- DEBUG(0, ("talloc failed\n"));
- TALLOC_FREE(result);
+ if (result->value.dsize != 0) {
+ result->value.dptr = talloc_memdup(
+ result, ctdb_data.dptr + sizeof(crec->header),
+ result->value.dsize);
+ if (result->value.dptr == NULL) {
+ DBG_ERR("talloc failed\n");
+ TALLOC_FREE(result);
+ }
}
SAFE_FREE(ctdb_data.dptr);
@@ -1530,12 +1532,20 @@ struct traverse_state {
static void traverse_callback(TDB_DATA key, TDB_DATA data, void *private_data)
{
struct traverse_state *state = (struct traverse_state *)private_data;
- struct db_record *rec;
- TALLOC_CTX *tmp_ctx = talloc_new(state->db);
+ struct db_record *rec = NULL;
+ TALLOC_CTX *tmp_ctx = NULL;
+
+ tmp_ctx = talloc_new(state->db);
+ if (tmp_ctx == NULL) {
+ DBG_ERR("talloc_new failed\n");
+ return;
+ }
+
/* we have to give them a locked record to prevent races */
rec = db_ctdb_fetch_locked(state->db, tmp_ctx, key);
- if (rec && rec->value.dsize > 0) {
+ if (rec != NULL && rec->value.dsize > 0) {
state->fn(rec, state->private_data);
+ state->count++;
}
talloc_free(tmp_ctx);
}
@@ -1616,10 +1626,11 @@ static int db_ctdb_traverse(struct db_context *db,
struct db_ctdb_ctx);
struct traverse_state state;
- state.db = db;
- state.fn = fn;
- state.private_data = private_data;
- state.count = 0;
+ state = (struct traverse_state) {
+ .db = db,
+ .fn = fn,
+ .private_data = private_data,
+ };
if (db->persistent) {
struct tdb_context *ltdb = ctx->wtdb->tdb;
@@ -1748,15 +1759,24 @@ static int db_ctdb_traverse_read(struct db_context *db,
struct db_ctdb_ctx);
struct traverse_state state;
- state.db = db;
- state.fn = fn;
- state.private_data = private_data;
- state.count = 0;
+ state = (struct traverse_state) {
+ .db = db,
+ .fn = fn,
+ .private_data = private_data,
+ };
if (db->persistent) {
/* for persistent databases we don't need to do a ctdb traverse,
we can do a faster local traverse */
- return tdb_traverse_read(ctx->wtdb->tdb, traverse_persistent_callback_read, &state);
+ int nrecs;
+
+ nrecs = tdb_traverse_read(ctx->wtdb->tdb,
+ traverse_persistent_callback_read,
+ &state);
+ if (nrecs == -1) {
+ return -1;
+ }
+ return state.count;
}
ret = db_ctdbd_traverse(ctx->db_id, traverse_read_callback, &state);
@@ -1856,6 +1876,11 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
db_path = ctdbd_dbpath(messaging_ctdb_connection(), db_ctdb,
db_ctdb->db_id);
+ if (db_path == NULL) {
+ DBG_ERR("ctdbd_dbpath failed\n");
+ TALLOC_FREE(result);
+ return NULL;
+ }
result->persistent = persistent;
result->lock_order = lock_order;
diff --git a/source3/lib/dbwrap/dbwrap_open.c b/source3/lib/dbwrap/dbwrap_open.c
index 33bf969..c8dfd91 100644
--- a/source3/lib/dbwrap/dbwrap_open.c
+++ b/source3/lib/dbwrap/dbwrap_open.c
@@ -65,7 +65,7 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx,
{
struct db_context *result = NULL;
const char *base;
- const char *sockname;
+ struct loadparm_context *lp_ctx = NULL;
if (!DBWRAP_LOCK_ORDER_VALID(lock_order)) {
errno = EINVAL;
@@ -126,9 +126,10 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx,
}
}
- sockname = lp_ctdbd_socket();
-
if (lp_clustering()) {
+ const char *sockname;
+
+ sockname = lp_ctdbd_socket();
if (!socket_exist(sockname)) {
DEBUG(1, ("ctdb socket does not exist - is ctdb not "
"running?\n"));
@@ -159,27 +160,26 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx,
}
return NULL;
}
+
+ return result;
}
}
- if (result == NULL) {
- struct loadparm_context *lp_ctx = loadparm_init_s3(mem_ctx, loadparm_s3_helpers());
+ lp_ctx = loadparm_init_s3(mem_ctx, loadparm_s3_helpers());
- if (hash_size == 0) {
- hash_size = lpcfg_tdb_hash_size(lp_ctx, name);
- }
- tdb_flags = lpcfg_tdb_flags(lp_ctx, tdb_flags);
-
- result = dbwrap_local_open(
- mem_ctx,
- name,
- hash_size,
- tdb_flags,
- open_flags,
- mode,
- lock_order,
- dbwrap_flags);
- talloc_unlink(mem_ctx, lp_ctx);
+ if (hash_size == 0) {
+ hash_size = lpcfg_tdb_hash_size(lp_ctx, name);
}
+ tdb_flags = lpcfg_tdb_flags(lp_ctx, tdb_flags);
+
+ result = dbwrap_local_open(mem_ctx,
+ name,
+ hash_size,
+ tdb_flags,
+ open_flags,
+ mode,
+ lock_order,
+ dbwrap_flags);
+ talloc_unlink(mem_ctx, lp_ctx);
return result;
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list