diff options
author | Bart Polot <bart@net.in.tum.de> | 2014-03-22 02:58:32 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2014-03-22 02:58:32 +0000 |
commit | c2b807282c1f53776d7df87d919647dc70c8938b (patch) | |
tree | 4bf7a0f2d344ec419ecf35bcb18d6393d6250b88 /src/mesh | |
parent | 436c859acf2df08b8772313c08786bf7d559473a (diff) | |
download | gnunet-c2b807282c1f53776d7df87d919647dc70c8938b.tar.gz gnunet-c2b807282c1f53776d7df87d919647dc70c8938b.zip |
- eliminate broken paths
Diffstat (limited to 'src/mesh')
-rw-r--r-- | src/mesh/gnunet-service-mesh_connection.c | 7 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_peer.c | 52 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_peer.h | 13 |
3 files changed, 69 insertions, 3 deletions
diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c index 31e8a48a8..15a6164cb 100644 --- a/src/mesh/gnunet-service-mesh_connection.c +++ b/src/mesh/gnunet-service-mesh_connection.c | |||
@@ -1775,16 +1775,17 @@ GMC_handle_broken (void* cls, | |||
1775 | fwd = is_fwd (c, id); | 1775 | fwd = is_fwd (c, id); |
1776 | if (GMC_is_terminal (c, fwd)) | 1776 | if (GMC_is_terminal (c, fwd)) |
1777 | { | 1777 | { |
1778 | struct GNUNET_MessageHeader *msg; | 1778 | struct GNUNET_MessageHeader *out_msg; |
1779 | struct MeshPeer *peer; | 1779 | struct MeshPeer *peer; |
1780 | 1780 | ||
1781 | peer = get_hop (c, !fwd); | 1781 | peer = get_hop (c, !fwd); |
1782 | path_invalidate (c->path); | 1782 | path_invalidate (c->path); |
1783 | GMP_notify_broken_link (c->t, &msg->peer1, &msg->peer2); | ||
1783 | c->state = MESH_CONNECTION_DESTROYED; | 1784 | c->state = MESH_CONNECTION_DESTROYED; |
1784 | while (NULL != (msg = GMP_connection_pop (peer, c))) | 1785 | while (NULL != (out_msg = GMP_connection_pop (peer, c))) |
1785 | { | 1786 | { |
1786 | GNUNET_assert (NULL == | 1787 | GNUNET_assert (NULL == |
1787 | GMT_send_prebuilt_message (msg, c->t, NULL, GNUNET_YES, | 1788 | GMT_send_prebuilt_message (out_msg, c->t, NULL, GNUNET_YES, |
1788 | NULL, NULL)); | 1789 | NULL, NULL)); |
1789 | } | 1790 | } |
1790 | 1791 | ||
diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c index c1fc835a2..d45e4f2b9 100644 --- a/src/mesh/gnunet-service-mesh_peer.c +++ b/src/mesh/gnunet-service-mesh_peer.c | |||
@@ -1234,6 +1234,7 @@ GMP_connection_pop (struct MeshPeer *peer, struct MeshConnection *c) | |||
1234 | struct MeshPeerQueue *q; | 1234 | struct MeshPeerQueue *q; |
1235 | struct GNUNET_MessageHeader *msg; | 1235 | struct GNUNET_MessageHeader *msg; |
1236 | 1236 | ||
1237 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Connection pop on %s\n", GMC_2s (c)); | ||
1237 | for (q = peer->queue_head; NULL != q; q = q->next) | 1238 | for (q = peer->queue_head; NULL != q; q = q->next) |
1238 | { | 1239 | { |
1239 | if (q->c != c) | 1240 | if (q->c != c) |
@@ -2028,6 +2029,57 @@ GMP_try_connect (struct MeshPeer *peer) | |||
2028 | 2029 | ||
2029 | 2030 | ||
2030 | /** | 2031 | /** |
2032 | * Notify a peer that a link between two other peers is broken. If any path | ||
2033 | * used that link, eliminate it. | ||
2034 | * | ||
2035 | * @param peer Peer affected by the change. | ||
2036 | * @param peer1 Peer whose link is broken. | ||
2037 | * @param peer2 Peer whose link is broken. | ||
2038 | */ | ||
2039 | void | ||
2040 | GMP_notify_broken_link (struct MeshPeer *peer, | ||
2041 | struct GNUNET_PeerIdentity *peer1, | ||
2042 | struct GNUNET_PeerIdentity *peer2) | ||
2043 | { | ||
2044 | struct MeshPeerPath *iter; | ||
2045 | struct MeshPeerPath *next; | ||
2046 | unsigned int i; | ||
2047 | GNUNET_PEER_Id p1; | ||
2048 | GNUNET_PEER_Id p2; | ||
2049 | |||
2050 | p1 = GNUNET_PEER_search (peer1); | ||
2051 | p2 = GNUNET_PEER_search (peer2); | ||
2052 | |||
2053 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Link %u-%u broken\n", p1, p2); | ||
2054 | if (0 == p1 || 0 == p2) | ||
2055 | { | ||
2056 | /* We don't even know them */ | ||
2057 | return; | ||
2058 | } | ||
2059 | |||
2060 | for (iter = peer->path_head; NULL != iter; iter = next) | ||
2061 | { | ||
2062 | next = iter->next; | ||
2063 | for (i = 0; i < iter->length - 1; i++) | ||
2064 | { | ||
2065 | if ((iter->peers[i] == p1 && iter->peers[i + 1] == p2) | ||
2066 | || (iter->peers[i] == p2 && iter->peers[i + 1] == p1)) | ||
2067 | { | ||
2068 | char *s; | ||
2069 | |||
2070 | s = path_2s (iter); | ||
2071 | LOG (GNUNET_ERROR_TYPE_DEBUG, " - destroying %s\n", s); | ||
2072 | GNUNET_free (s); | ||
2073 | |||
2074 | GNUNET_CONTAINER_DLL_remove (peer->path_head, peer->path_tail, iter); | ||
2075 | path_destroy (iter); | ||
2076 | } | ||
2077 | } | ||
2078 | } | ||
2079 | } | ||
2080 | |||
2081 | |||
2082 | /** | ||
2031 | * Count the number of known paths toward the peer. | 2083 | * Count the number of known paths toward the peer. |
2032 | * | 2084 | * |
2033 | * @param peer Peer to get path info. | 2085 | * @param peer Peer to get path info. |
diff --git a/src/mesh/gnunet-service-mesh_peer.h b/src/mesh/gnunet-service-mesh_peer.h index dd8bd2a5e..49bfd4050 100644 --- a/src/mesh/gnunet-service-mesh_peer.h +++ b/src/mesh/gnunet-service-mesh_peer.h | |||
@@ -358,6 +358,19 @@ void | |||
358 | GMP_try_connect (struct MeshPeer *peer); | 358 | GMP_try_connect (struct MeshPeer *peer); |
359 | 359 | ||
360 | /** | 360 | /** |
361 | * Notify a peer that a link between two other peers is broken. If any path | ||
362 | * used that link, eliminate it. | ||
363 | * | ||
364 | * @param peer Peer affected by the change. | ||
365 | * @param peer1 Peer whose link is broken. | ||
366 | * @param peer2 Peer whose link is broken. | ||
367 | */ | ||
368 | void | ||
369 | GMP_notify_broken_link (struct MeshPeer *peer, | ||
370 | struct GNUNET_PeerIdentity *peer1, | ||
371 | struct GNUNET_PeerIdentity *peer2); | ||
372 | |||
373 | /** | ||
361 | * Count the number of known paths toward the peer. | 374 | * Count the number of known paths toward the peer. |
362 | * | 375 | * |
363 | * @param peer Peer to get path info. | 376 | * @param peer Peer to get path info. |