Add job queue check on total workers size

Without this there could be a race condition where a job could create a
new worker during shutdown, and end up causing an assert failure.
This commit is contained in:
Jason Rhinelander 2020-03-29 15:43:17 -03:00
parent 4c470f3e33
commit 6ba70923b9
1 changed files with 2 additions and 2 deletions

View File

@ -28,8 +28,8 @@ void LokiMQ::proxy_schedule_reply_job(std::function<void()> f) {
}
void LokiMQ::proxy_run_batch_jobs(std::queue<batch_job>& jobs, const int reserved, int& active, bool reply) {
while (!jobs.empty() &&
(active < reserved || static_cast<int>(workers.size() - idle_workers.size()) < general_workers)) {
while (!jobs.empty() && static_cast<int>(workers.size()) < max_workers &&
(active < reserved || active_workers() < general_workers)) {
proxy_run_worker(get_idle_worker().load(std::move(jobs.front()), reply));
jobs.pop();
active++;