Browse Source

Merge commit '6972ec6' into cg_merges_20130606a

Conflicts:
	miner.c
Luke Dashjr 12 years ago
parent
commit
0adb40f54d
3 changed files with 9 additions and 4 deletions
  1. 3 3
      deviceapi.c
  2. 4 1
      miner.c
  3. 2 0
      miner.h

+ 3 - 3
deviceapi.c

@@ -157,7 +157,7 @@ void minerloop_scanhash(struct thr_info *mythr)
 	pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
 #endif
 	
-	while (1) {
+	while (likely(!cgpu->shutdown)) {
 		mythr->work_restart = false;
 		request_work(mythr);
 		work = get_and_prepare_work(mythr);
@@ -401,7 +401,7 @@ void minerloop_async(struct thr_info *mythr)
 	if (mythr->work_restart_notifier[1] == -1)
 		notifier_init(mythr->work_restart_notifier);
 	
-	while (1) {
+	while (likely(!cgpu->shutdown)) {
 		tv_timeout.tv_sec = -1;
 		gettimeofday(&tv_now, NULL);
 		for (proc = cgpu; proc; proc = proc->next_proc)
@@ -486,7 +486,7 @@ void minerloop_queue(struct thr_info *thr)
 	if (thr->work_restart_notifier[1] == -1)
 		notifier_init(thr->work_restart_notifier);
 	
-	while (1) {
+	while (likely(!cgpu->shutdown)) {
 		tv_timeout.tv_sec = -1;
 		gettimeofday(&tv_now, NULL);
 		for (proc = cgpu; proc; proc = proc->next_proc)

+ 4 - 1
miner.c

@@ -3496,6 +3496,9 @@ static void __kill_work(void)
 		thr = get_thread(i);
 		if (thr->cgpu->threads)
 		{
+			struct device_drv *drv = thr->cgpu->drv;
+
+			drv->thread_shutdown(thr);
 			thr_info_cancel(thr);
 			pthread_join(thr->pth, NULL);
 		}
@@ -7266,7 +7269,7 @@ void hash_queued_work(struct thr_info *mythr)
 	const int thr_id = mythr->id;
 	int64_t hashes_done = 0;
 
-	while (42) {
+	while (likely(!cgpu->shutdown)) {
 		struct timeval diff;
 		int64_t hashes;
 

+ 2 - 0
miner.h

@@ -553,6 +553,8 @@ struct cgpu_info {
 	pthread_rwlock_t qlock;
 	struct work *queued_work;
 	unsigned int queued_count;
+
+	bool shutdown;
 };
 
 extern void renumber_cgpu(struct cgpu_info *);