diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-12-16 18:37:50 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-12-16 18:37:50 +0300 |
commit | 4b1dbdccc7067ff71565b48c1e9722c152a83a4a (patch) | |
tree | fb132da61adc0b98e725a17ecd266a5cfb6da14d /src/kvstorage.c | |
parent | b272d240f712e15a93478db124cbf4bd8f7496af (diff) | |
download | rspamd-4b1dbdccc7067ff71565b48c1e9722c152a83a4a.tar.gz rspamd-4b1dbdccc7067ff71565b48c1e9722c152a83a4a.zip |
Add expire and whitelist options to ip_score plugin.
Some fixes to expiration of keys (still need to be reworked however).
Diffstat (limited to 'src/kvstorage.c')
-rw-r--r-- | src/kvstorage.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/kvstorage.c b/src/kvstorage.c index 76e58adba..76def504e 100644 --- a/src/kvstorage.c +++ b/src/kvstorage.c @@ -341,8 +341,14 @@ rspamd_kv_storage_increment (struct rspamd_kv_storage *storage, gpointer key, gu } if (elt && (elt->flags & KV_ELT_INTEGER) != 0) { lp = &ELT_LONG (elt); - *lp += *value; - *value = *lp; + /* Handle need expire here */ + if (elt->flags & KV_ELT_NEED_EXPIRE) { + *lp = *value; + } + else { + *lp += *value; + *value = *lp; + } elt->age = time (NULL); if (storage->backend) { if (storage->backend->replace_func (storage->backend, key, keylen, elt)) { @@ -394,6 +400,8 @@ rspamd_kv_storage_lookup (struct rspamd_kv_storage *storage, gpointer key, guint if (elt && (elt->flags & KV_ELT_PERSISTENT) == 0 && elt->expire > 0) { /* Check expiration */ if (now - elt->age > elt->expire) { + /* Set need expire as we have no write lock here */ + elt->flags |= KV_ELT_NEED_EXPIRE; elt = NULL; } } |