diff --git a/main.c b/main.c index b840bce9..11d8b97e 100644 --- a/main.c +++ b/main.c @@ -4549,7 +4549,7 @@ select_cgpu: thr->rolling = thr->cgpu->rolling = 0; /* Reports the last time we tried to revive a sick GPU */ gettimeofday(&thr->sick, NULL); - if (thr->pth && !pthread_cancel(*thr->pth)) { + if (!pthread_cancel(thr->pth)) { applog(LOG_WARNING, "Thread %d still exists, killing it off", thr_id); } else applog(LOG_WARNING, "Thread %d no longer exists", thr_id); @@ -5349,7 +5349,7 @@ int main (int argc, char *argv[]) /* start stage thread */ if (thr_info_create(thr, NULL, stage_thread, thr)) quit(1, "stage thread create failed"); - pthread_detach(*thr->pth); + pthread_detach(thr->pth); /* Create a unique get work queue */ getq = tq_new(); @@ -5525,7 +5525,7 @@ int main (int argc, char *argv[]) thr = &thr_info[input_thr_id]; if (thr_info_create(thr, NULL, input_thread, thr)) quit(1, "input thread create failed"); - pthread_detach(*thr->pth); + pthread_detach(thr->pth); /* Create reinit cpu thread */ cpur_thr_id = mining_threads + 5; @@ -5546,7 +5546,7 @@ int main (int argc, char *argv[]) quit(1, "reinit_gpu thread create failed"); /* main loop - simply wait for workio thread to exit */ - pthread_join(*thr_info[work_thr_id].pth, NULL); + pthread_join(thr_info[work_thr_id].pth, NULL); applog(LOG_INFO, "workio thread dead, exiting."); gettimeofday(&total_tv_end, NULL); diff --git a/miner.h b/miner.h index 75c53cef..d272cb21 100644 --- a/miner.h +++ b/miner.h @@ -225,7 +225,7 @@ struct thread_q { struct thr_info { int id; - pthread_t *pth; + pthread_t pth; struct thread_q *q; struct cgpu_info *cgpu; struct timeval last; diff --git a/util.c b/util.c index aca9e812..1f364501 100644 --- a/util.c +++ b/util.c @@ -655,21 +655,9 @@ out: int thr_info_create(struct thr_info *thr, pthread_attr_t *attr, void *(*start) (void *), void *arg) { - int ret = -1; - - thr->pth = malloc(sizeof(pthread_t)); - if (unlikely(!thr->pth)) { - applog(LOG_ERR, "Failed to malloc in thr_info_create"); - return ret; - } - - ret = pthread_create(thr->pth, attr, start, arg); - if (unlikely(ret)) { - applog(LOG_ERR, "Failed to pthread_create in thr_info_create"); - free(thr->pth); - thr->pth = NULL; - } + int ret; + ret = pthread_create(&thr->pth, attr, start, arg); return ret; } @@ -680,10 +668,6 @@ void thr_info_cancel(struct thr_info *thr) if (thr->q) tq_freeze(thr->q); - if (thr->pth) { - if (pthread_cancel(*thr->pth)) - pthread_join(*thr->pth, NULL); - free(thr->pth); - thr->pth = NULL; - } + if (pthread_cancel(thr->pth)) + pthread_join(thr->pth, NULL); }