diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-04-27 15:32:55 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-04-27 15:32:55 +0000 |
commit | 7346e9edb1c5d68312a76ae10a38d360beaa39b5 (patch) | |
tree | c545520152b6507a471a371bdcdaf6a15ccefcd1 /src/testing/test_testing_topology.c | |
parent | c457e0af785fbb91c06869ac789ae39e5cfda7c3 (diff) | |
download | gnunet-7346e9edb1c5d68312a76ae10a38d360beaa39b5.tar.gz gnunet-7346e9edb1c5d68312a76ae10a38d360beaa39b5.zip |
testing bug fixes (hopefully)
Diffstat (limited to 'src/testing/test_testing_topology.c')
-rw-r--r-- | src/testing/test_testing_topology.c | 360 |
1 files changed, 186 insertions, 174 deletions
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c index eae59913c..6961f0418 100644 --- a/src/testing/test_testing_topology.c +++ b/src/testing/test_testing_topology.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include "gnunet_testing_lib.h" | 25 | #include "gnunet_testing_lib.h" |
26 | #include "gnunet_core_service.h" | 26 | #include "gnunet_core_service.h" |
27 | 27 | ||
28 | #define VERBOSE GNUNET_NO | 28 | #define VERBOSE GNUNET_YES |
29 | 29 | ||
30 | /** | 30 | /** |
31 | * How long until we fail the whole testcase? | 31 | * How long until we fail the whole testcase? |
@@ -37,7 +37,9 @@ | |||
37 | */ | 37 | */ |
38 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) | 38 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) |
39 | 39 | ||
40 | #define DEFAULT_NUM_PEERS 4; | 40 | #define DEFAULT_NUM_PEERS 4 |
41 | |||
42 | #define MAX_OUTSTANDING_CONNECTIONS 300 | ||
41 | 43 | ||
42 | static float fail_percentage = 0.05; | 44 | static float fail_percentage = 0.05; |
43 | 45 | ||
@@ -75,12 +77,25 @@ static char *topology_string; | |||
75 | 77 | ||
76 | static int transmit_ready_scheduled; | 78 | static int transmit_ready_scheduled; |
77 | 79 | ||
78 | static int transmit_ready_called; | 80 | static int transmit_ready_failed; |
79 | 81 | ||
80 | struct TestMessageContext *global_pos; | 82 | static int transmit_ready_called; |
81 | 83 | ||
82 | #define MTYPE 12345 | 84 | #define MTYPE 12345 |
83 | 85 | ||
86 | struct GNUNET_TestMessage | ||
87 | { | ||
88 | /** | ||
89 | * Header of the message | ||
90 | */ | ||
91 | struct GNUNET_MessageHeader header; | ||
92 | |||
93 | /** | ||
94 | * Unique identifier for this message. | ||
95 | */ | ||
96 | uint32_t uid; | ||
97 | }; | ||
98 | |||
84 | struct TestMessageContext | 99 | struct TestMessageContext |
85 | { | 100 | { |
86 | /* This is a linked list */ | 101 | /* This is a linked list */ |
@@ -98,46 +113,45 @@ struct TestMessageContext | |||
98 | /* Handle to the receiving peer daemon */ | 113 | /* Handle to the receiving peer daemon */ |
99 | struct GNUNET_TESTING_Daemon *peer2; | 114 | struct GNUNET_TESTING_Daemon *peer2; |
100 | 115 | ||
101 | /* Maintain some state */ | 116 | /* Identifier for this message, so we don't disconnect other peers! */ |
102 | int first_step_done; | 117 | uint32_t uid; |
103 | 118 | ||
104 | }; | 119 | }; |
105 | 120 | ||
106 | struct Connection | ||
107 | { | ||
108 | struct Connection *next; | ||
109 | struct GNUNET_TESTING_Daemon *peer; | ||
110 | struct GNUNET_CORE_Handle *server; | ||
111 | }; | ||
112 | |||
113 | static struct Connection *global_connections; | ||
114 | |||
115 | static struct TestMessageContext *test_messages; | 121 | static struct TestMessageContext *test_messages; |
116 | 122 | ||
117 | static void | 123 | static void |
118 | finish_testing () | 124 | finish_testing () |
119 | { | 125 | { |
120 | GNUNET_assert (pg != NULL); | 126 | GNUNET_assert (pg != NULL); |
121 | struct Connection *pos; | 127 | struct TestMessageContext *pos; |
128 | struct TestMessageContext *free_pos; | ||
122 | #if VERBOSE | 129 | #if VERBOSE |
123 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 130 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
124 | "Called finish testing, stopping daemons.\n"); | 131 | "Called finish testing, stopping daemons.\n"); |
125 | #endif | 132 | #endif |
126 | int count; | 133 | int count; |
127 | count = 0; | 134 | count = 0; |
128 | pos = global_connections; | 135 | pos = test_messages; |
129 | while (pos != NULL) | 136 | while (pos != NULL) |
130 | { | 137 | { |
131 | if (pos->server != NULL) | 138 | if (pos->peer1handle != NULL) |
139 | { | ||
140 | GNUNET_CORE_disconnect(pos->peer1handle); | ||
141 | pos->peer1handle = NULL; | ||
142 | } | ||
143 | if (pos->peer2handle != NULL) | ||
132 | { | 144 | { |
133 | GNUNET_CORE_disconnect(pos->server); | 145 | GNUNET_CORE_disconnect(pos->peer2handle); |
134 | pos->server = NULL; | 146 | pos->peer2handle = NULL; |
135 | } | 147 | } |
148 | free_pos = pos; | ||
136 | pos = pos->next; | 149 | pos = pos->next; |
150 | GNUNET_free(free_pos); | ||
137 | } | 151 | } |
138 | #if VERBOSE | 152 | #if VERBOSE |
139 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 153 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
140 | "transmit_ready's scheduled %d, transmit_ready's called %d\n", transmit_ready_scheduled, transmit_ready_called); | 154 | "transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", transmit_ready_scheduled, transmit_ready_failed, transmit_ready_called); |
141 | #endif | 155 | #endif |
142 | sleep(1); | 156 | sleep(1); |
143 | #if VERBOSE | 157 | #if VERBOSE |
@@ -158,6 +172,32 @@ finish_testing () | |||
158 | ok = 0; | 172 | ok = 0; |
159 | } | 173 | } |
160 | 174 | ||
175 | |||
176 | static void | ||
177 | disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | ||
178 | { | ||
179 | struct TestMessageContext *pos = cls; | ||
180 | |||
181 | /* Disconnect from the respective cores */ | ||
182 | #if VERBOSE | ||
183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
184 | "Disconnecting from peer 1 `%4s'\n", GNUNET_i2s (&pos->peer1->id)); | ||
185 | #endif | ||
186 | if (pos->peer1handle != NULL) | ||
187 | GNUNET_CORE_disconnect(pos->peer1handle); | ||
188 | #if VERBOSE | ||
189 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
190 | "Disconnecting from peer 2 `%4s'\n", GNUNET_i2s (&pos->peer2->id)); | ||
191 | #endif | ||
192 | if (pos->peer2handle != NULL) | ||
193 | GNUNET_CORE_disconnect(pos->peer2handle); | ||
194 | /* Set handles to NULL so test case can be ended properly */ | ||
195 | pos->peer1handle = NULL; | ||
196 | pos->peer2handle = NULL; | ||
197 | /* Decrement total connections so new can be established */ | ||
198 | total_server_connections -= 2; | ||
199 | } | ||
200 | |||
161 | static int | 201 | static int |
162 | process_mtype (void *cls, | 202 | process_mtype (void *cls, |
163 | const struct GNUNET_PeerIdentity *peer, | 203 | const struct GNUNET_PeerIdentity *peer, |
@@ -165,6 +205,11 @@ process_mtype (void *cls, | |||
165 | struct GNUNET_TIME_Relative latency, | 205 | struct GNUNET_TIME_Relative latency, |
166 | uint32_t distance) | 206 | uint32_t distance) |
167 | { | 207 | { |
208 | struct TestMessageContext *pos = cls; | ||
209 | struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *)message; | ||
210 | if (pos->uid != ntohl(msg->uid)) | ||
211 | return GNUNET_OK; | ||
212 | |||
168 | total_messages_received++; | 213 | total_messages_received++; |
169 | #if VERBOSE | 214 | #if VERBOSE |
170 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 215 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -178,6 +223,11 @@ process_mtype (void *cls, | |||
178 | GNUNET_SCHEDULER_cancel (sched, die_task); | 223 | GNUNET_SCHEDULER_cancel (sched, die_task); |
179 | GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); | 224 | GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); |
180 | } | 225 | } |
226 | else | ||
227 | { | ||
228 | GNUNET_SCHEDULER_add_now(sched, &disconnect_cores, pos); | ||
229 | } | ||
230 | |||
181 | return GNUNET_OK; | 231 | return GNUNET_OK; |
182 | } | 232 | } |
183 | 233 | ||
@@ -187,17 +237,25 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
187 | char *msg = cls; | 237 | char *msg = cls; |
188 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 238 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
189 | "End badly was called (%s)... stopping daemons.\n", msg); | 239 | "End badly was called (%s)... stopping daemons.\n", msg); |
190 | struct Connection *pos; | 240 | struct TestMessageContext *pos; |
241 | struct TestMessageContext *free_pos; | ||
191 | 242 | ||
192 | pos = global_connections; | 243 | pos = test_messages; |
193 | while (pos != NULL) | 244 | while (pos != NULL) |
194 | { | 245 | { |
195 | if (pos->server != NULL) | 246 | if (pos->peer1handle != NULL) |
247 | { | ||
248 | GNUNET_CORE_disconnect(pos->peer1handle); | ||
249 | pos->peer1handle = NULL; | ||
250 | } | ||
251 | if (pos->peer2handle != NULL) | ||
196 | { | 252 | { |
197 | GNUNET_CORE_disconnect(pos->server); | 253 | GNUNET_CORE_disconnect(pos->peer2handle); |
198 | pos->server = NULL; | 254 | pos->peer2handle = NULL; |
199 | } | 255 | } |
256 | free_pos = pos; | ||
200 | pos = pos->next; | 257 | pos = pos->next; |
258 | GNUNET_free(free_pos); | ||
201 | } | 259 | } |
202 | 260 | ||
203 | if (pg != NULL) | 261 | if (pg != NULL) |
@@ -216,195 +274,151 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
216 | } | 274 | } |
217 | 275 | ||
218 | 276 | ||
219 | /** | ||
220 | * Forward declaration. | ||
221 | */ | ||
222 | static size_t | ||
223 | transmit_ready (void *cls, size_t size, void *buf); | ||
224 | |||
225 | static void | ||
226 | schedule_transmission (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | ||
227 | { | ||
228 | |||
229 | if (global_pos != NULL) | ||
230 | { | ||
231 | if (NULL == GNUNET_CORE_notify_transmit_ready (global_pos->peer1handle, | ||
232 | 0, | ||
233 | TIMEOUT, | ||
234 | &global_pos->peer2->id, | ||
235 | sizeof (struct GNUNET_MessageHeader), | ||
236 | &transmit_ready, &global_pos->peer1->id)) | ||
237 | { | ||
238 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
239 | "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", | ||
240 | GNUNET_i2s (&global_pos->peer2->id)); | ||
241 | } | ||
242 | else | ||
243 | { | ||
244 | transmit_ready_scheduled++; | ||
245 | } | ||
246 | global_pos = global_pos->next; | ||
247 | } | ||
248 | else | ||
249 | { | ||
250 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
251 | "Transmit ready scheduled on %d messages\n", | ||
252 | transmit_ready_scheduled); | ||
253 | } | ||
254 | |||
255 | } | ||
256 | 277 | ||
257 | static size_t | 278 | static size_t |
258 | transmit_ready (void *cls, size_t size, void *buf) | 279 | transmit_ready (void *cls, size_t size, void *buf) |
259 | { | 280 | { |
260 | struct GNUNET_MessageHeader *m; | 281 | struct GNUNET_TestMessage *m; |
261 | #if VERBOSE | 282 | struct TestMessageContext *pos = cls; |
262 | struct GNUNET_PeerIdentity *peer = cls; | ||
263 | #endif | ||
264 | GNUNET_assert (buf != NULL); | ||
265 | m = (struct GNUNET_MessageHeader *) buf; | ||
266 | m->type = htons (MTYPE); | ||
267 | m->size = htons (sizeof (struct GNUNET_MessageHeader)); | ||
268 | 283 | ||
284 | GNUNET_assert (buf != NULL); | ||
285 | m = (struct GNUNET_TestMessage *) buf; | ||
286 | m->header.type = htons (MTYPE); | ||
287 | m->header.size = htons (sizeof (struct GNUNET_TestMessage)); | ||
288 | m->uid = htonl(pos->uid); | ||
269 | transmit_ready_called++; | 289 | transmit_ready_called++; |
270 | #if VERBOSE | 290 | #if VERBOSE |
271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 291 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
272 | "transmit ready for peer %s\ntransmit_ready's scheduled %d, transmit_ready's called %d\n", GNUNET_i2s(peer), transmit_ready_scheduled, transmit_ready_called); | 292 | "transmit ready for peer %s\ntransmit_ready's scheduled %d, transmit_ready's called %d\n", GNUNET_i2s(&pos->peer1->id), transmit_ready_scheduled, transmit_ready_called); |
273 | #endif | 293 | #endif |
274 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 50), &schedule_transmission, NULL); | 294 | return sizeof (struct GNUNET_TestMessage); |
275 | return sizeof (struct GNUNET_MessageHeader); | ||
276 | } | 295 | } |
277 | 296 | ||
278 | 297 | ||
279 | static struct GNUNET_CORE_MessageHandler handlers[] = { | 298 | static struct GNUNET_CORE_MessageHandler no_handlers[] = { |
280 | {&process_mtype, MTYPE, sizeof (struct GNUNET_MessageHeader)}, | ||
281 | {NULL, 0, 0} | 299 | {NULL, 0, 0} |
282 | }; | 300 | }; |
283 | 301 | ||
284 | 302 | static struct GNUNET_CORE_MessageHandler handlers[] = { | |
303 | {&process_mtype, MTYPE, sizeof (struct GNUNET_TestMessage)}, | ||
304 | {NULL, 0, 0} | ||
305 | }; | ||
285 | 306 | ||
286 | static void | 307 | static void |
287 | send_test_messages () | 308 | init_notify_peer2 (void *cls, |
309 | struct GNUNET_CORE_Handle *server, | ||
310 | const struct GNUNET_PeerIdentity *my_identity, | ||
311 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) | ||
288 | { | 312 | { |
289 | struct TestMessageContext *pos; | 313 | struct TestMessageContext *pos = cls; |
290 | struct Connection *conn_pos; | ||
291 | die_task = GNUNET_SCHEDULER_add_delayed (sched, | ||
292 | TEST_TIMEOUT, | ||
293 | &end_badly, "from send test messages"); | ||
294 | |||
295 | int count = 0; | ||
296 | int conn_count = 0; | ||
297 | pos = test_messages; | ||
298 | while (pos != NULL) | ||
299 | { | ||
300 | conn_pos = global_connections; | ||
301 | conn_count = 0; | ||
302 | while (conn_pos != NULL) | ||
303 | { | ||
304 | if (conn_pos->peer == pos->peer1) | ||
305 | { | ||
306 | pos->peer1handle = conn_pos->server; | ||
307 | break; | ||
308 | } | ||
309 | conn_count++; | ||
310 | conn_pos = conn_pos->next; | ||
311 | } | ||
312 | GNUNET_assert(pos->peer1handle != NULL); | ||
313 | |||
314 | /* | ||
315 | if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, | ||
316 | 0, | ||
317 | TIMEOUT, | ||
318 | &pos->peer2->id, | ||
319 | sizeof (struct GNUNET_MessageHeader), | ||
320 | &transmit_ready, &pos->peer1->id)) | ||
321 | { | ||
322 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
323 | "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", | ||
324 | GNUNET_i2s (&pos->peer2->id)); | ||
325 | } | ||
326 | else | ||
327 | { | ||
328 | transmit_ready_scheduled++; | ||
329 | } | ||
330 | */ | ||
331 | pos = pos->next; | ||
332 | count++; | ||
333 | |||
334 | } | ||
335 | 314 | ||
315 | #if VERBOSE | ||
336 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 316 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
337 | "Prepared %d messages\n", | 317 | "Core connection to `%4s' established, scheduling message send\n", |
338 | count); | 318 | GNUNET_i2s (my_identity)); |
339 | global_pos = test_messages; | 319 | #endif |
320 | total_server_connections++; | ||
340 | 321 | ||
341 | GNUNET_SCHEDULER_add_now(sched, &schedule_transmission, NULL); | 322 | if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, |
323 | 0, | ||
324 | TIMEOUT, | ||
325 | &pos->peer2->id, | ||
326 | sizeof (struct GNUNET_TestMessage), | ||
327 | &transmit_ready, pos)) | ||
328 | { | ||
329 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
330 | "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", | ||
331 | GNUNET_i2s (&pos->peer2->id)); | ||
332 | transmit_ready_failed++; | ||
333 | } | ||
334 | else | ||
335 | { | ||
336 | transmit_ready_scheduled++; | ||
337 | } | ||
342 | } | 338 | } |
343 | 339 | ||
344 | 340 | ||
345 | |||
346 | static void | 341 | static void |
347 | init_notify (void *cls, | 342 | init_notify_peer1 (void *cls, |
348 | struct GNUNET_CORE_Handle *server, | 343 | struct GNUNET_CORE_Handle *server, |
349 | const struct GNUNET_PeerIdentity *my_identity, | 344 | const struct GNUNET_PeerIdentity *my_identity, |
350 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) | 345 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) |
351 | { | 346 | { |
352 | struct Connection *connection = cls; | 347 | struct TestMessageContext *pos = cls; |
348 | total_server_connections++; | ||
353 | 349 | ||
354 | #if VERBOSE | 350 | #if VERBOSE |
355 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 351 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
356 | "Core connection to `%4s' established, setting up handles\n", | 352 | "Core connection to `%4s' established, setting up handles\n", |
357 | GNUNET_i2s (my_identity)); | 353 | GNUNET_i2s (my_identity)); |
358 | #endif | 354 | #endif |
359 | connection->server = server; | ||
360 | total_server_connections++; | ||
361 | 355 | ||
362 | if (total_server_connections == num_peers) | 356 | /* |
363 | { | 357 | * Connect to the receiving peer |
364 | GNUNET_SCHEDULER_cancel(sched, die_task); | 358 | */ |
365 | GNUNET_SCHEDULER_add_now(sched, &send_test_messages, NULL); | 359 | pos->peer2handle = GNUNET_CORE_connect (sched, |
366 | } | 360 | pos->peer2->cfg, |
361 | TIMEOUT, | ||
362 | pos, | ||
363 | &init_notify_peer2, | ||
364 | NULL, | ||
365 | NULL, | ||
366 | NULL, | ||
367 | GNUNET_YES, NULL, GNUNET_YES, handlers); | ||
368 | |||
367 | } | 369 | } |
368 | 370 | ||
369 | 371 | ||
370 | static void | 372 | static void |
371 | setup_handlers () | 373 | send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) |
372 | { | 374 | { |
373 | int i; | 375 | struct TestMessageContext *pos = cls; |
374 | struct Connection *new_connection; | ||
375 | 376 | ||
376 | struct GNUNET_TESTING_Daemon *temp_daemon; | 377 | if ((tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) || (cls == NULL)) |
377 | die_task = GNUNET_SCHEDULER_add_delayed (sched, | 378 | return; |
378 | TEST_TIMEOUT, | ||
379 | &end_badly, "from setup_handlers"); | ||
380 | 379 | ||
380 | if (die_task == GNUNET_SCHEDULER_NO_TASK) | ||
381 | { | ||
382 | die_task = GNUNET_SCHEDULER_add_delayed (sched, | ||
383 | TEST_TIMEOUT, | ||
384 | &end_badly, "from create topology (timeout)"); | ||
385 | } | ||
381 | 386 | ||
382 | /** | 387 | if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) |
383 | * Set up a single handler for each peer | 388 | { |
389 | GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), | ||
390 | &send_test_messages, pos); | ||
391 | return; /* Otherwise we'll double schedule messages here! */ | ||
392 | } | ||
393 | |||
394 | /* | ||
395 | * Connect to the sending peer | ||
384 | */ | 396 | */ |
385 | for (i = 0; i < num_peers; i++) | 397 | pos->peer1handle = GNUNET_CORE_connect (sched, |
398 | pos->peer1->cfg, | ||
399 | TIMEOUT, | ||
400 | pos, | ||
401 | &init_notify_peer1, | ||
402 | NULL, | ||
403 | NULL, | ||
404 | NULL, | ||
405 | GNUNET_NO, NULL, GNUNET_NO, no_handlers); | ||
406 | |||
407 | GNUNET_assert(pos->peer1handle != NULL); | ||
408 | |||
409 | if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS) | ||
386 | { | 410 | { |
387 | new_connection = GNUNET_malloc(sizeof(struct Connection)); | 411 | GNUNET_SCHEDULER_add_now (sched, |
388 | temp_daemon = GNUNET_TESTING_daemon_get(pg, i); | 412 | &send_test_messages, pos->next); |
389 | new_connection->peer = temp_daemon; | 413 | } |
390 | new_connection->server = NULL; | 414 | else |
391 | new_connection->next = global_connections; | 415 | { |
392 | global_connections = new_connection; | 416 | GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), |
393 | 417 | &send_test_messages, pos->next); | |
394 | GNUNET_CORE_connect (sched, | ||
395 | temp_daemon->cfg, | ||
396 | TIMEOUT, | ||
397 | new_connection, | ||
398 | &init_notify, | ||
399 | NULL, | ||
400 | NULL, | ||
401 | NULL, | ||
402 | GNUNET_YES, NULL, GNUNET_YES, handlers); | ||
403 | } | 418 | } |
404 | } | 419 | } |
405 | 420 | ||
406 | 421 | ||
407 | |||
408 | void | 422 | void |
409 | topology_callback (void *cls, | 423 | topology_callback (void *cls, |
410 | const struct GNUNET_PeerIdentity *first, | 424 | const struct GNUNET_PeerIdentity *first, |
@@ -425,12 +439,10 @@ topology_callback (void *cls, | |||
425 | second_daemon->shortname); | 439 | second_daemon->shortname); |
426 | #endif | 440 | #endif |
427 | temp_context = GNUNET_malloc(sizeof(struct TestMessageContext)); | 441 | temp_context = GNUNET_malloc(sizeof(struct TestMessageContext)); |
428 | temp_context->first_step_done = 0; | ||
429 | temp_context->peer1handle = NULL; | ||
430 | temp_context->peer1 = first_daemon; | 442 | temp_context->peer1 = first_daemon; |
431 | temp_context->peer2 = second_daemon; | 443 | temp_context->peer2 = second_daemon; |
432 | temp_context->peer2handle = NULL; | ||
433 | temp_context->next = test_messages; | 444 | temp_context->next = test_messages; |
445 | temp_context->uid = total_connections; | ||
434 | test_messages = temp_context; | 446 | test_messages = temp_context; |
435 | 447 | ||
436 | expected_messages++; | 448 | expected_messages++; |
@@ -456,16 +468,16 @@ topology_callback (void *cls, | |||
456 | #endif | 468 | #endif |
457 | 469 | ||
458 | GNUNET_SCHEDULER_cancel (sched, die_task); | 470 | GNUNET_SCHEDULER_cancel (sched, die_task); |
459 | /* die_task = GNUNET_SCHEDULER_add_now (sched, &setup_handlers, NULL); */ | 471 | die_task = GNUNET_SCHEDULER_NO_TASK; |
460 | die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &setup_handlers, NULL); | 472 | GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &send_test_messages, test_messages); |
461 | } | 473 | } |
462 | else if (total_connections + failed_connections == expected_connections) | 474 | else if (total_connections + failed_connections == expected_connections) |
463 | { | 475 | { |
464 | if (failed_connections < (unsigned int)(fail_percentage * total_connections)) | 476 | if (failed_connections < (unsigned int)(fail_percentage * total_connections)) |
465 | { | 477 | { |
466 | GNUNET_SCHEDULER_cancel (sched, die_task); | 478 | GNUNET_SCHEDULER_cancel (sched, die_task); |
467 | /* die_task = GNUNET_SCHEDULER_add_now (sched, &setup_handlers, NULL); */ | 479 | die_task = GNUNET_SCHEDULER_NO_TASK; |
468 | die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &setup_handlers, NULL); | 480 | GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &send_test_messages, test_messages); |
469 | } | 481 | } |
470 | else | 482 | else |
471 | { | 483 | { |
@@ -541,7 +553,7 @@ my_cb (void *cls, | |||
541 | die_task = GNUNET_SCHEDULER_add_delayed (sched, | 553 | die_task = GNUNET_SCHEDULER_add_delayed (sched, |
542 | GNUNET_TIME_relative_multiply | 554 | GNUNET_TIME_relative_multiply |
543 | (GNUNET_TIME_UNIT_MINUTES, 5), | 555 | (GNUNET_TIME_UNIT_MINUTES, 5), |
544 | &end_badly, NULL); | 556 | &end_badly, "from my_cb"); |
545 | create_topology (); | 557 | create_topology (); |
546 | ok = 0; | 558 | ok = 0; |
547 | } | 559 | } |
@@ -580,7 +592,7 @@ run (void *cls, | |||
580 | die_task = GNUNET_SCHEDULER_add_delayed (sched, | 592 | die_task = GNUNET_SCHEDULER_add_delayed (sched, |
581 | GNUNET_TIME_relative_multiply | 593 | GNUNET_TIME_relative_multiply |
582 | (GNUNET_TIME_UNIT_MINUTES, 5), | 594 | (GNUNET_TIME_UNIT_MINUTES, 5), |
583 | &end_badly, NULL); | 595 | &end_badly, "didn't start all daemons in reasonable amount of time!!!"); |
584 | 596 | ||
585 | pg = GNUNET_TESTING_daemons_start (sched, cfg, | 597 | pg = GNUNET_TESTING_daemons_start (sched, cfg, |
586 | peers_left, &my_cb, NULL, | 598 | peers_left, &my_cb, NULL, |