Browse Source

Merge branch 'gbt' into bfgminer-2.8.x

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

+ 1 - 1
libblkmaker

@@ -1 +1 @@
-Subproject commit b86d129ed4f2444f215638539b8fec22a6877c75
+Subproject commit ca3cf0173806d39d2b3a1400de3fa4bec7ab772a

+ 12 - 2
miner.c

@@ -2215,6 +2215,7 @@ static bool submit_upstream_work(const struct work *work, CURL *curl, bool resub
 		swap32yes(data, work->data, 80 / 4);
 		json_t *req = blkmk_submit_jansson(work->tmpl, data, work->dataid, *((uint32_t*)&work->data[76]));
 		s = json_dumps(req, 0);
+		json_decref(req);
 		sd = bin2hex(data, 80);
 	} else {
 		s  = malloc(345);
@@ -2545,13 +2546,15 @@ static void get_benchmark_work(struct work *work)
 	calc_diff(work);
 }
 
+static void clear_work(struct work *);
+
 static char *prepare_rpc_req(struct work *work, enum pool_protocol proto, const char *lpid)
 {
 	char *rpc_req;
 
+	clear_work(work);
 	switch (proto) {
 		case PLP_GETWORK:
-			work->tmpl = NULL;
 			return strdup(getwork_rpc_req);
 		case PLP_GETBLOCKTEMPLATE:
 			work->tmpl_refcount = malloc(sizeof(*work->tmpl_refcount));
@@ -2690,7 +2693,7 @@ static struct work *make_work(void)
 	return work;
 }
 
-static void free_work(struct work *work)
+static void clear_work(struct work *work)
 {
 	if (work->tmpl) {
 		struct pool *pool = work->pool;
@@ -2700,8 +2703,15 @@ static void free_work(struct work *work)
 		if (free_tmpl) {
 			blktmpl_free(work->tmpl);
 			free(work->tmpl_refcount);
+			work->tmpl = NULL;
+			work->tmpl_refcount = NULL;
 		}
 	}
+}
+
+static void free_work(struct work *work)
+{
+	clear_work(work);
 	free(work);
 }