summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-11-12 13:03:56 +0100
committerMichael Adam <obnox@samba.org>2012-11-29 18:05:25 +0100
commit7b43362a9ea942e6759fd9298b2a67cb3328520f (patch)
tree29f9f6ff946f464ffd9b51ee9bac1e222c3cb1d7 /source3/lib
parent93219f92bb4294f0d7be7ba91f6a2e312336469d (diff)
downloadsamba-7b43362a9ea942e6759fd9298b2a67cb3328520f.tar.gz
samba-7b43362a9ea942e6759fd9298b2a67cb3328520f.tar.bz2
samba-7b43362a9ea942e6759fd9298b2a67cb3328520f.zip
s3: Avoid db_ctdb_fetch for persistent databases
Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/dbwrap/dbwrap_ctdb.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index a971d21d2e..639e385150 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -1347,15 +1347,59 @@ static NTSTATUS db_ctdb_fetch(struct db_context *db, TALLOC_CTX *mem_ctx,
return status;
}
+struct db_ctdb_parse_record_state {
+ void (*parser)(TDB_DATA key, TDB_DATA data, void *private_data);
+ void *private_data;
+};
+
+static void db_ctdb_parse_record_parser(
+ 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;
+ state->parser(key, data, state->private_data);
+}
+
static NTSTATUS db_ctdb_parse_record(struct db_context *db, TDB_DATA key,
void (*parser)(TDB_DATA key,
TDB_DATA data,
void *private_data),
void *private_data)
{
+ struct db_ctdb_ctx *ctx = talloc_get_type_abort(
+ db->private_data, struct db_ctdb_ctx);
+ struct db_ctdb_parse_record_state state;
NTSTATUS status;
TDB_DATA data;
+ state.parser = parser;
+ state.private_data = private_data;
+
+ if (ctx->transaction != NULL) {
+ struct db_ctdb_transaction_handle *h = ctx->transaction;
+ bool found;
+
+ /*
+ * Transactions only happen for persistent db's.
+ */
+
+ found = parse_newest_in_marshall_buffer(
+ h->m_write, key, db_ctdb_parse_record_parser, &state);
+
+ if (found) {
+ return NT_STATUS_OK;
+ }
+ }
+
+ if (db->persistent) {
+ /*
+ * Persistent db, but not found in the transaction buffer
+ */
+ return db_ctdb_ltdb_parse(
+ ctx, key, db_ctdb_parse_record_parser, &state);
+ }
+
status = db_ctdb_fetch(db, talloc_tos(), key, &data);
if (!NT_STATUS_IS_OK(status)) {
return status;