aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/test_testbed_api_3peers_3controllers.c
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-12-03 13:58:54 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-12-03 13:58:54 +0000
commit91443f0b2069987845c458ab70eee8f0600f5939 (patch)
tree2ad1d5cb676f2146cccc009bf2a9209c56012ef2 /src/testbed/test_testbed_api_3peers_3controllers.c
parent020a5d9860368e63c997fb5dd82b2498b85f0584 (diff)
downloadgnunet-91443f0b2069987845c458ab70eee8f0600f5939.tar.gz
gnunet-91443f0b2069987845c458ab70eee8f0600f5939.zip
making GNUNET_TESTBED_is_host_compatible() asynchronous
Diffstat (limited to 'src/testbed/test_testbed_api_3peers_3controllers.c')
-rw-r--r--src/testbed/test_testbed_api_3peers_3controllers.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/testbed/test_testbed_api_3peers_3controllers.c b/src/testbed/test_testbed_api_3peers_3controllers.c
index 3e75469ff..0bdcb6147 100644
--- a/src/testbed/test_testbed_api_3peers_3controllers.c
+++ b/src/testbed/test_testbed_api_3peers_3controllers.c
@@ -144,6 +144,11 @@ static struct GNUNET_CONFIGURATION_Handle *cfg2;
144static struct GNUNET_TESTBED_Operation *common_operation; 144static struct GNUNET_TESTBED_Operation *common_operation;
145 145
146/** 146/**
147 * The handle for whether a host is habitable or not
148 */
149struct GNUNET_TESTBED_HostHabitableCheckHandle *hc_handle;
150
151/**
147 * Abort task identifier 152 * Abort task identifier
148 */ 153 */
149static GNUNET_SCHEDULER_TaskIdentifier abort_task; 154static GNUNET_SCHEDULER_TaskIdentifier abort_task;
@@ -256,6 +261,8 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
256{ 261{
257 if (GNUNET_SCHEDULER_NO_TASK != abort_task) 262 if (GNUNET_SCHEDULER_NO_TASK != abort_task)
258 GNUNET_SCHEDULER_cancel (abort_task); 263 GNUNET_SCHEDULER_cancel (abort_task);
264 if (NULL != hc_handle)
265 GNUNET_TESTBED_is_host_habitable_cancel (hc_handle);
259 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == delayed_connect_task); 266 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == delayed_connect_task);
260 if (NULL != reg_handle) 267 if (NULL != reg_handle)
261 GNUNET_TESTBED_cancel_registration (reg_handle); 268 GNUNET_TESTBED_cancel_registration (reg_handle);
@@ -854,6 +861,23 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, int stat
854 861
855 862
856/** 863/**
864 * Callbacks of this type are called by GNUNET_TESTBED_is_host_habitable to
865 * inform whether the given host is habitable or not. The Handle returned by
866 * GNUNET_TESTBED_is_host_habitable() is invalid after this callback is called
867 *
868 * @param cls NULL
869 * @param status GNUNET_YES if it is habitable; GNUNET_NO if not
870 */
871static void
872host_habitable_cb (void *cls, int status)
873{
874 hc_handle = NULL;
875 cp1 = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb,
876 NULL);
877}
878
879
880/**
857 * Main run function. 881 * Main run function.
858 * 882 *
859 * @param cls NULL 883 * @param cls NULL
@@ -872,7 +896,9 @@ run (void *cls, char *const *args, const char *cfgfile,
872 abort_test(); 896 abort_test();
873 return; 897 return;
874 } 898 }
875 if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (host, config)) 899 if (NULL == (hc_handle = GNUNET_TESTBED_is_host_habitable (host, config,
900 &host_habitable_cb,
901 NULL)))
876 { 902 {
877 GNUNET_TESTBED_host_destroy (host); 903 GNUNET_TESTBED_host_destroy (host);
878 host = NULL; 904 host = NULL;
@@ -884,8 +910,6 @@ run (void *cls, char *const *args, const char *cfgfile,
884 return; 910 return;
885 } 911 }
886 cfg = GNUNET_CONFIGURATION_dup (config); 912 cfg = GNUNET_CONFIGURATION_dup (config);
887 cp1 = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb,
888 NULL);
889 abort_task = 913 abort_task =
890 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 914 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
891 (GNUNET_TIME_UNIT_MINUTES, 3), &do_abort, 915 (GNUNET_TIME_UNIT_MINUTES, 3), &do_abort,