Store last_getwork time on a per-device basis.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
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;