Browse Source

Bugfix: Clear work template when preparing a new request

Luke Dashjr 13 years ago
parent
commit
ad571f6de5
2 changed files with 12 additions and 3 deletions
  1. 1 1
      libblkmaker
  2. 11 2
      miner.c

+ 1 - 1
libblkmaker

@@ -1 +1 @@
-Subproject commit 243684e40d203bed04a04d665bacab701860a282
+Subproject commit ca3cf0173806d39d2b3a1400de3fa4bec7ab772a

+ 11 - 2
miner.c

@@ -2343,13 +2343,15 @@ static void get_benchmark_work(struct work *work)
 	work->pool = pools[0];
 	work->pool = pools[0];
 }
 }
 
 
+static void clear_work(struct work *);
+
 static char *prepare_rpc_req(struct work *work, enum pool_protocol proto, const char *lpid)
 static char *prepare_rpc_req(struct work *work, enum pool_protocol proto, const char *lpid)
 {
 {
 	char *rpc_req;
 	char *rpc_req;
 
 
+	clear_work(work);
 	switch (proto) {
 	switch (proto) {
 		case PLP_GETWORK:
 		case PLP_GETWORK:
-			work->tmpl = NULL;
 			return strdup(getwork_rpc_req);
 			return strdup(getwork_rpc_req);
 		case PLP_GETBLOCKTEMPLATE:
 		case PLP_GETBLOCKTEMPLATE:
 			work->tmpl_refcount = malloc(sizeof(*work->tmpl_refcount));
 			work->tmpl_refcount = malloc(sizeof(*work->tmpl_refcount));
@@ -2486,7 +2488,7 @@ static struct work *make_work(void)
 	return work;
 	return work;
 }
 }
 
 
-static void free_work(struct work *work)
+static void clear_work(struct work *work)
 {
 {
 	if (work->tmpl) {
 	if (work->tmpl) {
 		struct pool *pool = work->pool;
 		struct pool *pool = work->pool;
@@ -2496,8 +2498,15 @@ static void free_work(struct work *work)
 		if (free_tmpl) {
 		if (free_tmpl) {
 			blktmpl_free(work->tmpl);
 			blktmpl_free(work->tmpl);
 			free(work->tmpl_refcount);
 			free(work->tmpl_refcount);
+			work->tmpl = NULL;
+			work->tmpl_refcount = NULL;
 		}
 		}
 	}
 	}
+}
+
+static void free_work(struct work *work)
+{
+	clear_work(work);
 	free(work);
 	free(work);
 }
 }