static void terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct GNUNET_CORE_Handle *ch; err_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_STATISTICS_destroy (p1.stats, GNUNET_NO); GNUNET_STATISTICS_destroy (p2.stats, GNUNET_NO); GNUNET_TRANSPORT_get_hello_cancel (p2.ghh); GNUNET_TRANSPORT_get_hello_cancel (p1.ghh); if (p1.nth != NULL) { GNUNET_CORE_notify_transmit_ready_cancel (p1.nth); p1.nth = NULL; } if (connect_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (connect_task); connect_task = GNUNET_SCHEDULER_NO_TASK; } ch = p1.ch; p1.ch = NULL; GNUNET_CORE_disconnect (ch); ch = p2.ch; p2.ch = NULL; GNUNET_CORE_disconnect (ch); GNUNET_TRANSPORT_disconnect (p1.th); p1.th = NULL; GNUNET_TRANSPORT_disconnect (p2.th); p2.th = NULL; GNUNET_free_non_null (p1.hello); GNUNET_free_non_null (p2.hello); }
static void force_shutdown (void *cls) { fprintf (stderr, "Timeout, failed to receive notifications: %d\n", ok); GNUNET_STATISTICS_destroy (h, GNUNET_NO); GNUNET_STATISTICS_destroy (h2, GNUNET_NO); ok = 7; }
static void force_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { fprintf (stderr, "Timeout, failed to receive notifications: %d\n", ok); GNUNET_STATISTICS_destroy (h, GNUNET_NO); GNUNET_STATISTICS_destroy (h2, GNUNET_NO); ok = 7; }
static void shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct SysmonProperty *sp; struct SysmonProperty *next; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sysdaemon stopping ... \n"); end_task = GNUNET_SCHEDULER_NO_TASK; if (NULL != stats) { GNUNET_STATISTICS_destroy (stats, GNUNET_YES); stats = NULL; } next = sp_head; while (NULL != (sp = next)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping `%s' \n", sp->desc); GNUNET_CONTAINER_DLL_remove (sp_head, sp_tail, sp); next = sp->next; if (GNUNET_SCHEDULER_NO_TASK != sp->task_id) { GNUNET_SCHEDULER_cancel (sp->task_id); sp->task_id = GNUNET_SCHEDULER_NO_TASK; } GNUNET_free_non_null (sp->cmd); GNUNET_free_non_null (sp->cmd_args); GNUNET_free (sp->desc); GNUNET_free (sp); } }
/** * Task run during shutdown. * * @param cls unused * @param tc unused */ static void shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct Ego *e; if (NULL != nc) { GNUNET_SERVER_notification_context_destroy (nc); nc = NULL; } if (NULL != stats) { GNUNET_STATISTICS_destroy (stats, GNUNET_NO); stats = NULL; } GNUNET_CONFIGURATION_destroy (subsystem_cfg); subsystem_cfg = NULL; GNUNET_free (subsystem_cfg_file); subsystem_cfg_file = NULL; GNUNET_free (ego_directory); ego_directory = NULL; while (NULL != (e = ego_head)) { GNUNET_CONTAINER_DLL_remove (ego_head, ego_tail, e); GNUNET_free (e->pk); GNUNET_free (e->identifier); GNUNET_free (e); } }
/** * Last task run during shutdown. Disconnects us from * the transport and core. * * @param cls unused, NULL * @param tc scheduler context */ static void cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { if (NULL != peerinfo_notify) { GNUNET_PEERINFO_notify_cancel (peerinfo_notify); peerinfo_notify = NULL; } GNUNET_TRANSPORT_disconnect (transport); transport = NULL; if (handle != NULL) { GNUNET_CORE_disconnect (handle); handle = NULL; } whitelist_peers (); if (GNUNET_SCHEDULER_NO_TASK != add_task) { GNUNET_SCHEDULER_cancel (add_task); add_task = GNUNET_SCHEDULER_NO_TASK; } GNUNET_CONTAINER_multihashmap_iterate (peers, &free_peer, NULL); GNUNET_CONTAINER_multihashmap_destroy (peers); peers = NULL; if (stats != NULL) { GNUNET_STATISTICS_destroy (stats, GNUNET_NO); stats = NULL; } }
static void end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n"); if (die_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (die_task); die_task = GNUNET_SCHEDULER_NO_TASK; } if (NULL != sched_ats) { GNUNET_ATS_scheduling_done (sched_ats); sched_ats = NULL; } GNUNET_STATISTICS_watch_cancel (stats, "ats", "# addresses", &stat_cb, NULL); if (NULL != stats) { GNUNET_STATISTICS_destroy (stats, GNUNET_NO); stats = NULL; } ret = 0; }
/** * Function called when the service shuts down. Unloads our plugins * and cancels pending validations. * * @param cls closure, unused * @param tc task context (unused) */ static void shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GST_neighbours_stop (); GST_validation_stop (); GST_plugins_unload (); GNUNET_ATS_scheduling_done (GST_ats); GST_ats = NULL; GST_clients_stop (); GST_blacklist_stop (); GST_hello_stop (); if (GST_peerinfo != NULL) { GNUNET_PEERINFO_disconnect (GST_peerinfo); GST_peerinfo = NULL; } if (GST_stats != NULL) { GNUNET_STATISTICS_destroy (GST_stats, GNUNET_NO); GST_stats = NULL; } if (GST_my_private_key != NULL) { GNUNET_CRYPTO_rsa_key_free (GST_my_private_key); GST_my_private_key = NULL; } }
/** * Last task run during shutdown. Disconnects us from * the other services. * * @param cls NULL * @param tc scheduler context */ static void cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hostlist daemon is shutting down\n"); if (NULL != core) { GNUNET_CORE_disconnect (core); core = NULL; } if (bootstrapping) { GNUNET_HOSTLIST_client_stop (); } #if HAVE_MHD if (provide_hostlist) { GNUNET_HOSTLIST_server_stop (); } #endif if (NULL != stats) { GNUNET_STATISTICS_destroy (stats, GNUNET_NO); stats = NULL; } }
/** * Task run during shutdown. * * @param cls unused */ static void shutdown_task (void *cls) { if (NULL != flood_task) { GNUNET_SCHEDULER_cancel (flood_task); flood_task = NULL; } if (NULL != proof_task) { GNUNET_SCHEDULER_cancel (proof_task); proof_task = NULL; write_proof (); /* remember progress */ } if (NULL != nc) { GNUNET_notification_context_destroy (nc); nc = NULL; } if (NULL != core_api) { GNUNET_CORE_disconnect (core_api); core_api = NULL; } if (NULL != stats) { GNUNET_STATISTICS_destroy (stats, GNUNET_NO); stats = NULL; } if (NULL != peers) { GNUNET_CONTAINER_multipeermap_destroy (peers); peers = NULL; } if (NULL != my_private_key) { GNUNET_free (my_private_key); my_private_key = NULL; } #if ENABLE_NSE_HISTOGRAM if (NULL != logger_test) { GNUNET_CLIENT_service_test_cancel (logger_test); logger_test = NULL; } if (NULL != lh) { GNUNET_TESTBED_LOGGER_flush (lh, &flush_comp_cb, NULL); } if (NULL != histogram) { GNUNET_BIO_write_close (histogram); histogram = NULL; } #endif }
static void next_fin (void *cls, int success) { int *ok = cls; GNUNET_STATISTICS_destroy (h, GNUNET_NO); GNUNET_assert (success == GNUNET_OK); *ok = 0; }
/** * Clean up our state. Called during shutdown. * * @param cls unused * @param tc scheduler task context, unused */ static void shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_SERVER_notification_context_destroy (notify_list); notify_list = NULL; GNUNET_CONTAINER_multihashmap_iterate (hostmap, &free_host_entry, NULL); GNUNET_CONTAINER_multihashmap_destroy (hostmap); if (stats != NULL) { GNUNET_STATISTICS_destroy (stats, GNUNET_NO); stats = NULL; } }
/** * Function run on shutdown to clean up. * * @param cls the statistics handle * @param tc scheduler context */ static void shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct GNUNET_STATISTICS_Handle *h = cls; if (NULL == h) return; if ( (GNUNET_YES == watch) && (NULL != subsystem) && (NULL != name) ) GNUNET_assert (GNUNET_OK == GNUNET_STATISTICS_watch_cancel (h, subsystem, name, &printer, h)); GNUNET_STATISTICS_destroy (h, GNUNET_NO); h = NULL; }
/** * Adapter function called to destroy statistics connection * * @param cls the PeerGetStatsContext * @param op_result service handle returned from the connect adapter */ static void statistics_da (void *cls, void *op_result) { struct PeerGetStatsContext *peer_sc = cls; struct GNUNET_STATISTICS_Handle *sh = op_result; if (NULL != peer_sc->get_handle) { GNUNET_STATISTICS_get_cancel (peer_sc->get_handle); peer_sc->get_handle = NULL; } GNUNET_STATISTICS_destroy (sh, GNUNET_NO); if (NULL != peer_sc->op_done_task_id) GNUNET_SCHEDULER_cancel (peer_sc->op_done_task_id); GNUNET_free (peer_sc); }
/** * Do shutdown */ static void end_now (int res) { if (NULL != ph.stat) { GNUNET_STATISTICS_destroy (ph.stat, GNUNET_NO); ph.stat = NULL; } GNUNET_free_non_null (ph.peers); GNUNET_free_non_null (ph.iterations_results); GAS_normalization_stop (); GAS_preference_done (); ret = res; }
/** * Disconnect from the datastore service (and free * associated resources). * * @param h handle to the datastore * @param drop set to GNUNET_YES to delete all data in datastore (!) */ void GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h, int drop) { struct GNUNET_DATASTORE_QueueEntry *qe; LOG (GNUNET_ERROR_TYPE_DEBUG, "Datastore disconnect\n"); if (NULL != h->th) { GNUNET_CLIENT_notify_transmit_ready_cancel (h->th); h->th = NULL; } if (h->client != NULL) { GNUNET_CLIENT_disconnect (h->client); h->client = NULL; } if (h->reconnect_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (h->reconnect_task); h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; } while (NULL != (qe = h->queue_head)) { GNUNET_assert (NULL != qe->response_proc); qe->response_proc (h, NULL); } if (GNUNET_YES == drop) { h->client = GNUNET_CLIENT_connect ("datastore", h->cfg); if (h->client != NULL) { if (NULL != GNUNET_CLIENT_notify_transmit_ready (h->client, sizeof (struct GNUNET_MessageHeader), GNUNET_TIME_UNIT_MINUTES, GNUNET_YES, &transmit_drop, h)) return; GNUNET_CLIENT_disconnect (h->client); h->client = NULL; } GNUNET_break (0); } GNUNET_STATISTICS_destroy (h->stats, GNUNET_NO); h->stats = NULL; GNUNET_free (h); }
/** * Task run during shutdown. * * @param cls unused */ static void cleanup_task (void *cls) { struct ClientEntry *ce; while (NULL != (ce = client_head)) handle_client_disconnect (NULL, ce->client); GNUNET_DHT_disconnect (dht); dht = NULL; GNUNET_STATISTICS_destroy (stats, GNUNET_NO); stats = NULL; GNUNET_SERVER_notification_context_destroy (nc); nc = NULL; GNUNET_free (my_private_key); my_private_key = NULL; }
/** * Task run during shutdown. * * @param cls unused * @param tc unused */ static void shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GDS_NEIGHBOURS_done (); GDS_DATACACHE_done (); GDS_NSE_done (); if (GDS_block_context != NULL) { GNUNET_BLOCK_context_destroy (GDS_block_context); GDS_block_context = NULL; } if (GDS_stats != NULL) { GNUNET_STATISTICS_destroy (GDS_stats, GNUNET_YES); GDS_stats = NULL; } }
/** * Task run during shutdown. * * @param cls unused */ static void shutdown_task (void *cls) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "shutting down\n"); shutting_down = GNUNET_YES; GCO_shutdown (); if (NULL != stats) { GNUNET_STATISTICS_destroy (stats, GNUNET_NO); stats = NULL; } if (NULL != open_ports) { GNUNET_CONTAINER_multihashmap_destroy (open_ports); open_ports = NULL; } if (NULL != loose_channels) { GNUNET_CONTAINER_multihashmap_destroy (loose_channels); loose_channels = NULL; } /* All channels, connections and CORE must be down before this point. */ GCP_destroy_all_peers (); if (NULL != peers) { GNUNET_CONTAINER_multipeermap_destroy (peers); peers = NULL; } if (NULL != connections) { GNUNET_CONTAINER_multishortmap_destroy (connections); connections = NULL; } if (NULL != ats_ch) { GNUNET_ATS_connectivity_done (ats_ch); ats_ch = NULL; } GCD_shutdown (); GCH_shutdown (); GNUNET_free_non_null (my_private_key); my_private_key = NULL; }
/** * Task run during shutdown. * * @param cls unused * @param tc unused */ static void shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "shutting down\n"); shutting_down = GNUNET_YES; GML_shutdown (); GCH_shutdown (); GCC_shutdown (); GCT_shutdown (); GCD_shutdown (); GCP_shutdown (); GNUNET_STATISTICS_destroy (stats, GNUNET_NO); stats = NULL; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "shut down\n"); }
/** * Stop the sensor monitoring module */ void SENSOR_monitoring_stop () { if (NULL != statistics) { GNUNET_STATISTICS_destroy (statistics, GNUNET_YES); statistics = NULL; } if (NULL != peerstore) { GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_YES); peerstore = NULL; } if (NULL != sensor_dir) { GNUNET_free (sensor_dir); sensor_dir = NULL; } }
/** * Destroy a data cache (and free associated resources). * * @param h handle to the datastore */ void GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h) { if (NULL != h->filter) GNUNET_CONTAINER_bloomfilter_free (h->filter); if (h->api != NULL) GNUNET_break (NULL == GNUNET_PLUGIN_unload (h->lib_name, h->api)); GNUNET_free (h->lib_name); GNUNET_free (h->short_name); GNUNET_free (h->section); if (h->bloom_name != NULL) { if (0 != UNLINK (h->bloom_name)) GNUNET_log_from_strerror_file (GNUNET_ERROR_TYPE_WARNING, "datacache", "unlink", h->bloom_name); GNUNET_free (h->bloom_name); } GNUNET_STATISTICS_destroy (h->stats, GNUNET_NO); GNUNET_free (h); }
/** * Last task run during shutdown. Disconnects us from * the transport. * * @param cls NULL, unused * @param tc scheduler context, unused */ static void shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core service shutting down.\n"); if (NULL != GST_keygen) { GNUNET_CRYPTO_rsa_key_create_stop (GST_keygen); GST_keygen = NULL; } GSC_CLIENTS_done (); GSC_NEIGHBOURS_done (); GSC_SESSIONS_done (); GSC_KX_done (); GSC_TYPEMAP_done (); if (NULL != GSC_stats) { GNUNET_STATISTICS_destroy (GSC_stats, GNUNET_NO); GSC_stats = NULL; } GSC_cfg = NULL; }
/** * Last task run during shutdown. Disconnects us from * the transport and core. * * @param cls unused, NULL */ static void cleaning_task (void *cls) { if (NULL != peerinfo_notify) { GNUNET_PEERINFO_notify_cancel (peerinfo_notify); peerinfo_notify = NULL; } if (NULL != handle) { GNUNET_CORE_disconnect (handle); handle = NULL; } whitelist_peers (); if (NULL != add_task) { GNUNET_SCHEDULER_cancel (add_task); add_task = NULL; } if (NULL != oh) { GNUNET_TRANSPORT_offer_hello_cancel (oh); oh = NULL; } GNUNET_CONTAINER_multipeermap_iterate (peers, &free_peer, NULL); GNUNET_CONTAINER_multipeermap_destroy (peers); peers = NULL; if (NULL != ats) { GNUNET_ATS_connectivity_done (ats); ats = NULL; } if (NULL != stats) { GNUNET_STATISTICS_destroy (stats, GNUNET_NO); stats = NULL; } }
static void terminate_peer (struct PeerContext *p) { if (p->nth != NULL) { GNUNET_CORE_notify_transmit_ready_cancel (p->nth); p->nth = NULL; } if (NULL != p->ch) { GNUNET_CORE_disconnect (p->ch); p->ch = NULL; } if (NULL != p->th) { GNUNET_TRANSPORT_get_hello_cancel (p->ghh); GNUNET_TRANSPORT_disconnect (p->th); p->th = NULL; } if (NULL != p->ats_sh) { GNUNET_ATS_connectivity_suggest_cancel (p->ats_sh); p->ats_sh = NULL; } if (NULL != p->ats) { GNUNET_ATS_connectivity_done (p->ats); p->ats = NULL; } if (NULL != p->stats) { GNUNET_STATISTICS_destroy (p->stats, GNUNET_NO); p->stats = NULL; } if (NULL != p->hello) { GNUNET_free (p->hello); p->hello = NULL; } }
/** * Function called when the service shuts down. Unloads our plugins * and cancels pending validations. * * @param cls closure, unused * @param tc task context (unused) */ static void shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GST_neighbours_stop (); GST_plugins_unload (); GST_validation_stop (); GST_ats_done (); GNUNET_ATS_scheduling_done (GST_ats); GST_ats = NULL; GNUNET_ATS_connectivity_done (GST_ats_connect); GST_ats_connect = NULL; GNUNET_ATS_scanner_done (GST_is); GST_is = NULL; GST_clients_stop (); GST_blacklist_stop (); GST_hello_stop (); GST_manipulation_stop (); if (NULL != GST_peerinfo) { GNUNET_PEERINFO_disconnect (GST_peerinfo); GST_peerinfo = NULL; } if (NULL != GST_stats) { GNUNET_STATISTICS_destroy (GST_stats, GNUNET_NO); GST_stats = NULL; } if (NULL != GST_my_private_key) { GNUNET_free(GST_my_private_key); GST_my_private_key = NULL; } GST_server = NULL; }
static void normal_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_STATISTICS_destroy (h, GNUNET_NO); GNUNET_STATISTICS_destroy (h2, GNUNET_NO); }
static void shutdown_testcase () { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown testcase....\n"); if (timeout_task != NULL) { GNUNET_SCHEDULER_cancel (timeout_task); timeout_task = NULL; } if (NULL != download_stats) { GNUNET_STATISTICS_get_cancel (download_stats); download_stats = NULL; } if (NULL != urisrecv_stat) { GNUNET_STATISTICS_get_cancel (urisrecv_stat); urisrecv_stat = NULL; } if (NULL != advsent_stat) { GNUNET_STATISTICS_get_cancel (advsent_stat); advsent_stat = NULL; } if (NULL != adv_peer.stats) { GNUNET_STATISTICS_destroy (adv_peer.stats, GNUNET_NO); adv_peer.stats = NULL; } if (NULL != learn_peer.stats) { GNUNET_STATISTICS_destroy (learn_peer.stats, GNUNET_NO); learn_peer.stats = NULL; } if (check_task != NULL) { GNUNET_SCHEDULER_cancel (check_task); check_task = NULL; } if (NULL != current_adv_uri) { GNUNET_free (current_adv_uri); current_adv_uri = NULL; } if (adv_peer.th != NULL) { GNUNET_TRANSPORT_disconnect (adv_peer.th); adv_peer.th = NULL; } if (learn_peer.th != NULL) { GNUNET_TRANSPORT_disconnect (learn_peer.th); learn_peer.th = NULL; } if (adv_peer.core != NULL) { GNUNET_CORE_disconnect (adv_peer.core); adv_peer.core = NULL; } if (learn_peer.core != NULL) { GNUNET_CORE_disconnect (learn_peer.core); learn_peer.core = NULL; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Killing hostlist server ARM process.\n"); if (0 != GNUNET_OS_process_kill (adv_peer.arm_proc, GNUNET_TERM_SIG)) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (adv_peer.arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); GNUNET_OS_process_destroy (adv_peer.arm_proc); adv_peer.arm_proc = NULL; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Killing hostlist client ARM process.\n"); if (0 != GNUNET_OS_process_kill (learn_peer.arm_proc, GNUNET_TERM_SIG)) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (learn_peer.arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); GNUNET_OS_process_destroy (learn_peer.arm_proc); learn_peer.arm_proc = NULL; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown complete....\n"); }
static void check (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { #if !HAVE_LIBGLPK GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed!"); ret = 1; return; #endif struct ATS_Address addr[10]; struct ATS_PreferedAddress *res[10]; struct MLP_information *mlpi; struct GAS_MLP_SolutionContext ctx; stats = GNUNET_STATISTICS_create("ats", cfg); addresses = GNUNET_CONTAINER_multihashmap_create (10); mlp = GAS_mlp_init (cfg, NULL, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS); mlp->auto_solve = GNUNET_NO; struct GNUNET_PeerIdentity p[10]; /* Creating peer 1 */ GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &p[0].hashPubKey); /* Creating peer 1 address 1 */ addr[0].peer.hashPubKey = p[0].hashPubKey; struct GNUNET_ATS_Information a1_ats[3]; set_ats (&a1_ats[0], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 0); set_ats (&a1_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); create_address (&addr[0], "dummy", 3, &a1_ats[0]); addr[0].atsp_network_type = GNUNET_ATS_NET_LAN; GNUNET_CONTAINER_multihashmap_put(addresses, &addr[0].peer.hashPubKey, &addr[0], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); /* Add peer 1 address 1 */ GAS_mlp_address_update (mlp, addresses, &addr[0]); mlpi = addr[0].mlp_information; GNUNET_assert (mlp != NULL); GNUNET_assert (mlp->addr_in_problem == 1); /* Update an peer 1 address 1 */ set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 20); GAS_mlp_address_update (mlp, addresses, &addr[0]); GNUNET_assert (mlp->addr_in_problem == 1); /* Update an peer 1 address 1 */ set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 10); GAS_mlp_address_update (mlp, addresses, &addr[0]); GNUNET_assert (mlp->addr_in_problem == 1); /* Update an peer 1 address 1 */ set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 10); GAS_mlp_address_update (mlp, addresses, &addr[0]); GNUNET_assert (mlp->addr_in_problem == 1); /* Update an peer 1 address 1 */ set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 30); GAS_mlp_address_update (mlp, addresses, &addr[0]); GNUNET_assert (mlp->addr_in_problem == 1); GNUNET_assert (GNUNET_OK == GAS_mlp_solve_problem(mlp, &ctx)); GNUNET_assert (GNUNET_OK == ctx.lp_result); GNUNET_assert (GNUNET_OK == ctx.mlp_result); res[0] = GAS_mlp_get_preferred_address(mlp, addresses, &p[0]); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Preferred address `%s' outbound bandwidth: %u Bps\n",res[0]->address->plugin, res[0]->bandwidth_out); GNUNET_free (res[0]); /* Delete an address */ GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[0].peer.hashPubKey, &addr[0]); GAS_mlp_address_delete (mlp, addresses, &addr[0]); GNUNET_assert (mlp->addr_in_problem == 0); GAS_mlp_done (mlp); GNUNET_free (addr[0].plugin); GNUNET_CONTAINER_multihashmap_destroy (addresses); GNUNET_STATISTICS_destroy(stats, GNUNET_NO); ret = 0; return; }
static void normal_shutdown (void *cls) { GNUNET_STATISTICS_destroy (h, GNUNET_NO); GNUNET_STATISTICS_destroy (h2, GNUNET_NO); }