diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2014-08-20 14:11:29 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2014-08-20 14:11:29 +0000 |
commit | a1782d0f729d8396b55d061ddac27398b4237467 (patch) | |
tree | 1f7dd086e5029678c24b0df526f31c10095ae193 | |
parent | 5447f35b5322f59f0828699c4eef156496dbd6e6 (diff) | |
download | gnunet-a1782d0f729d8396b55d061ddac27398b4237467.tar.gz gnunet-a1782d0f729d8396b55d061ddac27398b4237467.zip |
Reconnect to DHT services for doing GETs after PUTs have been made.
-rw-r--r-- | src/dht/gnunet_dht_profiler.c | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/src/dht/gnunet_dht_profiler.c b/src/dht/gnunet_dht_profiler.c index 2f7fdde77..2eb95d6f4 100644 --- a/src/dht/gnunet_dht_profiler.c +++ b/src/dht/gnunet_dht_profiler.c | |||
@@ -339,6 +339,17 @@ struct Context **peer_contexts = NULL; | |||
339 | */ | 339 | */ |
340 | static int peers_started = 0; | 340 | static int peers_started = 0; |
341 | 341 | ||
342 | |||
343 | /** | ||
344 | * Should we do a PUT (mode = 0) or GET (mode = 1); | ||
345 | */ | ||
346 | static enum | ||
347 | { | ||
348 | MODE_PUT = 0, | ||
349 | |||
350 | MODE_GET = 1 | ||
351 | } mode; | ||
352 | |||
342 | /** | 353 | /** |
343 | * Task that collects successor statistics from all the peers. | 354 | * Task that collects successor statistics from all the peers. |
344 | * @param cls | 355 | * @param cls |
@@ -598,6 +609,13 @@ delayed_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
598 | 609 | ||
599 | 610 | ||
600 | /** | 611 | /** |
612 | * Connect to DHT services of active peers | ||
613 | */ | ||
614 | static void | ||
615 | start_profiling(); | ||
616 | |||
617 | |||
618 | /** | ||
601 | * Queue up a delayed task for doing DHT GET | 619 | * Queue up a delayed task for doing DHT GET |
602 | * | 620 | * |
603 | * @param cls the active context | 621 | * @param cls the active context |
@@ -611,13 +629,21 @@ static void | |||
611 | put_cont (void *cls, int success) | 629 | put_cont (void *cls, int success) |
612 | { | 630 | { |
613 | struct ActiveContext *ac = cls; | 631 | struct ActiveContext *ac = cls; |
632 | struct Context *ctx = ac->ctx; | ||
614 | 633 | ||
615 | ac->dht_put = NULL; | 634 | ac->dht_put = NULL; |
616 | if (success) | 635 | if (success) |
617 | n_puts_ok++; | 636 | n_puts_ok++; |
618 | else | 637 | else |
619 | n_puts_fail++; | 638 | n_puts_fail++; |
620 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (delay, &delayed_get, ac); | 639 | GNUNET_assert (NULL != ctx); |
640 | GNUNET_TESTBED_operation_done (ctx->op); | ||
641 | /* Start GETs if all PUTs have been made */ | ||
642 | if (n_active == n_puts_ok + n_puts_fail) | ||
643 | { | ||
644 | mode = MODE_GET; | ||
645 | start_profiling (); | ||
646 | } | ||
621 | } | 647 | } |
622 | 648 | ||
623 | 649 | ||
@@ -684,8 +710,15 @@ dht_connected (void *cls, | |||
684 | ctx->op = NULL; | 710 | ctx->op = NULL; |
685 | return; | 711 | return; |
686 | } | 712 | } |
687 | 713 | switch (mode) | |
688 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (delay, &delayed_put, ac); | 714 | { |
715 | case MODE_PUT: | ||
716 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (delay, &delayed_put, ac); | ||
717 | break; | ||
718 | case MODE_GET: | ||
719 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (delay, &delayed_get, ac); | ||
720 | break; | ||
721 | } | ||
689 | } | 722 | } |
690 | 723 | ||
691 | 724 | ||
@@ -728,12 +761,10 @@ dht_disconnect (void *cls, void *op_result) | |||
728 | 761 | ||
729 | 762 | ||
730 | /** | 763 | /** |
731 | * FIXME:Verify where is n_active used. Should this service be started only | 764 | * Connect to DHT services of active peers |
732 | * for n_active peers? | ||
733 | * Start testbed service for all the peers. | ||
734 | */ | 765 | */ |
735 | static void | 766 | static void |
736 | start_testbed_service_on_all_peers() | 767 | start_profiling() |
737 | { | 768 | { |
738 | unsigned int i; | 769 | unsigned int i; |
739 | DEBUG("GNUNET_TESTBED_service_connect \n"); | 770 | DEBUG("GNUNET_TESTBED_service_connect \n"); |
@@ -796,7 +827,7 @@ successor_stats_cont (void *cls, | |||
796 | 827 | ||
797 | if(GNUNET_SCHEDULER_NO_TASK == successor_stats_task) | 828 | if(GNUNET_SCHEDULER_NO_TASK == successor_stats_task) |
798 | { | 829 | { |
799 | start_testbed_service_on_all_peers(); | 830 | start_profiling(); |
800 | } | 831 | } |
801 | 832 | ||
802 | return; | 833 | return; |
@@ -817,7 +848,7 @@ successor_stats_cont (void *cls, | |||
817 | 848 | ||
818 | if(GNUNET_SCHEDULER_NO_TASK == successor_stats_task) | 849 | if(GNUNET_SCHEDULER_NO_TASK == successor_stats_task) |
819 | { | 850 | { |
820 | start_testbed_service_on_all_peers(); | 851 | start_profiling(); |
821 | } | 852 | } |
822 | 853 | ||
823 | return; | 854 | return; |