/* This number is used as limit while comparing two fuzzy hashes, this value can vary from 0 to 100 */
#define LEV_LIMIT 99
/* This number is used as limit while we are making decision to write new hash file or not */
-#define MOD_LIMIT 10000
+#define DEFAULT_MOD_LIMIT 10000
/* This number is used as expire time in seconds for cache items (2 days) */
#define DEFAULT_EXPIRE 172800L
/* Resync value in seconds */
/* Number of cache modifications */
static uint32_t mods = 0;
+static uint32_t max_mods = DEFAULT_MOD_LIMIT;
/* Frequent score number */
static uint32_t frequent_score = DEFAULT_FREQUENT_SCORE;
/* For evtimer */
#endif
/* Check for modifications */
- if (mods < MOD_LIMIT) {
+ if (mods < max_mods) {
return;
}
.tv_usec = 0
};
- mods = MOD_LIMIT + 1;
+ mods = max_mods + 1;
sync_cache (worker);
close (worker->cf->listen_sock);
(void)event_loopexit (&tv);
do_reopen_log = 1;
msg_info ("worker's shutdown is pending in %d sec", SOFT_SHUTDOWN_TIME);
event_loopexit (&tv);
+ mods = max_mods + 1;
+ sync_cache (worker);
return;
}
memcpy (s.hash_pipe, cmd->hash, sizeof (s.hash_pipe));
s.block_size = cmd->blocksize;
+ mods ++;
return check_hash_node (hashes[cmd->blocksize % BUCKETS], &s, cmd->value) != NULL;
}
else {
#endif
- g_queue_push_head (hashes[cmd->blocksize % BUCKETS], h);
+ g_queue_push_head (hashes[cmd->blocksize % BUCKETS], h);
#ifdef WITH_JUDY
}
#endif
if (pvalue) {
res = JudySLDel (&jtree, s->hash_pipe, PJE0);
g_free (*pvalue);
+ bloom_del (bf, s->hash_pipe);
+ msg_info ("fuzzy hash was successfully deleted");
+ server_stat->fuzzy_hashes --;
+ mods++;
}
}
else {
if ((value = g_hash_table_lookup (worker->cf->params, "frequent_score")) != NULL) {
frequent_score = strtol (value, NULL, 10);
}
+ if ((value = g_hash_table_lookup (worker->cf->params, "max_mods")) != NULL) {
+ max_mods = strtol (value, NULL, 10);
+ }
if ((value = g_hash_table_lookup (worker->cf->params, "use_judy")) != NULL) {
#ifdef WITH_JUDY
use_judy = TRUE;