From 2eaeb2a96c5997cc7bc0d468d1ba9c2ab1dcbba1 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 27 Dec 2015 14:36:56 +1100 Subject: [PATCH] Don't keep storing shares in redirector mode after we've attempted to redirect the client --- src/connector.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/connector.c b/src/connector.c index 87803eb0..d932855d 100644 --- a/src/connector.c +++ b/src/connector.c @@ -391,9 +391,7 @@ static int invalidate_client(ckpool_t *ckp, cdata_t *cdata, client_instance_t *c static void send_client(cdata_t *cdata, int64_t id, char *buf); /* Look for shares being submitted via a redirector and add them to a linked - * list for looking up the responses. Theoretically this could leak shares but - * we should only ever store one share before redirecting active clients unless - * they don't support redirection. */ + * list for looking up the responses. */ static void parse_redirector_share(client_instance_t *client, const char *msg, const json_t *val) { share_t *share, *tmp; @@ -494,7 +492,7 @@ reparse: passthrough_id = (client->id << 32) | passthrough_id; json_object_set_new_nocheck(val, "client_id", json_integer(passthrough_id)); } else { - if (ckp->redirector && strstr(msg, "mining.submit")) + if (ckp->redirector && !client->redirected && strstr(msg, "mining.submit")) parse_redirector_share(client, msg, val); json_object_set_new_nocheck(val, "client_id", json_integer(client->id)); json_object_set_new_nocheck(val, "address", json_string(client->address_name)); @@ -840,6 +838,12 @@ static void test_redirector_shares(ckpool_t *ckp, client_instance_t *client, con LOGNOTICE("Found accepted share for client %"PRId64" - redirecting", client->id); redirect_client(ckp, client); + + /* Clear the list now since we don't need it any more */ + DL_FOREACH_SAFE(client->shares, share, found) { + DL_DELETE(client->shares, share); + dealloc(share); + } } out: json_decref(val);