aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/gnunet-service-test-barriers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/gnunet-service-test-barriers.c')
-rw-r--r--src/testbed/gnunet-service-test-barriers.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/testbed/gnunet-service-test-barriers.c b/src/testbed/gnunet-service-test-barriers.c
index 281172cbf..ce5249696 100644
--- a/src/testbed/gnunet-service-test-barriers.c
+++ b/src/testbed/gnunet-service-test-barriers.c
@@ -39,7 +39,9 @@
39/** 39/**
40 * Our barrier wait handle 40 * Our barrier wait handle
41 */ 41 */
42struct GNUNET_TESTBED_BarrierWaitHandle *wh; 42static struct GNUNET_TESTBED_BarrierWaitHandle *wh;
43
44static struct GNUNET_SCHEDULER_Task *tt;
43 45
44 46
45/** 47/**
@@ -51,8 +53,15 @@ static void
51do_shutdown (void *cls) 53do_shutdown (void *cls)
52{ 54{
53 if (NULL != wh) 55 if (NULL != wh)
56 {
54 GNUNET_TESTBED_barrier_wait_cancel (wh); 57 GNUNET_TESTBED_barrier_wait_cancel (wh);
55 wh = NULL; 58 wh = NULL;
59 }
60 if (NULL != tt)
61 {
62 GNUNET_SCHEDULER_cancel (tt);
63 tt = NULL;
64 }
56} 65}
57 66
58 67
@@ -63,8 +72,8 @@ do_shutdown (void *cls)
63 * 72 *
64 * @param cls NULL 73 * @param cls NULL
65 * @param name the barrier name 74 * @param name the barrier name
66 * @param status GNUNET_SYSERR in case of error while waiting for the barrier; 75 * @param status #GNUNET_SYSERR in case of error while waiting for the barrier;
67 * GNUNET_OK if the barrier is crossed 76 * #GNUNET_OK if the barrier is crossed
68 */ 77 */
69static void 78static void
70barrier_wait_cb (void *cls, const char *name, int status) 79barrier_wait_cb (void *cls, const char *name, int status)
@@ -84,12 +93,10 @@ barrier_wait_cb (void *cls, const char *name, int status)
84static void 93static void
85do_wait (void *cls) 94do_wait (void *cls)
86{ 95{
87 const struct GNUNET_SCHEDULER_TaskContext *tc; 96 tt = NULL;
88 97 wh = GNUNET_TESTBED_barrier_wait (TEST_BARRIER_NAME,
89 tc = GNUNET_SCHEDULER_get_task_context (); 98 &barrier_wait_cb,
90 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) 99 NULL);
91 return;
92 wh = GNUNET_TESTBED_barrier_wait (TEST_BARRIER_NAME, &barrier_wait_cb, NULL);
93 GNUNET_break (NULL != wh); 100 GNUNET_break (NULL != wh);
94} 101}
95 102
@@ -103,17 +110,18 @@ do_wait (void *cls)
103 * @param config the configuration file handle 110 * @param config the configuration file handle
104 */ 111 */
105static void 112static void
106run (void *cls, char *const *args, const char *cfgfile, 113run (void *cls,
114 char *const *args,
115 const char *cfgfile,
107 const struct GNUNET_CONFIGURATION_Handle *config) 116 const struct GNUNET_CONFIGURATION_Handle *config)
108{ 117{
109 unsigned int rsec; 118 unsigned int rsec;
110 119
111 rsec = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, 10); 120 rsec = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, 10);
112 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 121 tt = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
113 (GNUNET_TIME_UNIT_SECONDS, rsec), 122 (GNUNET_TIME_UNIT_SECONDS, rsec),
114 &do_wait, NULL); 123 &do_wait, NULL);
115 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 124 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
116 &do_shutdown, NULL);
117} 125}
118 126
119 127
@@ -121,7 +129,8 @@ run (void *cls, char *const *args, const char *cfgfile,
121/** 129/**
122 * Main 130 * Main
123 */ 131 */
124int main (int argc, char **argv) 132int
133main (int argc, char **argv)
125{ 134{
126 struct GNUNET_GETOPT_CommandLineOption options[] = { 135 struct GNUNET_GETOPT_CommandLineOption options[] = {
127 GNUNET_GETOPT_OPTION_END 136 GNUNET_GETOPT_OPTION_END