From 326cf675b2d32b99c37a12acd45d116ee202cea8 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Wed, 9 Oct 2013 12:51:34 -0400 Subject: [PATCH] fixed a dead loop when n_threads==1 --- kthread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kthread.c b/kthread.c index 8260db0..0833cfd 100644 --- a/kthread.c +++ b/kthread.c @@ -87,7 +87,7 @@ static inline int steal_work(kt_for_t *f) // steal work from the worker with the for (i = 0; i < f->n; ++i) if (max < dq_size(f->w[i].q)) // max is not accurate as other workers may steal from the same queue, but it does not matter. max = dq_size(f->w[i].q), max_i = i; - if (dq_deq(f->w[max_i].q, 0, &k) < 0) k = -1; + if (max_i < 0 || dq_deq(f->w[max_i].q, 0, &k) < 0) k = -1; return k; } -- 2.47.3