summaryrefslogtreecommitdiffstats
path: root/src/libserver/task.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-06-02 16:28:27 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-06-02 16:28:27 +0100
commit6d7f11963edfd5113f32060267695c513613ec1f (patch)
tree72a78414885a7cbeb5d3cdbb7b93c99dc3f60672 /src/libserver/task.c
parent5b79e6254fffc507db1f537f38deaf3b7678369b (diff)
downloadrspamd-6d7f11963edfd5113f32060267695c513613ec1f.tar.gz
rspamd-6d7f11963edfd5113f32060267695c513613ec1f.zip
Use most significant bit, not least significant one.
Diffstat (limited to 'src/libserver/task.c')
-rw-r--r--src/libserver/task.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/libserver/task.c b/src/libserver/task.c
index c7803cabd..0f73c15f1 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -283,17 +283,21 @@ rspamd_task_load_message (struct rspamd_task *task,
static gint
rspamd_task_select_processing_stage (struct rspamd_task *task, guint stages)
{
- gint st;
+ gint st, mask;
- st = ffs (task->processed_stages);
+ mask = task->processed_stages;
- if (st == -1) {
- st = (1 << 0);
+ if (mask == 0) {
+ st = 0;
}
else {
- st = (1 << (st + 1));
+ for (st = 1; mask != 1; st ++) {
+ mask = (unsigned int)mask >> 1;
+ }
}
+ st = 1 << st;
+
if (stages & st) {
return st;
}