aboutsummaryrefslogtreecommitdiffstats
path: root/src/kvstorage.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-11-01 19:48:08 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-11-01 19:48:08 +0300
commit7770c0c2ff70150fe33358a461fadf91e01ae23f (patch)
tree74ec845002dbd64b0fafed52e1b228616ffb71dc /src/kvstorage.c
parentd194a7d577985268ff5f7f29379c90d694a8f230 (diff)
downloadrspamd-7770c0c2ff70150fe33358a461fadf91e01ae23f.tar.gz
rspamd-7770c0c2ff70150fe33358a461fadf91e01ae23f.zip
* Add initial support of bdb backend
Diffstat (limited to 'src/kvstorage.c')
-rw-r--r--src/kvstorage.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/kvstorage.c b/src/kvstorage.c
index e628b93ad..ef774dd7d 100644
--- a/src/kvstorage.c
+++ b/src/kvstorage.c
@@ -227,17 +227,21 @@ rspamd_kv_storage_replace (struct rspamd_kv_storage *storage, gpointer key, stru
struct rspamd_kv_element*
rspamd_kv_storage_lookup (struct rspamd_kv_storage *storage, gpointer key, time_t now)
{
- struct rspamd_kv_element *elt = NULL;
+ struct rspamd_kv_element *elt = NULL, *belt;
/* First try to look at cache */
elt = storage->cache->lookup_func (storage->cache, key);
/* Next look at the backend */
if (elt == NULL && storage->backend) {
- elt = storage->backend->lookup_func (storage->backend, key);
- if (elt) {
+ belt = storage->backend->lookup_func (storage->backend, key);
+ if (belt) {
/* Put this element into cache */
- rspamd_kv_storage_insert_internal (storage, elt->key, elt->data, elt->size, elt->flags, elt->expire, &elt);
+ rspamd_kv_storage_insert_internal (storage, belt->key, belt->data, belt->size, belt->flags,
+ belt->expire, &elt);
+ if ((belt->flags & KV_ELT_DIRTY) == 0) {
+ g_free (belt);
+ }
}
}
@@ -263,12 +267,7 @@ rspamd_kv_storage_delete (struct rspamd_kv_storage *storage, gpointer key)
/* Now delete from backend */
if (storage->backend) {
- if (elt == NULL) {
- elt = storage->backend->delete_func (storage->backend, key);
- }
- else {
- storage->backend->delete_func (storage->backend, key);
- }
+ storage->backend->delete_func (storage->backend, key);
}
/* Notify expire */
if (elt) {