aboutsummaryrefslogtreecommitdiff
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
114 struct GNUNET_OS_Process *resolver_proc; 114 struct GNUNET_OS_Process *resolver_proc;
115 115
116 /** 116 /**
117 * peerstore service process
118 */
119 struct GNUNET_OS_Process *ps_proc;
120
121 /**
117 * @brief Task that will be run on shutdown to stop and clean communicator 122 * @brief Task that will be run on shutdown to stop and clean communicator
118 */ 123 */
119 struct GNUNET_SCHEDULER_Task *c_shutdown_task; 124 struct GNUNET_SCHEDULER_Task *c_shutdown_task;
@@ -892,6 +897,12 @@ shutdown_process (struct GNUNET_OS_Process *proc)
892 GNUNET_OS_process_destroy (proc); 897 GNUNET_OS_process_destroy (proc);
893} 898}
894 899
900static void
901shutdown_peerstore (void *cls)
902{
903 struct GNUNET_OS_Process *proc = cls;
904 shutdown_process (proc);
905}
895 906
896static void 907static void
897shutdown_communicator (void *cls) 908shutdown_communicator (void *cls)
@@ -912,19 +923,31 @@ communicator_start (
912 const char *binary_name) 923 const char *binary_name)
913{ 924{
914 char *binary; 925 char *binary;
926 char *loprefix;
927 char *section_name;
915 928
916 LOG (GNUNET_ERROR_TYPE_DEBUG, "communicator_start\n"); 929 LOG (GNUNET_ERROR_TYPE_DEBUG, "communicator_start\n");
930
931 section_name = strchr (binary_name, '-');
932 section_name++;
933
934 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (tc_h->cfg,
935 section_name,
936 "PREFIX",
937 &loprefix))
938 loprefix = GNUNET_strdup ("");
939
940
917 binary = GNUNET_OS_get_libexec_binary_path (binary_name); 941 binary = GNUNET_OS_get_libexec_binary_path (binary_name);
918 tc_h->c_proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_OUT_AND_ERR 942 tc_h->c_proc = GNUNET_OS_start_process_s (GNUNET_YES,
919 | GNUNET_OS_USE_PIPE_CONTROL, 943 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
920 NULL, 944 NULL,
921 NULL, 945 loprefix,
922 NULL, 946 binary,
923 binary, 947 binary_name,
924 binary_name, 948 "-c",
925 "-c", 949 tc_h->cfg_filename,
926 tc_h->cfg_filename, 950 NULL);
927 NULL);
928 if (NULL == tc_h->c_proc) 951 if (NULL == tc_h->c_proc)
929 { 952 {
930 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start communicator!"); 953 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start communicator!");
@@ -992,6 +1015,37 @@ resolver_start (struct
992 1015
993 1016
994/** 1017/**
1018 * @brief Start Peerstore
1019 *
1020 */
1021static void
1022peerstore_start (
1023 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
1024{
1025 char *binary;
1026
1027 LOG (GNUNET_ERROR_TYPE_DEBUG, "peerstore_start\n");
1028 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-peerstore");
1029 tc_h->ps_proc = GNUNET_OS_start_process (GNUNET_YES,
1030 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
1031 NULL,
1032 NULL,
1033 NULL,
1034 binary,
1035 "gnunet-service-peerstore",
1036 "-c",
1037 tc_h->cfg_filename,
1038 NULL);
1039 if (NULL == tc_h->ps_proc)
1040 {
1041 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start Peerstore!");
1042 return;
1043 }
1044 LOG (GNUNET_ERROR_TYPE_INFO, "started Peerstore\n");
1045 GNUNET_free (binary);
1046}
1047
1048/**
995 * @brief Start NAT 1049 * @brief Start NAT
996 * 1050 *
997 */ 1051 */
@@ -1087,6 +1141,8 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
1087 nat_start (tc_h); 1141 nat_start (tc_h);
1088 /* Start resolver service */ 1142 /* Start resolver service */
1089 resolver_start (tc_h); 1143 resolver_start (tc_h);
1144 /* Start peerstore service */
1145 peerstore_start (tc_h);
1090 /* Schedule start communicator */ 1146 /* Schedule start communicator */
1091 communicator_start (tc_h, 1147 communicator_start (tc_h,
1092 binary_name); 1148 binary_name);
@@ -1102,6 +1158,7 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop (
1102 shutdown_service (tc_h->sh); 1158 shutdown_service (tc_h->sh);
1103 shutdown_nat (tc_h->nat_proc); 1159 shutdown_nat (tc_h->nat_proc);
1104 shutdown_resolver (tc_h->resolver_proc); 1160 shutdown_resolver (tc_h->resolver_proc);
1161 shutdown_peerstore (tc_h->ps_proc);
1105 GNUNET_CONFIGURATION_destroy (tc_h->cfg); 1162 GNUNET_CONFIGURATION_destroy (tc_h->cfg);
1106 GNUNET_free (tc_h); 1163 GNUNET_free (tc_h);
1107} 1164}