From 78ed386bb4ab38b31d225ec7c38f53e2b5cb6a60 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 11 Jul 2011 21:20:48 +1000 Subject: [PATCH] Delay any threads from starting till everything is set up properly. --- main.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index 50513542..91a26727 100644 --- a/main.c +++ b/main.c @@ -1902,13 +1902,8 @@ int main (int argc, char *argv[]) return 1; } - /* Put enough work in the queue */ - for (i = 0; i < opt_queue + mining_threads; i++) { - if (unlikely(!queue_request())) { - applog(LOG_ERR, "Failed to queue_request in main"); - return 1; - } - } + /* Flag the work as ready forcing the mining threads to wait till we + * actually put something into the queue */ inc_staged(mining_threads, true); #ifdef HAVE_OPENCL @@ -2005,6 +2000,14 @@ int main (int argc, char *argv[]) move(logcursor, 0); refresh_display(); + /* Now that everything's ready put enough work in the queue */ + for (i = 0; i < opt_queue + mining_threads; i++) { + if (unlikely(!queue_request())) { + applog(LOG_ERR, "Failed to queue_request in main"); + return 1; + } + } + /* main loop - simply wait for workio thread to exit */ pthread_join(thr_info[work_thr_id].pth, NULL); curl_global_cleanup();