From bbadc81d533d0abf122806a0aa6bd90868081fef Mon Sep 17 00:00:00 2001 From: Gregory Burd Date: Mon, 15 Jul 2013 16:51:08 -0400 Subject: [PATCH] Queue depth and num workers can race, so make sure that we start at least one worker when there are none active for that queue. --- c_src/async_nif.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c_src/async_nif.h b/c_src/async_nif.h index 07b2d39..b62f9f2 100644 --- a/c_src/async_nif.h +++ b/c_src/async_nif.h @@ -347,7 +347,7 @@ async_nif_enqueue_req(struct async_nif_state* async_nif, struct async_nif_req_en /* We've selected a queue for this new request now check to make sure there are enough workers actively processing requests on this queue. */ - if (q->depth > q->num_workers) + if (q->depth > q->num_workers || q->num_workers == 0) if (async_nif_start_worker(async_nif, q) == 0) q->num_workers++; /* Build the term before releasing the lock so as not to race on the use of