mirror of
https://github.com/oxen-io/oxen-mq.git
synced 2023-12-13 21:00:31 +01:00
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) {
|
void LokiMQ::proxy_run_batch_jobs(std::queue<batch_job>& jobs, const int reserved, int& active, bool reply) {
|
||||||
while (!jobs.empty() &&
|
while (!jobs.empty() && static_cast<int>(workers.size()) < max_workers &&
|
||||||
(active < reserved || static_cast<int>(workers.size() - idle_workers.size()) < general_workers)) {
|
(active < reserved || active_workers() < general_workers)) {
|
||||||
proxy_run_worker(get_idle_worker().load(std::move(jobs.front()), reply));
|
proxy_run_worker(get_idle_worker().load(std::move(jobs.front()), reply));
|
||||||
jobs.pop();
|
jobs.pop();
|
||||||
active++;
|
active++;
|
||||||
|
|
Loading…
Reference in a new issue