diff options
author | Florian Dold <florian.dold@gmail.com> | 2013-07-24 10:48:53 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2013-07-24 10:48:53 +0000 |
commit | e36ab4fe73d3eb9b0386e6fb381b34a369878b60 (patch) | |
tree | 2f3016eee812fb347b5992db9598ec1ff47aafe7 /src/consensus | |
parent | 8fc1908cf91e4c992e9ad9c85f1fa7eda5f7c8e8 (diff) | |
download | gnunet-e36ab4fe73d3eb9b0386e6fb381b34a369878b60.tar.gz gnunet-e36ab4fe73d3eb9b0386e6fb381b34a369878b60.zip |
-consensus fixes
Diffstat (limited to 'src/consensus')
-rw-r--r-- | src/consensus/gnunet-service-consensus.c | 46 | ||||
-rw-r--r-- | src/consensus/test_consensus.conf | 15 |
2 files changed, 55 insertions, 6 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] |
30 | OVERLAY_TOPOLOGY = CLIQUE | 30 | OVERLAY_TOPOLOGY = CLIQUE |
31 | |||
32 | [hostlist] | ||
33 | SERVERS = | ||
34 | |||
35 | |||
36 | [nat] | ||
37 | # Use addresses from the local network interfaces (inluding loopback, but also others) | ||
38 | USE_LOCALADDR = YES | ||
39 | |||
40 | # Disable IPv6 support | ||
41 | DISABLEV6 = NO | ||
42 | |||
43 | # Do we use addresses from localhost address ranges? (::1, 127.0.0.0/8) | ||
44 | RETURN_LOCAL_ADDRESSES = YES | ||
45 | |||