Commit 4aceffc95adc050f7b11f94b1a0133528cdf93a6

Con Kolivas 2014-02-23T15:35:39

Store last_getwork time on a per-device basis.

diff --git a/cgminer.c b/cgminer.c
index e8a348d..749f73c 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -6493,8 +6493,9 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
 
 struct work *get_work(struct thr_info *thr, const int thr_id)
 {
+	struct cgpu_info *cgpu = thr->cgpu;
 	struct work *work = NULL;
-	time_t diff_t;
+	time_t now_t, diff_t;
 
 	thread_reportout(thr);
 	applog(LOG_DEBUG, "Popping work from get queue to get work");
@@ -6507,20 +6508,22 @@ struct work *get_work(struct thr_info *thr, const int thr_id)
 			wake_gws();
 		}
 	}
-	diff_t = time(NULL) - diff_t;
+	now_t = time(NULL);
+	diff_t = now_t - diff_t;
 	/* Since this is a blocking function, we need to add grace time to
 	 * the device's last valid work to not make outages appear to be
 	 * device failures. */
 	if (diff_t > 0) {
 		applog(LOG_DEBUG, "Get work blocked for %d seconds", (int)diff_t);
-		thr->cgpu->last_device_valid_work += diff_t;
+		cgpu->last_device_valid_work += diff_t;
 	}
+	cgpu->last_getwork = now_t;
 	applog(LOG_DEBUG, "Got work from get queue to get work for thread %d", thr_id);
 
 	work->thr_id = thr_id;
 	thread_reportin(thr);
 	work->mined = true;
-	work->device_diff = MIN(thr->cgpu->drv->max_diff, work->work_difficulty);
+	work->device_diff = MIN(cgpu->drv->max_diff, work->work_difficulty);
 	return work;
 }
 
diff --git a/miner.h b/miner.h
index 88833ff..a7bb062 100644
--- a/miner.h
+++ b/miner.h
@@ -484,6 +484,7 @@ struct cgpu_info {
 	int last_share_pool;
 	time_t last_share_pool_time;
 	double last_share_diff;
+	time_t last_getwork;
 	time_t last_device_valid_work;
 
 	time_t device_last_well;