From ca56054a5a62b96904642580f83f1a871b607ffb Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 11 Apr 2012 15:38:29 +0200 Subject: [PATCH] s3:registry:db: update the value container seqnum after storing/deleting to prevent next read from going to disk if possible Note that this will currently only be effective in the local TDB implementation. For CTDB, this wont work since seqnum currently works differently there (needs fixing): For tdb, store and delete operations bump the db seqnum, while transaction commits don't. For ctdb, the seqnum is bumped by the transaction commit but not by store and delete operations. (cherry picked from commit 13347d11c0e918f82e7e3c21125acc5e241d389f) (cherry picked from commit f4d800d8d010e638d37d993d8eef00645398f811) --- source3/registry/reg_backend_db.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c index 2fa7f584dea..aaa2241997a 100644 --- a/source3/registry/reg_backend_db.c +++ b/source3/registry/reg_backend_db.c @@ -1805,6 +1805,7 @@ static bool regdb_store_values_internal(struct db_context *db, const char *key, int len; NTSTATUS status; bool result = false; + WERROR werr; DEBUG(10,("regdb_store_values: Looking for values of key [%s]\n", key)); @@ -1847,8 +1848,17 @@ static bool regdb_store_values_internal(struct db_context *db, const char *key, } status = dbwrap_trans_store_bystring(db, keystr, data, TDB_REPLACE); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("regdb_store_values_internal: error storing: %s\n", nt_errstr(status))); + goto done; + } - result = NT_STATUS_IS_OK(status); + /* + * update the seqnum in the cache to prevent the next read + * from going to disk + */ + werr = regval_ctr_set_seqnum(values, db->get_seqnum(db)); + result = W_ERROR_IS_OK(status); done: TALLOC_FREE(ctx); -- 2.11.4.GIT