diff options
author | Gregor Beck <gbeck@sernet.de> | 2011-09-22 13:58:24 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2011-10-12 03:49:05 +0200 |
commit | a6cd71da858062a66f83775cf655b79b6c8d75e7 (patch) | |
tree | 582e66acd3f46e2b2393e414a6e314866f6f5bbf /source3 | |
parent | 240d6217dd4d75a69b3f57f9668aa81ed042a6cf (diff) | |
download | samba-a6cd71da858062a66f83775cf655b79b6c8d75e7.tar.gz samba-a6cd71da858062a66f83775cf655b79b6c8d75e7.tar.bz2 samba-a6cd71da858062a66f83775cf655b79b6c8d75e7.zip |
s3:dbwrap: traverse records created within this transaction.
Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/dbwrap/dbwrap_ctdb.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c index 5823ab4695..95c23eeb42 100644 --- a/source3/lib/dbwrap/dbwrap_ctdb.c +++ b/source3/lib/dbwrap/dbwrap_ctdb.c @@ -1285,6 +1285,13 @@ done: return ret; } +/* wrapper to use traverse_persistent_callback with dbwrap */ +static int traverse_persistent_callback_dbwrap(struct db_record *rec, void* data) +{ + return traverse_persistent_callback(NULL, rec->key, rec->value, data); +} + + static int db_ctdb_traverse(struct db_context *db, int (*fn)(struct db_record *rec, void *private_data), @@ -1299,9 +1306,40 @@ static int db_ctdb_traverse(struct db_context *db, state.private_data = private_data; if (db->persistent) { + struct tdb_context *ltdb = ctx->wtdb->tdb; + int ret; + /* for persistent databases we don't need to do a ctdb traverse, we can do a faster local traverse */ - return tdb_traverse(ctx->wtdb->tdb, traverse_persistent_callback, &state); + ret = tdb_traverse(ltdb, traverse_persistent_callback, &state); + if (ret < 0) { + return ret; + } + if (ctx->transaction && ctx->transaction->m_write) { + /* we now have to handle keys not yet present at transaction start */ + struct db_context *newkeys = db_open_rbt(talloc_tos()); + struct ctdb_marshall_buffer *mbuf = ctx->transaction->m_write; + struct ctdb_rec_data *rec=NULL; + NTSTATUS status; + int i; + for (i=0; i<mbuf->count; i++) { + TDB_DATA key; + rec =db_ctdb_marshall_loop_next(mbuf, rec, + NULL, NULL, + &key, NULL); + SMB_ASSERT(rec != NULL); + + if (!tdb_exists(ltdb, key)) { + dbwrap_store(newkeys, key, tdb_null, 0); + } + } + status = dbwrap_traverse(newkeys, + traverse_persistent_callback_dbwrap, + &state); + ret = NT_STATUS_IS_OK(status) ? 0 : -1; + talloc_free(newkeys); + } + return ret; } |