]> xenbits.xensource.com Git - libvirt.git/commitdiff
threadpool: Don't wait on condition if pool has no workers
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 9 Dec 2011 14:12:37 +0000 (15:12 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 9 Dec 2011 14:25:46 +0000 (15:25 +0100)
Pool creates new workers dynamically. However, it is possible
for a pool to have no workers. If we want to free that pool,
we don't want to wait on quit condition as it will never be
signaled.

src/util/threadpool.c

index c16e2aff6046d521656368e631e39212feb20606..883d1e5bddd856e479b7caa8c0ab7b77a6232300 100644 (file)
@@ -258,7 +258,8 @@ void virThreadPoolFree(virThreadPoolPtr pool)
         virCondBroadcast(&pool->prioCond);
     }
 
-    ignore_value(virCondWait(&pool->quit_cond, &pool->mutex));
+    if (pool->nWorkers > 0 || pool->nPrioWorkers > 0)
+        ignore_value(virCondWait(&pool->quit_cond, &pool->mutex));
 
     while ((job = pool->jobList.head)) {
         pool->jobList.head = pool->jobList.head->next;