diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-01-03 14:58:20 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-01-03 14:58:20 +0000 |
commit | 213bc87131772ae2b808428a6e5ff65a1d963e24 (patch) | |
tree | 6ad732e452c3a1284a7edeeb8682f1b16a8869d8 /src/testbed/testbed_api_testbed.c | |
parent | 75d8aca501ee46d055772ac73870a6ff09cee297 (diff) | |
download | gnunet-213bc87131772ae2b808428a6e5ff65a1d963e24.tar.gz gnunet-213bc87131772ae2b808428a6e5ff65a1d963e24.zip |
fix #2720
Diffstat (limited to 'src/testbed/testbed_api_testbed.c')
-rw-r--r-- | src/testbed/testbed_api_testbed.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c index e11739df8..42bc4d606 100644 --- a/src/testbed/testbed_api_testbed.c +++ b/src/testbed/testbed_api_testbed.c | |||
@@ -218,6 +218,11 @@ struct RunContext | |||
218 | enum GNUNET_TESTBED_TopologyOption topology; | 218 | enum GNUNET_TESTBED_TopologyOption topology; |
219 | 219 | ||
220 | /** | 220 | /** |
221 | * Have we already shutdown | ||
222 | */ | ||
223 | int shutdown; | ||
224 | |||
225 | /** | ||
221 | * Number of hosts in the given host file | 226 | * Number of hosts in the given host file |
222 | */ | 227 | */ |
223 | unsigned int num_hosts; | 228 | unsigned int num_hosts; |
@@ -316,7 +321,7 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) | |||
316 | rc->peer_count++; | 321 | rc->peer_count++; |
317 | if (rc->peer_count < rc->num_peers) | 322 | if (rc->peer_count < rc->num_peers) |
318 | return; | 323 | return; |
319 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Required peers created successfully\n"); | 324 | LOG (GNUNET_ERROR_TYPE_DEBUG, "%u peers created successfully\n", rc->num_peers); |
320 | GNUNET_SCHEDULER_add_now (&start_peers_task, rc); | 325 | GNUNET_SCHEDULER_add_now (&start_peers_task, rc); |
321 | } | 326 | } |
322 | 327 | ||
@@ -382,6 +387,8 @@ shutdown_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | |||
382 | static void | 387 | static void |
383 | shutdown_now (struct RunContext *rc) | 388 | shutdown_now (struct RunContext *rc) |
384 | { | 389 | { |
390 | if (GNUNET_YES == rc->shutdown) | ||
391 | return; | ||
385 | if (GNUNET_SCHEDULER_NO_TASK != rc->shutdown_run_task) | 392 | if (GNUNET_SCHEDULER_NO_TASK != rc->shutdown_run_task) |
386 | GNUNET_SCHEDULER_cancel (rc->shutdown_run_task); | 393 | GNUNET_SCHEDULER_cancel (rc->shutdown_run_task); |
387 | rc->shutdown_run_task = GNUNET_SCHEDULER_add_now (&shutdown_run, rc); | 394 | rc->shutdown_run_task = GNUNET_SCHEDULER_add_now (&shutdown_run, rc); |
@@ -405,6 +412,8 @@ shutdown_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
405 | 412 | ||
406 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != rc->shutdown_run_task); | 413 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != rc->shutdown_run_task); |
407 | rc->shutdown_run_task = GNUNET_SCHEDULER_NO_TASK; | 414 | rc->shutdown_run_task = GNUNET_SCHEDULER_NO_TASK; |
415 | GNUNET_assert (GNUNET_NO == rc->shutdown); | ||
416 | rc->shutdown = GNUNET_YES; | ||
408 | if (NULL != rc->hc_handles) | 417 | if (NULL != rc->hc_handles) |
409 | { | 418 | { |
410 | for (nhost = 0; nhost < rc->num_hosts; nhost++) | 419 | for (nhost = 0; nhost < rc->num_hosts; nhost++) |
@@ -470,6 +479,7 @@ shutdown_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
470 | rc->peer_count++; | 479 | rc->peer_count++; |
471 | continue; | 480 | continue; |
472 | } | 481 | } |
482 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Stopping peer %u\n", peer); | ||
473 | dll_op = GNUNET_malloc (sizeof (struct DLLOperation)); | 483 | dll_op = GNUNET_malloc (sizeof (struct DLLOperation)); |
474 | dll_op->op = GNUNET_TESTBED_peer_stop (rc->peers[peer], NULL, NULL); | 484 | dll_op->op = GNUNET_TESTBED_peer_stop (rc->peers[peer], NULL, NULL); |
475 | dll_op->cls = rc->peers[peer]; | 485 | dll_op->cls = rc->peers[peer]; |