diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-09-04 15:00:03 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-09-04 15:00:03 +0000 |
commit | 9bdbd137ac0e95419782cf4d70bece01844e7e72 (patch) | |
tree | c1d26c1477c97dd7ab7aae1a8b8281d0e6b9bd5d /src/testbed/testbed_api_testbed.c | |
parent | 1e1588ebf966c590ec7282a48caac3e960c827ee (diff) | |
download | gnunet-9bdbd137ac0e95419782cf4d70bece01844e7e72.tar.gz gnunet-9bdbd137ac0e95419782cf4d70bece01844e7e72.zip |
- remove dead code and fixes
Diffstat (limited to 'src/testbed/testbed_api_testbed.c')
-rw-r--r-- | src/testbed/testbed_api_testbed.c | 56 |
1 files changed, 43 insertions, 13 deletions
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c index 4d5768af6..064e43b9f 100644 --- a/src/testbed/testbed_api_testbed.c +++ b/src/testbed/testbed_api_testbed.c | |||
@@ -257,6 +257,11 @@ struct RunContext | |||
257 | GNUNET_SCHEDULER_TaskIdentifier interrupt_task; | 257 | GNUNET_SCHEDULER_TaskIdentifier interrupt_task; |
258 | 258 | ||
259 | /** | 259 | /** |
260 | * Task for cleaning up the run context and various resources it uses | ||
261 | */ | ||
262 | GNUNET_SCHEDULER_TaskIdentifier cleanup_task; | ||
263 | |||
264 | /** | ||
260 | * The event mask for the controller | 265 | * The event mask for the controller |
261 | */ | 266 | */ |
262 | uint64_t event_mask; | 267 | uint64_t event_mask; |
@@ -443,7 +448,7 @@ remove_rcop (struct RunContext *rc, struct RunContextOperation *rcop) | |||
443 | * @param tc the task context from scheduler | 448 | * @param tc the task context from scheduler |
444 | */ | 449 | */ |
445 | static void | 450 | static void |
446 | cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 451 | cleanup (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
447 | { | 452 | { |
448 | struct RunContext *rc = cls; | 453 | struct RunContext *rc = cls; |
449 | unsigned int hid; | 454 | unsigned int hid; |
@@ -473,6 +478,20 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
473 | 478 | ||
474 | 479 | ||
475 | /** | 480 | /** |
481 | * Perform the cleanup task now | ||
482 | * | ||
483 | * @param rc the run context to be cleaned up | ||
484 | */ | ||
485 | static void | ||
486 | cleanup_now (struct RunContext *rc) | ||
487 | { | ||
488 | if (GNUNET_SCHEDULER_NO_TASK != rc->cleanup_task) | ||
489 | GNUNET_SCHEDULER_cancel (rc->cleanup_task); | ||
490 | rc->cleanup_task = GNUNET_SCHEDULER_add_now (&cleanup, rc); | ||
491 | } | ||
492 | |||
493 | |||
494 | /** | ||
476 | * Iterator for cleaning up elements from rcop_map | 495 | * Iterator for cleaning up elements from rcop_map |
477 | * | 496 | * |
478 | * @param cls the RunContext | 497 | * @param cls the RunContext |
@@ -495,13 +514,27 @@ rcop_cleanup_iterator (void *cls, uint32_t key, void *value) | |||
495 | 514 | ||
496 | 515 | ||
497 | /** | 516 | /** |
498 | * Frees memory, closes pending operations, cancels actives tasks of the given | 517 | * Cleanup existing operation in given run context |
499 | * RunContext | 518 | * |
519 | * @param rc the run context | ||
520 | */ | ||
521 | static void | ||
522 | cleanup_operations (struct RunContext *rc) | ||
523 | { | ||
524 | GNUNET_assert (GNUNET_SYSERR != | ||
525 | GNUNET_CONTAINER_multihashmap32_iterate (rc->rcop_map, | ||
526 | &rcop_cleanup_iterator, | ||
527 | rc)); | ||
528 | } | ||
529 | |||
530 | |||
531 | /** | ||
532 | * Cancels operations and tasks which are assigned to the given run context | ||
500 | * | 533 | * |
501 | * @param rc the RunContext | 534 | * @param rc the RunContext |
502 | */ | 535 | */ |
503 | static void | 536 | static void |
504 | cleanup (struct RunContext *rc) | 537 | rc_cleanup_operations (struct RunContext *rc) |
505 | { | 538 | { |
506 | struct CompatibilityCheckContext *hc; | 539 | struct CompatibilityCheckContext *hc; |
507 | unsigned int nhost; | 540 | unsigned int nhost; |
@@ -544,10 +577,7 @@ cleanup (struct RunContext *rc) | |||
544 | rc->topology_operation = NULL; | 577 | rc->topology_operation = NULL; |
545 | } | 578 | } |
546 | /* cancel any exiting operations */ | 579 | /* cancel any exiting operations */ |
547 | GNUNET_assert (GNUNET_SYSERR != | 580 | cleanup_operations (rc); |
548 | GNUNET_CONTAINER_multihashmap32_iterate (rc->rcop_map, | ||
549 | &rcop_cleanup_iterator, | ||
550 | rc)); | ||
551 | } | 581 | } |
552 | 582 | ||
553 | 583 | ||
@@ -567,7 +597,7 @@ shutdown_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
567 | rc->shutdown_run_task = GNUNET_SCHEDULER_NO_TASK; | 597 | rc->shutdown_run_task = GNUNET_SCHEDULER_NO_TASK; |
568 | GNUNET_assert (GNUNET_NO == rc->shutdown); | 598 | GNUNET_assert (GNUNET_NO == rc->shutdown); |
569 | rc->shutdown = GNUNET_YES; | 599 | rc->shutdown = GNUNET_YES; |
570 | cleanup (rc); | 600 | rc_cleanup_operations (rc); |
571 | if (NULL != rc->c) | 601 | if (NULL != rc->c) |
572 | { | 602 | { |
573 | if (NULL != rc->peers) | 603 | if (NULL != rc->peers) |
@@ -584,7 +614,7 @@ shutdown_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
584 | } | 614 | } |
585 | rc->state = RC_PEERS_SHUTDOWN; /* No peers are present so we consider the | 615 | rc->state = RC_PEERS_SHUTDOWN; /* No peers are present so we consider the |
586 | * state where all peers are SHUTDOWN */ | 616 | * state where all peers are SHUTDOWN */ |
587 | GNUNET_SCHEDULER_add_now (&cleanup_task, rc); | 617 | cleanup_now (rc); |
588 | } | 618 | } |
589 | 619 | ||
590 | 620 | ||
@@ -845,7 +875,7 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
845 | GNUNET_free_non_null (rc->peers); | 875 | GNUNET_free_non_null (rc->peers); |
846 | rc->peers = NULL; | 876 | rc->peers = NULL; |
847 | DEBUG ("Peers shut down in %s\n", prof_time (rc)); | 877 | DEBUG ("Peers shut down in %s\n", prof_time (rc)); |
848 | GNUNET_SCHEDULER_add_now (&cleanup_task, rc); | 878 | cleanup_now (rc); |
849 | break; | 879 | break; |
850 | default: | 880 | default: |
851 | GNUNET_assert (0); | 881 | GNUNET_assert (0); |
@@ -1008,7 +1038,7 @@ controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1008 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1038 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1009 | _("Controller crash detected. Shutting down.\n")); | 1039 | _("Controller crash detected. Shutting down.\n")); |
1010 | rc->cproc = NULL; | 1040 | rc->cproc = NULL; |
1011 | cleanup (rc); | 1041 | rc_cleanup_operations (rc); |
1012 | if (NULL != rc->peers) | 1042 | if (NULL != rc->peers) |
1013 | { | 1043 | { |
1014 | GNUNET_free (rc->peers); | 1044 | GNUNET_free (rc->peers); |
@@ -1017,7 +1047,7 @@ controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1017 | if (GNUNET_YES == rc->shutdown) | 1047 | if (GNUNET_YES == rc->shutdown) |
1018 | { | 1048 | { |
1019 | rc->state = RC_PEERS_SHUTDOWN; | 1049 | rc->state = RC_PEERS_SHUTDOWN; |
1020 | GNUNET_SCHEDULER_add_now (&cleanup_task, rc); | 1050 | cleanup_now (rc); |
1021 | } | 1051 | } |
1022 | else | 1052 | else |
1023 | shutdown_now (rc); | 1053 | shutdown_now (rc); |