diff options
author | Michael Adam <obnox@samba.org> | 2012-04-11 15:38:29 +0200 |
---|---|---|
committer | Andreas Schneider <asn@samba.org> | 2012-04-25 14:31:11 +0200 |
commit | 4367071f62d2994f1d3d4f33d45fcd6b4c7bec26 (patch) | |
tree | b510762bd4110c3990a16fa6a7dafb26609ce319 | |
parent | 8c7047b0e7b1ee25a6a5535cf495c9afded2d924 (diff) | |
download | samba-4367071f62d2994f1d3d4f33d45fcd6b4c7bec26.tar.gz samba-4367071f62d2994f1d3d4f33d45fcd6b4c7bec26.tar.bz2 samba-4367071f62d2994f1d3d4f33d45fcd6b4c7bec26.zip |
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.
Signed-off-by: Andreas Schneider <asn@samba.org>
-rw-r--r-- | source3/registry/reg_backend_db.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c index 24f6a72b95..d4f52b7571 100644 --- a/source3/registry/reg_backend_db.c +++ b/source3/registry/reg_backend_db.c @@ -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); |