diff options
author | Michael Adam <obnox@samba.org> | 2008-01-14 18:31:11 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2008-01-14 19:38:01 +0100 |
commit | d35bda0ffd5bea57087dba9a6da8c20df8fa165c (patch) | |
tree | 40be9067b2d4fb2090d53c1da1466848d47e0af3 /source3/registry/reg_db.c | |
parent | 36a7316bfc9d7582ccd908f2b9d96e0fe983e884 (diff) | |
download | samba-d35bda0ffd5bea57087dba9a6da8c20df8fa165c.tar.gz samba-d35bda0ffd5bea57087dba9a6da8c20df8fa165c.tar.bz2 samba-d35bda0ffd5bea57087dba9a6da8c20df8fa165c.zip |
Add detection for need of update to the registry db.
This only detects if the tdb sequence number has changed
since the data has last been read.
Michael
(This used to be commit 3f081ebeadf30a7943723703ecae479e0412c60c)
Diffstat (limited to 'source3/registry/reg_db.c')
-rw-r--r-- | source3/registry/reg_db.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/source3/registry/reg_db.c b/source3/registry/reg_db.c index f50a41816c..c4bfc2b6c9 100644 --- a/source3/registry/reg_db.c +++ b/source3/registry/reg_db.c @@ -622,7 +622,15 @@ int regdb_fetch_keys(const char *key, REGSUBKEY_CTR *ctr) } strupper_m(path); + if (tdb_read_lock_bystring_with_timeout(tdb_reg->tdb, path, 10) == -1) { + return 0; + } + dbuf = tdb_fetch_bystring(tdb_reg->tdb, path); + ctr->seqnum = regdb_get_seqnum(); + + tdb_read_unlock_bystring(tdb_reg->tdb, path); + buf = dbuf.dptr; buflen = dbuf.dsize; @@ -750,7 +758,14 @@ int regdb_fetch_values( const char* key, REGVAL_CTR *values ) return 0; } + if (tdb_read_lock_bystring_with_timeout(tdb_reg->tdb, keystr, 10) == -1) { + return 0; + } + data = tdb_fetch_bystring(tdb_reg->tdb, keystr); + values->seqnum = regdb_get_seqnum(); + + tdb_read_unlock_bystring(tdb_reg->tdb, keystr); if (!data.dptr) { /* all keys have zero values by default */ @@ -907,6 +922,16 @@ static WERROR regdb_set_secdesc(const char *key, return err; } +bool regdb_subkeys_need_update(REGSUBKEY_CTR *subkeys) +{ + return (regdb_get_seqnum() != subkeys->seqnum); +} + +bool regdb_values_need_update(REGVAL_CTR *values) +{ + return (regdb_get_seqnum() != values->seqnum); +} + /* * Table of function pointers for default access */ @@ -918,5 +943,7 @@ REGISTRY_OPS regdb_ops = { regdb_store_values, NULL, regdb_get_secdesc, - regdb_set_secdesc + regdb_set_secdesc, + regdb_subkeys_need_update, + regdb_values_need_update }; |