From 435dc5318a81c05563853c432da93d8e8eb8fc61 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 22 Jan 2015 12:03:24 +1100 Subject: [PATCH 1/4] Decrease verbosity of invalid char being passed to validate_address --- src/bitcoin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bitcoin.c b/src/bitcoin.c index 5812b994..88e37817 100644 --- a/src/bitcoin.c +++ b/src/bitcoin.c @@ -1,5 +1,5 @@ /* - * Copyright 2014 Con Kolivas + * Copyright 2014-2015 Con Kolivas * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -46,7 +46,7 @@ bool validate_address(connsock_t *cs, const char *address) } } if (!found) { - LOGWARNING("Invalid char %.1s passed to validate_address", &c); + LOGNOTICE("Invalid char %.1s passed to validate_address", &c); return ret; } } From e009db5dc50567aa82e245484d562925200a7498 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 22 Jan 2015 12:43:47 +1100 Subject: [PATCH 2/4] Add information when disconnecting a client --- src/stratifier.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index 678062d2..2cc56239 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1256,7 +1256,7 @@ static void drop_client(sdata_t *sdata, int64_t id) ckpool_t *ckp = NULL; bool dec = false; - LOGINFO("Stratifier dropping client %ld", id); + LOGINFO("Stratifier asked to drop client %ld", id); ck_wlock(&sdata->instance_lock); client = __instance_by_id(sdata, id); @@ -1276,11 +1276,15 @@ static void drop_client(sdata_t *sdata, int64_t id) HASH_FIND(hh, sdata->disconnected_instances, &client->enonce1_64, sizeof(uint64_t), old_client); /* Only keep around one copy of the old client in server mode */ if (!client->ckp->proxy && !old_client && client->enonce1_64 && dec) { - LOGDEBUG("Adding disconnected instance %ld", client->id); + LOGNOTICE("Disconnecting client %ld %s", client->id, client->workername); HASH_ADD(hh, sdata->disconnected_instances, enonce1_64, sizeof(uint64_t), client); sdata->stats.disconnected++; client->disconnected_time = time(NULL); } else { + if (client->workername) + LOGNOTICE("Dropping client %ld %s", client->id, client->workername); + else + LOGINFO("Dropping workerless client %ld", client->id); __add_dead(sdata, client); } } From 01ce6a65a0c93884c43a2b308f35444e5d024bc7 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 22 Jan 2015 12:57:56 +1100 Subject: [PATCH 3/4] Revert wrongly implicated linked list freeing workaround --- src/connector.c | 7 ++----- src/stratifier.c | 10 ++-------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/connector.c b/src/connector.c index 811e20b1..a2dbbf2b 100644 --- a/src/connector.c +++ b/src/connector.c @@ -238,7 +238,7 @@ static void stratifier_drop_client(ckpool_t *ckp, int64_t id) * count. */ static int invalidate_client(ckpool_t *ckp, cdata_t *cdata, client_instance_t *client) { - client_instance_t *tmp, *client_delete = NULL; + client_instance_t *tmp; int ret; ret = drop_client(cdata, client); @@ -250,15 +250,12 @@ static int invalidate_client(ckpool_t *ckp, cdata_t *cdata, client_instance_t *c * counts for them. */ ck_wlock(&cdata->lock); LL_FOREACH_SAFE(cdata->dead_clients, client, tmp) { - /* Don't free client ram when loop may still access it */ - dealloc(client_delete); if (!client->ref) { LL_DELETE(cdata->dead_clients, client); LOGINFO("Connector discarding client %ld", client->id); - client_delete = client; + dealloc(client); } } - dealloc(client_delete); ck_wunlock(&cdata->lock); out: diff --git a/src/stratifier.c b/src/stratifier.c index 2cc56239..ca7b57ee 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1250,7 +1250,7 @@ static void dec_worker(ckpool_t *ckp, user_instance_t *instance) static void drop_client(sdata_t *sdata, int64_t id) { - stratum_instance_t *client, *tmp, *client_delete = NULL; + stratum_instance_t *client, *tmp; user_instance_t *instance = NULL; time_t now_t = time(NULL); ckpool_t *ckp = NULL; @@ -1304,20 +1304,14 @@ static void drop_client(sdata_t *sdata, int64_t id) /* Cull old unused clients lazily when there are no more reference * counts for them. */ LL_FOREACH_SAFE(sdata->dead_instances, client, tmp) { - /* We can't delete the ram safely in this loop, even if we can - * safely remove the entry from the linked list so we do it on - * the next pass through the loop. */ - if (client != client_delete) - dealloc(client_delete); if (!client->ref) { LOGINFO("Stratifier discarding dead instance %ld", client->id); __del_dead(sdata, client); dealloc(client->workername); dealloc(client->useragent); - client_delete = client; + dealloc(client); } } - dealloc(client_delete); ck_wunlock(&sdata->instance_lock); /* Decrease worker count outside of instance_lock to avoid recursive From a72510df7f5b5579da72f1c810eaa39c2e2c9784 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 22 Jan 2015 13:53:13 +1100 Subject: [PATCH 4/4] Only ask the stratifier to drop a client once --- src/connector.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/connector.c b/src/connector.c index a2dbbf2b..bd884e44 100644 --- a/src/connector.c +++ b/src/connector.c @@ -556,7 +556,6 @@ static void send_client(cdata_t *cdata, int64_t id, char *buf) invalidate_client(ckp, cdata, client); } else { LOGINFO("Connector failed to find client id %ld to send to", id); - stratifier_drop_client(ckp, id); } free(buf); return; @@ -690,7 +689,6 @@ retry: client = ref_client_by_id(cdata, client_id); if (unlikely(!client)) { LOGINFO("Connector failed to find client id %ld to drop", client_id); - stratifier_drop_client(ckp, client_id); goto retry; } ret = invalidate_client(ckp, cdata, client);