/** * Kill a #Slave object * * @param slave the #Slave object */ static void kill_slave (struct Slave *slave) { struct HostRegistration *hr_entry; while (NULL != (hr_entry = slave->hr_dll_head)) { GNUNET_CONTAINER_DLL_remove (slave->hr_dll_head, slave->hr_dll_tail, hr_entry); GNUNET_free (hr_entry); } if (NULL != slave->rhandle) GNUNET_TESTBED_cancel_registration (slave->rhandle); GNUNET_assert (GNUNET_SYSERR != GNUNET_CONTAINER_multihashmap_iterate (slave->reghost_map, reghost_free_iterator, slave)); GNUNET_CONTAINER_multihashmap_destroy (slave->reghost_map); if (NULL != slave->controller) GNUNET_TESTBED_controller_disconnect (slave->controller); if (NULL != slave->controller_proc) { LOG_DEBUG ("Stopping a slave\n"); GNUNET_TESTBED_controller_kill_ (slave->controller_proc); } }
/** * Assuming all peers have been destroyed cleanup run handle * * @param rc the run context */ static void cleanup (struct GNUNET_TESTBED_RunHandle *rc) { unsigned int hid; GNUNET_assert (NULL == rc->register_hosts_task); GNUNET_assert (NULL == rc->reg_handle); GNUNET_assert (NULL == rc->peers); GNUNET_assert (NULL == rc->hclist); GNUNET_assert (RC_PEERS_SHUTDOWN == rc->state); GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap32_size (rc->rcop_map)); GNUNET_CONTAINER_multihashmap32_destroy (rc->rcop_map); if (NULL != rc->c) GNUNET_TESTBED_controller_disconnect (rc->c); if (NULL != rc->cproc) GNUNET_TESTBED_controller_stop (rc->cproc); if (NULL != rc->h) GNUNET_TESTBED_host_destroy (rc->h); for (hid = 0; hid < rc->num_hosts; hid++) GNUNET_TESTBED_host_destroy (rc->hosts[hid]); GNUNET_free_non_null (rc->hosts); if (NULL != rc->cfg) GNUNET_CONFIGURATION_destroy (rc->cfg); GNUNET_free_non_null (rc->topo_file); GNUNET_free_non_null (rc->trusted_ip); GNUNET_free (rc); }
/** * Shutdown nicely * * @param cls NULL * @param tc the task context */ static void do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct DLLOperation *dll_op; unsigned int nhost; shutdown_task = GNUNET_SCHEDULER_NO_TASK; if (GNUNET_SCHEDULER_NO_TASK != abort_task) GNUNET_SCHEDULER_cancel (abort_task); if (GNUNET_SCHEDULER_NO_TASK != register_hosts_task) GNUNET_SCHEDULER_cancel (register_hosts_task); if (NULL != reg_handle) GNUNET_TESTBED_cancel_registration (reg_handle); if (NULL != topology_op) GNUNET_TESTBED_operation_done (topology_op); for (nhost = 0; nhost < num_hosts; nhost++) if (NULL != hosts[nhost]) GNUNET_TESTBED_host_destroy (hosts[nhost]); GNUNET_free_non_null (hosts); while (NULL != (dll_op = dll_op_head)) { GNUNET_TESTBED_operation_done (dll_op->op); GNUNET_CONTAINER_DLL_remove (dll_op_head, dll_op_tail, dll_op); GNUNET_free (dll_op); } if (NULL != mc) GNUNET_TESTBED_controller_disconnect (mc); if (NULL != mc_proc) GNUNET_TESTBED_controller_stop (mc_proc); if (NULL != cfg) GNUNET_CONFIGURATION_destroy (cfg); GNUNET_SCHEDULER_shutdown (); /* Stop scheduler to shutdown testbed run */ }
/** * Shutdown nicely * * @param cls NULL * @param tc the task context */ static void do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { if (NULL != abort_task) GNUNET_SCHEDULER_cancel (abort_task); if (NULL != delay_task_id) { GNUNET_SCHEDULER_cancel (delay_task_id); delay_task_id = NULL; } if (NULL != hc_handle) GNUNET_TESTBED_is_host_habitable_cancel (hc_handle); if (NULL != mc) GNUNET_TESTBED_controller_disconnect (mc); if (NULL != cp) GNUNET_TESTBED_controller_stop (cp); if (NULL != slave3) GNUNET_TESTBED_host_destroy (slave3); if (NULL != slave2) GNUNET_TESTBED_host_destroy (slave2); if (NULL != slave) GNUNET_TESTBED_host_destroy (slave); if (NULL != host) GNUNET_TESTBED_host_destroy (host); if (NULL != cfg) GNUNET_CONFIGURATION_destroy (cfg); if (NULL != cfg3) GNUNET_CONFIGURATION_destroy (cfg3); if (NULL != rh) GNUNET_TESTBED_cancel_registration (rh); }
/** * Shutdown nicely * * @param cls NULL * @param tc the task context */ static void do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { if (NULL != abort_task) GNUNET_SCHEDULER_cancel (abort_task); if (NULL != hc_handle) GNUNET_TESTBED_is_host_habitable_cancel (hc_handle); GNUNET_assert (NULL == delayed_connect_task); if (NULL != common_operation) GNUNET_TESTBED_operation_done (common_operation); if (NULL != reg_handle) GNUNET_TESTBED_cancel_registration (reg_handle); if (NULL != controller1) GNUNET_TESTBED_controller_disconnect (controller1); GNUNET_CONFIGURATION_destroy (cfg); if (NULL != cfg2) GNUNET_CONFIGURATION_destroy (cfg2); if (NULL != cp1) GNUNET_TESTBED_controller_stop (cp1); if (NULL != host) GNUNET_TESTBED_host_destroy (host); if (NULL != neighbour1) GNUNET_TESTBED_host_destroy (neighbour1); if (NULL != neighbour2) GNUNET_TESTBED_host_destroy (neighbour2); }
/** * Callback to be called when the neighbour connect operation is released * * @param cls the neighbour */ static void oprelease_neighbour_conn (void *cls) { struct Neighbour *n = cls; GNUNET_assert (0 == n->reference_cnt); GNUNET_assert (NULL == n->notify_task); GNUNET_assert (NULL == n->nl_head); if (NULL != n->controller) { LOG_DEBUG ("Closing connection to controller on host %u\n", n->host_id); GNUNET_TESTBED_controller_disconnect (n->controller); n->controller = NULL; } n->conn_op = NULL; n->inactive = 0; }
/** * Shutdown nicely * * @param cls NULL * @param tc the task context */ static void do_shutdown (void *cls) { LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down...\n"); if (NULL != abort_task) GNUNET_SCHEDULER_cancel (abort_task); if (NULL != reg_handle) GNUNET_TESTBED_cancel_registration (reg_handle); if (NULL != controller) GNUNET_TESTBED_controller_disconnect (controller); if (NULL != cfg) GNUNET_CONFIGURATION_destroy (cfg); if (NULL != cp) GNUNET_TESTBED_controller_stop (cp); if (NULL != neighbour) GNUNET_TESTBED_host_destroy (neighbour); if (NULL != host) GNUNET_TESTBED_host_destroy (host); }
/** * Shutdown nicely * * @param cls NULL * @param tc the task context */ static void do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { if (GNUNET_SCHEDULER_NO_TASK != abort_task) GNUNET_SCHEDULER_cancel (abort_task); if (NULL != slave3) GNUNET_TESTBED_host_destroy (slave3); if (NULL != slave2) GNUNET_TESTBED_host_destroy (slave2); if (NULL != slave) GNUNET_TESTBED_host_destroy (slave); if (NULL != host) GNUNET_TESTBED_host_destroy (host); if (NULL != mc) GNUNET_TESTBED_controller_disconnect (mc); if (NULL != cfg) GNUNET_CONFIGURATION_destroy (cfg); if (NULL != cfg3) GNUNET_CONFIGURATION_destroy (cfg3); if (NULL != cp) GNUNET_TESTBED_controller_stop (cp); if (NULL != rh) GNUNET_TESTBED_cancel_registration (rh); }