summaryrefslogtreecommitdiff
path: root/src/transport/transport-testing2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/transport-testing2.c')
-rw-r--r--src/transport/transport-testing2.c77
1 files changed, 67 insertions, 10 deletions
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c
index 772ad9f2d..10b064241 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -114,6 +114,11 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
struct GNUNET_OS_Process *resolver_proc;
/**
+ * peerstore service process
+ */
+ struct GNUNET_OS_Process *ps_proc;
+
+ /**
* @brief Task that will be run on shutdown to stop and clean communicator
*/
struct GNUNET_SCHEDULER_Task *c_shutdown_task;
@@ -892,6 +897,12 @@ shutdown_process (struct GNUNET_OS_Process *proc)
GNUNET_OS_process_destroy (proc);
}
+static void
+shutdown_peerstore (void *cls)
+{
+ struct GNUNET_OS_Process *proc = cls;
+ shutdown_process (proc);
+}
static void
shutdown_communicator (void *cls)
@@ -912,19 +923,31 @@ communicator_start (
const char *binary_name)
{
char *binary;
+ char *loprefix;
+ char *section_name;
LOG (GNUNET_ERROR_TYPE_DEBUG, "communicator_start\n");
+
+ section_name = strchr (binary_name, '-');
+ section_name++;
+
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (tc_h->cfg,
+ section_name,
+ "PREFIX",
+ &loprefix))
+ loprefix = GNUNET_strdup ("");
+
+
binary = GNUNET_OS_get_libexec_binary_path (binary_name);
- tc_h->c_proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_OUT_AND_ERR
- | GNUNET_OS_USE_PIPE_CONTROL,
- NULL,
- NULL,
- NULL,
- binary,
- binary_name,
- "-c",
- tc_h->cfg_filename,
- NULL);
+ tc_h->c_proc = GNUNET_OS_start_process_s (GNUNET_YES,
+ GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+ NULL,
+ loprefix,
+ binary,
+ binary_name,
+ "-c",
+ tc_h->cfg_filename,
+ NULL);
if (NULL == tc_h->c_proc)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start communicator!");
@@ -992,6 +1015,37 @@ resolver_start (struct
/**
+ * @brief Start Peerstore
+ *
+ */
+static void
+peerstore_start (
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
+{
+ char *binary;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "peerstore_start\n");
+ binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-peerstore");
+ tc_h->ps_proc = GNUNET_OS_start_process (GNUNET_YES,
+ GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+ NULL,
+ NULL,
+ NULL,
+ binary,
+ "gnunet-service-peerstore",
+ "-c",
+ tc_h->cfg_filename,
+ NULL);
+ if (NULL == tc_h->ps_proc)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start Peerstore!");
+ return;
+ }
+ LOG (GNUNET_ERROR_TYPE_INFO, "started Peerstore\n");
+ GNUNET_free (binary);
+}
+
+/**
* @brief Start NAT
*
*/
@@ -1087,6 +1141,8 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
nat_start (tc_h);
/* Start resolver service */
resolver_start (tc_h);
+ /* Start peerstore service */
+ peerstore_start (tc_h);
/* Schedule start communicator */
communicator_start (tc_h,
binary_name);
@@ -1102,6 +1158,7 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop (
shutdown_service (tc_h->sh);
shutdown_nat (tc_h->nat_proc);
shutdown_resolver (tc_h->resolver_proc);
+ shutdown_peerstore (tc_h->ps_proc);
GNUNET_CONFIGURATION_destroy (tc_h->cfg);
GNUNET_free (tc_h);
}