aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-04-17 08:42:36 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-04-17 08:42:36 +0000
commitdb854346c14f08d5cb53912c352af94b022ae572 (patch)
treed73eb7595bdd07a29580c7b48c1cd606ccc148d0 /src/ats
parente9bf1ce50673a6876bc21d347f9dc089e04b585f (diff)
downloadgnunet-db854346c14f08d5cb53912c352af94b022ae572.tar.gz
gnunet-db854346c14f08d5cb53912c352af94b022ae572.zip
- mem leak and changes
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.c12
-rw-r--r--src/ats/perf_ats_mlp.c42
2 files changed, 26 insertions, 28 deletions
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
1733GAS_mlp_done (struct GAS_MLP_Handle *mlp) 1733GAS_mlp_done (struct GAS_MLP_Handle *mlp)
1734{ 1734{
1735 struct ATS_Peer * peer; 1735 struct ATS_Peer * peer;
1736 struct ATS_Peer * tmp; 1736 struct ATS_Address *addr;
1737 1737
1738 GNUNET_assert (mlp != NULL); 1738 GNUNET_assert (mlp != NULL);
1739 1739
@@ -1747,10 +1747,16 @@ GAS_mlp_done (struct GAS_MLP_Handle *mlp)
1747 peer = mlp->peer_head; 1747 peer = mlp->peer_head;
1748 while (peer != NULL) 1748 while (peer != NULL)
1749 { 1749 {
1750 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up peer `%s'\n", GNUNET_i2s (&peer->id));
1750 GNUNET_CONTAINER_DLL_remove(mlp->peer_head, mlp->peer_tail, peer); 1751 GNUNET_CONTAINER_DLL_remove(mlp->peer_head, mlp->peer_tail, peer);
1751 tmp = peer->next; 1752 for (addr = peer->head; NULL != addr; addr = peer->head)
1753 {
1754 GNUNET_CONTAINER_DLL_remove(peer->head, peer->tail, addr);
1755 GNUNET_free (addr->mlp_information);
1756 addr->mlp_information = NULL;
1757 }
1752 GNUNET_free (peer); 1758 GNUNET_free (peer);
1753 peer = tmp; 1759 peer = mlp->peer_head;
1754 } 1760 }
1755 mlp_delete_problem (mlp); 1761 mlp_delete_problem (mlp);
1756 1762
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 @@
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20/** 20/**
21 * @file ats/test_ats_mlp.c 21 * @file ats/perf_ats_mlp
22 * @brief test for the MLP solver 22 * @brief performance test for the MLP solver
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 * @author Matthias Wachs 24 * @author Matthias Wachs
25 25
@@ -82,7 +82,6 @@ check (void *cls, char *const *args, const char *cfgfile,
82 unsigned int c = 0; 82 unsigned int c = 0;
83 unsigned int c2 = 0; 83 unsigned int c2 = 0;
84 unsigned int ca = 0; 84 unsigned int ca = 0;
85 //char * pid;
86 85
87 if (peers == 0) 86 if (peers == 0)
88 peers = DEF_PEERS; 87 peers = DEF_PEERS;
@@ -106,9 +105,16 @@ check (void *cls, char *const *args, const char *cfgfile,
106 for (c2=0; c2 < addresses; c2++) 105 for (c2=0; c2 < addresses; c2++)
107 { 106 {
108 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up address %u for peer %u\n", c2, c); 107 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up address %u for peer %u\n", c2, c);
108 /* Setting required information */
109 a[ca].mlp_information = NULL; 109 a[ca].mlp_information = NULL;
110 a[ca].prev = NULL;
111 a[ca].next = NULL;
112
113 /* Setting address */
110 a[ca].peer = p[c].id; 114 a[ca].peer = p[c].id;
111 a[ca].plugin = strdup("test"); 115 a[ca].plugin = strdup("test");
116 a[ca].atsp_network_type = GNUNET_ATS_NET_LOOPBACK;
117
112 //a[ca].addr = GNUNET_HELLO_address_allocate(&a[ca].peer, a[ca].plugin, NULL, 0); 118 //a[ca].addr = GNUNET_HELLO_address_allocate(&a[ca].peer, a[ca].plugin, NULL, 0);
113 //a[ca].addr_len = GNUNET_HELLO_address_get_size(a[ca].addr); 119 //a[ca].addr_len = GNUNET_HELLO_address_get_size(a[ca].addr);
114 a[ca].ats = GNUNET_malloc (2 * sizeof (struct GNUNET_ATS_Information)); 120 a[ca].ats = GNUNET_malloc (2 * sizeof (struct GNUNET_ATS_Information));
@@ -118,22 +124,18 @@ check (void *cls, char *const *args, const char *cfgfile,
118 a[ca].ats[1].value = 2; 124 a[ca].ats[1].value = 2;
119 a[ca].ats_count = 2; 125 a[ca].ats_count = 2;
120 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up address %u\n", ca); 126 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up address %u\n", ca);
121 ca++;
122 /*
123 GNUNET_CONTAINER_multihashmap_put (amap, &a[ca].peer.hashPubKey, &a[ca], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 127 GNUNET_CONTAINER_multihashmap_put (amap, &a[ca].peer.hashPubKey, &a[ca], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
124 GAS_mlp_address_update(mlp, amap, &a[ca]); 128 GAS_mlp_address_update(mlp, amap, &a[ca]);
125 */
126 }
127 129
130 ca++;
131 }
128 } 132 }
129
130
131 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem contains %u peers and %u adresses\n", mlp->c_p, mlp->addr_in_problem); 133 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem contains %u peers and %u adresses\n", mlp->c_p, mlp->addr_in_problem);
134
132 /* Solving the problem */ 135 /* Solving the problem */
133 //GAS_mlp_solve_problem(mlp); 136 //GAS_mlp_solve_problem(mlp);
134 137
135 138 GAS_mlp_done (mlp);
136 //GAS_mlp_done (mlp);
137 139
138 for (ca=0; ca < (peers * addresses); ca++) 140 for (ca=0; ca < (peers * addresses); ca++)
139 { 141 {
@@ -141,6 +143,7 @@ check (void *cls, char *const *args, const char *cfgfile,
141 GNUNET_free (a[ca].ats); 143 GNUNET_free (a[ca].ats);
142 // GNUNET_free ((void *) a[c2].addr); 144 // GNUNET_free ((void *) a[c2].addr);
143 } 145 }
146 GNUNET_CONTAINER_multihashmap_destroy(amap);
144 147
145 ret = 0; 148 ret = 0;
146 return; 149 return;
@@ -151,17 +154,6 @@ int
151main (int argc, char *argv[]) 154main (int argc, char *argv[])
152{ 155{
153 156
154 static char *const argv2[] = { "test_ats_mlp",
155 "-c",
156 "test_ats_api.conf",
157#if VERBOSE
158 "-L", "DEBUG",
159#else
160 "-L", "WARNING",
161#endif
162 NULL
163 };
164
165 static struct GNUNET_GETOPT_CommandLineOption options[] = { 157 static struct GNUNET_GETOPT_CommandLineOption options[] = {
166 {'a', "addresses", NULL, 158 {'a', "addresses", NULL,
167 gettext_noop ("addresses per peer"), 1, 159 gettext_noop ("addresses per peer"), 1,
@@ -172,12 +164,12 @@ main (int argc, char *argv[])
172 GNUNET_GETOPT_OPTION_END 164 GNUNET_GETOPT_OPTION_END
173 }; 165 };
174 166
175 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, 167 GNUNET_PROGRAM_run (argc, argv,
176 "test_ats_mlp", "nohelp", options, 168 "perf_ats_mlp", "nohelp", options,
177 &check, NULL); 169 &check, NULL);
178 170
179 171
180 return ret; 172 return ret;
181} 173}
182 174
183/* end of file test_ats_api_bandwidth_consumption.c */ 175/* end of file perf_ats_mlp.c */