Commit 894a3d64f0d8e9ae57cd654e92cf27c328076bc3

Con Kolivas 2013-05-19T12:55:20

Properly pthread_join miner threads on shutdown.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/cgminer.c b/cgminer.c
index 439de24..102a370 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2804,10 +2804,14 @@ static void __kill_work(void)
 	applog(LOG_DEBUG, "Killing off mining threads");
 	/* Kill the mining threads*/
 	for (i = 0; i < mining_threads; i++) {
+		pthread_t *pth = NULL;
+
 		thr = get_thread(i);
+		if (thr && PTH(thr) != 0L)
+			pth = &thr->pth;
 		thr_info_cancel(thr);
-		if (thr && thr->pth)
-			pthread_join(thr->pth, NULL);
+		if (pth)
+			pthread_join(*pth, NULL);
 	}
 
 	applog(LOG_DEBUG, "Killing off stage thread");