From b19ee2f5f5d31bae703cd59e9c8cc947b66f17a0 Mon Sep 17 00:00:00 2001 From: ckolivas Date: Fri, 24 Jun 2011 09:39:33 +1000 Subject: [PATCH] Make sure a GPU doesn't work on a block longer than opt_scantime. --- cpu-miner.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cpu-miner.c b/cpu-miner.c index 998e8811..09681602 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -833,12 +833,13 @@ static void *gpuminer_thread(void *userdata) localThreads[0] = clState->max_work_size / vectors; while (1) { - struct timeval tv_end, diff; + struct timeval tv_end, diff, tv_workstart; unsigned int i; clFinish(clState->commandQueue); if (need_work) { + gettimeofday(&tv_workstart, NULL); /* obtain new work from internal workio thread */ if (unlikely(!get_work(mythr, work))) { applog(LOG_ERR, "work retrieval failed, exiting " @@ -897,6 +898,11 @@ static void *gpuminer_thread(void *userdata) gettimeofday(&tv_start, NULL); work->blk.nonce += hashes_done; + timeval_subtract(&diff, &tv_end, &tv_workstart); + if (diff.tv_sec > opt_scantime) { + need_work = true; + continue; + } if (unlikely(work->blk.nonce > MAXTHREADS - hashes_done) || (work_restart[thr_id].restart))