diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-12-03 13:58:54 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-12-03 13:58:54 +0000 |
commit | 91443f0b2069987845c458ab70eee8f0600f5939 (patch) | |
tree | 2ad1d5cb676f2146cccc009bf2a9209c56012ef2 /src/testbed/test_testbed_api_controllerlink.c | |
parent | 020a5d9860368e63c997fb5dd82b2498b85f0584 (diff) | |
download | gnunet-91443f0b2069987845c458ab70eee8f0600f5939.tar.gz gnunet-91443f0b2069987845c458ab70eee8f0600f5939.zip |
making GNUNET_TESTBED_is_host_compatible() asynchronous
Diffstat (limited to 'src/testbed/test_testbed_api_controllerlink.c')
-rw-r--r-- | src/testbed/test_testbed_api_controllerlink.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/testbed/test_testbed_api_controllerlink.c b/src/testbed/test_testbed_api_controllerlink.c index da9fd000b..3867df27b 100644 --- a/src/testbed/test_testbed_api_controllerlink.c +++ b/src/testbed/test_testbed_api_controllerlink.c | |||
@@ -243,6 +243,11 @@ static struct GNUNET_TESTBED_Peer *slave2_peer; | |||
243 | static struct GNUNET_TESTBED_Peer *master_peer; | 243 | static struct GNUNET_TESTBED_Peer *master_peer; |
244 | 244 | ||
245 | /** | 245 | /** |
246 | * The handle for whether a host is habitable or not | ||
247 | */ | ||
248 | struct GNUNET_TESTBED_HostHabitableCheckHandle *hc_handle; | ||
249 | |||
250 | /** | ||
246 | * Event mask | 251 | * Event mask |
247 | */ | 252 | */ |
248 | uint64_t event_mask; | 253 | uint64_t event_mask; |
@@ -264,6 +269,8 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
264 | { | 269 | { |
265 | if (GNUNET_SCHEDULER_NO_TASK != abort_task) | 270 | if (GNUNET_SCHEDULER_NO_TASK != abort_task) |
266 | GNUNET_SCHEDULER_cancel (abort_task); | 271 | GNUNET_SCHEDULER_cancel (abort_task); |
272 | if (NULL != hc_handle) | ||
273 | GNUNET_TESTBED_is_host_habitable_cancel (hc_handle); | ||
267 | if (NULL != slave3) | 274 | if (NULL != slave3) |
268 | GNUNET_TESTBED_host_destroy (slave3); | 275 | GNUNET_TESTBED_host_destroy (slave3); |
269 | if (NULL != slave2) | 276 | if (NULL != slave2) |
@@ -632,6 +639,23 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, | |||
632 | 639 | ||
633 | 640 | ||
634 | /** | 641 | /** |
642 | * Callbacks of this type are called by GNUNET_TESTBED_is_host_habitable to | ||
643 | * inform whether the given host is habitable or not. The Handle returned by | ||
644 | * GNUNET_TESTBED_is_host_habitable() is invalid after this callback is called | ||
645 | * | ||
646 | * @param cls NULL | ||
647 | * @param status GNUNET_YES if it is habitable; GNUNET_NO if not | ||
648 | */ | ||
649 | static void | ||
650 | host_habitable_cb (void *cls, int status) | ||
651 | { | ||
652 | hc_handle = NULL; | ||
653 | cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb, | ||
654 | NULL); | ||
655 | } | ||
656 | |||
657 | |||
658 | /** | ||
635 | * Main run function. | 659 | * Main run function. |
636 | * | 660 | * |
637 | * @param cls NULL | 661 | * @param cls NULL |
@@ -645,7 +669,9 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
645 | { | 669 | { |
646 | host = GNUNET_TESTBED_host_create (NULL, NULL, 0); | 670 | host = GNUNET_TESTBED_host_create (NULL, NULL, 0); |
647 | GNUNET_assert (NULL != host); | 671 | GNUNET_assert (NULL != host); |
648 | if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (host, config)) | 672 | if (NULL == (hc_handle = GNUNET_TESTBED_is_host_habitable (host, config, |
673 | &host_habitable_cb, | ||
674 | NULL))) | ||
649 | { | 675 | { |
650 | GNUNET_TESTBED_host_destroy (host); | 676 | GNUNET_TESTBED_host_destroy (host); |
651 | host = NULL; | 677 | host = NULL; |
@@ -656,9 +682,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
656 | result = SUCCESS; | 682 | result = SUCCESS; |
657 | return; | 683 | return; |
658 | } | 684 | } |
659 | cfg = GNUNET_CONFIGURATION_dup (config); | 685 | cfg = GNUNET_CONFIGURATION_dup (config); |
660 | cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb, | ||
661 | NULL); | ||
662 | abort_task = | 686 | abort_task = |
663 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 687 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
664 | (GNUNET_TIME_UNIT_MINUTES, 5), &do_abort, | 688 | (GNUNET_TIME_UNIT_MINUTES, 5), &do_abort, |