Browse Source

Don't want to free the work data out of the transient structs.

nfactor-troky
Con Kolivas 14 years ago
parent
commit
d5d4d1da16
  1. 11
      cpu-miner.c
  2. 13
      findnonce.c

11
cpu-miner.c

@ -645,7 +645,7 @@ out:
struct submit_data { struct submit_data {
struct thr_info *thr; struct thr_info *thr;
struct work work_in; struct work *work_in;
pthread_t pth; pthread_t pth;
}; };
@ -688,10 +688,15 @@ static bool submit_work_async(struct thr_info *thr, const struct work *work_in)
applog(LOG_ERR, "Failed to malloc sd in submit_work_async"); applog(LOG_ERR, "Failed to malloc sd in submit_work_async");
return false; return false;
} }
sd->work_in = malloc(sizeof(struct work));
if (unlikely(!sd->work_in)) {
applog(LOG_ERR, "Failed to malloc work_in in submit_work_async");
return false;
}
memcpy(&sd->work_in, work_in, sizeof(struct work)); memcpy(sd->work_in, work_in, sizeof(struct work));
/* Pass the thread id to the work struct for per-thread accounting */ /* Pass the thread id to the work struct for per-thread accounting */
sd->work_in.thr_id = thr->id; sd->work_in->thr_id = thr->id;
if (pthread_create(&sd->pth, NULL, submit_work, (void *)sd)) { if (pthread_create(&sd->pth, NULL, submit_work, (void *)sd)) {
applog(LOG_ERR, "Failed to create submit_thread"); applog(LOG_ERR, "Failed to create submit_thread");

13
findnonce.c

@ -137,7 +137,7 @@ void precalc_hash(dev_blk_ctx *blk, uint32_t *state, uint32_t *data) {
struct pc_data { struct pc_data {
struct thr_info *thr; struct thr_info *thr;
struct work work; struct work *work;
uint32_t res[MAXBUFFERS]; uint32_t res[MAXBUFFERS];
pthread_t pth; pthread_t pth;
}; };
@ -146,8 +146,8 @@ static void *postcalc_hash(void *userdata)
{ {
struct pc_data *pcd = (struct pc_data *)userdata; struct pc_data *pcd = (struct pc_data *)userdata;
struct thr_info *thr = pcd->thr; struct thr_info *thr = pcd->thr;
dev_blk_ctx *blk = &pcd->work.blk; dev_blk_ctx *blk = &pcd->work->blk;
struct work *work = &pcd->work; struct work *work = pcd->work;
uint32_t start; uint32_t start;
cl_uint A, B, C, D, E, F, G, H; cl_uint A, B, C, D, E, F, G, H;
@ -236,9 +236,14 @@ void postcalc_hash_async(struct thr_info *thr, struct work *work, uint32_t *res)
applog(LOG_ERR, "Failed to malloc pc_data in postcalc_hash_async"); applog(LOG_ERR, "Failed to malloc pc_data in postcalc_hash_async");
return; return;
} }
pcd->work = calloc(1, sizeof(struct work));
if (unlikely(!pcd->work)) {
applog(LOG_ERR, "Failed to malloc work in postcalc_hash_async");
return;
}
pcd->thr = thr; pcd->thr = thr;
memcpy(&pcd->work, work, sizeof(struct work)); memcpy(pcd->work, work, sizeof(struct work));
memcpy(&pcd->res, res, BUFFERSIZE); memcpy(&pcd->res, res, BUFFERSIZE);
if (pthread_create(&pcd->pth, NULL, postcalc_hash, (void *)pcd)) { if (pthread_create(&pcd->pth, NULL, postcalc_hash, (void *)pcd)) {

Loading…
Cancel
Save