INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory /var/run/rspamd/)")
INSTALL(CODE "EXECUTE_PROCESS(COMMAND chown ${RSPAMD_USER}:${RSPAMD_GROUP} /var/run/rspamd/)")
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
+
+# CPack section
+SET(CPACK_DEBIAN_PACKAGE_DEPENDS libevent1 libgmime-2.0-2a)
+SET(CPACK_PACKAGE_CONTACT "vsevolod@highsecure.ru")
+SET(CPACK_PACKAGE_NAME rspamd)
+SET(CPACK_SOURCE_IGNORE_FILES "\\\\.swp$" "/\\\\.hg/")
+SET(CPACK_PACKAGE_VERSION_MAJOR ${RSPAMD_VERSION_MAJOR})
+SET(CPACK_PACKAGE_VERSION_MINOR ${RSPAMD_VERSION_MINOR})
+SET(CPACK_PACKAGE_VERSION_PATCH ${RSPAMD_VERSION_PATCH})
+INCLUDE(CPack)
#include "cfg_file.h"
#define WEIGHT_MULT 2.0
-#define FREQUENCY_MULT 1.0
+#define FREQUENCY_MULT 100.0
#define TIME_MULT -1.0
/* After which number of messages try to resort cache */
#define MIN_CACHE 17
+uint64_t total_frequency;
+
int
cache_cmp (const void *p1, const void *p2)
{
{
const struct cache_item *i1 = p1, *i2 = p2;
double w1, w2;
-
+ int f1 = 0, f2 = 0;
+
+ if (total_frequency > 0) {
+ f1 = i1->s->frequency / total_frequency;
+ f2 = i2->s->frequency / total_frequency;
+ }
w1 = abs (i1->s->weight) * WEIGHT_MULT +
- i1->s->frequency * FREQUENCY_MULT +
+ f1 * FREQUENCY_MULT +
i1->s->avg_time * TIME_MULT;
w2 = abs (i2->s->weight) * WEIGHT_MULT +
- i2->s->frequency * FREQUENCY_MULT +
+ f2 * FREQUENCY_MULT +
i2->s->avg_time * TIME_MULT;
return (int)w2 - w1;
static void
post_cache_init (struct symbols_cache *cache)
{
+ int i;
+
+ total_frequency = 0;
+ for (i = 0; i < cache->used_items; i ++) {
+ total_frequency += cache->items[i].s->frequency;
+ }
+
qsort (cache->items, cache->used_items, sizeof (struct cache_item), cache_logic_cmp);
}