aboutsummaryrefslogtreecommitdiff
path: root/src/consensus/gnunet-service-consensus.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/consensus/gnunet-service-consensus.c')
-rw-r--r--src/consensus/gnunet-service-consensus.c46
1 files changed, 42 insertions, 4 deletions
diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c
index b934f468f..4af7199aa 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
396struct 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/**
@@ -894,7 +905,7 @@ cmp_uint64_t (const void *pa, const void *pb)
894 * in the result set. 905 * in the result set.
895 * 906 *
896 * @param cls closure 907 * @param cls closure
897 * @param element a result element, only valid if status is GNUNET_SET_STATUS_OK 908 * @param element a result element, only valid if status is #GNUNET_SET_STATUS_OK
898 * @param current_size current set size 909 * @param current_size current set size
899 * @param status see enum GNUNET_SET_Status 910 * @param status see enum GNUNET_SET_Status
900 */ 911 */
@@ -1011,6 +1022,7 @@ set_result_cb (void *cls,
1011 "P%u: lower bound %llu\n", 1022 "P%u: lower bound %llu\n",
1012 session->local_peer_idx, 1023 session->local_peer_idx,
1013 (long long) session->lower_bound); 1024 (long long) session->lower_bound);
1025 GNUNET_free (copy);
1014 } 1026 }
1015 return; 1027 return;
1016 } 1028 }
@@ -1329,7 +1341,10 @@ commit_set (struct ConsensusSession *session,
1329 if (PHASE_KIND_ALL_TO_ALL_2 == task->key.kind) 1341 if (PHASE_KIND_ALL_TO_ALL_2 == task->key.kind)
1330 { 1342 {
1331 struct GNUNET_SET_Element element; 1343 struct GNUNET_SET_Element element;
1332 struct ConsensusSizeElement cse = { 0 }; 1344 struct ConsensusSizeElement cse = {
1345 .size = 0,
1346 .sender_index = 0
1347 };
1333 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "inserting size marker\n"); 1348 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "inserting size marker\n");
1334 cse.ce.marker = CONSENSUS_MARKER_SIZE; 1349 cse.ce.marker = CONSENSUS_MARKER_SIZE;
1335 cse.size = GNUNET_htonll (session->first_size); 1350 cse.size = GNUNET_htonll (session->first_size);
@@ -1382,7 +1397,10 @@ commit_set (struct ConsensusSession *session,
1382 for (i = 0; i < evil.num; i++) 1397 for (i = 0; i < evil.num; i++)
1383 { 1398 {
1384 struct GNUNET_SET_Element element; 1399 struct GNUNET_SET_Element element;
1385 struct ConsensusStuffedElement se = { 0 }; 1400 struct ConsensusStuffedElement se = {
1401 .ce.payload_type = 0,
1402 .ce.marker = 0,
1403 };
1386 element.data = &se; 1404 element.data = &se;
1387 element.size = sizeof (struct ConsensusStuffedElement); 1405 element.size = sizeof (struct ConsensusStuffedElement);
1388 element.element_type = GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT; 1406 element.element_type = GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT;
@@ -1663,6 +1681,12 @@ set_copy_cb (void *cls, struct GNUNET_SET_Handle *copy)
1663 struct TaskEntry *task = scc->task; 1681 struct TaskEntry *task = scc->task;
1664 struct SetKey dst_set_key = scc->dst_set_key; 1682 struct SetKey dst_set_key = scc->dst_set_key;
1665 struct SetEntry *set; 1683 struct SetEntry *set;
1684 struct SetHandle *sh = GNUNET_new (struct SetHandle);
1685
1686 sh->h = copy;
1687 GNUNET_CONTAINER_DLL_insert (task->step->session->set_handles_head,
1688 task->step->session->set_handles_tail,
1689 sh);
1666 1690
1667 GNUNET_free (scc); 1691 GNUNET_free (scc);
1668 set = GNUNET_new (struct SetEntry); 1692 set = GNUNET_new (struct SetEntry);
@@ -2105,7 +2129,7 @@ task_start_reconcile (struct TaskEntry *task)
2105 2129
2106 if (task->key.peer1 == session->local_peer_idx) 2130 if (task->key.peer1 == session->local_peer_idx)
2107 { 2131 {
2108 struct GNUNET_CONSENSUS_RoundContextMessage rcm = { 0 }; 2132 struct GNUNET_CONSENSUS_RoundContextMessage rcm;
2109 2133
2110 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2134 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2111 "P%u: Looking up set {%s} to run remote union\n", 2135 "P%u: Looking up set {%s} to run remote union\n",
@@ -2120,6 +2144,7 @@ task_start_reconcile (struct TaskEntry *task)
2120 rcm.peer2 = htons (task->key.peer2); 2144 rcm.peer2 = htons (task->key.peer2);
2121 rcm.leader = htons (task->key.leader); 2145 rcm.leader = htons (task->key.leader);
2122 rcm.repetition = htons (task->key.repetition); 2146 rcm.repetition = htons (task->key.repetition);
2147 rcm.is_contested = htons (0);
2123 2148
2124 GNUNET_assert (NULL == setop->op); 2149 GNUNET_assert (NULL == setop->op);
2125 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "P%u: initiating set op with P%u, our set is %s\n", 2150 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "P%u: initiating set op with P%u, our set is %s\n",
@@ -3152,6 +3177,11 @@ handle_client_join (void *cls,
3152 client_set = GNUNET_new (struct SetEntry); 3177 client_set = GNUNET_new (struct SetEntry);
3153 client_set->h = GNUNET_SET_create (cfg, 3178 client_set->h = GNUNET_SET_create (cfg,
3154 GNUNET_SET_OPERATION_UNION); 3179 GNUNET_SET_OPERATION_UNION);
3180 struct SetHandle *sh = GNUNET_new (struct SetHandle);
3181 sh->h = client_set->h;
3182 GNUNET_CONTAINER_DLL_insert (session->set_handles_head,
3183 session->set_handles_tail,
3184 sh);
3155 client_set->key = ((struct SetKey) { SET_KIND_CURRENT, 0, 0 }); 3185 client_set->key = ((struct SetKey) { SET_KIND_CURRENT, 0, 0 });
3156 put_set (session, 3186 put_set (session,
3157 client_set); 3187 client_set);
@@ -3370,6 +3400,14 @@ client_disconnect_cb (void *cls,
3370 GNUNET_CONTAINER_DLL_remove (sessions_head, 3400 GNUNET_CONTAINER_DLL_remove (sessions_head,
3371 sessions_tail, 3401 sessions_tail,
3372 session); 3402 session);
3403
3404 while (session->set_handles_head)
3405 {
3406 struct SetHandle *sh = session->set_handles_head;
3407 session->set_handles_head = sh->next;
3408 GNUNET_SET_destroy (sh->h);
3409 GNUNET_free (sh);
3410 }
3373 GNUNET_free (session); 3411 GNUNET_free (session);
3374} 3412}
3375 3413