From 0f9e594dba9f69e1de1f5494e1d6c55d83ce2d3a Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 25 Jan 2015 00:10:46 +1100 Subject: [PATCH] Change dead instance linked list to doubly linked for O(1) removal --- src/stratifier.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index 978551e6..38a3fb78 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -873,7 +873,7 @@ static void update_base(ckpool_t *ckp, int prio) static void __add_dead(sdata_t *sdata, stratum_instance_t *client) { LOGDEBUG("Adding dead instance %ld", client->id); - LL_PREPEND(sdata->dead_instances, client); + DL_APPEND(sdata->dead_instances, client); sdata->stats.dead++; sdata->dead_generated++; } @@ -881,7 +881,7 @@ static void __add_dead(sdata_t *sdata, stratum_instance_t *client) static void __del_dead(sdata_t *sdata, stratum_instance_t *client) { LOGDEBUG("Deleting dead instance %ld", client->id); - LL_DELETE(sdata->dead_instances, client); + DL_DELETE(sdata->dead_instances, client); sdata->stats.dead--; } @@ -1333,7 +1333,7 @@ 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) { + DL_FOREACH_SAFE(sdata->dead_instances, client, tmp) { if (!client->ref) { LOGINFO("Stratifier discarding dead instance %ld", client->id); __del_dead(sdata, client);