diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-05-06 13:01:36 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-05-06 13:01:36 +0000 |
commit | 5db8393ac0292d55042f8a01f72541b3c9104387 (patch) | |
tree | 8036d57a80c6b62129dbd4393caf0c812d796359 /src/regex | |
parent | 629389ce6a11921b5324f236bc3b4fd497ada9ac (diff) | |
download | gnunet-5db8393ac0292d55042f8a01f72541b3c9104387.tar.gz gnunet-5db8393ac0292d55042f8a01f72541b3c9104387.zip |
- simplify parameters
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/gnunet-regex-profiler.c | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c index a533f04c9..8c36e440c 100644 --- a/src/regex/gnunet-regex-profiler.c +++ b/src/regex/gnunet-regex-profiler.c | |||
@@ -274,16 +274,11 @@ static char *hosts_file; | |||
274 | static char *strings_file; | 274 | static char *strings_file; |
275 | 275 | ||
276 | /** | 276 | /** |
277 | * Search strings. | 277 | * Search strings (num_peers of them). |
278 | */ | 278 | */ |
279 | static char **search_strings; | 279 | static char **search_strings; |
280 | 280 | ||
281 | /** | 281 | /** |
282 | * Number of search strings. | ||
283 | */ | ||
284 | static int num_search_strings; | ||
285 | |||
286 | /** | ||
287 | * How many searches are we going to start in parallel | 282 | * How many searches are we going to start in parallel |
288 | */ | 283 | */ |
289 | static long long unsigned int init_parallel_searches; | 284 | static long long unsigned int init_parallel_searches; |
@@ -469,7 +464,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
469 | GNUNET_DISK_file_close (data_file); | 464 | GNUNET_DISK_file_close (data_file); |
470 | 465 | ||
471 | for (search_str_cnt = 0; | 466 | for (search_str_cnt = 0; |
472 | search_str_cnt < num_search_strings && NULL != search_strings; | 467 | search_str_cnt < num_peers && NULL != search_strings; |
473 | search_str_cnt++) | 468 | search_str_cnt++) |
474 | { | 469 | { |
475 | GNUNET_free_non_null (search_strings[search_str_cnt]); | 470 | GNUNET_free_non_null (search_strings[search_str_cnt]); |
@@ -767,7 +762,7 @@ regex_found_handler (void *cls, | |||
767 | // FIXME not possible right now | 762 | // FIXME not possible right now |
768 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 763 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
769 | "String matching timed out for string %s on peer %u (%i/%i)\n", | 764 | "String matching timed out for string %s on peer %u (%i/%i)\n", |
770 | peer->search_str, peer->id, strings_found, num_search_strings); | 765 | peer->search_str, peer->id, strings_found, num_peers); |
771 | peer->search_str_matched = GNUNET_SYSERR; | 766 | peer->search_str_matched = GNUNET_SYSERR; |
772 | } | 767 | } |
773 | else | 768 | else |
@@ -778,7 +773,7 @@ regex_found_handler (void *cls, | |||
778 | "String %s found on peer %u after %s (%i/%i) (%u||)\n", | 773 | "String %s found on peer %u after %s (%i/%i) (%u||)\n", |
779 | peer->search_str, peer->id, | 774 | peer->search_str, peer->id, |
780 | GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO), | 775 | GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO), |
781 | strings_found, num_search_strings, parallel_searches); | 776 | strings_found, num_peers, parallel_searches); |
782 | 777 | ||
783 | peer->search_str_matched = GNUNET_YES; | 778 | peer->search_str_matched = GNUNET_YES; |
784 | 779 | ||
@@ -804,7 +799,7 @@ regex_found_handler (void *cls, | |||
804 | GNUNET_TESTBED_operation_done (peer->op_handle); | 799 | GNUNET_TESTBED_operation_done (peer->op_handle); |
805 | peer->op_handle = NULL; | 800 | peer->op_handle = NULL; |
806 | 801 | ||
807 | if (strings_found == num_search_strings) | 802 | if (strings_found == num_peers) |
808 | { | 803 | { |
809 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); | 804 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); |
810 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 805 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -837,7 +832,7 @@ search_timed_out (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
837 | GNUNET_STRINGS_relative_time_to_string (search_timeout_time, | 832 | GNUNET_STRINGS_relative_time_to_string (search_timeout_time, |
838 | GNUNET_NO)); | 833 | GNUNET_NO)); |
839 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 834 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
840 | "Found %i of %i strings\n", strings_found, num_search_strings); | 835 | "Found %i of %i strings\n", strings_found, num_peers); |
841 | 836 | ||
842 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 837 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
843 | "Search timed out after %s." | 838 | "Search timed out after %s." |
@@ -897,7 +892,7 @@ find_string (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
897 | unsigned int search_peer = (unsigned int) (long) cls; | 892 | unsigned int search_peer = (unsigned int) (long) cls; |
898 | 893 | ||
899 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) || | 894 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) || |
900 | search_peer >= num_search_strings) | 895 | search_peer >= num_peers) |
901 | return; | 896 | return; |
902 | 897 | ||
903 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 898 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -1336,8 +1331,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1336 | } | 1331 | } |
1337 | nsearchstrs = load_search_strings (strings_file, | 1332 | nsearchstrs = load_search_strings (strings_file, |
1338 | &search_strings, | 1333 | &search_strings, |
1339 | num_search_strings); | 1334 | num_peers); |
1340 | if (num_search_strings != nsearchstrs) | 1335 | if (num_peers != nsearchstrs) |
1341 | { | 1336 | { |
1342 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1337 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1343 | _("Error loading search strings." | 1338 | _("Error loading search strings." |
@@ -1345,14 +1340,14 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1345 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 1340 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
1346 | return; | 1341 | return; |
1347 | } | 1342 | } |
1348 | if (0 >= num_search_strings || NULL == search_strings) | 1343 | if (0 >= num_peers || NULL == search_strings) |
1349 | { | 1344 | { |
1350 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1345 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1351 | _("Error loading search strings. Exiting.\n")); | 1346 | _("Error loading search strings. Exiting.\n")); |
1352 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 1347 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
1353 | return; | 1348 | return; |
1354 | } | 1349 | } |
1355 | for (i = 0; i < num_search_strings; i++) | 1350 | for (i = 0; i < num_peers; i++) |
1356 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1351 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1357 | "search string: %s\n", | 1352 | "search string: %s\n", |
1358 | search_strings[i]); | 1353 | search_strings[i]); |
@@ -1419,19 +1414,16 @@ main (int argc, char *const *argv) | |||
1419 | GNUNET_YES, &GNUNET_GETOPT_set_string, &data_filename}, | 1414 | GNUNET_YES, &GNUNET_GETOPT_set_string, &data_filename}, |
1420 | {'t', "matching-timeout", "TIMEOUT", | 1415 | {'t', "matching-timeout", "TIMEOUT", |
1421 | gettext_noop ("wait TIMEOUT before ending the experiment"), | 1416 | gettext_noop ("wait TIMEOUT before ending the experiment"), |
1422 | GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &search_timeout_time }, | 1417 | GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &search_timeout_time}, |
1423 | {'n', "num-search-strings", "COUNT", | ||
1424 | gettext_noop ("number of search strings to read from search strings file"), | ||
1425 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_search_strings }, | ||
1426 | {'p', "policy-dir", "DIRECTORY", | 1418 | {'p', "policy-dir", "DIRECTORY", |
1427 | gettext_noop ("directory with policy files"), | 1419 | gettext_noop ("directory with policy files"), |
1428 | GNUNET_YES, &GNUNET_GETOPT_set_filename, &policy_dir }, | 1420 | GNUNET_YES, &GNUNET_GETOPT_set_filename, &policy_dir}, |
1429 | {'s', "strings-file", "FILENAME", | 1421 | {'s', "strings-file", "FILENAME", |
1430 | gettext_noop ("name of file with input strings"), | 1422 | gettext_noop ("name of file with input strings"), |
1431 | GNUNET_YES, &GNUNET_GETOPT_set_filename, &strings_file }, | 1423 | GNUNET_YES, &GNUNET_GETOPT_set_filename, &strings_file}, |
1432 | {'H', "hosts-file", "FILENAME", | 1424 | {'H', "hosts-file", "FILENAME", |
1433 | gettext_noop ("name of file with hosts' names"), | 1425 | gettext_noop ("name of file with hosts' names"), |
1434 | GNUNET_NO, &GNUNET_GETOPT_set_filename, &hosts_file }, | 1426 | GNUNET_NO, &GNUNET_GETOPT_set_filename, &hosts_file}, |
1435 | GNUNET_GETOPT_OPTION_END | 1427 | GNUNET_GETOPT_OPTION_END |
1436 | }; | 1428 | }; |
1437 | int ret; | 1429 | int ret; |