diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-03-11 16:34:55 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-03-11 16:34:55 +0000 |
commit | 6973ade884b8e22e7fcaa51a90d00a8caa2d2fa4 (patch) | |
tree | a472296f94a4a20b2838206cf13a20f9ac1cd3b9 /src/regex | |
parent | e2b8b97e769f8963876b7e820601d792058e9b55 (diff) | |
download | gnunet-6973ade884b8e22e7fcaa51a90d00a8caa2d2fa4.tar.gz gnunet-6973ade884b8e22e7fcaa51a90d00a8caa2d2fa4.zip |
- Remove printf, use GNUNET_log INFO
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/gnunet-regex-profiler.c | 121 |
1 files changed, 69 insertions, 52 deletions
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c index 139092686..0c104fab4 100644 --- a/src/regex/gnunet-regex-profiler.c +++ b/src/regex/gnunet-regex-profiler.c | |||
@@ -831,20 +831,17 @@ regex_found_handler (void *cls, | |||
831 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 831 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
832 | "String matching timed out for string %s on peer %u (%i/%i)\n", | 832 | "String matching timed out for string %s on peer %u (%i/%i)\n", |
833 | peer->search_str, peer->id, peers_found, num_search_strings); | 833 | peer->search_str, peer->id, peers_found, num_search_strings); |
834 | |||
835 | printf ("String matching timed out for string %s on peer %u (%i/%i)\n", | ||
836 | peer->search_str, peer->id, peers_found, num_search_strings); | ||
837 | |||
838 | peer->search_str_matched = GNUNET_SYSERR; | 834 | peer->search_str_matched = GNUNET_SYSERR; |
839 | } | 835 | } |
840 | else | 836 | else |
841 | { | 837 | { |
842 | prof_time = GNUNET_TIME_absolute_get_duration (peer->prof_start_time); | 838 | prof_time = GNUNET_TIME_absolute_get_duration (peer->prof_start_time); |
843 | 839 | ||
844 | printf ("String %s found on peer %u after %s (%i/%i) (%u||)\n", | 840 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
845 | peer->search_str, peer->id, GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO), | 841 | "String %s found on peer %u after %s (%i/%i) (%u||)\n", |
846 | peers_found, num_search_strings, parallel_searches); | 842 | peer->search_str, peer->id, |
847 | fflush (stdout); | 843 | GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO), |
844 | peers_found, num_search_strings, parallel_searches); | ||
848 | 845 | ||
849 | peer->search_str_matched = GNUNET_YES; | 846 | peer->search_str_matched = GNUNET_YES; |
850 | 847 | ||
@@ -878,13 +875,11 @@ regex_found_handler (void *cls, | |||
878 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 875 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
879 | "All strings successfully matched in %s\n", | 876 | "All strings successfully matched in %s\n", |
880 | GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO)); | 877 | GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO)); |
881 | printf ("All strings successfully matched.\n"); | ||
882 | fflush (stdout); | ||
883 | 878 | ||
884 | if (GNUNET_SCHEDULER_NO_TASK != search_timeout_task) | 879 | if (GNUNET_SCHEDULER_NO_TASK != search_timeout_task) |
885 | GNUNET_SCHEDULER_cancel (search_timeout_task); | 880 | GNUNET_SCHEDULER_cancel (search_timeout_task); |
886 | 881 | ||
887 | printf ("Collecting stats and shutting down.\n"); | 882 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Collecting stats and shutting down.\n"); |
888 | GNUNET_SCHEDULER_add_now (&do_collect_stats, NULL); | 883 | GNUNET_SCHEDULER_add_now (&do_collect_stats, NULL); |
889 | } | 884 | } |
890 | } | 885 | } |
@@ -955,6 +950,10 @@ find_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
955 | 950 | ||
956 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 951 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
957 | return; | 952 | return; |
953 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
954 | "Searching for string \"%s\" on peer %d timed out. Starting new search.\n", | ||
955 | p->search_str, | ||
956 | p->id); | ||
958 | GNUNET_SCHEDULER_add_now (&find_next_string, NULL); | 957 | GNUNET_SCHEDULER_add_now (&find_next_string, NULL); |
959 | } | 958 | } |
960 | 959 | ||
@@ -1081,10 +1080,11 @@ arm_start_cb (void *cls, enum GNUNET_ARM_ProcessStatus result) | |||
1081 | } | 1080 | } |
1082 | else | 1081 | else |
1083 | { | 1082 | { |
1084 | printf ("All daemons started. Waiting %s to start string searches\n", | 1083 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1085 | GNUNET_STRINGS_relative_time_to_string (search_delay, | 1084 | "All daemons started." |
1086 | GNUNET_NO)); | 1085 | " Waiting %s to start string searches\n", |
1087 | fflush (stdout); | 1086 | GNUNET_STRINGS_relative_time_to_string (search_delay, |
1087 | GNUNET_NO)); | ||
1088 | GNUNET_SCHEDULER_add_delayed (search_delay, | 1088 | GNUNET_SCHEDULER_add_delayed (search_delay, |
1089 | do_connect_by_string, | 1089 | do_connect_by_string, |
1090 | NULL); | 1090 | NULL); |
@@ -1210,8 +1210,7 @@ announce_next_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1210 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 1210 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
1211 | return; | 1211 | return; |
1212 | 1212 | ||
1213 | printf ("Starting daemon %ld\n", next_p); | 1213 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Starting daemon %ld\n", next_p); |
1214 | fflush (stdout); | ||
1215 | 1214 | ||
1216 | peers[next_p].op_handle = | 1215 | peers[next_p].op_handle = |
1217 | GNUNET_TESTBED_service_connect (NULL, | 1216 | GNUNET_TESTBED_service_connect (NULL, |
@@ -1381,8 +1380,9 @@ peer_churn_cb (void *cls, const char *emsg) | |||
1381 | if (++started_peers == num_peers) | 1380 | if (++started_peers == num_peers) |
1382 | { | 1381 | { |
1383 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); | 1382 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); |
1384 | printf("All peers started successfully in %s\n", | 1383 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1385 | GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO)); | 1384 | "All peers started successfully in %s\n", |
1385 | GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO)); | ||
1386 | result = GNUNET_OK; | 1386 | result = GNUNET_OK; |
1387 | 1387 | ||
1388 | peer_handles = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Peer *) * num_peers); | 1388 | peer_handles = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Peer *) * num_peers); |
@@ -1441,8 +1441,9 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) | |||
1441 | if (++created_peers == num_peers) | 1441 | if (++created_peers == num_peers) |
1442 | { | 1442 | { |
1443 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); | 1443 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); |
1444 | printf ("All peers created successfully in %s\n", | 1444 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1445 | GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO)); | 1445 | "All peers created successfully in %s\n", |
1446 | GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO)); | ||
1446 | /* Now peers are to be started */ | 1447 | /* Now peers are to be started */ |
1447 | state = STATE_PEERS_STARTING; | 1448 | state = STATE_PEERS_STARTING; |
1448 | prof_start_time = GNUNET_TIME_absolute_get (); | 1449 | prof_start_time = GNUNET_TIME_absolute_get (); |
@@ -1620,9 +1621,9 @@ controller_event_cb (void *cls, | |||
1620 | { | 1621 | { |
1621 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1622 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1622 | _("An operation has failed while linking\n")); | 1623 | _("An operation has failed while linking\n")); |
1623 | printf ("F%u/%u ", retry_links + 1, established_links + 1); | 1624 | printf ("F%u/%u(%s)", |
1624 | printf ("\n%s\n ", event->details.operation_finished.emsg); | 1625 | retry_links + 1, established_links + 1, |
1625 | fflush (stdout); | 1626 | event->details.operation_finished.emsg); |
1626 | retry_links++; | 1627 | retry_links++; |
1627 | } | 1628 | } |
1628 | /* We do no retries, consider this link as established */ | 1629 | /* We do no retries, consider this link as established */ |
@@ -1633,22 +1634,24 @@ controller_event_cb (void *cls, | |||
1633 | size_t size; | 1634 | size_t size; |
1634 | 1635 | ||
1635 | if (0 == established_links) | 1636 | if (0 == established_links) |
1636 | printf ("Establishing links ."); | 1637 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Establishing links ."); |
1637 | else | 1638 | else |
1638 | { | 1639 | { |
1639 | printf ("."); | 1640 | printf ("."); |
1640 | fflush (stdout); | ||
1641 | } | 1641 | } |
1642 | if (++established_links == num_links) | 1642 | if (++established_links == num_links) |
1643 | { | 1643 | { |
1644 | fflush (stdout); | ||
1645 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); | 1644 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); |
1646 | printf ("\n%u links established in %s\n", | 1645 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1647 | num_links, | 1646 | "\n%u links established in %s\n", |
1648 | GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO)); | 1647 | num_links, |
1648 | GNUNET_STRINGS_relative_time_to_string (prof_time, | ||
1649 | GNUNET_NO)); | ||
1649 | prof_time = GNUNET_TIME_relative_divide(prof_time, num_links); | 1650 | prof_time = GNUNET_TIME_relative_divide(prof_time, num_links); |
1650 | printf ("Average of %s per connection\n", | 1651 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1651 | GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO)); | 1652 | "Average of %s per connection\n", |
1653 | GNUNET_STRINGS_relative_time_to_string (prof_time, | ||
1654 | GNUNET_NO)); | ||
1652 | result = GNUNET_OK; | 1655 | result = GNUNET_OK; |
1653 | GNUNET_free (peer_handles); | 1656 | GNUNET_free (peer_handles); |
1654 | 1657 | ||
@@ -1658,11 +1661,14 @@ controller_event_cb (void *cls, | |||
1658 | GNUNET_snprintf (output_buffer, | 1661 | GNUNET_snprintf (output_buffer, |
1659 | sizeof (output_buffer), | 1662 | sizeof (output_buffer), |
1660 | "# of peers: %u\n# of links established: %u\n" | 1663 | "# of peers: %u\n# of links established: %u\n" |
1661 | "Time to establish links: %s\nLinking failures: %u\n" | 1664 | "Time to establish links: %s\n" |
1662 | "path compression length: %u\n# of search strings: %u\n", | 1665 | "Linking failures: %u\n" |
1666 | "path compression length: %u\n" | ||
1667 | "# of search strings: %u\n", | ||
1663 | num_peers, | 1668 | num_peers, |
1664 | (established_links - retry_links), | 1669 | (established_links - retry_links), |
1665 | GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO), | 1670 | GNUNET_STRINGS_relative_time_to_string (prof_time, |
1671 | GNUNET_NO), | ||
1666 | retry_links, | 1672 | retry_links, |
1667 | max_path_compression, | 1673 | max_path_compression, |
1668 | num_search_strings); | 1674 | num_search_strings); |
@@ -1671,12 +1677,11 @@ controller_event_cb (void *cls, | |||
1671 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n"); | 1677 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n"); |
1672 | } | 1678 | } |
1673 | 1679 | ||
1674 | printf ("\nWaiting %s before starting to announce.\n", | 1680 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1675 | GNUNET_STRINGS_relative_time_to_string (search_delay, GNUNET_NO)); | 1681 | "\nWaiting %s before starting to announce.\n", |
1676 | fflush (stdout); | 1682 | GNUNET_STRINGS_relative_time_to_string (search_delay, |
1677 | 1683 | GNUNET_NO)); | |
1678 | state = STATE_SEARCH_REGEX; | 1684 | state = STATE_SEARCH_REGEX; |
1679 | |||
1680 | search_task = GNUNET_SCHEDULER_add_delayed (search_delay, | 1685 | search_task = GNUNET_SCHEDULER_add_delayed (search_delay, |
1681 | &do_announce, NULL); | 1686 | &do_announce, NULL); |
1682 | } | 1687 | } |
@@ -1795,7 +1800,7 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, int stat | |||
1795 | if (GNUNET_OK != status) | 1800 | if (GNUNET_OK != status) |
1796 | { | 1801 | { |
1797 | mc_proc = NULL; | 1802 | mc_proc = NULL; |
1798 | printf("Oh, dear!\n"); | 1803 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Oh, dear!\n"); |
1799 | abort_task = GNUNET_SCHEDULER_add_now (&do_abort, (void*) __LINE__); | 1804 | abort_task = GNUNET_SCHEDULER_add_now (&do_abort, (void*) __LINE__); |
1800 | return; | 1805 | return; |
1801 | } | 1806 | } |
@@ -1955,21 +1960,26 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1955 | 1960 | ||
1956 | if (NULL == args[0]) | 1961 | if (NULL == args[0]) |
1957 | { | 1962 | { |
1958 | fprintf (stderr, _("No hosts-file specified on command line. Exiting.\n")); | 1963 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1964 | _("No hosts-file specified on command line. Exiting.\n")); | ||
1959 | return; | 1965 | return; |
1960 | } | 1966 | } |
1961 | if (NULL == args[1]) | 1967 | if (NULL == args[1]) |
1962 | { | 1968 | { |
1963 | fprintf (stderr, _("No policy directory specified on command line. Exiting.\n")); | 1969 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1970 | _("No policy directory specified on command line. Exiting.\n")); | ||
1964 | return; | 1971 | return; |
1965 | } | 1972 | } |
1966 | num_hosts = GNUNET_TESTBED_hosts_load_from_file (args[0], config, &hosts); | 1973 | num_hosts = GNUNET_TESTBED_hosts_load_from_file (args[0], config, &hosts); |
1967 | if (0 == num_hosts) | 1974 | if (0 == num_hosts) |
1968 | { | 1975 | { |
1969 | fprintf (stderr, _("No hosts loaded. Need at least one host\n")); | 1976 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1977 | _("No hosts loaded. Need at least one host\n")); | ||
1970 | return; | 1978 | return; |
1971 | } | 1979 | } |
1972 | printf (_("Checking whether given hosts can start testbed. Please wait\n")); | 1980 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1981 | _("Checking whether given hosts can start testbed." | ||
1982 | "Please wait\n")); | ||
1973 | hc_handles = GNUNET_malloc (sizeof (struct | 1983 | hc_handles = GNUNET_malloc (sizeof (struct |
1974 | GNUNET_TESTBED_HostHabitableCheckHandle *) | 1984 | GNUNET_TESTBED_HostHabitableCheckHandle *) |
1975 | * num_hosts); | 1985 | * num_hosts); |
@@ -1993,13 +2003,14 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1993 | } | 2003 | } |
1994 | if (num_hosts != nhost) | 2004 | if (num_hosts != nhost) |
1995 | { | 2005 | { |
1996 | fprintf (stderr, _("Exiting\n")); | 2006 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Exiting\n")); |
1997 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 2007 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
1998 | return; | 2008 | return; |
1999 | } | 2009 | } |
2000 | if (NULL == config) | 2010 | if (NULL == config) |
2001 | { | 2011 | { |
2002 | fprintf (stderr, _("No configuration file given. Exiting\n")); | 2012 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2013 | _("No configuration file given. Exiting\n")); | ||
2003 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 2014 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
2004 | return; | 2015 | return; |
2005 | } | 2016 | } |
@@ -2008,7 +2019,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
2008 | GNUNET_CONFIGURATION_get_value_string (config, "REGEXPROFILER", "REGEX_PREFIX", | 2019 | GNUNET_CONFIGURATION_get_value_string (config, "REGEXPROFILER", "REGEX_PREFIX", |
2009 | ®ex_prefix)) | 2020 | ®ex_prefix)) |
2010 | { | 2021 | { |
2011 | fprintf (stderr, _("Configuration option (regex_prefix) missing. Exiting\n")); | 2022 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2023 | _("Configuration option \"regex_prefix\" missing. Exiting\n")); | ||
2012 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 2024 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
2013 | return; | 2025 | return; |
2014 | } | 2026 | } |
@@ -2026,14 +2038,16 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
2026 | data_filename); | 2038 | data_filename); |
2027 | if (GNUNET_YES != GNUNET_DISK_directory_test (args[1], GNUNET_YES)) | 2039 | if (GNUNET_YES != GNUNET_DISK_directory_test (args[1], GNUNET_YES)) |
2028 | { | 2040 | { |
2029 | fprintf (stderr, _("Specified policies directory does not exist. Exiting.\n")); | 2041 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2042 | _("Specified policies directory does not exist. Exiting.\n")); | ||
2030 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 2043 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
2031 | return; | 2044 | return; |
2032 | } | 2045 | } |
2033 | policy_dir = args[1]; | 2046 | policy_dir = args[1]; |
2034 | if (GNUNET_YES != GNUNET_DISK_file_test (args[2])) | 2047 | if (GNUNET_YES != GNUNET_DISK_file_test (args[2])) |
2035 | { | 2048 | { |
2036 | fprintf (stderr, _("No search strings file given. Exiting.\n")); | 2049 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2050 | _("No search strings file given. Exiting.\n")); | ||
2037 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 2051 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
2038 | return; | 2052 | return; |
2039 | } | 2053 | } |
@@ -2041,13 +2055,16 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
2041 | if (num_search_strings != nsearchstrs) | 2055 | if (num_search_strings != nsearchstrs) |
2042 | { | 2056 | { |
2043 | num_search_strings = nsearchstrs; | 2057 | num_search_strings = nsearchstrs; |
2044 | fprintf (stderr, _("Error loading search strings. Given file does not contain enough strings. Exiting.\n")); | 2058 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2059 | _("Error loading search strings." | ||
2060 | "Given file does not contain enough strings. Exiting.\n")); | ||
2045 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 2061 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
2046 | return; | 2062 | return; |
2047 | } | 2063 | } |
2048 | if (0 >= num_search_strings || NULL == search_strings) | 2064 | if (0 >= num_search_strings || NULL == search_strings) |
2049 | { | 2065 | { |
2050 | fprintf (stderr, _("Error loading search strings. Exiting.\n")); | 2066 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2067 | _("Error loading search strings. Exiting.\n")); | ||
2051 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 2068 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
2052 | return; | 2069 | return; |
2053 | } | 2070 | } |