diff options
Diffstat (limited to 'src/testbed/gnunet-service-test-barriers.c')
-rw-r--r-- | src/testbed/gnunet-service-test-barriers.c | 77 |
1 files changed, 39 insertions, 38 deletions
diff --git a/src/testbed/gnunet-service-test-barriers.c b/src/testbed/gnunet-service-test-barriers.c index 5902a1576..b28f343a1 100644 --- a/src/testbed/gnunet-service-test-barriers.c +++ b/src/testbed/gnunet-service-test-barriers.c | |||
@@ -34,7 +34,7 @@ | |||
34 | * logging short hand | 34 | * logging short hand |
35 | */ | 35 | */ |
36 | #define LOG(type, ...) \ | 36 | #define LOG(type, ...) \ |
37 | GNUNET_log(type, __VA_ARGS__); | 37 | GNUNET_log (type, __VA_ARGS__); |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * Our barrier wait handle | 40 | * Our barrier wait handle |
@@ -50,18 +50,18 @@ static struct GNUNET_SCHEDULER_Task *tt; | |||
50 | * @param cls NULL | 50 | * @param cls NULL |
51 | */ | 51 | */ |
52 | static void | 52 | static void |
53 | do_shutdown(void *cls) | 53 | do_shutdown (void *cls) |
54 | { | 54 | { |
55 | if (NULL != wh) | 55 | if (NULL != wh) |
56 | { | 56 | { |
57 | GNUNET_TESTBED_barrier_wait_cancel(wh); | 57 | GNUNET_TESTBED_barrier_wait_cancel (wh); |
58 | wh = NULL; | 58 | wh = NULL; |
59 | } | 59 | } |
60 | if (NULL != tt) | 60 | if (NULL != tt) |
61 | { | 61 | { |
62 | GNUNET_SCHEDULER_cancel(tt); | 62 | GNUNET_SCHEDULER_cancel (tt); |
63 | tt = NULL; | 63 | tt = NULL; |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
@@ -76,13 +76,13 @@ do_shutdown(void *cls) | |||
76 | * #GNUNET_OK if the barrier is crossed | 76 | * #GNUNET_OK if the barrier is crossed |
77 | */ | 77 | */ |
78 | static void | 78 | static void |
79 | barrier_wait_cb(void *cls, | 79 | barrier_wait_cb (void *cls, |
80 | const char *name, | 80 | const char *name, |
81 | int status) | 81 | int status) |
82 | { | 82 | { |
83 | GNUNET_break(NULL == cls); | 83 | GNUNET_break (NULL == cls); |
84 | wh = NULL; | 84 | wh = NULL; |
85 | GNUNET_break(GNUNET_OK == status); | 85 | GNUNET_break (GNUNET_OK == status); |
86 | } | 86 | } |
87 | 87 | ||
88 | 88 | ||
@@ -93,13 +93,13 @@ barrier_wait_cb(void *cls, | |||
93 | * @return | 93 | * @return |
94 | */ | 94 | */ |
95 | static void | 95 | static void |
96 | do_wait(void *cls) | 96 | do_wait (void *cls) |
97 | { | 97 | { |
98 | tt = NULL; | 98 | tt = NULL; |
99 | wh = GNUNET_TESTBED_barrier_wait(TEST_BARRIER_NAME, | 99 | wh = GNUNET_TESTBED_barrier_wait (TEST_BARRIER_NAME, |
100 | &barrier_wait_cb, | 100 | &barrier_wait_cb, |
101 | NULL); | 101 | NULL); |
102 | GNUNET_break(NULL != wh); | 102 | GNUNET_break (NULL != wh); |
103 | } | 103 | } |
104 | 104 | ||
105 | 105 | ||
@@ -112,20 +112,21 @@ do_wait(void *cls) | |||
112 | * @param config the configuration file handle | 112 | * @param config the configuration file handle |
113 | */ | 113 | */ |
114 | static void | 114 | static void |
115 | run(void *cls, | 115 | run (void *cls, |
116 | char *const *args, | 116 | char *const *args, |
117 | const char *cfgfile, | 117 | const char *cfgfile, |
118 | const struct GNUNET_CONFIGURATION_Handle *config) | 118 | const struct GNUNET_CONFIGURATION_Handle *config) |
119 | { | 119 | { |
120 | unsigned int rsec; | 120 | unsigned int rsec; |
121 | 121 | ||
122 | rsec = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_NONCE, | 122 | rsec = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, |
123 | 10); | 123 | 10); |
124 | tt = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, | 124 | tt = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply ( |
125 | rsec), | 125 | GNUNET_TIME_UNIT_SECONDS, |
126 | &do_wait, | 126 | rsec), |
127 | NULL); | 127 | &do_wait, |
128 | GNUNET_SCHEDULER_add_shutdown(&do_shutdown, NULL); | 128 | NULL); |
129 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | ||
129 | } | 130 | } |
130 | 131 | ||
131 | 132 | ||
@@ -134,7 +135,7 @@ run(void *cls, | |||
134 | * Main | 135 | * Main |
135 | */ | 136 | */ |
136 | int | 137 | int |
137 | main(int argc, char **argv) | 138 | main (int argc, char **argv) |
138 | { | 139 | { |
139 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 140 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
140 | GNUNET_GETOPT_OPTION_END | 141 | GNUNET_GETOPT_OPTION_END |
@@ -142,11 +143,11 @@ main(int argc, char **argv) | |||
142 | int ret; | 143 | int ret; |
143 | 144 | ||
144 | ret = | 145 | ret = |
145 | GNUNET_PROGRAM_run(argc, argv, | 146 | GNUNET_PROGRAM_run (argc, argv, |
146 | "test-barriers", | 147 | "test-barriers", |
147 | "nohelp", | 148 | "nohelp", |
148 | options, | 149 | options, |
149 | &run, | 150 | &run, |
150 | NULL); | 151 | NULL); |
151 | return ret; | 152 | return ret; |
152 | } | 153 | } |