From b9b3abe264bd5d1e88326a5c961ca9abef90cad4 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 8 Feb 2014 07:42:53 +1100 Subject: [PATCH] Make the pthread cond wait in the getwork scheduler a timed wait in case we miss a wakeup. --- sgminer.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sgminer.c b/sgminer.c index f3587f91..c1c4774c 100644 --- a/sgminer.c +++ b/sgminer.c @@ -8143,6 +8143,8 @@ begin_bench: int ts, max_staged = opt_queue; struct pool *pool, *cp; bool lagging = false; + struct timespec then; + struct timeval now; struct work *work; if (opt_work_update) @@ -8155,6 +8157,10 @@ begin_bench: if (!pool_localgen(cp) && !staged_rollable) max_staged += mining_threads; + cgtime(&now); + then.tv_sec = now.tv_sec + 2; + then.tv_nsec = now.tv_usec * 1000; + mutex_lock(stgd_lock); ts = __total_staged(); @@ -8163,7 +8169,7 @@ begin_bench: /* Wait until hash_pop tells us we need to create more work */ if (ts > max_staged) { - pthread_cond_wait(&gws_cond, stgd_lock); + pthread_cond_timedwait(&gws_cond, stgd_lock, &then); ts = __total_staged(); } mutex_unlock(stgd_lock);