aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-10-06 16:43:13 +0000
committerBart Polot <bart@net.in.tum.de>2011-10-06 16:43:13 +0000
commita024e1fe61644a01d0c5a759c04c5deb754f80a9 (patch)
tree434231a27bf0f58b2018483f3897acf8012a85b7 /src/mesh
parentc06f842920f131a2bad6d92e178808c570d88af7 (diff)
downloadgnunet-a024e1fe61644a01d0c5a759c04c5deb754f80a9.tar.gz
gnunet-a024e1fe61644a01d0c5a759c04c5deb754f80a9.zip
Renamed functions, make valgrind stop complaining about memory leaks by explicitly freeing stuff before exit
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/test_mesh_small.conf4
-rw-r--r--src/mesh/test_mesh_small_unicast.c86
2 files changed, 84 insertions, 6 deletions
diff --git a/src/mesh/test_mesh_small.conf b/src/mesh/test_mesh_small.conf
index 98def94c0..580a36f88 100644
--- a/src/mesh/test_mesh_small.conf
+++ b/src/mesh/test_mesh_small.conf
@@ -49,6 +49,10 @@ PORT = 10004
49[mesh] 49[mesh]
50PORT = 10005 50PORT = 10005
51DEBUG=YES 51DEBUG=YES
52ACCEPT_FROM = 127.0.0.1;
53HOSTNAME = localhost
54# PREFIX = valgrind --leak-check=full
55# PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
52 56
53[testing] 57[testing]
54NUM_PEERS = 16 58NUM_PEERS = 16
diff --git a/src/mesh/test_mesh_small_unicast.c b/src/mesh/test_mesh_small_unicast.c
index 92e5d078b..826ef49f3 100644
--- a/src/mesh/test_mesh_small_unicast.c
+++ b/src/mesh/test_mesh_small_unicast.c
@@ -289,6 +289,61 @@ do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
289 289
290 290
291/** 291/**
292 * Prototype of a callback function indicating that two peers
293 * are currently connected.
294 *
295 * @param cls closure
296 * @param first peer id for first daemon
297 * @param second peer id for the second daemon
298 * @param distance distance between the connected peers
299 * @param emsg error message (NULL on success)
300 */
301void
302topo_cb (void *cls,
303 const struct GNUNET_PeerIdentity* first,
304 const struct GNUNET_PeerIdentity* second,
305 const char *emsg)
306{
307 GNUNET_PEER_Id p1;
308 GNUNET_PEER_Id p2;
309 uint16_t *connections = cls;
310 struct GNUNET_PeerIdentity id;
311
312 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
313 "test: :::::::::::::::::::::::::: %u\n",
314 connections[0]);
315 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: ###################### %p\n", connections);
316 GNUNET_PEER_resolve(connections[0], &id);
317 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
318 "test: looking for %s...\n",
319 GNUNET_i2s(&id));
320 p1 = GNUNET_PEER_search(first);
321 if (p1 == connections[0])
322 {
323 p2 = GNUNET_PEER_search(second);
324 GNUNET_assert(p2 < num_peers);
325 if (0 == p2) return;
326 connections[p2]++;
327 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
328 "test: %s IS a neighbor\n",
329 GNUNET_i2s(second));
330 return;
331 }
332 p1 = GNUNET_PEER_search(second);
333 if (p1 == connections[0])
334 {
335 p2 = GNUNET_PEER_search(first);
336 GNUNET_assert(p2 < num_peers);
337 if (0 == p2) return;
338 connections[p2]++;
339 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
340 "test: %s IS a neighbor\n",
341 GNUNET_i2s(first));
342 return;
343 }
344}
345
346/**
292 * connect_mesh_service: connect to the mesh service of one of the peers 347 * connect_mesh_service: connect to the mesh service of one of the peers
293 * 348 *
294 */ 349 */
@@ -296,20 +351,39 @@ static void
296connect_mesh_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 351connect_mesh_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
297{ 352{
298 GNUNET_MESH_ApplicationType app; 353 GNUNET_MESH_ApplicationType app;
354 uint16_t connections[num_peers];
355 uint16_t i;
299 356
300 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: connect_mesh_service\n"); 357 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: connect_mesh_service\n");
301 358
302 d1 = GNUNET_TESTING_daemon_get (pg, 1); 359 for (i = 0; i < num_peers; i++)
303 d2 = GNUNET_TESTING_daemon_get (pg, 3); 360 {
361 d1 = GNUNET_TESTING_daemon_get (pg, i);
362 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
363 "test: %u: %s\n",
364 GNUNET_PEER_intern(&d1->id),
365 GNUNET_i2s (&d1->id));
366 connections[i] = 0;
367 }
368 connections[0] = GNUNET_PEER_intern(&d1->id);
369 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: ###################### %p\n", connections);
370 GNUNET_TESTING_get_topology(pg, &topo_cb, connections);
371 for (i = 1; i < num_peers; i++)
372 if (connections[i] == 0)
373 break;
374 GNUNET_assert (i < num_peers);
375 d2 = GNUNET_TESTING_daemon_get (pg, i);
304 app = (GNUNET_MESH_ApplicationType) 0; 376 app = (GNUNET_MESH_ApplicationType) 0;
305 377
306#if VERBOSE 378#if VERBOSE
307 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
308 "test: connecting to mesh service of peer %s\n", 380 "test: connecting to mesh service of peer %s (%u)\n",
309 GNUNET_i2s (&d1->id)); 381 GNUNET_i2s (&d1->id),
382 connections[0]);
310 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 383 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
311 "test: connecting to mesh service of peer %s\n", 384 "test: connecting to mesh service of peer %s (%u)\n",
312 GNUNET_i2s (&d2->id)); 385 GNUNET_i2s (&d2->id),
386 i);
313#endif 387#endif
314 h1 = GNUNET_MESH_connect (d1->cfg, 388 h1 = GNUNET_MESH_connect (d1->cfg,
315 10, 389 10,