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)
committerAndreas Schneider <asn@samba.org>
Wed, 25 Apr 2012 12:31:11 +0000 (14:31 +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.

Signed-off-by: Andreas Schneider <asn@samba.org>
source3/registry/reg_backend_db.c

index 24f6a72b953d30e8da1f534c8d6c8dcba2d017cb..d4f52b7571ab91b7bff6411a5b8ecaea0b032ea0 100644 (file)
@@ -1902,6 +1902,7 @@ static NTSTATUS regdb_store_values_internal(struct db_context *db,
        TALLOC_CTX *ctx = talloc_stackframe();
        int len;
        NTSTATUS status;
+       WERROR werr;
 
        DEBUG(10,("regdb_store_values: Looking for values of key [%s]\n", key));
 
@@ -1911,7 +1912,16 @@ static NTSTATUS regdb_store_values_internal(struct db_context *db,
        }
 
        if (regval_ctr_numvals(values) == 0) {
-               WERROR werr = regdb_delete_values(db, key);
+               werr = regdb_delete_values(db, key);
+               if (!W_ERROR_IS_OK(werr)) {
+                       return werror_to_ntstatus(werr);
+               }
+
+               /*
+                * update the seqnum in the cache to prevent the next read
+                * from going to disk
+                */
+               werr = regval_ctr_set_seqnum(values, dbwrap_get_seqnum(db));
                return werror_to_ntstatus(werr);
        }
 
@@ -1954,6 +1964,17 @@ static NTSTATUS regdb_store_values_internal(struct db_context *db,
        }
 
        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;
+       }
+
+       /*
+        * update the seqnum in the cache to prevent the next read
+        * from going to disk
+        */
+       werr = regval_ctr_set_seqnum(values, dbwrap_get_seqnum(db));
+       status = werror_to_ntstatus(werr);
 
 done:
        TALLOC_FREE(ctx);