diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-02-06 09:05:32 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-02-06 09:05:32 +0000 |
commit | 07b5a02bdf2f53c9d52762522fd6a809bff67e92 (patch) | |
tree | 92349327998c9f364e39339c005a295b963e669a /src/testbed/testbed_api_testbed.c | |
parent | ca35f67faee8371fa763bdf49f04a8d5d4cdc021 (diff) | |
download | gnunet-07b5a02bdf2f53c9d52762522fd6a809bff67e92.tar.gz gnunet-07b5a02bdf2f53c9d52762522fd6a809bff67e92.zip |
- rely on topology completion callback instead of counting completed overlay connect operations
Diffstat (limited to 'src/testbed/testbed_api_testbed.c')
-rw-r--r-- | src/testbed/testbed_api_testbed.c | 60 |
1 files changed, 27 insertions, 33 deletions
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c index 1c9363c63..e9f7e4cbc 100644 --- a/src/testbed/testbed_api_testbed.c +++ b/src/testbed/testbed_api_testbed.c | |||
@@ -266,12 +266,6 @@ struct RunContext | |||
266 | unsigned int num_peers; | 266 | unsigned int num_peers; |
267 | 267 | ||
268 | /** | 268 | /** |
269 | * counter to count overlay connect attempts. This counter includes both | ||
270 | * successful and failed overlay connects | ||
271 | */ | ||
272 | unsigned int oc_count; | ||
273 | |||
274 | /** | ||
275 | * Expected overlay connects. Should be zero if no topology is relavant | 269 | * Expected overlay connects. Should be zero if no topology is relavant |
276 | */ | 270 | */ |
277 | unsigned int num_oc; | 271 | unsigned int num_oc; |
@@ -567,6 +561,27 @@ call_master (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
567 | 561 | ||
568 | 562 | ||
569 | /** | 563 | /** |
564 | * Callbacks of this type are called when topology configuration is completed | ||
565 | * | ||
566 | * @param cls the operation closure given to | ||
567 | * GNUNET_TESTBED_overlay_configure_topology_va() and | ||
568 | * GNUNET_TESTBED_overlay_configure() calls | ||
569 | * @param nsuccess the number of successful overlay connects | ||
570 | * @param nfailures the number of overlay connects which failed | ||
571 | */ | ||
572 | static void | ||
573 | topology_completion_callback (void *cls, unsigned int nsuccess, | ||
574 | unsigned int nfailures) | ||
575 | { | ||
576 | struct RunContext *rc = cls; | ||
577 | |||
578 | rc->state = RC_READY; | ||
579 | GNUNET_SCHEDULER_add_continuation (&call_master, rc, | ||
580 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | ||
581 | } | ||
582 | |||
583 | |||
584 | /** | ||
570 | * Function to create peers | 585 | * Function to create peers |
571 | * | 586 | * |
572 | * @param rc the RunContext | 587 | * @param rc the RunContext |
@@ -641,27 +656,6 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
641 | return; | 656 | return; |
642 | } | 657 | } |
643 | } | 658 | } |
644 | if (NULL != rc->topology_operation) | ||
645 | { | ||
646 | switch (event->type) | ||
647 | { | ||
648 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: | ||
649 | case GNUNET_TESTBED_ET_CONNECT: | ||
650 | rc->oc_count++; | ||
651 | break; | ||
652 | default: | ||
653 | GNUNET_break (0); | ||
654 | shutdown_now (rc); | ||
655 | return; | ||
656 | } | ||
657 | if (rc->oc_count == rc->num_oc) | ||
658 | { | ||
659 | rc->state = RC_READY; | ||
660 | GNUNET_SCHEDULER_add_continuation (&call_master, rc, | ||
661 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | ||
662 | } | ||
663 | goto call_cc; | ||
664 | } | ||
665 | for (dll_op = rc->dll_op_head; NULL != dll_op; dll_op = dll_op->next) | 659 | for (dll_op = rc->dll_op_head; NULL != dll_op; dll_op = dll_op->next) |
666 | { | 660 | { |
667 | if ((GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type) && | 661 | if ((GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type) && |
@@ -735,8 +729,8 @@ call_cc: | |||
735 | rc->topology_operation = | 729 | rc->topology_operation = |
736 | GNUNET_TESTBED_overlay_configure_topology (NULL, rc->num_peers, | 730 | GNUNET_TESTBED_overlay_configure_topology (NULL, rc->num_peers, |
737 | rc->peers, &rc->num_oc, | 731 | rc->peers, &rc->num_oc, |
738 | NULL, | 732 | &topology_completion_callback, |
739 | NULL, | 733 | rc, |
740 | rc->topology, | 734 | rc->topology, |
741 | rc->random_links, | 735 | rc->random_links, |
742 | GNUNET_TESTBED_TOPOLOGY_OPTION_END); | 736 | GNUNET_TESTBED_TOPOLOGY_OPTION_END); |
@@ -747,8 +741,8 @@ call_cc: | |||
747 | rc->topology_operation = | 741 | rc->topology_operation = |
748 | GNUNET_TESTBED_overlay_configure_topology (NULL, rc->num_peers, | 742 | GNUNET_TESTBED_overlay_configure_topology (NULL, rc->num_peers, |
749 | rc->peers, &rc->num_oc, | 743 | rc->peers, &rc->num_oc, |
750 | NULL, | 744 | &topology_completion_callback, |
751 | NULL, | 745 | rc, |
752 | rc->topology, | 746 | rc->topology, |
753 | rc->topo_file, | 747 | rc->topo_file, |
754 | GNUNET_TESTBED_TOPOLOGY_OPTION_END); | 748 | GNUNET_TESTBED_TOPOLOGY_OPTION_END); |
@@ -757,8 +751,8 @@ call_cc: | |||
757 | rc->topology_operation = | 751 | rc->topology_operation = |
758 | GNUNET_TESTBED_overlay_configure_topology (NULL, rc->num_peers, | 752 | GNUNET_TESTBED_overlay_configure_topology (NULL, rc->num_peers, |
759 | rc->peers, &rc->num_oc, | 753 | rc->peers, &rc->num_oc, |
760 | NULL, | 754 | &topology_completion_callback, |
761 | NULL, | 755 | rc, |
762 | rc->topology, | 756 | rc->topology, |
763 | GNUNET_TESTBED_TOPOLOGY_OPTION_END); | 757 | GNUNET_TESTBED_TOPOLOGY_OPTION_END); |
764 | if (NULL == rc->topology_operation) | 758 | if (NULL == rc->topology_operation) |