From 57c93d7e20cebf9f9cf0855cb4bac8217715e28a Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 26 Aug 2011 13:02:15 +1000 Subject: [PATCH] Prevent segfault on exit for when accessory threads don't exist. --- main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 9daf28ce..f369be4e 100644 --- a/main.c +++ b/main.c @@ -1753,7 +1753,8 @@ void kill_work(void) /* Kill the watchdog thread */ thr = &thr_info[watchdog_thr_id]; - pthread_cancel(*thr->pth); + if (thr->pth) + pthread_cancel(*thr->pth); /* Stop the mining threads*/ for (i = 0; i < mining_threads; i++) { @@ -1767,9 +1768,11 @@ void kill_work(void) /* Stop the others */ thr = &thr_info[stage_thr_id]; - pthread_cancel(*thr->pth); + if (thr->pth) + pthread_cancel(*thr->pth); thr = &thr_info[longpoll_thr_id]; - pthread_cancel(*thr->pth); + if (thr->pth) + pthread_cancel(*thr->pth); wc = calloc(1, sizeof(*wc)); if (unlikely(!wc)) {