aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/consensus/gnunet-service-consensus.c46
-rw-r--r--src/consensus/test_consensus.conf15
-rw-r--r--src/set/gnunet-service-set_union.c5
-rw-r--r--src/set/set_api.c3
4 files changed, 60 insertions, 9 deletions
diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c
index 472e96706..567480e58 100644
--- a/src/consensus/gnunet-service-consensus.c
+++ b/src/consensus/gnunet-service-consensus.c
@@ -293,7 +293,11 @@ destroy_session (struct ConsensusSession *session)
293 { 293 {
294 struct ConsensusPeerInformation *cpi; 294 struct ConsensusPeerInformation *cpi;
295 cpi = &session->info[i]; 295 cpi = &session->info[i];
296 GNUNET_free (cpi); 296 if (NULL != cpi->set_op)
297 {
298 GNUNET_SET_operation_cancel (cpi->set_op);
299 cpi->set_op = NULL;
300 }
297 } 301 }
298 GNUNET_free (session->info); 302 GNUNET_free (session->info);
299 session->info = NULL; 303 session->info = NULL;
@@ -315,17 +319,27 @@ send_to_client_iter (void *cls,
315 const struct GNUNET_SET_Element *element) 319 const struct GNUNET_SET_Element *element)
316{ 320{
317 struct ConsensusSession *session = cls; 321 struct ConsensusSession *session = cls;
322 struct GNUNET_MQ_Envelope *ev;
318 323
319 if (NULL != element) 324 if (NULL != element)
320 { 325 {
321 struct GNUNET_MQ_Envelope *ev;
322 struct GNUNET_CONSENSUS_ElementMessage *m; 326 struct GNUNET_CONSENSUS_ElementMessage *m;
323 327
328 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "P%d: got element for client\n",
329 session->local_peer_idx);
330
324 ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_RECEIVED_ELEMENT); 331 ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_RECEIVED_ELEMENT);
325 m->element_type = htons (element->type); 332 m->element_type = htons (element->type);
326 memcpy (&m[1], element->data, element->size); 333 memcpy (&m[1], element->data, element->size);
327 GNUNET_MQ_send (session->client_mq, ev); 334 GNUNET_MQ_send (session->client_mq, ev);
328 } 335 }
336 else
337 {
338 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "P%d: finished iterating elements for client\n",
339 session->local_peer_idx);
340 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_CONCLUDE_DONE);
341 GNUNET_MQ_send (session->client_mq, ev);
342 }
329 return GNUNET_YES; 343 return GNUNET_YES;
330} 344}
331 345
@@ -368,6 +382,7 @@ round_over (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
368 session->local_peer_idx); 382 session->local_peer_idx);
369 session->current_round = CONSENSUS_ROUND_FINISH; 383 session->current_round = CONSENSUS_ROUND_FINISH;
370 GNUNET_SET_iterate (session->element_set, send_to_client_iter, session); 384 GNUNET_SET_iterate (session->element_set, send_to_client_iter, session);
385 break;
371 default: 386 default:
372 GNUNET_assert (0); 387 GNUNET_assert (0);
373 } 388 }
@@ -425,9 +440,12 @@ find_partners (struct ConsensusSession *session)
425 int largest_arc; 440 int largest_arc;
426 int num_ghosts; 441 int num_ghosts;
427 442
443 /* shuffled local index */
444 int my_idx = session->shuffle[session->local_peer_idx];
445
428 /* distance to neighboring peer in current subround */ 446 /* distance to neighboring peer in current subround */
429 arc = 1 << session->exp_subround; 447 arc = 1 << session->exp_subround;
430 partner_idx = (session->local_peer_idx + arc) % session->num_peers; 448 partner_idx = (my_idx + arc) % session->num_peers;
431 largest_arc = 1; 449 largest_arc = 1;
432 while (largest_arc < session->num_peers) 450 while (largest_arc < session->num_peers)
433 largest_arc <<= 1; 451 largest_arc <<= 1;
@@ -435,7 +453,7 @@ find_partners (struct ConsensusSession *session)
435 453
436 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "num ghosts: %d\n", num_ghosts); 454 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "num ghosts: %d\n", num_ghosts);
437 455
438 if (0 == (session->local_peer_idx & arc)) 456 if (0 == (my_idx & arc))
439 { 457 {
440 /* we are outgoing */ 458 /* we are outgoing */
441 session->partner_outgoing = &session->info[session->shuffle[partner_idx]]; 459 session->partner_outgoing = &session->info[session->shuffle[partner_idx]];
@@ -443,10 +461,10 @@ find_partners (struct ConsensusSession *session)
443 * the number of peers was a power of two, and thus have to partner 461 * the number of peers was a power of two, and thus have to partner
444 * with an additional peer? 462 * with an additional peer?
445 */ 463 */
446 if (session->local_peer_idx < num_ghosts) 464 if (my_idx < num_ghosts)
447 { 465 {
448 int ghost_partner_idx; 466 int ghost_partner_idx;
449 ghost_partner_idx = (session->local_peer_idx - arc) % session->num_peers; 467 ghost_partner_idx = (my_idx - arc) % session->num_peers;
450 /* platform dependent; modulo sometimes returns negative values */ 468 /* platform dependent; modulo sometimes returns negative values */
451 if (ghost_partner_idx < 0) 469 if (ghost_partner_idx < 0)
452 ghost_partner_idx += arc; 470 ghost_partner_idx += arc;
@@ -487,11 +505,13 @@ set_result_cb (void *cls,
487 break; 505 break;
488 case GNUNET_SET_STATUS_FAILURE: 506 case GNUNET_SET_STATUS_FAILURE:
489 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set result: failure\n"); 507 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set result: failure\n");
508 cpi->set_op = NULL;
490 return; 509 return;
491 case GNUNET_SET_STATUS_HALF_DONE: 510 case GNUNET_SET_STATUS_HALF_DONE:
492 case GNUNET_SET_STATUS_DONE: 511 case GNUNET_SET_STATUS_DONE:
493 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set result: done\n"); 512 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set result: done\n");
494 cpi->exp_subround_finished = GNUNET_YES; 513 cpi->exp_subround_finished = GNUNET_YES;
514 cpi->set_op = NULL;
495 if (have_exp_subround_finished (cpi->session) == GNUNET_YES) 515 if (have_exp_subround_finished (cpi->session) == GNUNET_YES)
496 subround_over (cpi->session, NULL); 516 subround_over (cpi->session, NULL);
497 return; 517 return;
@@ -536,6 +556,13 @@ subround_over (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
536 GNUNET_SCHEDULER_cancel (session->round_timeout_tid); 556 GNUNET_SCHEDULER_cancel (session->round_timeout_tid);
537 session->round_timeout_tid = GNUNET_SCHEDULER_NO_TASK; 557 session->round_timeout_tid = GNUNET_SCHEDULER_NO_TASK;
538 } 558 }
559
560 if (session->exp_round > NUM_EXP_ROUNDS)
561 {
562 round_over (session, NULL);
563 return;
564 }
565
539 if (session->exp_round == 0) 566 if (session->exp_round == 0)
540 { 567 {
541 /* initialize everything for the log-rounds */ 568 /* initialize everything for the log-rounds */
@@ -752,6 +779,12 @@ set_listen_cb (void *cls,
752 struct ConsensusPeerInformation *cpi; 779 struct ConsensusPeerInformation *cpi;
753 int index; 780 int index;
754 781
782 /* FIXME: should this even happen? */
783 /*
784 if (NULL == request)
785 return;
786 */
787
755 if (NULL == context_msg) 788 if (NULL == context_msg)
756 { 789 {
757 GNUNET_break_op (0); 790 GNUNET_break_op (0);
@@ -900,6 +933,7 @@ client_join (void *cls,
900 } 933 }
901 session = GNUNET_new (struct ConsensusSession); 934 session = GNUNET_new (struct ConsensusSession);
902 session->client = client; 935 session->client = client;
936 session->client_mq = GNUNET_MQ_queue_for_server_client (client);
903 GNUNET_SERVER_client_keep (client); 937 GNUNET_SERVER_client_keep (client);
904 GNUNET_CONTAINER_DLL_insert (sessions_head, sessions_tail, session); 938 GNUNET_CONTAINER_DLL_insert (sessions_head, sessions_tail, session);
905 initialize_session (session, (struct GNUNET_CONSENSUS_JoinMessage *) m); 939 initialize_session (session, (struct GNUNET_CONSENSUS_JoinMessage *) m);
diff --git a/src/consensus/test_consensus.conf b/src/consensus/test_consensus.conf
index 37facf84e..d0190f8ba 100644
--- a/src/consensus/test_consensus.conf
+++ b/src/consensus/test_consensus.conf
@@ -28,3 +28,18 @@ PREFIX = valgrind
28 28
29[testbed] 29[testbed]
30OVERLAY_TOPOLOGY = CLIQUE 30OVERLAY_TOPOLOGY = CLIQUE
31
32[hostlist]
33SERVERS =
34
35
36[nat]
37# Use addresses from the local network interfaces (inluding loopback, but also others)
38USE_LOCALADDR = YES
39
40# Disable IPv6 support
41DISABLEV6 = NO
42
43# Do we use addresses from localhost address ranges? (::1, 127.0.0.0/8)
44RETURN_LOCAL_ADDRESSES = YES
45
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c
index 8a6bfa448..644f975b6 100644
--- a/src/set/gnunet-service-set_union.c
+++ b/src/set/gnunet-service-set_union.c
@@ -873,8 +873,9 @@ decode_and_send (struct OperationState *eo)
873 last_key = key; 873 last_key = key;
874 874
875 res = ibf_decode (diff_ibf, &side, &key); 875 res = ibf_decode (diff_ibf, &side, &key);
876 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "decoded ibf key %lx\n", 876 if (res == GNUNET_OK)
877 key.key_val); 877 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "decoded ibf key %lx\n",
878 key.key_val);
878 num_decoded += 1; 879 num_decoded += 1;
879 if (num_decoded > diff_ibf->size || (num_decoded > 1 && last_key.key_val == key.key_val)) 880 if (num_decoded > diff_ibf->size || (num_decoded > 1 && last_key.key_val == key.key_val))
880 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "detected cyclic ibf (decoded %u/%u)\n", 881 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "detected cyclic ibf (decoded %u/%u)\n",
diff --git a/src/set/set_api.c b/src/set/set_api.c
index c2e88e65f..b2e62cb4d 100644
--- a/src/set/set_api.c
+++ b/src/set/set_api.c
@@ -564,8 +564,9 @@ GNUNET_SET_listen (const struct GNUNET_CONFIGURATION_Handle *cfg,
564void 564void
565GNUNET_SET_listen_cancel (struct GNUNET_SET_ListenHandle *lh) 565GNUNET_SET_listen_cancel (struct GNUNET_SET_ListenHandle *lh)
566{ 566{
567 GNUNET_CLIENT_disconnect (lh->client); 567 LOG (GNUNET_ERROR_TYPE_DEBUG, "canceling listener\n");
568 GNUNET_MQ_destroy (lh->mq); 568 GNUNET_MQ_destroy (lh->mq);
569 GNUNET_CLIENT_disconnect (lh->client);
569 GNUNET_free (lh); 570 GNUNET_free (lh);
570} 571}
571 572