diff --git a/src/task.c b/src/task.c index cabfcbe1e..293aefe3b 100644 --- a/src/task.c +++ b/src/task.c @@ -219,11 +219,12 @@ void __task_queue(struct task *task, struct eb_root *wq) void wake_expired_tasks() { struct task_per_thread * const tt = sched; // thread's tasks + int max_processed = global.tune.runqueue_depth; struct task *task; struct eb32_node *eb; __decl_thread(int key); - while (1) { + while (max_processed-- > 0) { lookup_next_local: eb = eb32_lookup_ge(&tt->timers, now_ms - TIMER_LOOK_BACK); if (!eb) { @@ -298,6 +299,8 @@ void wake_expired_tasks() while (1) { HA_RWLOCK_WRLOCK(TASK_WQ_LOCK, &wq_lock); lookup_next: + if (max_processed-- <= 0) + break; eb = eb32_lookup_ge(&timers, now_ms - TIMER_LOOK_BACK); if (!eb) { /* we might have reached the end of the tree, typically because