diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-07-14 20:45:21 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-07-14 20:45:21 +0000 |
commit | a3cd32e111d3fd35137375559a464471be09a1a4 (patch) | |
tree | 34239495994f02bc4f295df2785f911935c98749 /src/transport/test_transport_api_unreliability.c | |
parent | 1b95efd9e4491be038c16fd7dca61e9b79dd502b (diff) | |
download | gnunet-a3cd32e111d3fd35137375559a464471be09a1a4.tar.gz gnunet-a3cd32e111d3fd35137375559a464471be09a1a4.zip |
fix
Diffstat (limited to 'src/transport/test_transport_api_unreliability.c')
-rw-r--r-- | src/transport/test_transport_api_unreliability.c | 110 |
1 files changed, 62 insertions, 48 deletions
diff --git a/src/transport/test_transport_api_unreliability.c b/src/transport/test_transport_api_unreliability.c index 7f31edffd..76e3e4995 100644 --- a/src/transport/test_transport_api_unreliability.c +++ b/src/transport/test_transport_api_unreliability.c | |||
@@ -257,6 +257,45 @@ stop_arm (struct PeerContext *p) | |||
257 | } | 257 | } |
258 | 258 | ||
259 | 259 | ||
260 | |||
261 | static void | ||
262 | exchange_hello_last (void *cls, | ||
263 | const struct GNUNET_MessageHeader *message) | ||
264 | { | ||
265 | struct PeerContext *me = cls; | ||
266 | |||
267 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
268 | "Exchanging HELLO of size %d with peer (%s)!\n", | ||
269 | (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message), | ||
270 | GNUNET_i2s (&me->id)); | ||
271 | GNUNET_assert (message != NULL); | ||
272 | GNUNET_assert (GNUNET_OK == | ||
273 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) | ||
274 | message, &me->id)); | ||
275 | GNUNET_TRANSPORT_offer_hello (p1.th, message, NULL, NULL); | ||
276 | } | ||
277 | |||
278 | |||
279 | |||
280 | static void | ||
281 | exchange_hello (void *cls, | ||
282 | const struct GNUNET_MessageHeader *message) | ||
283 | { | ||
284 | struct PeerContext *me = cls; | ||
285 | |||
286 | GNUNET_assert (message != NULL); | ||
287 | GNUNET_assert (GNUNET_OK == | ||
288 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) | ||
289 | message, &me->id)); | ||
290 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
291 | "Exchanging HELLO of size %d from peer %s!\n", | ||
292 | (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message), | ||
293 | GNUNET_i2s (&me->id)); | ||
294 | GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL); | ||
295 | } | ||
296 | |||
297 | |||
298 | |||
260 | static void | 299 | static void |
261 | end_badly (void *cls, | 300 | end_badly (void *cls, |
262 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 301 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -264,18 +303,30 @@ end_badly (void *cls, | |||
264 | if (test_failed == GNUNET_NO) | 303 | if (test_failed == GNUNET_NO) |
265 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 304 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
266 | "Testcase timeout\n"); | 305 | "Testcase timeout\n"); |
267 | else | 306 | else |
268 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 307 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
269 | "Reliability failed: Last message sent %u, Next message scheduled %u, Last message received %u, Message expected %u\n", | 308 | "Reliability failed: Last message sent %u, Next message scheduled %u, Last message received %u, Message expected %u\n", |
270 | msg_sent, | 309 | msg_sent, |
271 | msg_scheduled, | 310 | msg_scheduled, |
272 | msg_recv, | 311 | msg_recv, |
273 | msg_recv_expected); | 312 | msg_recv_expected); |
274 | if (th_p2 != NULL) | 313 | |
275 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(th_p2); | ||
276 | th_p2 = NULL; | ||
277 | |||
278 | GNUNET_break (0); | 314 | GNUNET_break (0); |
315 | if (th_p2 != NULL) | ||
316 | { | ||
317 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(th_p2); | ||
318 | th_p2 = NULL; | ||
319 | } | ||
320 | if (p2_hello_canceled == GNUNET_NO) | ||
321 | { | ||
322 | GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2); | ||
323 | p2_hello_canceled = GNUNET_YES; | ||
324 | } | ||
325 | if (p1_hello_canceled == GNUNET_NO) | ||
326 | { | ||
327 | GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1); | ||
328 | p1_hello_canceled = GNUNET_YES; | ||
329 | } | ||
279 | GNUNET_TRANSPORT_disconnect (p1.th); | 330 | GNUNET_TRANSPORT_disconnect (p1.th); |
280 | GNUNET_TRANSPORT_disconnect (p2.th); | 331 | GNUNET_TRANSPORT_disconnect (p2.th); |
281 | if (GNUNET_SCHEDULER_NO_TASK != tct) | 332 | if (GNUNET_SCHEDULER_NO_TASK != tct) |
@@ -475,43 +526,6 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
475 | 526 | ||
476 | 527 | ||
477 | static void | 528 | static void |
478 | exchange_hello_last (void *cls, | ||
479 | const struct GNUNET_MessageHeader *message) | ||
480 | { | ||
481 | struct PeerContext *me = cls; | ||
482 | |||
483 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
484 | "Exchanging HELLO of size %d with peer (%s)!\n", | ||
485 | (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message), | ||
486 | GNUNET_i2s (&me->id)); | ||
487 | GNUNET_assert (message != NULL); | ||
488 | GNUNET_assert (GNUNET_OK == | ||
489 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) | ||
490 | message, &me->id)); | ||
491 | GNUNET_TRANSPORT_offer_hello (p1.th, message, NULL, NULL); | ||
492 | } | ||
493 | |||
494 | |||
495 | |||
496 | static void | ||
497 | exchange_hello (void *cls, | ||
498 | const struct GNUNET_MessageHeader *message) | ||
499 | { | ||
500 | struct PeerContext *me = cls; | ||
501 | |||
502 | GNUNET_assert (message != NULL); | ||
503 | GNUNET_assert (GNUNET_OK == | ||
504 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) | ||
505 | message, &me->id)); | ||
506 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
507 | "Exchanging HELLO of size %d from peer %s!\n", | ||
508 | (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message), | ||
509 | GNUNET_i2s (&me->id)); | ||
510 | GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL); | ||
511 | } | ||
512 | |||
513 | |||
514 | static void | ||
515 | notify_connect (void *cls, | 529 | notify_connect (void *cls, |
516 | const struct GNUNET_PeerIdentity *peer, | 530 | const struct GNUNET_PeerIdentity *peer, |
517 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | 531 | const struct GNUNET_TRANSPORT_ATS_Information *ats, |