diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-03-19 12:05:53 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-03-19 12:05:53 +0000 |
commit | 963060fd10b77167b3850dc3f4fe2cf8a69dee34 (patch) | |
tree | 18af29688a9ac1d1b0998549fa8c7a195d7ce2d6 /src/regex | |
parent | 0f4c35dae599772c40e16304285c21393578f372 (diff) | |
download | gnunet-963060fd10b77167b3850dc3f4fe2cf8a69dee34.tar.gz gnunet-963060fd10b77167b3850dc3f4fe2cf8a69dee34.zip |
- simplify start
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/gnunet-regex-profiler.c | 76 |
1 files changed, 31 insertions, 45 deletions
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c index 991cd40f3..cc8d5af6b 100644 --- a/src/regex/gnunet-regex-profiler.c +++ b/src/regex/gnunet-regex-profiler.c | |||
@@ -36,14 +36,11 @@ | |||
36 | #include "gnunet_dht_service.h" | 36 | #include "gnunet_dht_service.h" |
37 | #include "gnunet_testbed_service.h" | 37 | #include "gnunet_testbed_service.h" |
38 | 38 | ||
39 | #define FIND_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 90) | 39 | #define FIND_TIMEOUT \ |
40 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 90) | ||
41 | #define ANNOUNCE_TIME \ | ||
42 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 200) | ||
40 | #define SEARCHES_IN_PARALLEL 100 | 43 | #define SEARCHES_IN_PARALLEL 100 |
41 | #define ANNOUNCE_DELAY GNUNET_TIME_relative_multiply(\ | ||
42 | GNUNET_TIME_UNIT_MILLISECONDS,\ | ||
43 | 300) | ||
44 | #define SEARCH_DELAY GNUNET_TIME_relative_multiply(\ | ||
45 | GNUNET_TIME_UNIT_MILLISECONDS,\ | ||
46 | 200) | ||
47 | 44 | ||
48 | /** | 45 | /** |
49 | * DLL of operations | 46 | * DLL of operations |
@@ -571,7 +568,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
571 | if (NULL != cfg) | 568 | if (NULL != cfg) |
572 | GNUNET_CONFIGURATION_destroy (cfg); | 569 | GNUNET_CONFIGURATION_destroy (cfg); |
573 | 570 | ||
574 | GNUNET_SCHEDULER_shutdown (); /* Stop scheduler to shutdown testbed run */ | 571 | GNUNET_SCHEDULER_shutdown (); /* Stop scheduler to shutdown testbed run */ |
575 | } | 572 | } |
576 | 573 | ||
577 | 574 | ||
@@ -713,13 +710,13 @@ stats_cb (void *cls, | |||
713 | { | 710 | { |
714 | peer->stats_op_handle = | 711 | peer->stats_op_handle = |
715 | GNUNET_TESTBED_service_connect (NULL, | 712 | GNUNET_TESTBED_service_connect (NULL, |
716 | peer->peer_handle, | 713 | peer->peer_handle, |
717 | "statistics", | 714 | "statistics", |
718 | &stats_connect_cb, | 715 | &stats_connect_cb, |
719 | peer, | 716 | peer, |
720 | &stats_ca, | 717 | &stats_ca, |
721 | &stats_da, | 718 | &stats_da, |
722 | peer); | 719 | peer); |
723 | } | 720 | } |
724 | } | 721 | } |
725 | 722 | ||
@@ -754,12 +751,12 @@ stats_connect_cb (void *cls, | |||
754 | peer->stats_handle = ca_result; | 751 | peer->stats_handle = ca_result; |
755 | 752 | ||
756 | if (NULL == GNUNET_STATISTICS_get (peer->stats_handle, NULL, NULL, | 753 | if (NULL == GNUNET_STATISTICS_get (peer->stats_handle, NULL, NULL, |
757 | GNUNET_TIME_UNIT_FOREVER_REL, | 754 | GNUNET_TIME_UNIT_FOREVER_REL, |
758 | &stats_cb, | 755 | &stats_cb, |
759 | &stats_iterator, peer)) | 756 | &stats_iterator, peer)) |
760 | { | 757 | { |
761 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 758 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
762 | "Could not get statistics of peer %u!\n", peer->id); | 759 | "Could not get statistics of peer %u!\n", peer->id); |
763 | } | 760 | } |
764 | } | 761 | } |
765 | 762 | ||
@@ -780,13 +777,13 @@ do_collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
780 | 777 | ||
781 | peer->stats_op_handle = | 778 | peer->stats_op_handle = |
782 | GNUNET_TESTBED_service_connect (NULL, | 779 | GNUNET_TESTBED_service_connect (NULL, |
783 | peer->peer_handle, | 780 | peer->peer_handle, |
784 | "statistics", | 781 | "statistics", |
785 | &stats_connect_cb, | 782 | &stats_connect_cb, |
786 | peer, | 783 | peer, |
787 | &stats_ca, | 784 | &stats_ca, |
788 | &stats_da, | 785 | &stats_da, |
789 | peer); | 786 | peer); |
790 | } | 787 | } |
791 | 788 | ||
792 | 789 | ||
@@ -843,7 +840,7 @@ regex_found_handler (void *cls, | |||
843 | { | 840 | { |
844 | GNUNET_SCHEDULER_cancel (peer->timeout); | 841 | GNUNET_SCHEDULER_cancel (peer->timeout); |
845 | peer->timeout = GNUNET_SCHEDULER_NO_TASK; | 842 | peer->timeout = GNUNET_SCHEDULER_NO_TASK; |
846 | GNUNET_SCHEDULER_add_delayed (SEARCH_DELAY, &announce_next_regex, NULL); | 843 | GNUNET_SCHEDULER_add_now (&announce_next_regex, NULL); |
847 | } | 844 | } |
848 | 845 | ||
849 | if (NULL == id) | 846 | if (NULL == id) |
@@ -1105,8 +1102,8 @@ arm_start_cb (void *cls, struct GNUNET_ARM_Handle *arm, | |||
1105 | if (i > num_peers) | 1102 | if (i > num_peers) |
1106 | GNUNET_abort (); /* we run out of peers, must be a bug */ | 1103 | GNUNET_abort (); /* we run out of peers, must be a bug */ |
1107 | } | 1104 | } |
1108 | peers[search_peer].search_str = search_strings[search_index]; | 1105 | peers[search_peer].search_str = search_strings[search_index]; |
1109 | GNUNET_SCHEDULER_add_delayed (SEARCH_DELAY, | 1106 | GNUNET_SCHEDULER_add_delayed (ANNOUNCE_TIME, |
1110 | &find_string, | 1107 | &find_string, |
1111 | (void *) search_peer); | 1108 | (void *) search_peer); |
1112 | } | 1109 | } |
@@ -1176,20 +1173,7 @@ do_announce (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1176 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Starting announce.\n"); | 1173 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Starting announce.\n"); |
1177 | 1174 | ||
1178 | for (search_index = 0; search_index < SEARCHES_IN_PARALLEL; search_index++) | 1175 | for (search_index = 0; search_index < SEARCHES_IN_PARALLEL; search_index++) |
1179 | { | 1176 | (void) GNUNET_SCHEDULER_add_now (&announce_next_regex, NULL); |
1180 | /* First connect to arm service, then announce. Next | ||
1181 | announce will be in arm_connect_cb */ | ||
1182 | peers[search_index].op_handle = | ||
1183 | GNUNET_TESTBED_service_connect (NULL, | ||
1184 | peers[search_index].peer_handle, | ||
1185 | "arm", | ||
1186 | &arm_connect_cb, | ||
1187 | &peers[search_index], | ||
1188 | &arm_ca, | ||
1189 | &arm_da, | ||
1190 | &peers[search_index]); | ||
1191 | parallel_searches++; | ||
1192 | } | ||
1193 | } | 1177 | } |
1194 | 1178 | ||
1195 | 1179 | ||
@@ -1205,8 +1189,9 @@ announce_next_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1205 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 1189 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
1206 | return; | 1190 | return; |
1207 | 1191 | ||
1192 | /* First connect to arm service, then announce. Next | ||
1193 | * a nnounce will be in arm_connect_cb */ | ||
1208 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Starting daemon %u\n", search_index); | 1194 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Starting daemon %u\n", search_index); |
1209 | |||
1210 | peers[search_index].op_handle = | 1195 | peers[search_index].op_handle = |
1211 | GNUNET_TESTBED_service_connect (NULL, | 1196 | GNUNET_TESTBED_service_connect (NULL, |
1212 | peers[search_index].peer_handle, | 1197 | peers[search_index].peer_handle, |
@@ -1216,6 +1201,7 @@ announce_next_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1216 | &arm_ca, | 1201 | &arm_ca, |
1217 | &arm_da, | 1202 | &arm_da, |
1218 | &peers[search_index]); | 1203 | &peers[search_index]); |
1204 | parallel_searches++; | ||
1219 | } | 1205 | } |
1220 | 1206 | ||
1221 | /** | 1207 | /** |
@@ -2014,7 +2000,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
2014 | 2000 | ||
2015 | if (GNUNET_OK != | 2001 | if (GNUNET_OK != |
2016 | GNUNET_CONFIGURATION_get_value_string (config, "REGEXPROFILER", "REGEX_PREFIX", | 2002 | GNUNET_CONFIGURATION_get_value_string (config, "REGEXPROFILER", "REGEX_PREFIX", |
2017 | ®ex_prefix)) | 2003 | ®ex_prefix)) |
2018 | { | 2004 | { |
2019 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2005 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2020 | _("Configuration option \"regex_prefix\" missing. Exiting\n")); | 2006 | _("Configuration option \"regex_prefix\" missing. Exiting\n")); |