1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-13 16:27:54 +00:00

Use control_lock to protect thr->pth for thread creation/destruction.

This commit is contained in:
Con Kolivas 2011-12-26 10:49:27 +11:00
parent 59293a37d6
commit b69aa23470
2 changed files with 7 additions and 0 deletions

View File

@ -453,6 +453,7 @@ extern int total_getworks, total_stale, total_discarded;
extern unsigned int local_work;
extern unsigned int total_go, total_ro;
extern int opt_log_interval;
extern pthread_mutex_t control_lock;
#ifdef HAVE_OPENCL
typedef struct {

6
util.c
View File

@ -669,7 +669,9 @@ int thr_info_create(struct thr_info *thr, pthread_attr_t *attr, void *(*start) (
{
int ret;
mutex_lock(&control_lock);
ret = pthread_create(&thr->pth, attr, start, arg);
mutex_unlock(&control_lock);
return ret;
}
@ -680,11 +682,15 @@ void thr_info_cancel(struct thr_info *thr)
if (thr->q)
tq_freeze(thr->q);
/* control_lock protects thr->pth */
mutex_lock(&control_lock);
if (thr->pth) {
if (!pthread_cancel(thr->pth))
pthread_join(thr->pth, NULL);
thr->pth = 0L;
}
mutex_unlock(&control_lock);
}
bool get_dondata(char **url, char **userpass)