mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
ldb_tdb: Remove tdb_get_seqnum and use a generic 'has_changed'
Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
e21a476c27
commit
c66a0054fb
@ -391,8 +391,7 @@ int ltdb_cache_load(struct ldb_module *module)
|
||||
ldb = ldb_module_get_ctx(module);
|
||||
|
||||
/* a very fast check to avoid extra database reads */
|
||||
if (ltdb->cache != NULL &&
|
||||
tdb_get_seqnum(ltdb->tdb) == ltdb->tdb_seqnum) {
|
||||
if (ltdb->cache != NULL && !ltdb->kv_ops->has_changed(ltdb)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -432,7 +431,8 @@ int ltdb_cache_load(struct ldb_module *module)
|
||||
}
|
||||
}
|
||||
|
||||
ltdb->tdb_seqnum = tdb_get_seqnum(ltdb->tdb);
|
||||
/* Ignore the result, and update the sequence number */
|
||||
ltdb->kv_ops->has_changed(ltdb);
|
||||
|
||||
/* if the current internal sequence number is the same as the one
|
||||
in the database then assume the rest of the cache is OK */
|
||||
@ -594,7 +594,7 @@ int ltdb_increase_sequence_number(struct ldb_module *module)
|
||||
|
||||
/* updating the tdb_seqnum here avoids us reloading the cache
|
||||
records due to our own modification */
|
||||
ltdb->tdb_seqnum = tdb_get_seqnum(ltdb->tdb);
|
||||
ltdb->kv_ops->has_changed(ltdb);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1714,6 +1714,15 @@ static const char * ltdb_tdb_name(struct ltdb_private *ltdb)
|
||||
return tdb_name(ltdb->tdb);
|
||||
}
|
||||
|
||||
static bool ltdb_tdb_changed(struct ltdb_private *ltdb)
|
||||
{
|
||||
bool ret = (tdb_get_seqnum(ltdb->tdb) != ltdb->tdb_seqnum);
|
||||
|
||||
ltdb->tdb_seqnum = tdb_get_seqnum(ltdb->tdb);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct kv_db_ops key_value_ops = {
|
||||
.store = ltdb_tdb_store,
|
||||
.delete = ltdb_tdb_delete,
|
||||
@ -1725,6 +1734,7 @@ static const struct kv_db_ops key_value_ops = {
|
||||
.abort_write = ltdb_tdb_transaction_cancel,
|
||||
.error = ltdb_error,
|
||||
.name = ltdb_tdb_name,
|
||||
.has_changed = ltdb_tdb_changed,
|
||||
};
|
||||
|
||||
static void ltdb_callback(struct tevent_context *ev,
|
||||
|
@ -16,6 +16,7 @@ struct kv_db_ops {
|
||||
int (*finish_write)(struct ltdb_private *);
|
||||
int (*error)(struct ltdb_private *ltdb);
|
||||
const char * (*name)(struct ltdb_private *ltdb);
|
||||
bool (*has_changed)(struct ltdb_private *ltdb);
|
||||
};
|
||||
|
||||
/* this private structure is used by the ltdb backend in the
|
||||
|
Loading…
Reference in New Issue
Block a user