aboutsummaryrefslogtreecommitdiffstats
path: root/src/fuzzy_storage.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-26 18:50:03 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-26 18:50:03 +0000
commit86c5962983c4e1f97eccfa8636ebe5bdc88599cc (patch)
treeaa20f30dc112c0f53efa8a6821f2fd4bc16127b9 /src/fuzzy_storage.c
parentef3d454616a1b1bae06f035374a64fbde5bbbfff (diff)
downloadrspamd-86c5962983c4e1f97eccfa8636ebe5bdc88599cc.tar.gz
rspamd-86c5962983c4e1f97eccfa8636ebe5bdc88599cc.zip
Use atomic ops if possible
Diffstat (limited to 'src/fuzzy_storage.c')
-rw-r--r--src/fuzzy_storage.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index f3be2ab68..bde583387 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -288,11 +288,21 @@ rspamd_fuzzy_process_command (struct fuzzy_session *session)
result = rspamd_fuzzy_backend_check (session->ctx->backend, cmd,
session->ctx->expire);
/* XXX: actually, these updates are not atomic, but we don't care */
+#ifndef HAVE_ATOMIC_BUILTINS
server_stat->fuzzy_hashes_checked[session->epoch] ++;
if (result.prob > 0.5) {
server_stat->fuzzy_hashes_found[session->epoch] ++;
}
+#else
+ __atomic_add_fetch (&server_stat->fuzzy_hashes_checked[session->epoch],
+ 1, __ATOMIC_RELEASE);
+
+ if (result.prob > 0.5) {
+ __atomic_add_fetch (&server_stat->fuzzy_hashes_found[session->epoch],
+ 1, __ATOMIC_RELEASE);
+ }
+#endif
}
else {
result.flag = cmd->flag;