From 86c5962983c4e1f97eccfa8636ebe5bdc88599cc Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 26 Nov 2015 18:50:03 +0000 Subject: Use atomic ops if possible --- src/libserver/protocol.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/libserver') diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index d20c50ff8..5cd3589f6 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -1035,13 +1035,22 @@ rspamd_protocol_http_reply (struct rspamd_http_message *msg, action = rspamd_check_action_metric (task, metric_res->score, &required_score, metric_res->metric); if (action <= METRIC_ACTION_NOACTION) { +#ifndef HAVE_ATOMIC_BUILTINS task->worker->srv->stat->actions_stat[action]++; +#else + __atomic_add_fetch (&task->worker->srv->stat->actions_stat[action], + 1, __ATOMIC_RELEASE); +#endif } } /* Increase counters */ - +#ifndef HAVE_ATOMIC_BUILTINS task->worker->srv->stat->messages_scanned++; +#else + __atomic_add_fetch (&task->worker->srv->stat->messages_scanned, + 1, __ATOMIC_RELEASE); +#endif } } -- cgit v1.2.3