diff --git a/cgminer.c b/cgminer.c index cab06727..30c51cbe 100644 --- a/cgminer.c +++ b/cgminer.c @@ -3590,7 +3590,7 @@ static void discard_stale(void) * work restart is required. Returns the value of pthread_cond_timedwait * which is zero if the condition was met or ETIMEDOUT if not. */ -int restart_wait(unsigned int mstime) +int restart_wait(struct thr_info *thr, unsigned int mstime) { struct timeval now, then, tdiff; struct timespec abstime; @@ -3604,7 +3604,10 @@ int restart_wait(unsigned int mstime) abstime.tv_nsec = then.tv_usec * 1000; mutex_lock(&restart_lock); - rc = pthread_cond_timedwait(&restart_cond, &restart_lock, &abstime); + if (thr->work_restart) + rc = ETIMEDOUT; + else + rc = pthread_cond_timedwait(&restart_cond, &restart_lock, &abstime); mutex_unlock(&restart_lock); return rc; diff --git a/driver-bflsc.c b/driver-bflsc.c index dac33f7b..55dc827a 100644 --- a/driver-bflsc.c +++ b/driver-bflsc.c @@ -1740,7 +1740,7 @@ static int64_t bflsc_scanwork(struct thr_info *thr) } } - waited = restart_wait(sc_info->scan_sleep_time); + waited = restart_wait(thr, sc_info->scan_sleep_time); if (waited == ETIMEDOUT) { unsigned int old_sleep_time, new_sleep_time = 0; int min_queued = sc_info->que_size; diff --git a/driver-bitforce.c b/driver-bitforce.c index 07a26831..9afa36d1 100644 --- a/driver-bitforce.c +++ b/driver-bitforce.c @@ -678,7 +678,7 @@ static int64_t bitforce_scanhash(struct thr_info *thr, struct work *work, int64_ send_ret = bitforce_send_work(thr, work); - if (!restart_wait(bitforce->sleep_ms)) + if (!restart_wait(thr, bitforce->sleep_ms)) return 0; bitforce->wait_ms = bitforce->sleep_ms; diff --git a/miner.h b/miner.h index 36ed5263..a87d1a5f 100644 --- a/miner.h +++ b/miner.h @@ -945,7 +945,7 @@ extern pthread_cond_t restart_cond; extern void thread_reportin(struct thr_info *thr); extern void clear_stratum_shares(struct pool *pool); extern void set_target(unsigned char *dest_target, double diff); -extern int restart_wait(unsigned int mstime); +extern int restart_wait(struct thr_info *thr, unsigned int mstime); extern void kill_work(void);