From d15d19bf3a62064f3133048fe17254383e953c19 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 7 Aug 2014 10:51:17 +1000 Subject: [PATCH 1/4] si should only be dealloced on shutdown --- src/generator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generator.c b/src/generator.c index 7a96e095..e2d3d2a4 100644 --- a/src/generator.c +++ b/src/generator.c @@ -192,7 +192,6 @@ static void kill_server(server_instance_t *si) dealloc(cs->port); dealloc(cs->auth); dealloc(si->data); - dealloc(si); } static int gen_loop(proc_instance_t *pi) @@ -1315,6 +1314,7 @@ static int server_mode(ckpool_t *ckp, proc_instance_t *pi) for (i = 0; i < ckp->btcds; i++) { si = ckp->servers[i]; kill_server(si); + dealloc(si); } dealloc(ckp->servers); return ret; From c5eb3c75af40f413b73efd05c6acd29e529ec0cd Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 7 Aug 2014 10:59:10 +1000 Subject: [PATCH 2/4] Allocate the gbt data from within live_server --- src/generator.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/generator.c b/src/generator.c index e2d3d2a4..5acc3227 100644 --- a/src/generator.c +++ b/src/generator.c @@ -153,7 +153,8 @@ retry: keep_sockalive(cs->fd); /* Test we can connect, authorise and get a block template */ - gbt = si->data; + gbt = ckzalloc(sizeof(gbtbase_t)); + si->data = gbt; if (!gen_gbtbase(cs, gbt)) { LOGINFO("Failed to get test block template from %s:%s!", cs->url, cs->port); @@ -1298,15 +1299,11 @@ static int server_mode(ckpool_t *ckp, proc_instance_t *pi) ckp->servers = ckalloc(sizeof(server_instance_t *) * ckp->btcds); for (i = 0; i < ckp->btcds; i++) { - gbtbase_t *gbt; - ckp->servers[i] = ckzalloc(sizeof(server_instance_t)); si = ckp->servers[i]; si->url = ckp->btcdurl[i]; si->auth = ckp->btcdauth[i]; si->pass = ckp->btcdpass[i]; - gbt = ckzalloc(sizeof(gbtbase_t)); - si->data = gbt; } ret = gen_loop(pi); From d5be610d40d3b2035043f30f3224f4550b819394 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 7 Aug 2014 10:59:59 +1000 Subject: [PATCH 3/4] Fix harmless valgrind warning --- src/stratifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stratifier.c b/src/stratifier.c index 19074635..77dba375 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -331,7 +331,7 @@ static void generate_coinbase(ckpool_t *ckp, workbase_t *wb) len += wb->enonce1varlen; len += wb->enonce2varlen; - wb->coinb2bin = ckalloc(128); + wb->coinb2bin = ckzalloc(128); memcpy(wb->coinb2bin, "\x0a\x63\x6b\x70\x6f\x6f\x6c", 7); wb->coinb2len = 7; if (ckp->btcsig) { From 83d2da1d70f550e47c88279a4f3cb68841b56afa Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 7 Aug 2014 11:04:54 +1000 Subject: [PATCH 4/4] Use a deep copy for stratum notify of the merkle array --- src/stratifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stratifier.c b/src/stratifier.c index 77dba375..37ede260 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1841,7 +1841,7 @@ static json_t *__stratum_notify(bool clean) current_workbase->prevhash, current_workbase->coinb1, current_workbase->coinb2, - json_copy(current_workbase->merkle_array), + json_deep_copy(current_workbase->merkle_array), current_workbase->bbversion, current_workbase->nbit, current_workbase->ntime,