mirror of https://github.com/oxen-io/oxen-mq.git
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:
parent
4c470f3e33
commit
6ba70923b9
|
@ -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++;
|
||||
|
|
Loading…
Reference in New Issue