aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-04-26 08:47:58 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-04-26 08:47:58 +0000
commita5e2b65182c5e73f723f2b49d07aabfbe54ad112 (patch)
treec04c725718c5940908990b275f0d6c2d54de75b3 /src
parent45b8f1cfb99e0f75139fb935763556c8dc39807b (diff)
downloadgnunet-a5e2b65182c5e73f723f2b49d07aabfbe54ad112.tar.gz
gnunet-a5e2b65182c5e73f723f2b49d07aabfbe54ad112.zip
- signal termination to peers when controller crashes
Diffstat (limited to 'src')
-rw-r--r--src/testbed/Makefile.am7
-rw-r--r--src/testbed/gnunet-helper-testbed.c12
-rw-r--r--src/testbed/test_testbed_api_testbed_run.c21
3 files changed, 35 insertions, 5 deletions
diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am
index 3802cfebe..e95dd3fa1 100644
--- a/src/testbed/Makefile.am
+++ b/src/testbed/Makefile.am
@@ -144,6 +144,7 @@ check_PROGRAMS = \
144 test_testbed_api_testbed_run_topologysmallworld \ 144 test_testbed_api_testbed_run_topologysmallworld \
145 test_testbed_api_testbed_run_topologyfromfile \ 145 test_testbed_api_testbed_run_topologyfromfile \
146 test_testbed_api_testbed_run_topologyscalefree \ 146 test_testbed_api_testbed_run_topologyscalefree \
147 test_testbed_api_testbed_run_waitforever \ #Can be used for manual debugging
147 test_testbed_api_statistics 148 test_testbed_api_statistics
148 149
149if ENABLE_TEST_RUN 150if ENABLE_TEST_RUN
@@ -319,6 +320,12 @@ test_testbed_api_testbed_run_topologyscalefree_LDADD = \
319 $(top_builddir)/src/util/libgnunetutil.la \ 320 $(top_builddir)/src/util/libgnunetutil.la \
320 libgnunettestbed.la 321 libgnunettestbed.la
321 322
323test_testbed_api_testbed_run_waitforever_SOURCES = \
324 test_testbed_api_testbed_run.c
325test_testbed_api_testbed_run_waitforever_LDADD = \
326 $(top_builddir)/src/util/libgnunetutil.la \
327 libgnunettestbed.la
328
322test_testbed_api_statistics_SOURCES = \ 329test_testbed_api_statistics_SOURCES = \
323 test_testbed_api_statistics.c 330 test_testbed_api_statistics.c
324test_testbed_api_statistics_LDADD = \ 331test_testbed_api_statistics_LDADD = \
diff --git a/src/testbed/gnunet-helper-testbed.c b/src/testbed/gnunet-helper-testbed.c
index bdd8911de..be9154fdc 100644
--- a/src/testbed/gnunet-helper-testbed.c
+++ b/src/testbed/gnunet-helper-testbed.c
@@ -29,7 +29,10 @@
29 * This helper monitors for three termination events. They are: (1)The 29 * This helper monitors for three termination events. They are: (1)The
30 * stdin of the helper is closed for reading; (2)the helper received 30 * stdin of the helper is closed for reading; (2)the helper received
31 * SIGTERM/SIGINT; (3)the testbed crashed. In case of events 1 and 2 31 * SIGTERM/SIGINT; (3)the testbed crashed. In case of events 1 and 2
32 * the helper kills the testbed service. 32 * the helper kills the testbed service. When testbed crashed (event
33 * 3), the helper should send a SIGTERM to its own process group; this
34 * behaviour will help terminate any child processes (peers) testbed
35 * has started and prevents them from leaking and running forever.
33 * 36 *
34 * @author Sree Harsha Totakura <sreeharsha@totakura.in> 37 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
35 */ 38 */
@@ -294,7 +297,12 @@ child_death_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
294 { 297 {
295 GNUNET_OS_process_destroy (testbed); 298 GNUNET_OS_process_destroy (testbed);
296 testbed = NULL; 299 testbed = NULL;
297 shutdown_now (); 300 /* Send SIGTERM to our process group */
301 if (0 != PLIBC_KILL (0, SIGTERM))
302 {
303 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "signal");
304 shutdown_now (); /* Couldn't send the signal, we shutdown frowning */
305 }
298 return; 306 return;
299 } 307 }
300 LOG_DEBUG ("Child hasn't died. Resuming to monitor its status\n"); 308 LOG_DEBUG ("Child hasn't died. Resuming to monitor its status\n");
diff --git a/src/testbed/test_testbed_api_testbed_run.c b/src/testbed/test_testbed_api_testbed_run.c
index 293e77baf..5c69732a3 100644
--- a/src/testbed/test_testbed_api_testbed_run.c
+++ b/src/testbed/test_testbed_api_testbed_run.c
@@ -51,13 +51,18 @@ static GNUNET_SCHEDULER_TaskIdentifier abort_task;
51/** 51/**
52 * Current peer id 52 * Current peer id
53 */ 53 */
54unsigned int peer_id; 54static unsigned int peer_id;
55 55
56/** 56/**
57 * Testing result 57 * Testing result
58 */ 58 */
59static int result; 59static int result;
60 60
61/**
62 * Should we wait forever after testbed is initialized?
63 */
64static int wait_forever;
65
61 66
62/** 67/**
63 * Shutdown nicely 68 * Shutdown nicely
@@ -85,7 +90,7 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
85{ 90{
86 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n"); 91 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n");
87 abort_task = GNUNET_SCHEDULER_NO_TASK; 92 abort_task = GNUNET_SCHEDULER_NO_TASK;
88 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); 93 (void) GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
89} 94}
90 95
91 96
@@ -107,6 +112,14 @@ test_master (void *cls, unsigned int num_peers,
107 unsigned int links_failed) 112 unsigned int links_failed)
108{ 113{
109 result = GNUNET_OK; 114 result = GNUNET_OK;
115 if (GNUNET_YES == wait_forever)
116 {
117 GNUNET_SCHEDULER_cancel (abort_task);
118 abort_task = GNUNET_SCHEDULER_NO_TASK;
119 (void) GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
120 &do_shutdown, NULL);
121 return;
122 }
110 GNUNET_assert (NULL != peers[0]); 123 GNUNET_assert (NULL != peers[0]);
111 op = GNUNET_TESTBED_peer_stop (NULL, peers[0], NULL, NULL); 124 op = GNUNET_TESTBED_peer_stop (NULL, peers[0], NULL, NULL);
112 GNUNET_assert (NULL != op); 125 GNUNET_assert (NULL != op);
@@ -206,7 +219,9 @@ main (int argc, char **argv)
206 GNUNET_break (0); /* Windows with no .exe? */ 219 GNUNET_break (0); /* Windows with no .exe? */
207 } 220 }
208#endif 221#endif
209 if (0 != strcmp ("run", testname)) 222 if (0 == strcmp ("waitforever", testname))
223 wait_forever = GNUNET_YES;
224 if ( (GNUNET_YES != wait_forever) && (0 != strcmp ("run", testname)) )
210 { 225 {
211 GNUNET_asprintf (&config_filename, "test_testbed_api_testbed_run_%s.conf", 226 GNUNET_asprintf (&config_filename, "test_testbed_api_testbed_run_%s.conf",
212 testname); 227 testname);