From: Bart Polot Date: Mon, 16 Dec 2013 11:55:37 +0000 (+0000) Subject: - don't loop on the same invalid path X-Git-Tag: initial-import-from-subversion-38251~5454 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3433da9486f4f6064a85fcb7c63e482ec60c8609;p=oweals%2Fgnunet.git - don't loop on the same invalid path --- diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c index 85a10bcfe..8ae297f63 100644 --- a/src/mesh/gnunet-service-mesh_connection.c +++ b/src/mesh/gnunet-service-mesh_connection.c @@ -179,7 +179,8 @@ struct MeshConnection enum MeshConnectionState state; /** - * Path being used for the tunnel. + * Path being used for the tunnel. At the origin of the connection + * it's a pointer to the destination's path pool, otherwise just a copy. */ struct MeshPeerPath *path; @@ -1149,7 +1150,7 @@ register_neighbors (struct MeshConnection *c) || GNUNET_NO == GMP_is_neighbor (prev_peer)) { if (GMC_is_origin (c, GNUNET_YES)) - GNUNET_STATISTICS_update (stats, "# local bad paths", 1, GNUNET_NO); + GNUNET_STATISTICS_update (stats, "# local bad paths", 1, GNUNET_NO); GNUNET_STATISTICS_update (stats, "# bad paths", 1, GNUNET_NO); LOG (GNUNET_ERROR_TYPE_DEBUG, " register neighbors failed\n"); @@ -2220,6 +2221,11 @@ GMC_new (const struct GNUNET_HashCode *cid, if (GNUNET_OK != register_neighbors (c)) { + if (0 == own_pos) + { + GMT_remove_path (c->t, p); + path_destroy (p); + } GMC_destroy (c); return NULL; } diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c index 30c64377f..2adc9483b 100644 --- a/src/mesh/gnunet-service-mesh_peer.c +++ b/src/mesh/gnunet-service-mesh_peer.c @@ -1594,6 +1594,32 @@ GMP_add_path_to_all (const struct MeshPeerPath *p, int confirmed) } +/** + * Remove any path to the peer that has the extact same peers as the one given. + * + * @param peer Peer to remove the path from. + * @param path Path to remove. + */ +void +GMP_remove_path (struct MeshPeer *peer, struct MeshPeerPath *path) +{ + struct MeshPeerPath *iter; + struct MeshPeerPath *next; + + GNUNET_assert (myid == path->peers[path->length - 1]); + + for (iter = peer->path_head; NULL != iter; iter = next) + { + next = iter->next; + if (0 == memcmp (path->peers, iter->peers, + sizeof (GNUNET_PEER_Id) * path->length)) + { + path_destroy (iter); + } + } +} + + /** * Remove a connection from a neighboring peer. * diff --git a/src/mesh/gnunet-service-mesh_peer.h b/src/mesh/gnunet-service-mesh_peer.h index 58386c0aa..2377c2052 100644 --- a/src/mesh/gnunet-service-mesh_peer.h +++ b/src/mesh/gnunet-service-mesh_peer.h @@ -250,6 +250,15 @@ GMP_add_path_to_origin (struct MeshPeer *peer, void GMP_add_path_to_all (const struct MeshPeerPath *p, int confirmed); +/** + * Remove any path to the peer that has the extact same peers as the one given. + * + * @param peer Peer to remove the path from. + * @param path Path to remove. + */ +void +GMP_remove_path (struct MeshPeer *peer, struct MeshPeerPath *path); + /** * Remove a connection from a neighboring peer. * diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c index 181395b09..82fcde649 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.c +++ b/src/mesh/gnunet-service-mesh_tunnel.c @@ -1755,6 +1755,19 @@ GMT_add_connection (struct MeshTunnel3 *t, struct MeshConnection *c) } +/** + * Mark a path as no longer valid for this tunnel: has been tried and failed. + * + * @param t Tunnel to update. + * @param path Invalid path. + */ +void +GMT_remove_path (struct MeshTunnel3 *t, struct MeshPeerPath *path) +{ + GMP_remove_path (t->peer, path); +} + + /** * Remove a connection from a tunnel. * diff --git a/src/mesh/gnunet-service-mesh_tunnel.h b/src/mesh/gnunet-service-mesh_tunnel.h index 26064c642..af36ff4e5 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.h +++ b/src/mesh/gnunet-service-mesh_tunnel.h @@ -213,6 +213,15 @@ GMT_change_estate (struct MeshTunnel3* t, enum MeshTunnel3EState state); void GMT_add_connection (struct MeshTunnel3 *t, struct MeshConnection *c); +/** + * Mark a path as no longer valid for this tunnel: has been tried and failed. + * + * @param t Tunnel to update. + * @param path Invalid path. + */ +void +GMT_remove_path (struct MeshTunnel3 *t, struct MeshPeerPath *path); + /** * Remove a connection from a tunnel. *