mirror of
https://github.com/GOSTSec/sgminer
synced 2025-02-02 01:44:23 +00:00
Change pth from being a pointer as we can dereference if we're unlucky on stopping longpoll.
This commit is contained in:
parent
88fd7c1d38
commit
8e2becc12d
8
main.c
8
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);
|
||||
|
2
miner.h
2
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;
|
||||
|
24
util.c
24
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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user