diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-01-07 16:37:24 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-01-07 16:37:24 +0000 |
commit | eb0d78ddbb8884c441a3467df62659be27384056 (patch) | |
tree | 617f4907ac6448026f64b9a2d1d9f8a9507bd779 /src/testbed/test_testbed_api_3peers_3controllers.c | |
parent | 0a67f09f0ecd7d01c304bf22e56a63d479ba4e42 (diff) | |
download | gnunet-eb0d78ddbb8884c441a3467df62659be27384056.tar.gz gnunet-eb0d78ddbb8884c441a3467df62659be27384056.zip |
- call controller callback before operation completion callback; only way to ensure that GNUNET_TESTBED_operation_done() on GNUNET_TESTBED_underlay_configure_topology() operations doesn't result in segfault.
Diffstat (limited to 'src/testbed/test_testbed_api_3peers_3controllers.c')
-rw-r--r-- | src/testbed/test_testbed_api_3peers_3controllers.c | 97 |
1 files changed, 41 insertions, 56 deletions
diff --git a/src/testbed/test_testbed_api_3peers_3controllers.c b/src/testbed/test_testbed_api_3peers_3controllers.c index 376881c8e..2f08fb475 100644 --- a/src/testbed/test_testbed_api_3peers_3controllers.c +++ b/src/testbed/test_testbed_api_3peers_3controllers.c | |||
@@ -264,6 +264,8 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
264 | if (NULL != hc_handle) | 264 | if (NULL != hc_handle) |
265 | GNUNET_TESTBED_is_host_habitable_cancel (hc_handle); | 265 | GNUNET_TESTBED_is_host_habitable_cancel (hc_handle); |
266 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == delayed_connect_task); | 266 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == delayed_connect_task); |
267 | if (NULL != common_operation) | ||
268 | GNUNET_TESTBED_operation_done (common_operation); | ||
267 | if (NULL != reg_handle) | 269 | if (NULL != reg_handle) |
268 | GNUNET_TESTBED_cancel_registration (reg_handle); | 270 | GNUNET_TESTBED_cancel_registration (reg_handle); |
269 | if (NULL != controller1) | 271 | if (NULL != controller1) |
@@ -360,61 +362,26 @@ op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg) | |||
360 | abort_test(); | 362 | abort_test(); |
361 | return; | 363 | return; |
362 | } | 364 | } |
365 | |||
363 | switch(result) | 366 | switch(result) |
364 | { | 367 | { |
365 | case PEER3_STARTED: | 368 | case PEER3_STARTED: |
366 | if ((NULL != peer1.operation) || | ||
367 | (NULL != peer2.operation) || | ||
368 | (NULL == common_operation)) | ||
369 | { | ||
370 | GNUNET_break (0); | ||
371 | abort_test(); | ||
372 | return; | ||
373 | } | ||
374 | GNUNET_TESTBED_operation_done (common_operation); | ||
375 | common_operation = NULL; | ||
376 | result = PEERS_1_2_CONNECTED; | ||
377 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n"); | ||
378 | common_operation = | ||
379 | GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer2.peer, | ||
380 | peer3.peer); | ||
381 | break; | ||
382 | case PEERS_1_2_CONNECTED: | ||
383 | if (NULL == common_operation) | ||
384 | { | ||
385 | GNUNET_break (0); | ||
386 | abort_test(); | ||
387 | return; | ||
388 | } | ||
389 | GNUNET_TESTBED_operation_done (common_operation); | ||
390 | common_operation = NULL; | ||
391 | result = PEERS_2_3_CONNECTED; | ||
392 | delayed_connect_task = | ||
393 | GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (3), | ||
394 | &do_delayed_connect, NULL); | ||
395 | break; | ||
396 | case PEERS_2_3_CONNECTED: | 369 | case PEERS_2_3_CONNECTED: |
397 | if ((NULL != peer1.operation) || | 370 | case PEERS_1_2_CONNECTED: |
398 | (NULL != peer2.operation) || | ||
399 | (NULL == common_operation)) | ||
400 | { | ||
401 | GNUNET_break (0); | ||
402 | abort_test(); | ||
403 | return; | ||
404 | } | ||
405 | GNUNET_TESTBED_operation_done (common_operation); | ||
406 | common_operation = NULL; | ||
407 | result = PEERS_CONNECTED_2; | ||
408 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected again\n"); | ||
409 | peer1.operation = GNUNET_TESTBED_peer_stop (peer1.peer, NULL, NULL); | ||
410 | peer2.operation = GNUNET_TESTBED_peer_stop (peer2.peer, NULL, NULL); | ||
411 | peer3.operation = GNUNET_TESTBED_peer_stop (peer3.peer, NULL, NULL); | ||
412 | break; | 371 | break; |
413 | default: | 372 | default: |
414 | GNUNET_break (0); | 373 | GNUNET_break (0); |
415 | abort_test(); | 374 | abort_test(); |
416 | return; | 375 | return; |
417 | } | 376 | } |
377 | if ((NULL != peer1.operation) || | ||
378 | (NULL != peer2.operation) || | ||
379 | (NULL != peer3.operation)) | ||
380 | { | ||
381 | GNUNET_break (0); | ||
382 | abort_test(); | ||
383 | return; | ||
384 | } | ||
418 | } | 385 | } |
419 | 386 | ||
420 | 387 | ||
@@ -696,7 +663,8 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
696 | case GNUNET_TESTBED_ET_CONNECT: | 663 | case GNUNET_TESTBED_ET_CONNECT: |
697 | if ((NULL != peer1.operation) || | 664 | if ((NULL != peer1.operation) || |
698 | (NULL != peer2.operation) || | 665 | (NULL != peer2.operation) || |
699 | (NULL != peer3.operation)) | 666 | (NULL != peer3.operation) || |
667 | (NULL == common_operation)) | ||
700 | { | 668 | { |
701 | GNUNET_break (0); | 669 | GNUNET_break (0); |
702 | abort_test(); | 670 | abort_test(); |
@@ -705,34 +673,51 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
705 | switch (result) | 673 | switch (result) |
706 | { | 674 | { |
707 | case PEER3_STARTED: | 675 | case PEER3_STARTED: |
708 | if ((NULL == common_operation) || | 676 | if ((event->details.peer_connect.peer1 != peer2.peer) || |
709 | (event->details.peer_connect.peer1 != peer2.peer) || | ||
710 | (event->details.peer_connect.peer2 != peer1.peer)) | 677 | (event->details.peer_connect.peer2 != peer1.peer)) |
711 | { | 678 | { |
712 | GNUNET_break (0); | 679 | GNUNET_break (0); |
713 | abort_test(); | 680 | abort_test(); |
714 | return; | 681 | return; |
715 | } | 682 | } |
683 | GNUNET_TESTBED_operation_done (common_operation); | ||
684 | common_operation = NULL; | ||
685 | result = PEERS_1_2_CONNECTED; | ||
686 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n"); | ||
687 | common_operation = | ||
688 | GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer2.peer, | ||
689 | peer3.peer); | ||
716 | break; | 690 | break; |
717 | case PEERS_2_3_CONNECTED: | 691 | case PEERS_1_2_CONNECTED: |
718 | if ((NULL == common_operation) || | 692 | if ((event->details.peer_connect.peer1 != peer2.peer) || |
719 | (event->details.peer_connect.peer1 != peer1.peer) || | 693 | (event->details.peer_connect.peer2 != peer3.peer)) |
720 | (event->details.peer_connect.peer2 != peer2.peer)) | ||
721 | { | 694 | { |
722 | GNUNET_break (0); | 695 | GNUNET_break (0); |
723 | abort_test(); | 696 | abort_test(); |
724 | return; | 697 | return; |
725 | } | 698 | } |
699 | GNUNET_TESTBED_operation_done (common_operation); | ||
700 | common_operation = NULL; | ||
701 | result = PEERS_2_3_CONNECTED; | ||
702 | delayed_connect_task = | ||
703 | GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (3), | ||
704 | &do_delayed_connect, NULL); | ||
726 | break; | 705 | break; |
727 | case PEERS_1_2_CONNECTED: | 706 | case PEERS_2_3_CONNECTED: |
728 | if ((NULL == common_operation) || | 707 | if ((event->details.peer_connect.peer1 != peer1.peer) || |
729 | (event->details.peer_connect.peer1 != peer2.peer) || | 708 | (event->details.peer_connect.peer2 != peer2.peer)) |
730 | (event->details.peer_connect.peer2 != peer3.peer)) | ||
731 | { | 709 | { |
732 | GNUNET_break (0); | 710 | GNUNET_break (0); |
733 | abort_test(); | 711 | abort_test(); |
734 | return; | 712 | return; |
735 | } | 713 | } |
714 | GNUNET_TESTBED_operation_done (common_operation); | ||
715 | common_operation = NULL; | ||
716 | result = PEERS_CONNECTED_2; | ||
717 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected again\n"); | ||
718 | peer1.operation = GNUNET_TESTBED_peer_stop (peer1.peer, NULL, NULL); | ||
719 | peer2.operation = GNUNET_TESTBED_peer_stop (peer2.peer, NULL, NULL); | ||
720 | peer3.operation = GNUNET_TESTBED_peer_stop (peer3.peer, NULL, NULL); | ||
736 | break; | 721 | break; |
737 | default: | 722 | default: |
738 | GNUNET_break (0); | 723 | GNUNET_break (0); |