summaryrefslogtreecommitdiff
path: root/src/consensus
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-02-28 20:43:12 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-02-28 20:43:12 +0100
commit50034dd9abff47b5e81a5d91128fd3cb6ae906d5 (patch)
tree5b36dde988e4aad694c94922f53af7053154d114 /src/consensus
parent4bf1d97b60faba3b75e0964678b3834bd859475f (diff)
consensus: destroy set handles
Diffstat (limited to 'src/consensus')
-rw-r--r--src/consensus/gnunet-service-consensus.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c
index b934f468f..ba84f64a2 100644
--- a/src/consensus/gnunet-service-consensus.c
+++ b/src/consensus/gnunet-service-consensus.c
@@ -393,6 +393,14 @@ struct DiffEntry
struct GNUNET_CONTAINER_MultiHashMap *changes;
};
+struct SetHandle
+{
+ struct SetHandle *prev;
+ struct SetHandle *next;
+
+ struct GNUNET_SET_Handle *h;
+};
+
/**
@@ -499,6 +507,9 @@ struct ConsensusSession
* Bounded Eppstein lower bound.
*/
uint64_t lower_bound;
+
+ struct SetHandle *set_handles_head;
+ struct SetHandle *set_handles_tail;
};
/**
@@ -1663,6 +1674,12 @@ set_copy_cb (void *cls, struct GNUNET_SET_Handle *copy)
struct TaskEntry *task = scc->task;
struct SetKey dst_set_key = scc->dst_set_key;
struct SetEntry *set;
+ struct SetHandle *sh = GNUNET_new (struct SetHandle);
+
+ sh->h = copy;
+ GNUNET_CONTAINER_DLL_insert (task->step->session->set_handles_head,
+ task->step->session->set_handles_tail,
+ sh);
GNUNET_free (scc);
set = GNUNET_new (struct SetEntry);
@@ -3152,6 +3169,11 @@ handle_client_join (void *cls,
client_set = GNUNET_new (struct SetEntry);
client_set->h = GNUNET_SET_create (cfg,
GNUNET_SET_OPERATION_UNION);
+ struct SetHandle *sh = GNUNET_new (struct SetHandle);
+ sh->h = client_set->h;
+ GNUNET_CONTAINER_DLL_insert (session->set_handles_head,
+ session->set_handles_tail,
+ sh);
client_set->key = ((struct SetKey) { SET_KIND_CURRENT, 0, 0 });
put_set (session,
client_set);
@@ -3370,6 +3392,14 @@ client_disconnect_cb (void *cls,
GNUNET_CONTAINER_DLL_remove (sessions_head,
sessions_tail,
session);
+
+ while (session->set_handles_head)
+ {
+ struct SetHandle *sh = session->set_handles_head;
+ session->set_handles_head = sh->next;
+ GNUNET_SET_destroy (sh->h);
+ GNUNET_free (sh);
+ }
GNUNET_free (session);
}