summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-11-12 13:36:48 +0100
committerMichael Adam <obnox@samba.org>2012-11-29 18:10:13 +0100
commit6b8a37f5ca83c45e2cac262f4d9eee5c7750c283 (patch)
tree241a3f45512b070f1deac26e2ff6d39ec959bdc8
parent9dd047d67e4b53f1240956e20af986a1d03dce32 (diff)
downloadsamba-6b8a37f5ca83c45e2cac262f4d9eee5c7750c283.tar.gz
samba-6b8a37f5ca83c45e2cac262f4d9eee5c7750c283.tar.bz2
samba-6b8a37f5ca83c45e2cac262f4d9eee5c7750c283.zip
s3: Directly parse local existing records in db_ctdb_parse_record
Reviewed-by: Michael Adam <obnox@samba.org>
-rw-r--r--source3/lib/dbwrap/dbwrap_ctdb.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index 6037585230..624840e746 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -1224,6 +1224,7 @@ static NTSTATUS db_ctdb_fetch(struct db_context *db, TALLOC_CTX *mem_ctx,
struct db_ctdb_parse_record_state {
void (*parser)(TDB_DATA key, TDB_DATA data, void *private_data);
void *private_data;
+ bool done;
};
static void db_ctdb_parse_record_parser(
@@ -1235,6 +1236,19 @@ static void db_ctdb_parse_record_parser(
state->parser(key, data, state->private_data);
}
+static void db_ctdb_parse_record_parser_nonpersistent(
+ TDB_DATA key, struct ctdb_ltdb_header *header,
+ TDB_DATA data, void *private_data)
+{
+ struct db_ctdb_parse_record_state *state =
+ (struct db_ctdb_parse_record_state *)private_data;
+
+ if (db_ctdb_can_use_local_hdr(header, true)) {
+ state->parser(key, data, state->private_data);
+ state->done = true;
+ }
+}
+
static NTSTATUS db_ctdb_parse_record(struct db_context *db, TDB_DATA key,
void (*parser)(TDB_DATA key,
TDB_DATA data,
@@ -1274,6 +1288,14 @@ static NTSTATUS db_ctdb_parse_record(struct db_context *db, TDB_DATA key,
ctx, key, db_ctdb_parse_record_parser, &state);
}
+ state.done = false;
+
+ status = db_ctdb_ltdb_parse(
+ ctx, key, db_ctdb_parse_record_parser_nonpersistent, &state);
+ if (NT_STATUS_IS_OK(status) && state.done) {
+ return NT_STATUS_OK;
+ }
+
status = db_ctdb_fetch(db, talloc_tos(), key, &data);
if (!NT_STATUS_IS_OK(status)) {
return status;