MINOR: thread: make wake_thread() take care of the sleeping threads mask
Almost every call place of wake_thread() checks for sleeping threads and
clears the sleeping mask itself, while the function is solely used for
there. Let's move the check and the clearing of the bit inside the function
itself. Note that updt_fd_polling() still performs the check because its
rules are a bit different.
diff --git a/src/task.c b/src/task.c
index fc698d5..76a7432 100644
--- a/src/task.c
+++ b/src/task.c
@@ -86,10 +86,7 @@
list_to_mt_list(&((struct tasklet *)t)->list));
_HA_ATOMIC_INC(&ha_thread_ctx[thr].rq_total);
_HA_ATOMIC_INC(&ha_thread_ctx[thr].tasks_in_list);
- if (sleeping_thread_mask & (1UL << thr)) {
- _HA_ATOMIC_AND(&sleeping_thread_mask, ~(1UL << thr));
- wake_thread(thr);
- }
+ wake_thread(thr);
return;
}
}
@@ -124,10 +121,7 @@
MT_LIST_APPEND(&ha_thread_ctx[thr].shared_tasklet_list,
list_to_mt_list(&t->list));
_HA_ATOMIC_INC(&ha_thread_ctx[thr].rq_total);
- if (sleeping_thread_mask & (1UL << thr)) {
- _HA_ATOMIC_AND(&sleeping_thread_mask, ~(1UL << thr));
- wake_thread(thr);
- }
+ wake_thread(thr);
return;
}
}
@@ -168,10 +162,7 @@
/* this tasklet runs on a specific thread. */
MT_LIST_APPEND(&ha_thread_ctx[thr].shared_tasklet_list, list_to_mt_list(&tl->list));
_HA_ATOMIC_INC(&ha_thread_ctx[thr].rq_total);
- if (sleeping_thread_mask & (1UL << thr)) {
- _HA_ATOMIC_AND(&sleeping_thread_mask, ~(1UL << thr));
- wake_thread(thr);
- }
+ wake_thread(thr);
}
}
@@ -262,12 +253,7 @@
/* If all threads that are supposed to handle this task are sleeping,
* wake one.
*/
- if (sleeping_thread_mask & (1UL << thr)) {
- unsigned long m = 1UL << thr;
-
- _HA_ATOMIC_AND(&sleeping_thread_mask, ~m);
- wake_thread(thr);
- }
+ wake_thread(thr);
}
#endif
return;