diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-12-03 14:16:34 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-12-03 14:16:34 +0000 |
commit | 7098267e7ae29b19bc797c5c5c5f5a7e1b146a78 (patch) | |
tree | 2cc530e6a9b3ecf055fbd85ac7600d33d386d735 /src/mesh/gnunet-regex-profiler.c | |
parent | 91443f0b2069987845c458ab70eee8f0600f5939 (diff) | |
download | gnunet-7098267e7ae29b19bc797c5c5c5f5a7e1b146a78.tar.gz gnunet-7098267e7ae29b19bc797c5c5c5f5a7e1b146a78.zip |
- fixes
Diffstat (limited to 'src/mesh/gnunet-regex-profiler.c')
-rw-r--r-- | src/mesh/gnunet-regex-profiler.c | 63 |
1 files changed, 54 insertions, 9 deletions
diff --git a/src/mesh/gnunet-regex-profiler.c b/src/mesh/gnunet-regex-profiler.c index 0733e267f..6ea28a79c 100644 --- a/src/mesh/gnunet-regex-profiler.c +++ b/src/mesh/gnunet-regex-profiler.c | |||
@@ -232,6 +232,11 @@ static struct DLLOperation *dll_op_tail; | |||
232 | static struct GNUNET_TESTBED_Operation *topology_op; | 232 | static struct GNUNET_TESTBED_Operation *topology_op; |
233 | 233 | ||
234 | /** | 234 | /** |
235 | * The handle for whether a host is habitable or not | ||
236 | */ | ||
237 | struct GNUNET_TESTBED_HostHabitableCheckHandle **hc_handles; | ||
238 | |||
239 | /** | ||
235 | * Abort task identifier | 240 | * Abort task identifier |
236 | */ | 241 | */ |
237 | static GNUNET_SCHEDULER_TaskIdentifier abort_task; | 242 | static GNUNET_SCHEDULER_TaskIdentifier abort_task; |
@@ -491,6 +496,14 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
491 | shutdown_task = GNUNET_SCHEDULER_NO_TASK; | 496 | shutdown_task = GNUNET_SCHEDULER_NO_TASK; |
492 | if (GNUNET_SCHEDULER_NO_TASK != abort_task) | 497 | if (GNUNET_SCHEDULER_NO_TASK != abort_task) |
493 | GNUNET_SCHEDULER_cancel (abort_task); | 498 | GNUNET_SCHEDULER_cancel (abort_task); |
499 | if (NULL != hc_handles) | ||
500 | { | ||
501 | for (nhost = 0; nhost < num_hosts; nhost++) | ||
502 | if (NULL != hc_handles[num_hosts]) | ||
503 | GNUNET_TESTBED_is_host_habitable_cancel (hc_handles[num_hosts]); | ||
504 | GNUNET_free (hc_handles); | ||
505 | hc_handles = NULL; | ||
506 | } | ||
494 | if (GNUNET_SCHEDULER_NO_TASK != register_hosts_task) | 507 | if (GNUNET_SCHEDULER_NO_TASK != register_hosts_task) |
495 | GNUNET_SCHEDULER_cancel (register_hosts_task); | 508 | GNUNET_SCHEDULER_cancel (register_hosts_task); |
496 | 509 | ||
@@ -1668,6 +1681,35 @@ load_search_strings (const char *filename, char ***strings, unsigned int limit) | |||
1668 | 1681 | ||
1669 | 1682 | ||
1670 | /** | 1683 | /** |
1684 | * Callbacks of this type are called by GNUNET_TESTBED_is_host_habitable to | ||
1685 | * inform whether the given host is habitable or not. The Handle returned by | ||
1686 | * GNUNET_TESTBED_is_host_habitable() is invalid after this callback is called | ||
1687 | * | ||
1688 | * @param cls NULL | ||
1689 | * @param status GNUNET_YES if it is habitable; GNUNET_NO if not | ||
1690 | */ | ||
1691 | static void | ||
1692 | host_habitable_cb (void *cls, int status) | ||
1693 | { | ||
1694 | struct GNUNET_TESTBED_HostHabitableCheckHandle **hc_handle = cls; | ||
1695 | static unsigned int hosts_checked; | ||
1696 | |||
1697 | *hc_handle = NULL; | ||
1698 | if (++hosts_checked < num_hosts) | ||
1699 | return; | ||
1700 | GNUNET_free (hc_handles); | ||
1701 | hc_handles = NULL; | ||
1702 | mc_proc = | ||
1703 | GNUNET_TESTBED_controller_start (GNUNET_TESTBED_host_get_hostname | ||
1704 | (hosts[0]), | ||
1705 | hosts[0], | ||
1706 | cfg, | ||
1707 | status_cb, | ||
1708 | NULL); | ||
1709 | } | ||
1710 | |||
1711 | |||
1712 | /** | ||
1671 | * Main function that will be run by the scheduler. | 1713 | * Main function that will be run by the scheduler. |
1672 | * | 1714 | * |
1673 | * @param cls closure | 1715 | * @param cls closure |
@@ -1698,12 +1740,22 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1698 | fprintf (stderr, _("No hosts loaded. Need at least one host\n")); | 1740 | fprintf (stderr, _("No hosts loaded. Need at least one host\n")); |
1699 | return; | 1741 | return; |
1700 | } | 1742 | } |
1743 | hc_handles = GNUNET_malloc (sizeof (struct | ||
1744 | GNUNET_TESTBED_HostHabitableCheckHandle *) | ||
1745 | * num_hosts); | ||
1701 | for (nhost = 0; nhost < num_hosts; nhost++) | 1746 | for (nhost = 0; nhost < num_hosts; nhost++) |
1702 | { | 1747 | { |
1703 | if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (hosts[nhost], config)) | 1748 | if (NULL == (hc_handles[nhost] = GNUNET_TESTBED_is_host_habitable (hosts[nhost], config, |
1749 | &host_habitable_cb, | ||
1750 | &hc_handles[nhost]))) | ||
1704 | { | 1751 | { |
1705 | fprintf (stderr, _("Host %s cannot start testbed\n"), | 1752 | fprintf (stderr, _("Host %s cannot start testbed\n"), |
1706 | GNUNET_TESTBED_host_get_hostname (hosts[nhost])); | 1753 | GNUNET_TESTBED_host_get_hostname (hosts[nhost])); |
1754 | for (nhost = 0; nhost < num_hosts; nhost++) | ||
1755 | if (NULL != hc_handles[num_hosts]) | ||
1756 | GNUNET_TESTBED_is_host_habitable_cancel (hc_handles[num_hosts]); | ||
1757 | GNUNET_free (hc_handles); | ||
1758 | hc_handles = NULL; | ||
1707 | break; | 1759 | break; |
1708 | } | 1760 | } |
1709 | } | 1761 | } |
@@ -1771,13 +1823,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1771 | for (i = 0; i < num_search_strings; i++) | 1823 | for (i = 0; i < num_search_strings; i++) |
1772 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "search string: %s\n", search_strings[i]); | 1824 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "search string: %s\n", search_strings[i]); |
1773 | cfg = GNUNET_CONFIGURATION_dup (config); | 1825 | cfg = GNUNET_CONFIGURATION_dup (config); |
1774 | mc_proc = | ||
1775 | GNUNET_TESTBED_controller_start (GNUNET_TESTBED_host_get_hostname | ||
1776 | (hosts[0]), | ||
1777 | hosts[0], | ||
1778 | cfg, | ||
1779 | status_cb, | ||
1780 | NULL); | ||
1781 | abort_task = | 1826 | abort_task = |
1782 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 1827 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
1783 | (GNUNET_TIME_UNIT_SECONDS, 5), &do_abort, | 1828 | (GNUNET_TIME_UNIT_SECONDS, 5), &do_abort, |