From 561596641606ecc0b5f71658c34eab1312ad8f18 Mon Sep 17 00:00:00 2001 From: t3sserakt Date: Mon, 14 Dec 2020 11:18:18 +0100 Subject: - added code again that was accidentally lost during merge --- src/transport/test_communicator_basic.c | 22 +++++----- src/transport/transport-testing-communicator.c | 57 ++++++++++++++++++++++++++ src/transport/transport-testing-communicator.h | 5 +++ 3 files changed, 74 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c index 21c371f3a..10c942daa 100644 --- a/src/transport/test_communicator_basic.c +++ b/src/transport/test_communicator_basic.c @@ -743,9 +743,11 @@ incoming_message_cb (void *cls, &process_statistics, NULL); } - /* LOG (GNUNET_ERROR_TYPE_DEBUG, */ - /* "Finished\n"); */ - /* GNUNET_SCHEDULER_shutdown (); */ + else{ + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Finished\n"); + GNUNET_SCHEDULER_shutdown (); + } } break; } @@ -795,13 +797,6 @@ run (void *cls) // num_sent = 0; for (unsigned int i = 0; i < NUM_PEERS; i++) { - if ((0 == strcmp ("rekey", test_name))||(0 == strcmp ("backchannel", - test_name)) ) - { - stats[i] = GNUNET_STATISTICS_create ("C-UDP", - cfg_peers[i]); - } - tc_hs[i] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( "transport", communicator_binary, @@ -814,6 +809,13 @@ run (void *cls) &incoming_message_cb, &handle_backchannel_cb, cfg_peers_name[i]); /* cls */ + + if ((0 == strcmp ("rekey", test_name))||(0 == strcmp ("backchannel", + test_name)) ) + { + stats[i] = GNUNET_STATISTICS_create ("C-UDP", + cfg_peers[i]); + } } GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); diff --git a/src/transport/transport-testing-communicator.c b/src/transport/transport-testing-communicator.c index 6d74b12e8..56240864c 100644 --- a/src/transport/transport-testing-communicator.c +++ b/src/transport/transport-testing-communicator.c @@ -766,6 +766,23 @@ shutdown_process (struct GNUNET_OS_Process *proc) GNUNET_OS_process_destroy (proc); } +/** + * @brief Task run at shutdown to kill the statistics process + * + * @param cls Closure - Process of communicator + */ +static void +shutdown_statistics (void *cls) +{ + struct GNUNET_OS_Process *proc = cls; + shutdown_process (proc); +} + +/** + * @brief Task run at shutdown to kill the peerstore process + * + * @param cls Closure - Process of communicator + */ static void shutdown_peerstore (void *cls) { @@ -773,6 +790,11 @@ shutdown_peerstore (void *cls) shutdown_process (proc); } +/** + * @brief Task run at shutdown to kill a communicator process + * + * @param cls Closure - Process of communicator + */ static void shutdown_communicator (void *cls) { @@ -852,6 +874,10 @@ shutdown_resolver (void *cls) } +/** + * @brief Start Resolver + * + */ static void resolver_start (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h) @@ -881,6 +907,34 @@ resolver_start (struct } +/** + * @brief Start Statistics + * + */ +static void +statistics_start ( + struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h) +{ + char *binary; + + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-statistics"); + tc_h->stat_proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_OUT_AND_ERR, + NULL, + NULL, + NULL, + binary, + "gnunet-service-statistics", + "-c", + tc_h->cfg_filename, + NULL); + if (NULL == tc_h->stat_proc) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start Statistics!"); + return; + } + LOG (GNUNET_ERROR_TYPE_INFO, "started Statistics\n"); + GNUNET_free (binary); +} /** * @brief Start Peerstore @@ -1009,6 +1063,8 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( resolver_start (tc_h); /* Start peerstore service */ peerstore_start (tc_h); + /* Start statistic service */ + statistics_start (tc_h); /* Schedule start communicator */ communicator_start (tc_h, binary_name); @@ -1025,6 +1081,7 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop ( shutdown_nat (tc_h->nat_proc); shutdown_resolver (tc_h->resolver_proc); shutdown_peerstore (tc_h->ps_proc); + shutdown_statistics (tc_h->stat_proc); GNUNET_CONFIGURATION_destroy (tc_h->cfg); GNUNET_free (tc_h); } diff --git a/src/transport/transport-testing-communicator.h b/src/transport/transport-testing-communicator.h index 693e61515..1875258b4 100644 --- a/src/transport/transport-testing-communicator.h +++ b/src/transport/transport-testing-communicator.h @@ -199,6 +199,11 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle */ struct GNUNET_OS_Process *resolver_proc; + /** + * statistics service process + */ + struct GNUNET_OS_Process *stat_proc; + /** * peerstore service process */ -- cgit v1.2.3