summaryrefslogtreecommitdiffstats
path: root/src/classifiers
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-12-14 19:03:43 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-12-14 19:03:43 +0300
commit9f300615e8fca8076266de1a220c74a226d09979 (patch)
treefdc9f00222cb59f72a39c67431e06f958fea89be /src/classifiers
parent2293622f1de6455d1356abdc5ff7187815c184ec (diff)
downloadrspamd-9f300615e8fca8076266de1a220c74a226d09979.tar.gz
rspamd-9f300615e8fca8076266de1a220c74a226d09979.zip
* Fix symbols cache (init lua filters before symbols cache initialization)
* Remove LRU expiration logic from statfiles and replace it with random/lowerest value expiration logic: expire random block or block with lowerest value ! statfiles are incompatible again
Diffstat (limited to 'src/classifiers')
-rw-r--r--src/classifiers/winnow.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/classifiers/winnow.c b/src/classifiers/winnow.c
index 7e1144ae7..4b1bd5549 100644
--- a/src/classifiers/winnow.c
+++ b/src/classifiers/winnow.c
@@ -54,7 +54,12 @@ classify_callback (gpointer key, gpointer value, gpointer data)
/* Consider that not found blocks have value 1 */
v = statfile_pool_get_block (cd->pool, cd->file, node->h1, node->h2, cd->now);
if (fabs (v) > 0.00001) {
- cd->sum += v;
+ if (cd->sum + v > G_MAXDOUBLE / 2.) {
+ cd->sum = G_MAXDOUBLE / 2.;
+ }
+ else {
+ cd->sum += v;
+ }
cd->in_class++;
}
@@ -80,10 +85,23 @@ learn_callback (gpointer key, gpointer value, gpointer data)
}
else {
statfile_pool_set_block (cd->pool, cd->file, node->h1, node->h2, cd->now, v * c);
- node->value = v * c;
+ /* Set some limit on growing */
+ if (v > G_MAXDOUBLE / 2.) {
+ node->value = v;
+ }
+ else {
+ node->value = v * c;
+ }
}
- cd->sum += node->value;
+
+ if (cd->sum + node->value > G_MAXDOUBLE / 2.) {
+ cd->sum = G_MAXDOUBLE / 2.;
+ }
+ else {
+ cd->sum += node->value;
+ }
+
cd->count++;
return FALSE;