diff options
author | Volker Lendecke <vl@samba.org> | 2016-11-09 16:34:28 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2017-08-16 00:27:10 +0200 |
commit | 5095733f923158701fb5a566cd16c2112d51e1c4 (patch) | |
tree | 9b936c97ccd3f92cf5dc0f2c0e098a0edee72f1c /lib/dbwrap | |
parent | 0dbcd6a4eafb75e1d888e71ee0fa74f36cc6af62 (diff) | |
download | samba-5095733f923158701fb5a566cd16c2112d51e1c4.tar.gz |
dbwrap: Convert dbwrap_store to dbwrap_do_locked
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/dbwrap')
-rw-r--r-- | lib/dbwrap/dbwrap.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/lib/dbwrap/dbwrap.c b/lib/dbwrap/dbwrap.c index 22437f62083..0e576b30f60 100644 --- a/lib/dbwrap/dbwrap.c +++ b/lib/dbwrap/dbwrap.c @@ -301,22 +301,30 @@ bool dbwrap_exists(struct db_context *db, TDB_DATA key) return (result == 1); } +struct dbwrap_store_state { + TDB_DATA data; + int flags; + NTSTATUS status; +}; + +static void dbwrap_store_fn(struct db_record *rec, void *private_data) +{ + struct dbwrap_store_state *state = private_data; + state->status = dbwrap_record_store(rec, state->data, state->flags); +} + NTSTATUS dbwrap_store(struct db_context *db, TDB_DATA key, TDB_DATA data, int flags) { - struct db_record *rec; + struct dbwrap_store_state state = { .data = data, .flags = flags }; NTSTATUS status; - TALLOC_CTX *frame = talloc_stackframe(); - rec = dbwrap_fetch_locked(db, frame, key); - if (rec == NULL) { - TALLOC_FREE(frame); - return NT_STATUS_NO_MEMORY; + status = dbwrap_do_locked(db, key, dbwrap_store_fn, &state); + if (!NT_STATUS_IS_OK(status)) { + return status; } - status = dbwrap_record_store(rec, data, flags); - TALLOC_FREE(frame); - return status; + return state.status; } NTSTATUS dbwrap_delete(struct db_context *db, TDB_DATA key) |