From 775a1abc06ae080db47d3801bada7443740534cc Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 10 Feb 2013 13:28:06 +1100 Subject: [PATCH] Keep the unique id of each work item across copy_work to prevent multiple work items having the same id. --- cgminer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cgminer.c b/cgminer.c index 3d54b720..a023e8be 100644 --- a/cgminer.c +++ b/cgminer.c @@ -2939,8 +2939,13 @@ static void roll_work(struct work *work) * prevent a copied work struct from freeing ram belonging to another struct */ void __copy_work(struct work *work, struct work *base_work) { + int id = work->id; + clean_work(work); memcpy(work, base_work, sizeof(struct work)); + /* Keep the unique new id assigned during make_work to prevent copied + * work from having the same id. */ + work->id = id; if (base_work->job_id) work->job_id = strdup(base_work->job_id); if (base_work->nonce2) @@ -2957,7 +2962,7 @@ struct work *copy_work(struct work *base_work) { struct work *work = make_work(); - __copy_work(work, base_work); + __copy_work(work, base_work); return work; }