Multiscan queues a lot of scan tasks. If thread_idle wasn't zero when multiscan

started queueing, it will only spawn at most one thread, and keep queueing
without spawning more threads (because threads_idle now non-zero), but the idle
thread doesn't get a chance to pick up the tasks.

Fix this by testing whether we have enough idle threads to pick up the items in
the work queue. If there aren't then spawn some more until max limit is reached,
or we have enough idle threads to handle all tasks in the queue.

git-svn: trunk@4066
0.95
Török Edvin 17 years ago
parent 6484d65227
commit 4a0bd44290
  1. 2
      clamd/thrmgr.c

@ -304,7 +304,7 @@ int thrmgr_dispatch(threadpool_t *threadpool, void *user_data)
return FALSE;
}
if ((threadpool->thr_idle == 0) &&
if ((threadpool->thr_idle < threadpool->queue->item_count) &&
(threadpool->thr_alive < threadpool->thr_max)) {
/* Start a new thread */
if (pthread_create(&thr_id, &(threadpool->pool_attr),

Loading…
Cancel
Save