Browse Source

Only free the thread structures if the thread still exists.

Con Kolivas 14 years ago
parent
commit
6f905932af
1 changed files with 5 additions and 4 deletions
  1. 5 4
      main.c

+ 5 - 4
main.c

@@ -3149,15 +3149,16 @@ static void *reinit_gpu(void *userdata)
 		thr = &thr_info[thr_id];
 		thr = &thr_info[thr_id];
 		thr->rolling = thr->cgpu->rolling = 0;
 		thr->rolling = thr->cgpu->rolling = 0;
 		tq_freeze(thr->q);
 		tq_freeze(thr->q);
-		if (!pthread_cancel(*thr->pth))
+		if (!pthread_cancel(*thr->pth)) {
 			pthread_join(*thr->pth, NULL);
 			pthread_join(*thr->pth, NULL);
-		free(thr->q);
+			free(thr->q);
+			free(clStates[thr_id]);
+		}
+
 		thr->q = tq_new();
 		thr->q = tq_new();
 		if (!thr->q)
 		if (!thr->q)
 			quit(1, "Failed to tq_new in reinit_gputhread");
 			quit(1, "Failed to tq_new in reinit_gputhread");
 
 
-		free(clStates[thr_id]);
-
 		applog(LOG_INFO, "Reinit GPU thread %d", thr_id);
 		applog(LOG_INFO, "Reinit GPU thread %d", thr_id);
 		clStates[thr_id] = initCl(gpu, name, sizeof(name));
 		clStates[thr_id] = initCl(gpu, name, sizeof(name));
 		if (!clStates[thr_id]) {
 		if (!clStates[thr_id]) {