diff options
-rw-r--r-- | src/dht/gnunet_dht_profiler.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/dht/gnunet_dht_profiler.c b/src/dht/gnunet_dht_profiler.c index fb56cc19c..fcec257f0 100644 --- a/src/dht/gnunet_dht_profiler.c +++ b/src/dht/gnunet_dht_profiler.c | |||
@@ -206,6 +206,11 @@ static unsigned int n_gets_fail; | |||
206 | static unsigned int replication; | 206 | static unsigned int replication; |
207 | 207 | ||
208 | /** | 208 | /** |
209 | * Number of times we try to find the successor circle formation | ||
210 | */ | ||
211 | static unsigned int max_searches; | ||
212 | |||
213 | /** | ||
209 | * Testbed Operation (to get stats). | 214 | * Testbed Operation (to get stats). |
210 | */ | 215 | */ |
211 | static struct GNUNET_TESTBED_Operation *bandwidth_stats_op; | 216 | static struct GNUNET_TESTBED_Operation *bandwidth_stats_op; |
@@ -566,10 +571,24 @@ successor_stats_cont (void *cls, | |||
566 | if (start_val == val) | 571 | if (start_val == val) |
567 | { | 572 | { |
568 | DEBUG("Circle complete\n"); | 573 | DEBUG("Circle complete\n"); |
574 | /* FIXME: Schedule the delayed PUT task */ | ||
569 | } | 575 | } |
570 | else | 576 | else |
571 | { | 577 | { |
578 | static unsigned int tries; | ||
579 | |||
572 | DEBUG("Circle not complete\n"); | 580 | DEBUG("Circle not complete\n"); |
581 | if (max_searches == ++tries) | ||
582 | { | ||
583 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
584 | "Maximum tries %u exceeded while checking successor" | ||
585 | " cirle formation. Exiting\n", | ||
586 | max_searches); | ||
587 | GNUNET_SCHEDULER_shutdown (); | ||
588 | return; | ||
589 | } | ||
590 | /* FIXME: Re-schedule the successor stats gathering task to run after some | ||
591 | delay */ | ||
573 | } | 592 | } |
574 | } | 593 | } |
575 | 594 | ||
@@ -708,6 +727,8 @@ dht_connected (void *cls, | |||
708 | 727 | ||
709 | DEBUG (" Call stats \n"); | 728 | DEBUG (" Call stats \n"); |
710 | 729 | ||
730 | /* FIXME: move this to happen after the successor circle formation is | ||
731 | complete */ | ||
711 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (delay, &delayed_put, ac); | 732 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (delay, &delayed_put, ac); |
712 | } | 733 | } |
713 | 734 | ||
@@ -764,6 +785,7 @@ service_started (void *cls, | |||
764 | const char *emsg) | 785 | const char *emsg) |
765 | { | 786 | { |
766 | struct Context *ctx = cls; | 787 | struct Context *ctx = cls; |
788 | static unsigned int nstarted; | ||
767 | 789 | ||
768 | GNUNET_assert (NULL != ctx); | 790 | GNUNET_assert (NULL != ctx); |
769 | GNUNET_assert (NULL != ctx->op); | 791 | GNUNET_assert (NULL != ctx->op); |
@@ -771,13 +793,17 @@ service_started (void *cls, | |||
771 | ctx->op = NULL; | 793 | ctx->op = NULL; |
772 | if (NULL == ctx->ac) | 794 | if (NULL == ctx->ac) |
773 | return; | 795 | return; |
774 | /* FIXME: connect to the DHT service and wait before starting a PUT */ | ||
775 | ctx->op = GNUNET_TESTBED_service_connect (ctx, ctx->peer, | 796 | ctx->op = GNUNET_TESTBED_service_connect (ctx, ctx->peer, |
776 | "dht", | 797 | "dht", |
777 | &dht_connected, ctx->ac, | 798 | &dht_connected, ctx->ac, |
778 | &dht_connect, | 799 | &dht_connect, |
779 | &dht_disconnect, | 800 | &dht_disconnect, |
780 | ctx->ac); | 801 | ctx->ac); |
802 | if (num_peers == ++nstarted) | ||
803 | { | ||
804 | /* FIXME: schedule a delayed task to scan the successors from statistics of | ||
805 | all peers */ | ||
806 | } | ||
781 | } | 807 | } |
782 | 808 | ||
783 | 809 | ||
@@ -892,6 +918,9 @@ main (int argc, char *const *argv) | |||
892 | {'n', "peers", "COUNT", | 918 | {'n', "peers", "COUNT", |
893 | gettext_noop ("number of peers to start"), | 919 | gettext_noop ("number of peers to start"), |
894 | 1, &GNUNET_GETOPT_set_uint, &num_peers}, | 920 | 1, &GNUNET_GETOPT_set_uint, &num_peers}, |
921 | {'s', "searches", "COUNT", | ||
922 | gettext_noop ("maximum number of times we try to search for successor circle formation (default is 1)"), | ||
923 | 1, &GNUNET_GETOPT_set_uint, &max_searches}, | ||
895 | {'H', "hosts", "FILENAME", | 924 | {'H', "hosts", "FILENAME", |
896 | gettext_noop ("name of the file with the login information for the testbed"), | 925 | gettext_noop ("name of the file with the login information for the testbed"), |
897 | 1, &GNUNET_GETOPT_set_string, &hosts_file}, | 926 | 1, &GNUNET_GETOPT_set_string, &hosts_file}, |
@@ -907,6 +936,7 @@ main (int argc, char *const *argv) | |||
907 | GNUNET_GETOPT_OPTION_END | 936 | GNUNET_GETOPT_OPTION_END |
908 | }; | 937 | }; |
909 | 938 | ||
939 | max_searches = 1; | ||
910 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 940 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
911 | return 2; | 941 | return 2; |
912 | delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1); /* default delay */ | 942 | delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1); /* default delay */ |