diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-02-28 20:43:12 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-02-28 20:43:12 +0100 |
commit | 50034dd9abff47b5e81a5d91128fd3cb6ae906d5 (patch) | |
tree | 5b36dde988e4aad694c94922f53af7053154d114 /src/consensus/gnunet-service-consensus.c | |
parent | 4bf1d97b60faba3b75e0964678b3834bd859475f (diff) | |
download | gnunet-50034dd9abff47b5e81a5d91128fd3cb6ae906d5.tar.gz gnunet-50034dd9abff47b5e81a5d91128fd3cb6ae906d5.zip |
consensus: destroy set handles
Diffstat (limited to 'src/consensus/gnunet-service-consensus.c')
-rw-r--r-- | src/consensus/gnunet-service-consensus.c | 30 |
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 | |||
393 | struct GNUNET_CONTAINER_MultiHashMap *changes; | 393 | struct GNUNET_CONTAINER_MultiHashMap *changes; |
394 | }; | 394 | }; |
395 | 395 | ||
396 | struct SetHandle | ||
397 | { | ||
398 | struct SetHandle *prev; | ||
399 | struct SetHandle *next; | ||
400 | |||
401 | struct GNUNET_SET_Handle *h; | ||
402 | }; | ||
403 | |||
396 | 404 | ||
397 | 405 | ||
398 | /** | 406 | /** |
@@ -499,6 +507,9 @@ struct ConsensusSession | |||
499 | * Bounded Eppstein lower bound. | 507 | * Bounded Eppstein lower bound. |
500 | */ | 508 | */ |
501 | uint64_t lower_bound; | 509 | uint64_t lower_bound; |
510 | |||
511 | struct SetHandle *set_handles_head; | ||
512 | struct SetHandle *set_handles_tail; | ||
502 | }; | 513 | }; |
503 | 514 | ||
504 | /** | 515 | /** |
@@ -1663,6 +1674,12 @@ set_copy_cb (void *cls, struct GNUNET_SET_Handle *copy) | |||
1663 | struct TaskEntry *task = scc->task; | 1674 | struct TaskEntry *task = scc->task; |
1664 | struct SetKey dst_set_key = scc->dst_set_key; | 1675 | struct SetKey dst_set_key = scc->dst_set_key; |
1665 | struct SetEntry *set; | 1676 | struct SetEntry *set; |
1677 | struct SetHandle *sh = GNUNET_new (struct SetHandle); | ||
1678 | |||
1679 | sh->h = copy; | ||
1680 | GNUNET_CONTAINER_DLL_insert (task->step->session->set_handles_head, | ||
1681 | task->step->session->set_handles_tail, | ||
1682 | sh); | ||
1666 | 1683 | ||
1667 | GNUNET_free (scc); | 1684 | GNUNET_free (scc); |
1668 | set = GNUNET_new (struct SetEntry); | 1685 | set = GNUNET_new (struct SetEntry); |
@@ -3152,6 +3169,11 @@ handle_client_join (void *cls, | |||
3152 | client_set = GNUNET_new (struct SetEntry); | 3169 | client_set = GNUNET_new (struct SetEntry); |
3153 | client_set->h = GNUNET_SET_create (cfg, | 3170 | client_set->h = GNUNET_SET_create (cfg, |
3154 | GNUNET_SET_OPERATION_UNION); | 3171 | GNUNET_SET_OPERATION_UNION); |
3172 | struct SetHandle *sh = GNUNET_new (struct SetHandle); | ||
3173 | sh->h = client_set->h; | ||
3174 | GNUNET_CONTAINER_DLL_insert (session->set_handles_head, | ||
3175 | session->set_handles_tail, | ||
3176 | sh); | ||
3155 | client_set->key = ((struct SetKey) { SET_KIND_CURRENT, 0, 0 }); | 3177 | client_set->key = ((struct SetKey) { SET_KIND_CURRENT, 0, 0 }); |
3156 | put_set (session, | 3178 | put_set (session, |
3157 | client_set); | 3179 | client_set); |
@@ -3370,6 +3392,14 @@ client_disconnect_cb (void *cls, | |||
3370 | GNUNET_CONTAINER_DLL_remove (sessions_head, | 3392 | GNUNET_CONTAINER_DLL_remove (sessions_head, |
3371 | sessions_tail, | 3393 | sessions_tail, |
3372 | session); | 3394 | session); |
3395 | |||
3396 | while (session->set_handles_head) | ||
3397 | { | ||
3398 | struct SetHandle *sh = session->set_handles_head; | ||
3399 | session->set_handles_head = sh->next; | ||
3400 | GNUNET_SET_destroy (sh->h); | ||
3401 | GNUNET_free (sh); | ||
3402 | } | ||
3373 | GNUNET_free (session); | 3403 | GNUNET_free (session); |
3374 | } | 3404 | } |
3375 | 3405 | ||