aboutsummaryrefslogtreecommitdiff
path: root/src/nse
diff options
context:
space:
mode:
Diffstat (limited to 'src/nse')
-rw-r--r--src/nse/gnunet-nse-profiler.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/src/nse/gnunet-nse-profiler.c b/src/nse/gnunet-nse-profiler.c
index 7803ca947..d25ad7ad0 100644
--- a/src/nse/gnunet-nse-profiler.c
+++ b/src/nse/gnunet-nse-profiler.c
@@ -136,6 +136,11 @@ struct OpListEntry
136 */ 136 */
137 struct GNUNET_TESTBED_Operation *op; 137 struct GNUNET_TESTBED_Operation *op;
138 138
139 /**
140 * Depending on whether we start or stop NSE service at the peer set this to 1
141 * or -1
142 */
143 int delta;
139}; 144};
140 145
141 146
@@ -625,18 +630,27 @@ make_oplist_entry ()
625 630
626 631
627/** 632/**
628 * Functions of this signature are called when a peer has been successfully 633 * Callback to be called when NSE service is started or stopped at peers
629 * started or stopped.
630 * 634 *
631 * @param cls NULL 635 * @param cls NULL
636 * @param op the operation handle
632 * @param emsg NULL on success; otherwise an error description 637 * @param emsg NULL on success; otherwise an error description
633 */ 638 */
634static void 639static void
635peer_churn_cb (void *cls, const char *emsg) 640manage_service_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
641 const char *emsg)
636{ 642{
637 struct OpListEntry *entry = cls; 643 struct OpListEntry *entry = cls;
638 644
639 GNUNET_TESTBED_operation_done (entry->op); 645 GNUNET_TESTBED_operation_done (entry->op);
646 if (NULL != emsg)
647 {
648 LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to start/stop NSE at a peer\n");
649 GNUNET_SCHEDULER_shutdown ();
650 return;
651 }
652 GNUNET_assert (0 != entry->delta);
653 peers_running += entry->delta;
640 GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry); 654 GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry);
641 GNUNET_free (entry); 655 GNUNET_free (entry);
642 if (num_peers_in_round[current_round] == peers_running) 656 if (num_peers_in_round[current_round] == peers_running)
@@ -658,15 +672,25 @@ adjust_running_peers ()
658 for (i=peers_running;i<num_peers_in_round[current_round];i++) 672 for (i=peers_running;i<num_peers_in_round[current_round];i++)
659 { 673 {
660 entry = make_oplist_entry (); 674 entry = make_oplist_entry ();
661 entry->op = GNUNET_TESTBED_peer_start (NULL, daemons[i], 675 entry->delta = 1;
662 &peer_churn_cb, entry); 676 entry->op = GNUNET_TESTBED_peer_manage_service (NULL,
677 daemons[i],
678 "nse",
679 &manage_service_cb,
680 entry,
681 1);
663 } 682 }
664 /* stop peers if we have too many */ 683 /* stop peers if we have too many */
665 for (i=num_peers_in_round[current_round];i<peers_running;i++) 684 for (i=num_peers_in_round[current_round];i<peers_running;i++)
666 { 685 {
667 entry = make_oplist_entry (); 686 entry = make_oplist_entry ();
668 entry->op = GNUNET_TESTBED_peer_stop (NULL, daemons[i], 687 entry->delta = -1;
669 &peer_churn_cb, entry); 688 entry->op = GNUNET_TESTBED_peer_manage_service (NULL,
689 daemons[i],
690 "nse",
691 &manage_service_cb,
692 entry,
693 0);
670 } 694 }
671} 695}
672 696
@@ -716,12 +740,6 @@ master_controller_cb (void *cls,
716{ 740{
717 switch (event->type) 741 switch (event->type)
718 { 742 {
719 case GNUNET_TESTBED_ET_PEER_START:
720 peers_running++;
721 break;
722 case GNUNET_TESTBED_ET_PEER_STOP:
723 peers_running--;
724 break;
725 case GNUNET_TESTBED_ET_CONNECT: 743 case GNUNET_TESTBED_ET_CONNECT:
726 total_connections++; 744 total_connections++;
727 break; 745 break;