From a38370ae1e835d9ad452788ad1fc6424926fe31c Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Mon, 31 Oct 2011 16:27:32 +0000 Subject: [PATCH] Dont add whole path to peer, just the relevant part --- src/mesh/gnunet-service-mesh.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index ca60433de..9b76e6b1e 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -1509,18 +1509,34 @@ path_add_to_peer (struct MeshPeerInfo *peer_info, struct MeshPeerPath *path) path_destroy (path); return; } + for (l = 1; l < path->length; l++) + { + if (path->peers[l] == myid) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "MESH: shortening path by %u\n", + l); + for (l2 = 0; l2 < path->length - l - 1 ; l2++) + { + path->peers[l2] = path->peers[l + l2]; + } + path->length -= l; + l = 0; + path->peers = GNUNET_realloc (path->peers, + path->length * sizeof (GNUNET_PEER_Id)); + } + } #if MESH_DEBUG { struct GNUNET_PeerIdentity id; - + GNUNET_PEER_resolve (peer_info->id, &id); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "MESH: adding path [%u] to peer %s\n", - path->length, - GNUNET_i2s (&id)); + "MESH: adding path [%u] to peer %s\n", + path->length, + GNUNET_i2s (&id)); } #endif - l = path_get_length (path); if (0 == l) { -- 2.25.1