s3:registry:db: update the value container seqnum after storing/deleting to prevent...
authorMichael Adam <obnox@samba.org>
Wed, 11 Apr 2012 13:38:29 +0000 (15:38 +0200)
committerKarolin Seeger <kseeger@samba.org>
Thu, 10 May 2012 09:15:29 +0000 (11:15 +0200)
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)

source3/registry/reg_backend_db.c

index 2fa7f584dea90780bd924cd232bf88b58d16a861..aaa2241997ac7d83956412458fabedbfeb2f7369 100644 (file)
@@ -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);