diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-06-25 20:01:13 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-06-25 20:01:13 +0000 |
commit | 4a381daf63c41550306834dc605378bb39afc6da (patch) | |
tree | 565f2a066344c38fcc1aa57cbff13fc1ef7a7a1e /src/testbed/testbed_api.c | |
parent | 3971743af72d4517e9cf5cc2e08645e11b917331 (diff) | |
download | gnunet-4a381daf63c41550306834dc605378bb39afc6da.tar.gz gnunet-4a381daf63c41550306834dc605378bb39afc6da.zip |
first steps towards MQ
Diffstat (limited to 'src/testbed/testbed_api.c')
-rw-r--r-- | src/testbed/testbed_api.c | 316 |
1 files changed, 151 insertions, 165 deletions
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c index dd24e83f8..90b0e06c8 100644 --- a/src/testbed/testbed_api.c +++ b/src/testbed/testbed_api.c | |||
@@ -26,8 +26,6 @@ | |||
26 | * @author Christian Grothoff | 26 | * @author Christian Grothoff |
27 | * @author Sree Harsha Totakura | 27 | * @author Sree Harsha Totakura |
28 | */ | 28 | */ |
29 | |||
30 | |||
31 | #include "platform.h" | 29 | #include "platform.h" |
32 | #include "gnunet_testbed_service.h" | 30 | #include "gnunet_testbed_service.h" |
33 | #include "gnunet_core_service.h" | 31 | #include "gnunet_core_service.h" |
@@ -241,7 +239,9 @@ exop_check (const struct GNUNET_TESTBED_Operation *const op) | |||
241 | while (NULL != entry) | 239 | while (NULL != entry) |
242 | { | 240 | { |
243 | entry2 = entry->next; | 241 | entry2 = entry->next; |
244 | GNUNET_CONTAINER_DLL_remove (exop_head, exop_tail, entry); | 242 | GNUNET_CONTAINER_DLL_remove (exop_head, |
243 | exop_tail, | ||
244 | entry); | ||
245 | GNUNET_free (entry); | 245 | GNUNET_free (entry); |
246 | entry = entry2; | 246 | entry = entry2; |
247 | } | 247 | } |
@@ -366,10 +366,11 @@ GNUNET_TESTBED_remove_opc_ (const struct GNUNET_TESTBED_Controller *c, | |||
366 | * @param msg the message | 366 | * @param msg the message |
367 | */ | 367 | */ |
368 | static void | 368 | static void |
369 | handle_forwarded_operation_msg (struct GNUNET_TESTBED_Controller *c, | 369 | handle_forwarded_operation_msg (void *cls, |
370 | struct OperationContext *opc, | 370 | struct OperationContext *opc, |
371 | const struct GNUNET_MessageHeader *msg) | 371 | const struct GNUNET_MessageHeader *msg) |
372 | { | 372 | { |
373 | struct GNUNET_TESTBED_Controller *c = cls; | ||
373 | struct ForwardedOperationData *fo_data; | 374 | struct ForwardedOperationData *fo_data; |
374 | 375 | ||
375 | fo_data = opc->data; | 376 | fo_data = opc->data; |
@@ -387,14 +388,12 @@ handle_forwarded_operation_msg (struct GNUNET_TESTBED_Controller *c, | |||
387 | * | 388 | * |
388 | * @param c the controller handler | 389 | * @param c the controller handler |
389 | * @param msg message received | 390 | * @param msg message received |
390 | * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if | ||
391 | * not | ||
392 | */ | 391 | */ |
393 | static int | 392 | static void |
394 | handle_opsuccess (struct GNUNET_TESTBED_Controller *c, | 393 | handle_opsuccess (void *cls, |
395 | const struct | 394 | const struct GNUNET_TESTBED_GenericOperationSuccessEventMessage *msg) |
396 | GNUNET_TESTBED_GenericOperationSuccessEventMessage *msg) | ||
397 | { | 395 | { |
396 | struct GNUNET_TESTBED_Controller *c = cls; | ||
398 | struct OperationContext *opc; | 397 | struct OperationContext *opc; |
399 | GNUNET_TESTBED_OperationCompletionCallback op_comp_cb; | 398 | GNUNET_TESTBED_OperationCompletionCallback op_comp_cb; |
400 | void *op_comp_cb_cls; | 399 | void *op_comp_cb_cls; |
@@ -406,7 +405,7 @@ handle_opsuccess (struct GNUNET_TESTBED_Controller *c, | |||
406 | if (NULL == (opc = find_opc (c, op_id))) | 405 | if (NULL == (opc = find_opc (c, op_id))) |
407 | { | 406 | { |
408 | LOG_DEBUG ("Operation not found\n"); | 407 | LOG_DEBUG ("Operation not found\n"); |
409 | return GNUNET_YES; | 408 | return; |
410 | } | 409 | } |
411 | event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; | 410 | event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; |
412 | event.op = opc->op; | 411 | event.op = opc->op; |
@@ -418,11 +417,11 @@ handle_opsuccess (struct GNUNET_TESTBED_Controller *c, | |||
418 | switch (opc->type) | 417 | switch (opc->type) |
419 | { | 418 | { |
420 | case OP_FORWARDED: | 419 | case OP_FORWARDED: |
421 | { | 420 | { |
422 | handle_forwarded_operation_msg (c, opc, | 421 | handle_forwarded_operation_msg (c, opc, |
423 | (const struct GNUNET_MessageHeader *) msg); | 422 | (const struct GNUNET_MessageHeader *) msg); |
424 | return GNUNET_YES; | 423 | return; |
425 | } | 424 | } |
426 | break; | 425 | break; |
427 | case OP_PEER_DESTROY: | 426 | case OP_PEER_DESTROY: |
428 | { | 427 | { |
@@ -471,7 +470,7 @@ handle_opsuccess (struct GNUNET_TESTBED_Controller *c, | |||
471 | if (NULL != c->cc) | 470 | if (NULL != c->cc) |
472 | c->cc (c->cc_cls, &event); | 471 | c->cc (c->cc_cls, &event); |
473 | if (GNUNET_NO == exop_check (event.op)) | 472 | if (GNUNET_NO == exop_check (event.op)) |
474 | return GNUNET_YES; | 473 | return; |
475 | } | 474 | } |
476 | else | 475 | else |
477 | LOG_DEBUG ("Not calling callback\n"); | 476 | LOG_DEBUG ("Not calling callback\n"); |
@@ -479,7 +478,6 @@ handle_opsuccess (struct GNUNET_TESTBED_Controller *c, | |||
479 | op_comp_cb (op_comp_cb_cls, event.op, NULL); | 478 | op_comp_cb (op_comp_cb_cls, event.op, NULL); |
480 | /* You could have marked the operation as done by now */ | 479 | /* You could have marked the operation as done by now */ |
481 | GNUNET_break (GNUNET_NO == exop_check (event.op)); | 480 | GNUNET_break (GNUNET_NO == exop_check (event.op)); |
482 | return GNUNET_YES; | ||
483 | } | 481 | } |
484 | 482 | ||
485 | 483 | ||
@@ -489,20 +487,18 @@ handle_opsuccess (struct GNUNET_TESTBED_Controller *c, | |||
489 | * | 487 | * |
490 | * @param c the controller handle | 488 | * @param c the controller handle |
491 | * @param msg message received | 489 | * @param msg message received |
492 | * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if | ||
493 | * not | ||
494 | */ | 490 | */ |
495 | static int | 491 | static void |
496 | handle_peer_create_success (struct GNUNET_TESTBED_Controller *c, | 492 | handle_peer_create_success (void *cls, |
497 | const struct | 493 | const struct GNUNET_TESTBED_PeerCreateSuccessEventMessage *msg) |
498 | GNUNET_TESTBED_PeerCreateSuccessEventMessage *msg) | ||
499 | { | 494 | { |
495 | struct GNUNET_TESTBED_Controller *c = cls; | ||
500 | struct OperationContext *opc; | 496 | struct OperationContext *opc; |
501 | struct PeerCreateData *data; | 497 | struct PeerCreateData *data; |
502 | struct GNUNET_TESTBED_Peer *peer; | 498 | struct GNUNET_TESTBED_Peer *peer; |
503 | struct GNUNET_TESTBED_Operation *op; | 499 | struct GNUNET_TESTBED_Operation *op; |
504 | GNUNET_TESTBED_PeerCreateCallback cb; | 500 | GNUNET_TESTBED_PeerCreateCallback cb; |
505 | void *cls; | 501 | void *cb_cls; |
506 | uint64_t op_id; | 502 | uint64_t op_id; |
507 | 503 | ||
508 | GNUNET_assert (sizeof (struct GNUNET_TESTBED_PeerCreateSuccessEventMessage) == | 504 | GNUNET_assert (sizeof (struct GNUNET_TESTBED_PeerCreateSuccessEventMessage) == |
@@ -511,13 +507,13 @@ handle_peer_create_success (struct GNUNET_TESTBED_Controller *c, | |||
511 | if (NULL == (opc = find_opc (c, op_id))) | 507 | if (NULL == (opc = find_opc (c, op_id))) |
512 | { | 508 | { |
513 | LOG_DEBUG ("Operation context for PeerCreateSuccessEvent not found\n"); | 509 | LOG_DEBUG ("Operation context for PeerCreateSuccessEvent not found\n"); |
514 | return GNUNET_YES; | 510 | return; |
515 | } | 511 | } |
516 | if (OP_FORWARDED == opc->type) | 512 | if (OP_FORWARDED == opc->type) |
517 | { | 513 | { |
518 | handle_forwarded_operation_msg (c, opc, | 514 | handle_forwarded_operation_msg (c, opc, |
519 | (const struct GNUNET_MessageHeader *) msg); | 515 | (const struct GNUNET_MessageHeader *) msg); |
520 | return GNUNET_YES; | 516 | return; |
521 | } | 517 | } |
522 | GNUNET_assert (OP_PEER_CREATE == opc->type); | 518 | GNUNET_assert (OP_PEER_CREATE == opc->type); |
523 | GNUNET_assert (NULL != opc->data); | 519 | GNUNET_assert (NULL != opc->data); |
@@ -528,17 +524,16 @@ handle_peer_create_success (struct GNUNET_TESTBED_Controller *c, | |||
528 | peer->state = TESTBED_PS_CREATED; | 524 | peer->state = TESTBED_PS_CREATED; |
529 | GNUNET_TESTBED_peer_register_ (peer); | 525 | GNUNET_TESTBED_peer_register_ (peer); |
530 | cb = data->cb; | 526 | cb = data->cb; |
531 | cls = data->cls; | 527 | cb_cls = data->cls; |
532 | op = opc->op; | 528 | op = opc->op; |
533 | GNUNET_free (opc->data); | 529 | GNUNET_free (opc->data); |
534 | GNUNET_TESTBED_remove_opc_ (opc->c, opc); | 530 | GNUNET_TESTBED_remove_opc_ (opc->c, opc); |
535 | opc->state = OPC_STATE_FINISHED; | 531 | opc->state = OPC_STATE_FINISHED; |
536 | exop_insert (op); | 532 | exop_insert (op); |
537 | if (NULL != cb) | 533 | if (NULL != cb) |
538 | cb (cls, peer, NULL); | 534 | cb (cb_cls, peer, NULL); |
539 | /* You could have marked the operation as done by now */ | 535 | /* You could have marked the operation as done by now */ |
540 | GNUNET_break (GNUNET_NO == exop_check (op)); | 536 | GNUNET_break (GNUNET_NO == exop_check (op)); |
541 | return GNUNET_YES; | ||
542 | } | 537 | } |
543 | 538 | ||
544 | 539 | ||
@@ -548,13 +543,12 @@ handle_peer_create_success (struct GNUNET_TESTBED_Controller *c, | |||
548 | * | 543 | * |
549 | * @param c the controller handler | 544 | * @param c the controller handler |
550 | * @param msg message received | 545 | * @param msg message received |
551 | * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if | ||
552 | * not | ||
553 | */ | 546 | */ |
554 | static int | 547 | static void |
555 | handle_peer_event (struct GNUNET_TESTBED_Controller *c, | 548 | handle_peer_event (void *cls, |
556 | const struct GNUNET_TESTBED_PeerEventMessage *msg) | 549 | const struct GNUNET_TESTBED_PeerEventMessage *msg) |
557 | { | 550 | { |
551 | struct GNUNET_TESTBED_Controller *c = cls; | ||
558 | struct OperationContext *opc; | 552 | struct OperationContext *opc; |
559 | struct GNUNET_TESTBED_Peer *peer; | 553 | struct GNUNET_TESTBED_Peer *peer; |
560 | struct PeerEventData *data; | 554 | struct PeerEventData *data; |
@@ -570,13 +564,13 @@ handle_peer_event (struct GNUNET_TESTBED_Controller *c, | |||
570 | if (NULL == (opc = find_opc (c, op_id))) | 564 | if (NULL == (opc = find_opc (c, op_id))) |
571 | { | 565 | { |
572 | LOG_DEBUG ("Operation not found\n"); | 566 | LOG_DEBUG ("Operation not found\n"); |
573 | return GNUNET_YES; | 567 | return; |
574 | } | 568 | } |
575 | if (OP_FORWARDED == opc->type) | 569 | if (OP_FORWARDED == opc->type) |
576 | { | 570 | { |
577 | handle_forwarded_operation_msg (c, opc, | 571 | handle_forwarded_operation_msg (c, opc, |
578 | (const struct GNUNET_MessageHeader *) msg); | 572 | (const struct GNUNET_MessageHeader *) msg); |
579 | return GNUNET_YES; | 573 | return; |
580 | } | 574 | } |
581 | GNUNET_assert ((OP_PEER_START == opc->type) || (OP_PEER_STOP == opc->type)); | 575 | GNUNET_assert ((OP_PEER_START == opc->type) || (OP_PEER_STOP == opc->type)); |
582 | data = opc->data; | 576 | data = opc->data; |
@@ -613,13 +607,12 @@ handle_peer_event (struct GNUNET_TESTBED_Controller *c, | |||
613 | if (NULL != c->cc) | 607 | if (NULL != c->cc) |
614 | c->cc (c->cc_cls, &event); | 608 | c->cc (c->cc_cls, &event); |
615 | if (GNUNET_NO == exop_check (event.op)) | 609 | if (GNUNET_NO == exop_check (event.op)) |
616 | return GNUNET_YES; | 610 | return; |
617 | } | 611 | } |
618 | if (NULL != pcc) | 612 | if (NULL != pcc) |
619 | pcc (pcc_cls, NULL); | 613 | pcc (pcc_cls, NULL); |
620 | /* You could have marked the operation as done by now */ | 614 | /* You could have marked the operation as done by now */ |
621 | GNUNET_break (GNUNET_NO == exop_check (event.op)); | 615 | GNUNET_break (GNUNET_NO == exop_check (event.op)); |
622 | return GNUNET_YES; | ||
623 | } | 616 | } |
624 | 617 | ||
625 | 618 | ||
@@ -629,13 +622,12 @@ handle_peer_event (struct GNUNET_TESTBED_Controller *c, | |||
629 | * | 622 | * |
630 | * @param c the controller handler | 623 | * @param c the controller handler |
631 | * @param msg message received | 624 | * @param msg message received |
632 | * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if | ||
633 | * not | ||
634 | */ | 625 | */ |
635 | static int | 626 | static void |
636 | handle_peer_conevent (struct GNUNET_TESTBED_Controller *c, | 627 | handle_peer_conevent (void *cls, |
637 | const struct GNUNET_TESTBED_ConnectionEventMessage *msg) | 628 | const struct GNUNET_TESTBED_ConnectionEventMessage *msg) |
638 | { | 629 | { |
630 | struct GNUNET_TESTBED_Controller *c = cls; | ||
639 | struct OperationContext *opc; | 631 | struct OperationContext *opc; |
640 | struct OverlayConnectData *data; | 632 | struct OverlayConnectData *data; |
641 | GNUNET_TESTBED_OperationCompletionCallback cb; | 633 | GNUNET_TESTBED_OperationCompletionCallback cb; |
@@ -648,13 +640,13 @@ handle_peer_conevent (struct GNUNET_TESTBED_Controller *c, | |||
648 | if (NULL == (opc = find_opc (c, op_id))) | 640 | if (NULL == (opc = find_opc (c, op_id))) |
649 | { | 641 | { |
650 | LOG_DEBUG ("Operation not found\n"); | 642 | LOG_DEBUG ("Operation not found\n"); |
651 | return GNUNET_YES; | 643 | return; |
652 | } | 644 | } |
653 | if (OP_FORWARDED == opc->type) | 645 | if (OP_FORWARDED == opc->type) |
654 | { | 646 | { |
655 | handle_forwarded_operation_msg (c, opc, | 647 | handle_forwarded_operation_msg (c, opc, |
656 | (const struct GNUNET_MessageHeader *) msg); | 648 | (const struct GNUNET_MessageHeader *) msg); |
657 | return GNUNET_YES; | 649 | return; |
658 | } | 650 | } |
659 | GNUNET_assert (OP_OVERLAY_CONNECT == opc->type); | 651 | GNUNET_assert (OP_OVERLAY_CONNECT == opc->type); |
660 | GNUNET_assert (NULL != (data = opc->data)); | 652 | GNUNET_assert (NULL != (data = opc->data)); |
@@ -688,13 +680,12 @@ handle_peer_conevent (struct GNUNET_TESTBED_Controller *c, | |||
688 | if (NULL != c->cc) | 680 | if (NULL != c->cc) |
689 | c->cc (c->cc_cls, &event); | 681 | c->cc (c->cc_cls, &event); |
690 | if (GNUNET_NO == exop_check (event.op)) | 682 | if (GNUNET_NO == exop_check (event.op)) |
691 | return GNUNET_YES; | 683 | return; |
692 | } | 684 | } |
693 | if (NULL != cb) | 685 | if (NULL != cb) |
694 | cb (cb_cls, opc->op, NULL); | 686 | cb (cb_cls, opc->op, NULL); |
695 | /* You could have marked the operation as done by now */ | 687 | /* You could have marked the operation as done by now */ |
696 | GNUNET_break (GNUNET_NO == exop_check (event.op)); | 688 | GNUNET_break (GNUNET_NO == exop_check (event.op)); |
697 | return GNUNET_YES; | ||
698 | } | 689 | } |
699 | 690 | ||
700 | 691 | ||
@@ -704,14 +695,13 @@ handle_peer_conevent (struct GNUNET_TESTBED_Controller *c, | |||
704 | * | 695 | * |
705 | * @param c the controller handler | 696 | * @param c the controller handler |
706 | * @param msg message received | 697 | * @param msg message received |
707 | * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if | ||
708 | * not | ||
709 | */ | 698 | */ |
710 | static int | 699 | static void |
711 | handle_peer_config (struct GNUNET_TESTBED_Controller *c, | 700 | handle_peer_config (void *cls, |
712 | const struct | 701 | const struct |
713 | GNUNET_TESTBED_PeerConfigurationInformationMessage *msg) | 702 | GNUNET_TESTBED_PeerConfigurationInformationMessage *msg) |
714 | { | 703 | { |
704 | struct GNUNET_TESTBED_Controller *c = cls; | ||
715 | struct OperationContext *opc; | 705 | struct OperationContext *opc; |
716 | struct GNUNET_TESTBED_Peer *peer; | 706 | struct GNUNET_TESTBED_Peer *peer; |
717 | struct PeerInfoData *data; | 707 | struct PeerInfoData *data; |
@@ -724,13 +714,13 @@ handle_peer_config (struct GNUNET_TESTBED_Controller *c, | |||
724 | if (NULL == (opc = find_opc (c, op_id))) | 714 | if (NULL == (opc = find_opc (c, op_id))) |
725 | { | 715 | { |
726 | LOG_DEBUG ("Operation not found\n"); | 716 | LOG_DEBUG ("Operation not found\n"); |
727 | return GNUNET_YES; | 717 | return; |
728 | } | 718 | } |
729 | if (OP_FORWARDED == opc->type) | 719 | if (OP_FORWARDED == opc->type) |
730 | { | 720 | { |
731 | handle_forwarded_operation_msg (c, opc, | 721 | handle_forwarded_operation_msg (c, opc, |
732 | (const struct GNUNET_MessageHeader *) msg); | 722 | (const struct GNUNET_MessageHeader *) msg); |
733 | return GNUNET_YES; | 723 | return; |
734 | } | 724 | } |
735 | data = opc->data; | 725 | data = opc->data; |
736 | GNUNET_assert (NULL != data); | 726 | GNUNET_assert (NULL != data); |
@@ -748,7 +738,8 @@ handle_peer_config (struct GNUNET_TESTBED_Controller *c, | |||
748 | { | 738 | { |
749 | case GNUNET_TESTBED_PIT_IDENTITY: | 739 | case GNUNET_TESTBED_PIT_IDENTITY: |
750 | pinfo->result.id = GNUNET_new (struct GNUNET_PeerIdentity); | 740 | pinfo->result.id = GNUNET_new (struct GNUNET_PeerIdentity); |
751 | (void) memcpy (pinfo->result.id, &msg->peer_identity, | 741 | (void) memcpy (pinfo->result.id, |
742 | &msg->peer_identity, | ||
752 | sizeof (struct GNUNET_PeerIdentity)); | 743 | sizeof (struct GNUNET_PeerIdentity)); |
753 | break; | 744 | break; |
754 | case GNUNET_TESTBED_PIT_CONFIGURATION: | 745 | case GNUNET_TESTBED_PIT_CONFIGURATION: |
@@ -766,7 +757,6 @@ handle_peer_config (struct GNUNET_TESTBED_Controller *c, | |||
766 | /* We dont check whether the operation is marked as done here as the | 757 | /* We dont check whether the operation is marked as done here as the |
767 | operation contains data (cfg/identify) which will be freed at a later point | 758 | operation contains data (cfg/identify) which will be freed at a later point |
768 | */ | 759 | */ |
769 | return GNUNET_YES; | ||
770 | } | 760 | } |
771 | 761 | ||
772 | 762 | ||
@@ -776,14 +766,12 @@ handle_peer_config (struct GNUNET_TESTBED_Controller *c, | |||
776 | * | 766 | * |
777 | * @param c the controller handler | 767 | * @param c the controller handler |
778 | * @param msg message received | 768 | * @param msg message received |
779 | * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if | ||
780 | * not | ||
781 | */ | 769 | */ |
782 | static int | 770 | static void |
783 | handle_op_fail_event (struct GNUNET_TESTBED_Controller *c, | 771 | handle_op_fail_event (void *cls, |
784 | const struct GNUNET_TESTBED_OperationFailureEventMessage | 772 | const struct GNUNET_TESTBED_OperationFailureEventMessage *msg) |
785 | *msg) | ||
786 | { | 773 | { |
774 | struct GNUNET_TESTBED_Controller *c = cls; | ||
787 | struct OperationContext *opc; | 775 | struct OperationContext *opc; |
788 | const char *emsg; | 776 | const char *emsg; |
789 | uint64_t op_id; | 777 | uint64_t op_id; |
@@ -794,13 +782,13 @@ handle_op_fail_event (struct GNUNET_TESTBED_Controller *c, | |||
794 | if (NULL == (opc = find_opc (c, op_id))) | 782 | if (NULL == (opc = find_opc (c, op_id))) |
795 | { | 783 | { |
796 | LOG_DEBUG ("Operation not found\n"); | 784 | LOG_DEBUG ("Operation not found\n"); |
797 | return GNUNET_YES; | 785 | return; |
798 | } | 786 | } |
799 | if (OP_FORWARDED == opc->type) | 787 | if (OP_FORWARDED == opc->type) |
800 | { | 788 | { |
801 | handle_forwarded_operation_msg (c, opc, | 789 | handle_forwarded_operation_msg (c, opc, |
802 | (const struct GNUNET_MessageHeader *) msg); | 790 | (const struct GNUNET_MessageHeader *) msg); |
803 | return GNUNET_YES; | 791 | return; |
804 | } | 792 | } |
805 | GNUNET_TESTBED_remove_opc_ (opc->c, opc); | 793 | GNUNET_TESTBED_remove_opc_ (opc->c, opc); |
806 | opc->state = OPC_STATE_FINISHED; | 794 | opc->state = OPC_STATE_FINISHED; |
@@ -815,7 +803,7 @@ handle_op_fail_event (struct GNUNET_TESTBED_Controller *c, | |||
815 | if (NULL != data->cb) | 803 | if (NULL != data->cb) |
816 | data->cb (data->cb_cls, opc->op, NULL, emsg); | 804 | data->cb (data->cb_cls, opc->op, NULL, emsg); |
817 | GNUNET_free (data); | 805 | GNUNET_free (data); |
818 | return GNUNET_YES; /* We do not call controller callback for peer info */ | 806 | return; /* We do not call controller callback for peer info */ |
819 | } | 807 | } |
820 | event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; | 808 | event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; |
821 | event.op = opc->op; | 809 | event.op = opc->op; |
@@ -828,81 +816,80 @@ handle_op_fail_event (struct GNUNET_TESTBED_Controller *c, | |||
828 | exop_insert (event.op); | 816 | exop_insert (event.op); |
829 | c->cc (c->cc_cls, &event); | 817 | c->cc (c->cc_cls, &event); |
830 | if (GNUNET_NO == exop_check (event.op)) | 818 | if (GNUNET_NO == exop_check (event.op)) |
831 | return GNUNET_YES; | 819 | return; |
832 | } | 820 | } |
833 | switch (opc->type) | 821 | switch (opc->type) |
834 | { | 822 | { |
835 | case OP_PEER_CREATE: | 823 | case OP_PEER_CREATE: |
836 | { | 824 | { |
837 | struct PeerCreateData *data; | 825 | struct PeerCreateData *data; |
838 | 826 | ||
839 | data = opc->data; | 827 | data = opc->data; |
840 | GNUNET_free (data->peer); | 828 | GNUNET_free (data->peer); |
841 | if (NULL != data->cb) | 829 | if (NULL != data->cb) |
842 | data->cb (data->cls, NULL, emsg); | 830 | data->cb (data->cls, NULL, emsg); |
843 | GNUNET_free (data); | 831 | GNUNET_free (data); |
844 | } | 832 | } |
845 | break; | 833 | break; |
846 | case OP_PEER_START: | 834 | case OP_PEER_START: |
847 | case OP_PEER_STOP: | 835 | case OP_PEER_STOP: |
848 | { | 836 | { |
849 | struct PeerEventData *data; | 837 | struct PeerEventData *data; |
850 | 838 | ||
851 | data = opc->data; | 839 | data = opc->data; |
852 | if (NULL != data->pcc) | 840 | if (NULL != data->pcc) |
853 | data->pcc (data->pcc_cls, emsg); | 841 | data->pcc (data->pcc_cls, emsg); |
854 | GNUNET_free (data); | 842 | GNUNET_free (data); |
855 | } | 843 | } |
856 | break; | 844 | break; |
857 | case OP_PEER_DESTROY: | 845 | case OP_PEER_DESTROY: |
858 | break; | 846 | break; |
859 | case OP_PEER_INFO: | 847 | case OP_PEER_INFO: |
860 | GNUNET_assert (0); | 848 | GNUNET_assert (0); |
861 | case OP_OVERLAY_CONNECT: | 849 | case OP_OVERLAY_CONNECT: |
862 | { | 850 | { |
863 | struct OverlayConnectData *data; | 851 | struct OverlayConnectData *data; |
864 | 852 | ||
865 | data = opc->data; | 853 | data = opc->data; |
866 | GNUNET_TESTBED_operation_mark_failed (opc->op); | 854 | GNUNET_TESTBED_operation_mark_failed (opc->op); |
867 | if (NULL != data->cb) | 855 | if (NULL != data->cb) |
868 | data->cb (data->cb_cls, opc->op, emsg); | 856 | data->cb (data->cb_cls, opc->op, emsg); |
869 | } | 857 | } |
870 | break; | 858 | break; |
871 | case OP_FORWARDED: | 859 | case OP_FORWARDED: |
872 | GNUNET_assert (0); | 860 | GNUNET_assert (0); |
873 | case OP_LINK_CONTROLLERS: /* No secondary callback */ | 861 | case OP_LINK_CONTROLLERS: /* No secondary callback */ |
874 | break; | 862 | break; |
875 | case OP_SHUTDOWN_PEERS: | 863 | case OP_SHUTDOWN_PEERS: |
876 | { | 864 | { |
877 | struct ShutdownPeersData *data; | 865 | struct ShutdownPeersData *data; |
878 | 866 | ||
879 | data = opc->data; | 867 | data = opc->data; |
880 | GNUNET_free (data); /* FIXME: Decide whether we call data->op_cb */ | 868 | GNUNET_free (data); /* FIXME: Decide whether we call data->op_cb */ |
881 | opc->data = NULL; | 869 | opc->data = NULL; |
882 | } | 870 | } |
883 | break; | 871 | break; |
884 | case OP_MANAGE_SERVICE: | 872 | case OP_MANAGE_SERVICE: |
885 | { | 873 | { |
886 | struct ManageServiceData *data = opc->data; | 874 | struct ManageServiceData *data = opc->data; |
887 | GNUNET_TESTBED_OperationCompletionCallback cb; | 875 | GNUNET_TESTBED_OperationCompletionCallback cb; |
888 | void *cb_cls; | 876 | void *cb_cls; |
889 | 877 | ||
890 | GNUNET_assert (NULL != data); | 878 | GNUNET_assert (NULL != data); |
891 | cb = data->cb; | 879 | cb = data->cb; |
892 | cb_cls = data->cb_cls; | 880 | cb_cls = data->cb_cls; |
893 | GNUNET_free (data); | 881 | GNUNET_free (data); |
894 | opc->data = NULL; | 882 | opc->data = NULL; |
895 | exop_insert (event.op); | 883 | exop_insert (event.op); |
896 | if (NULL != cb) | 884 | if (NULL != cb) |
897 | cb (cb_cls, opc->op, emsg); | 885 | cb (cb_cls, opc->op, emsg); |
898 | /* You could have marked the operation as done by now */ | 886 | /* You could have marked the operation as done by now */ |
899 | GNUNET_break (GNUNET_NO == exop_check (event.op)); | 887 | GNUNET_break (GNUNET_NO == exop_check (event.op)); |
900 | } | 888 | } |
901 | break; | 889 | break; |
902 | default: | 890 | default: |
903 | GNUNET_break (0); | 891 | GNUNET_break (0); |
904 | } | 892 | } |
905 | return GNUNET_YES; | ||
906 | } | 893 | } |
907 | 894 | ||
908 | 895 | ||
@@ -936,13 +923,12 @@ GNUNET_TESTBED_generate_slavegetconfig_msg_ (uint64_t op_id, uint32_t slave_id) | |||
936 | * | 923 | * |
937 | * @param c the controller handler | 924 | * @param c the controller handler |
938 | * @param msg message received | 925 | * @param msg message received |
939 | * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if | ||
940 | * not | ||
941 | */ | 926 | */ |
942 | static int | 927 | static void |
943 | handle_slave_config (struct GNUNET_TESTBED_Controller *c, | 928 | handle_slave_config (void *cls, |
944 | const struct GNUNET_TESTBED_SlaveConfiguration *msg) | 929 | const struct GNUNET_TESTBED_SlaveConfiguration *msg) |
945 | { | 930 | { |
931 | struct GNUNET_TESTBED_Controller *c = cls; | ||
946 | struct OperationContext *opc; | 932 | struct OperationContext *opc; |
947 | uint64_t op_id; | 933 | uint64_t op_id; |
948 | uint64_t mask; | 934 | uint64_t mask; |
@@ -952,12 +938,12 @@ handle_slave_config (struct GNUNET_TESTBED_Controller *c, | |||
952 | if (NULL == (opc = find_opc (c, op_id))) | 938 | if (NULL == (opc = find_opc (c, op_id))) |
953 | { | 939 | { |
954 | LOG_DEBUG ("Operation not found\n"); | 940 | LOG_DEBUG ("Operation not found\n"); |
955 | return GNUNET_YES; | 941 | return; |
956 | } | 942 | } |
957 | if (OP_GET_SLAVE_CONFIG != opc->type) | 943 | if (OP_GET_SLAVE_CONFIG != opc->type) |
958 | { | 944 | { |
959 | GNUNET_break (0); | 945 | GNUNET_break (0); |
960 | return GNUNET_YES; | 946 | return; |
961 | } | 947 | } |
962 | opc->state = OPC_STATE_FINISHED; | 948 | opc->state = OPC_STATE_FINISHED; |
963 | GNUNET_TESTBED_remove_opc_ (opc->c, opc); | 949 | GNUNET_TESTBED_remove_opc_ (opc->c, opc); |
@@ -973,7 +959,6 @@ handle_slave_config (struct GNUNET_TESTBED_Controller *c, | |||
973 | event.details.operation_finished.emsg = NULL; | 959 | event.details.operation_finished.emsg = NULL; |
974 | c->cc (c->cc_cls, &event); | 960 | c->cc (c->cc_cls, &event); |
975 | } | 961 | } |
976 | return GNUNET_YES; | ||
977 | } | 962 | } |
978 | 963 | ||
979 | 964 | ||
@@ -983,14 +968,13 @@ handle_slave_config (struct GNUNET_TESTBED_Controller *c, | |||
983 | * | 968 | * |
984 | * @param c the controller handler | 969 | * @param c the controller handler |
985 | * @param msg message received | 970 | * @param msg message received |
986 | * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if | ||
987 | * not | ||
988 | */ | 971 | */ |
989 | static int | 972 | static void |
990 | handle_link_controllers_result (struct GNUNET_TESTBED_Controller *c, | 973 | handle_link_controllers_result (void *cls, |
991 | const struct | 974 | const struct |
992 | GNUNET_TESTBED_ControllerLinkResponse *msg) | 975 | GNUNET_TESTBED_ControllerLinkResponse *msg) |
993 | { | 976 | { |
977 | struct GNUNET_TESTBED_Controller *c = cls; | ||
994 | struct OperationContext *opc; | 978 | struct OperationContext *opc; |
995 | struct ControllerLinkData *data; | 979 | struct ControllerLinkData *data; |
996 | struct GNUNET_CONFIGURATION_Handle *cfg; | 980 | struct GNUNET_CONFIGURATION_Handle *cfg; |
@@ -1003,18 +987,18 @@ handle_link_controllers_result (struct GNUNET_TESTBED_Controller *c, | |||
1003 | if (NULL == (opc = find_opc (c, op_id))) | 987 | if (NULL == (opc = find_opc (c, op_id))) |
1004 | { | 988 | { |
1005 | LOG_DEBUG ("Operation not found\n"); | 989 | LOG_DEBUG ("Operation not found\n"); |
1006 | return GNUNET_YES; | 990 | return; |
1007 | } | 991 | } |
1008 | if (OP_FORWARDED == opc->type) | 992 | if (OP_FORWARDED == opc->type) |
1009 | { | 993 | { |
1010 | handle_forwarded_operation_msg (c, opc, | 994 | handle_forwarded_operation_msg (c, opc, |
1011 | (const struct GNUNET_MessageHeader *) msg); | 995 | (const struct GNUNET_MessageHeader *) msg); |
1012 | return GNUNET_YES; | 996 | return; |
1013 | } | 997 | } |
1014 | if (OP_LINK_CONTROLLERS != opc->type) | 998 | if (OP_LINK_CONTROLLERS != opc->type) |
1015 | { | 999 | { |
1016 | GNUNET_break (0); | 1000 | GNUNET_break (0); |
1017 | return GNUNET_YES; | 1001 | return; |
1018 | } | 1002 | } |
1019 | GNUNET_assert (NULL != (data = opc->data)); | 1003 | GNUNET_assert (NULL != (data = opc->data)); |
1020 | host = GNUNET_TESTBED_host_lookup_by_id_ (data->host_id); | 1004 | host = GNUNET_TESTBED_host_lookup_by_id_ (data->host_id); |
@@ -1059,7 +1043,6 @@ handle_link_controllers_result (struct GNUNET_TESTBED_Controller *c, | |||
1059 | if (NULL != cfg) | 1043 | if (NULL != cfg) |
1060 | GNUNET_CONFIGURATION_destroy (cfg); | 1044 | GNUNET_CONFIGURATION_destroy (cfg); |
1061 | GNUNET_free_non_null (emsg); | 1045 | GNUNET_free_non_null (emsg); |
1062 | return GNUNET_YES; | ||
1063 | } | 1046 | } |
1064 | 1047 | ||
1065 | 1048 | ||
@@ -1097,77 +1080,80 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
1097 | GNUNET_assert (msize == | 1080 | GNUNET_assert (msize == |
1098 | sizeof (struct | 1081 | sizeof (struct |
1099 | GNUNET_TESTBED_GenericOperationSuccessEventMessage)); | 1082 | GNUNET_TESTBED_GenericOperationSuccessEventMessage)); |
1100 | status = | 1083 | handle_opsuccess (c, |
1101 | handle_opsuccess (c, | 1084 | (const struct |
1102 | (const struct | 1085 | GNUNET_TESTBED_GenericOperationSuccessEventMessage *) |
1103 | GNUNET_TESTBED_GenericOperationSuccessEventMessage *) | 1086 | msg); |
1104 | msg); | 1087 | status = GNUNET_YES; |
1105 | break; | 1088 | break; |
1106 | case GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT: | 1089 | case GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT: |
1107 | GNUNET_assert (msize >= | 1090 | GNUNET_assert (msize >= |
1108 | sizeof (struct GNUNET_TESTBED_OperationFailureEventMessage)); | 1091 | sizeof (struct GNUNET_TESTBED_OperationFailureEventMessage)); |
1109 | status = | 1092 | handle_op_fail_event (c, |
1110 | handle_op_fail_event (c, | 1093 | (const struct |
1111 | (const struct | 1094 | GNUNET_TESTBED_OperationFailureEventMessage *) |
1112 | GNUNET_TESTBED_OperationFailureEventMessage *) | 1095 | msg); |
1113 | msg); | 1096 | status = GNUNET_YES; |
1114 | break; | 1097 | break; |
1115 | case GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS: | 1098 | case GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS: |
1116 | GNUNET_assert (msize == | 1099 | GNUNET_assert (msize == |
1117 | sizeof (struct | 1100 | sizeof (struct |
1118 | GNUNET_TESTBED_PeerCreateSuccessEventMessage)); | 1101 | GNUNET_TESTBED_PeerCreateSuccessEventMessage)); |
1119 | status = | 1102 | handle_peer_create_success (c, |
1120 | handle_peer_create_success (c, | 1103 | (const struct |
1121 | (const struct | 1104 | GNUNET_TESTBED_PeerCreateSuccessEventMessage |
1122 | GNUNET_TESTBED_PeerCreateSuccessEventMessage | 1105 | *) msg); |
1123 | *) msg); | 1106 | status = GNUNET_YES; |
1124 | break; | 1107 | break; |
1125 | case GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT: | 1108 | case GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT: |
1126 | GNUNET_assert (msize == sizeof (struct GNUNET_TESTBED_PeerEventMessage)); | 1109 | GNUNET_assert (msize == sizeof (struct GNUNET_TESTBED_PeerEventMessage)); |
1127 | status = | 1110 | handle_peer_event (c, |
1128 | handle_peer_event (c, | 1111 | (const struct GNUNET_TESTBED_PeerEventMessage *) |
1129 | (const struct GNUNET_TESTBED_PeerEventMessage *) | 1112 | msg); |
1130 | msg); | ||
1131 | 1113 | ||
1114 | status = GNUNET_YES; | ||
1132 | break; | 1115 | break; |
1133 | case GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION: | 1116 | case GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION: |
1134 | GNUNET_assert (msize >= | 1117 | GNUNET_assert (msize >= |
1135 | sizeof (struct | 1118 | sizeof (struct |
1136 | GNUNET_TESTBED_PeerConfigurationInformationMessage)); | 1119 | GNUNET_TESTBED_PeerConfigurationInformationMessage)); |
1137 | status = | 1120 | handle_peer_config (c, |
1138 | handle_peer_config (c, | 1121 | (const struct |
1139 | (const struct | 1122 | GNUNET_TESTBED_PeerConfigurationInformationMessage |
1140 | GNUNET_TESTBED_PeerConfigurationInformationMessage | 1123 | *) msg); |
1141 | *) msg); | 1124 | status = GNUNET_YES; |
1125 | |||
1142 | break; | 1126 | break; |
1143 | case GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT: | 1127 | case GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT: |
1144 | GNUNET_assert (msize == | 1128 | GNUNET_assert (msize == |
1145 | sizeof (struct GNUNET_TESTBED_ConnectionEventMessage)); | 1129 | sizeof (struct GNUNET_TESTBED_ConnectionEventMessage)); |
1146 | status = | 1130 | handle_peer_conevent (c, |
1147 | handle_peer_conevent (c, | 1131 | (const struct |
1148 | (const struct | 1132 | GNUNET_TESTBED_ConnectionEventMessage *) msg); |
1149 | GNUNET_TESTBED_ConnectionEventMessage *) msg); | 1133 | status = GNUNET_YES; |
1150 | break; | 1134 | break; |
1151 | case GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION: | 1135 | case GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION: |
1152 | GNUNET_assert (msize > sizeof (struct GNUNET_TESTBED_SlaveConfiguration)); | 1136 | GNUNET_assert (msize > sizeof (struct GNUNET_TESTBED_SlaveConfiguration)); |
1153 | status = | 1137 | handle_slave_config (c, |
1154 | handle_slave_config (c, | 1138 | (const struct GNUNET_TESTBED_SlaveConfiguration *) |
1155 | (const struct GNUNET_TESTBED_SlaveConfiguration *) | 1139 | msg); |
1156 | msg); | 1140 | status = GNUNET_YES; |
1157 | break; | 1141 | break; |
1158 | case GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT: | 1142 | case GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT: |
1159 | status = | 1143 | handle_link_controllers_result (c, |
1160 | handle_link_controllers_result (c, | 1144 | (const struct |
1161 | (const struct | 1145 | GNUNET_TESTBED_ControllerLinkResponse |
1162 | GNUNET_TESTBED_ControllerLinkResponse | 1146 | *) msg); |
1163 | *) msg); | 1147 | status = GNUNET_YES; |
1164 | break; | 1148 | break; |
1165 | case GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS: | 1149 | case GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS: |
1166 | status = | 1150 | status = check_barrier_status_ (c, |
1167 | GNUNET_TESTBED_handle_barrier_status_ (c, | 1151 | (const struct GNUNET_TESTBED_BarrierStatusMsg *) msg); |
1168 | (const struct | 1152 | if (GNUNET_OK == status) |
1169 | GNUNET_TESTBED_BarrierStatusMsg *) | 1153 | handle_barrier_status_ (c, |
1170 | msg); | 1154 | (const struct |
1155 | GNUNET_TESTBED_BarrierStatusMsg *) | ||
1156 | msg); | ||
1171 | break; | 1157 | break; |
1172 | default: | 1158 | default: |
1173 | GNUNET_assert (0); | 1159 | GNUNET_assert (0); |