From: Matthias Wachs Date: Tue, 17 Apr 2012 08:42:36 +0000 (+0000) Subject: - mem leak and changes X-Git-Tag: initial-import-from-subversion-38251~13913 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=db854346c14f08d5cb53912c352af94b022ae572;p=oweals%2Fgnunet.git - mem leak and changes --- diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index 21604edad..33b7e32e5 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c @@ -1733,7 +1733,7 @@ void GAS_mlp_done (struct GAS_MLP_Handle *mlp) { struct ATS_Peer * peer; - struct ATS_Peer * tmp; + struct ATS_Address *addr; GNUNET_assert (mlp != NULL); @@ -1747,10 +1747,16 @@ GAS_mlp_done (struct GAS_MLP_Handle *mlp) peer = mlp->peer_head; while (peer != NULL) { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up peer `%s'\n", GNUNET_i2s (&peer->id)); GNUNET_CONTAINER_DLL_remove(mlp->peer_head, mlp->peer_tail, peer); - tmp = peer->next; + for (addr = peer->head; NULL != addr; addr = peer->head) + { + GNUNET_CONTAINER_DLL_remove(peer->head, peer->tail, addr); + GNUNET_free (addr->mlp_information); + addr->mlp_information = NULL; + } GNUNET_free (peer); - peer = tmp; + peer = mlp->peer_head; } mlp_delete_problem (mlp); diff --git a/src/ats/perf_ats_mlp.c b/src/ats/perf_ats_mlp.c index b87bf21f0..115fbf01a 100644 --- a/src/ats/perf_ats_mlp.c +++ b/src/ats/perf_ats_mlp.c @@ -18,8 +18,8 @@ Boston, MA 02111-1307, USA. */ /** - * @file ats/test_ats_mlp.c - * @brief test for the MLP solver + * @file ats/perf_ats_mlp + * @brief performance test for the MLP solver * @author Christian Grothoff * @author Matthias Wachs @@ -82,7 +82,6 @@ check (void *cls, char *const *args, const char *cfgfile, unsigned int c = 0; unsigned int c2 = 0; unsigned int ca = 0; - //char * pid; if (peers == 0) peers = DEF_PEERS; @@ -106,9 +105,16 @@ check (void *cls, char *const *args, const char *cfgfile, for (c2=0; c2 < addresses; c2++) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up address %u for peer %u\n", c2, c); + /* Setting required information */ a[ca].mlp_information = NULL; + a[ca].prev = NULL; + a[ca].next = NULL; + + /* Setting address */ a[ca].peer = p[c].id; a[ca].plugin = strdup("test"); + a[ca].atsp_network_type = GNUNET_ATS_NET_LOOPBACK; + //a[ca].addr = GNUNET_HELLO_address_allocate(&a[ca].peer, a[ca].plugin, NULL, 0); //a[ca].addr_len = GNUNET_HELLO_address_get_size(a[ca].addr); a[ca].ats = GNUNET_malloc (2 * sizeof (struct GNUNET_ATS_Information)); @@ -118,22 +124,18 @@ check (void *cls, char *const *args, const char *cfgfile, a[ca].ats[1].value = 2; a[ca].ats_count = 2; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up address %u\n", ca); - ca++; - /* GNUNET_CONTAINER_multihashmap_put (amap, &a[ca].peer.hashPubKey, &a[ca], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); GAS_mlp_address_update(mlp, amap, &a[ca]); - */ - } + ca++; + } } - - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem contains %u peers and %u adresses\n", mlp->c_p, mlp->addr_in_problem); + /* Solving the problem */ //GAS_mlp_solve_problem(mlp); - - //GAS_mlp_done (mlp); + GAS_mlp_done (mlp); for (ca=0; ca < (peers * addresses); ca++) { @@ -141,6 +143,7 @@ check (void *cls, char *const *args, const char *cfgfile, GNUNET_free (a[ca].ats); // GNUNET_free ((void *) a[c2].addr); } + GNUNET_CONTAINER_multihashmap_destroy(amap); ret = 0; return; @@ -151,17 +154,6 @@ int main (int argc, char *argv[]) { - static char *const argv2[] = { "test_ats_mlp", - "-c", - "test_ats_api.conf", -#if VERBOSE - "-L", "DEBUG", -#else - "-L", "WARNING", -#endif - NULL - }; - static struct GNUNET_GETOPT_CommandLineOption options[] = { {'a', "addresses", NULL, gettext_noop ("addresses per peer"), 1, @@ -172,12 +164,12 @@ main (int argc, char *argv[]) GNUNET_GETOPT_OPTION_END }; - GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, - "test_ats_mlp", "nohelp", options, + GNUNET_PROGRAM_run (argc, argv, + "perf_ats_mlp", "nohelp", options, &check, NULL); return ret; } -/* end of file test_ats_api_bandwidth_consumption.c */ +/* end of file perf_ats_mlp.c */