Browse Source

Change pth from being a pointer as we can dereference if we're unlucky on stopping longpoll.

nfactor-troky
Con Kolivas 13 years ago
parent
commit
8e2becc12d
  1. 8
      main.c
  2. 2
      miner.h
  3. 24
      util.c

8
main.c

@ -4549,7 +4549,7 @@ select_cgpu:
thr->rolling = thr->cgpu->rolling = 0; thr->rolling = thr->cgpu->rolling = 0;
/* Reports the last time we tried to revive a sick GPU */ /* Reports the last time we tried to revive a sick GPU */
gettimeofday(&thr->sick, NULL); 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); applog(LOG_WARNING, "Thread %d still exists, killing it off", thr_id);
} else } else
applog(LOG_WARNING, "Thread %d no longer exists", thr_id); applog(LOG_WARNING, "Thread %d no longer exists", thr_id);
@ -5349,7 +5349,7 @@ int main (int argc, char *argv[])
/* start stage thread */ /* start stage thread */
if (thr_info_create(thr, NULL, stage_thread, thr)) if (thr_info_create(thr, NULL, stage_thread, thr))
quit(1, "stage thread create failed"); quit(1, "stage thread create failed");
pthread_detach(*thr->pth); pthread_detach(thr->pth);
/* Create a unique get work queue */ /* Create a unique get work queue */
getq = tq_new(); getq = tq_new();
@ -5525,7 +5525,7 @@ int main (int argc, char *argv[])
thr = &thr_info[input_thr_id]; thr = &thr_info[input_thr_id];
if (thr_info_create(thr, NULL, input_thread, thr)) if (thr_info_create(thr, NULL, input_thread, thr))
quit(1, "input thread create failed"); quit(1, "input thread create failed");
pthread_detach(*thr->pth); pthread_detach(thr->pth);
/* Create reinit cpu thread */ /* Create reinit cpu thread */
cpur_thr_id = mining_threads + 5; cpur_thr_id = mining_threads + 5;
@ -5546,7 +5546,7 @@ int main (int argc, char *argv[])
quit(1, "reinit_gpu thread create failed"); quit(1, "reinit_gpu thread create failed");
/* main loop - simply wait for workio thread to exit */ /* 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."); applog(LOG_INFO, "workio thread dead, exiting.");
gettimeofday(&total_tv_end, NULL); gettimeofday(&total_tv_end, NULL);

2
miner.h

@ -225,7 +225,7 @@ struct thread_q {
struct thr_info { struct thr_info {
int id; int id;
pthread_t *pth; pthread_t pth;
struct thread_q *q; struct thread_q *q;
struct cgpu_info *cgpu; struct cgpu_info *cgpu;
struct timeval last; struct timeval last;

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 thr_info_create(struct thr_info *thr, pthread_attr_t *attr, void *(*start) (void *), void *arg)
{ {
int ret = -1; int ret;
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;
}
ret = pthread_create(&thr->pth, attr, start, arg);
return ret; return ret;
} }
@ -680,10 +668,6 @@ void thr_info_cancel(struct thr_info *thr)
if (thr->q) if (thr->q)
tq_freeze(thr->q); tq_freeze(thr->q);
if (thr->pth) { if (pthread_cancel(thr->pth))
if (pthread_cancel(*thr->pth)) pthread_join(thr->pth, NULL);
pthread_join(*thr->pth, NULL);
free(thr->pth);
thr->pth = NULL;
}
} }

Loading…
Cancel
Save