/** * 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); }
/** * Callback called when a client disconnected from the service * * @param cls closure for the service * @param client the client that disconnected * @param internal_cls should be equal to @a c */ static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls) { struct CadetClient *c = internal_cls; GNUNET_assert (c->client == client); c->shutting_down = GNUNET_YES; if (NULL != c->own_channels) { GNUNET_CONTAINER_multihashmap32_iterate (c->own_channels, &own_channel_destroy_iterator, c); GNUNET_CONTAINER_multihashmap32_destroy (c->own_channels); } if (NULL != c->incoming_channels) { GNUNET_CONTAINER_multihashmap32_iterate (c->incoming_channels, &incoming_channel_destroy_iterator, c); GNUNET_CONTAINER_multihashmap32_destroy (c->incoming_channels); } if (NULL != c->ports) { GNUNET_CONTAINER_multihashmap_iterate (c->ports, &client_release_ports, c); GNUNET_CONTAINER_multihashmap_destroy (c->ports); } GNUNET_CONTAINER_DLL_remove (clients_head, clients_tail, c); GNUNET_STATISTICS_update (stats, "# clients", -1, GNUNET_NO); GNUNET_free (c); }
/** * Clear cache */ void GST_cache_clear () { if (NULL != cache) { GNUNET_CONTAINER_multihashmap32_iterate (cache, &cache_clear_iterator, NULL); GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap32_size (cache)); GNUNET_CONTAINER_multihashmap32_destroy (cache); cache = NULL; } cache_size = 0; cache_head = NULL; cache_tail = NULL; }
/** * Shut down the DHT subsystem. */ void GCD_shutdown (void) { LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down DHT\n"); GNUNET_CONTAINER_multihashmap32_iterate (get_requests, &stop_get, NULL); GNUNET_CONTAINER_multihashmap32_destroy (get_requests); if (dht_handle != NULL) { GNUNET_DHT_disconnect (dht_handle); dht_handle = NULL; } if (NULL != announce_id_task) { GNUNET_SCHEDULER_cancel (announce_id_task); announce_id_task = NULL; } }
void GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq) { if (NULL != mq->destroy_impl) { mq->destroy_impl (mq, mq->impl_state); } if (NULL != mq->continue_task) { GNUNET_SCHEDULER_cancel (mq->continue_task); mq->continue_task = NULL; } while (NULL != mq->envelope_head) { struct GNUNET_MQ_Envelope *ev; ev = mq->envelope_head; ev->parent_queue = NULL; GNUNET_CONTAINER_DLL_remove (mq->envelope_head, mq->envelope_tail, ev); GNUNET_MQ_discard (ev); } if (NULL != mq->current_envelope) { /* we can only discard envelopes that * are not queued! */ mq->current_envelope->parent_queue = NULL; GNUNET_MQ_discard (mq->current_envelope); mq->current_envelope = NULL; } if (NULL != mq->assoc_map) { GNUNET_CONTAINER_multihashmap32_destroy (mq->assoc_map); mq->assoc_map = NULL; } GNUNET_free (mq); }
/** * This tunnel is no longer used, destroy it. * * @param cls the idle tunnel */ static void destroy_tunnel (void *cls) { struct CadetTunnel *t = cls; struct CadetTConnection *ct; struct CadetTunnelQueueEntry *tqe; t->destroy_task = NULL; GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap32_size (t->channels)); while (NULL != (ct = t->connection_head)) { GNUNET_assert (ct->t == t); GNUNET_CONTAINER_DLL_remove (t->connection_head, t->connection_tail, ct); GCC_destroy (ct->cc); GNUNET_free (ct); } while (NULL != (tqe = t->tq_head)) { GNUNET_CONTAINER_DLL_remove (t->tq_head, t->tq_tail, tqe); GNUNET_MQ_discard (tqe->env); GNUNET_free (tqe); } GCP_drop_tunnel (t->destination, t); GNUNET_CONTAINER_multihashmap32_destroy (t->channels); if (NULL != t->maintain_connections_task) { GNUNET_SCHEDULER_cancel (t->maintain_connections_task); t->maintain_connections_task = NULL; } GNUNET_free (t); }