|
|
@@ -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);
|
|
|
}
|
|
|
|