Reuse times extracted from the clock in bflsc_get_results.
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
diff --git a/driver-bflsc.c b/driver-bflsc.c
index 8b76f20..7fb91f9 100644
--- a/driver-bflsc.c
+++ b/driver-bflsc.c
@@ -1387,6 +1387,7 @@ static void *bflsc_get_results(void *userdata)
struct cgpu_info *bflsc = (struct cgpu_info *)userdata;
struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
struct timeval elapsed, now;
+ cgtimer_t ts_start;
float oldest, f;
char buf[BFLSC_BUFSIZ+1];
int err, amount;
@@ -1401,14 +1402,13 @@ static void *bflsc_get_results(void *userdata)
}
while (sc_info->shutdown == false) {
- cgtimer_t ts_start;
-
if (bflsc->usbinfo.nodev)
return NULL;
dev = -1;
oldest = FLT_MAX;
- cgtime(&now);
+ cgsleep_prepare_r(&ts_start);
+ cgtimer_to_timeval(&now, &ts_start);
// Find the first oldest ... that also needs checking
for (i = 0; i < sc_info->sc_count; i++) {
@@ -1420,10 +1420,12 @@ static void *bflsc_get_results(void *userdata)
}
}
- if (bflsc->usbinfo.nodev)
+ if (bflsc->usbinfo.nodev) {
+ /* To clean up the setup timer */
+ cgsleep_ms_r(&ts_start, 0);
return NULL;
+ }
- cgsleep_prepare_r(&ts_start);
if (dev == -1) {
/* Sleep for only half a work period before checking
* again. */
@@ -1431,7 +1433,7 @@ static void *bflsc_get_results(void *userdata)
continue;
}
- cgtime(&(sc_info->sc_devs[dev].last_check_result));
+ copy_time(&sc_info->sc_devs[dev].last_check_result, &now);
readok = bflsc_qres(bflsc, buf, sizeof(buf), dev, &err, &amount, false);
if (err < 0 || (!readok && amount != BFLSC_QRES_LEN) || (readok && amount < 1)) {
@@ -1439,10 +1441,13 @@ static void *bflsc_get_results(void *userdata)
} else {
que = process_results(bflsc, dev, buf, &nonces);
sc_info->not_first_work = true; // in case it failed processing it
- if (que > 0)
- cgtime(&(sc_info->sc_devs[dev].last_dev_result));
- if (nonces > 0)
- cgtime(&(sc_info->sc_devs[dev].last_nonce_result));
+ if (que > 0 || nonces > 0) {
+ cgtime(&now);
+ if (que > 0)
+ copy_time(&sc_info->sc_devs[dev].last_dev_result, &now);
+ if (nonces > 0)
+ copy_time(&sc_info->sc_devs[dev].last_nonce_result, &now);
+ }
// TODO: if not getting results ... reinit?
}