Browse Source

Check for thr->work_restart in restart_wait.

Con Kolivas 12 years ago
parent
commit
a61e41a070
4 changed files with 8 additions and 5 deletions
  1. 5 2
      cgminer.c
  2. 1 1
      driver-bflsc.c
  3. 1 1
      driver-bitforce.c
  4. 1 1
      miner.h

+ 5 - 2
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;

+ 1 - 1
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;

+ 1 - 1
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;

+ 1 - 1
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);