aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-xdht_neighbours.c
diff options
context:
space:
mode:
authorSupriti Singh <supritisingh08@gmail.com>2014-07-01 08:21:04 +0000
committerSupriti Singh <supritisingh08@gmail.com>2014-07-01 08:21:04 +0000
commit33ccf61eb6b2a102f720111737f3c9b7f6c6099b (patch)
tree763eb62d4dfdd836cb396cc7f1a82ac40358e0f0 /src/dht/gnunet-service-xdht_neighbours.c
parent5ab82d972d1b300af56a680950726b810133cd89 (diff)
downloadgnunet-33ccf61eb6b2a102f720111737f3c9b7f6c6099b.tar.gz
gnunet-33ccf61eb6b2a102f720111737f3c9b7f6c6099b.zip
xvine: fixes
Diffstat (limited to 'src/dht/gnunet-service-xdht_neighbours.c')
-rw-r--r--src/dht/gnunet-service-xdht_neighbours.c103
1 files changed, 54 insertions, 49 deletions
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c
index d667c829b..64678026d 100644
--- a/src/dht/gnunet-service-xdht_neighbours.c
+++ b/src/dht/gnunet-service-xdht_neighbours.c
@@ -820,9 +820,9 @@ struct Closest_Peer
820 820
821 /** 821 /**
822 * Trail id to reach to peer. 822 * Trail id to reach to peer.
823 * In case peer is my identity or friend, it is set to 0. 823 * In case peer is my identity or friend, it is set to NULL.
824 */ 824 */
825 struct GNUNET_HashCode trail_id; 825 struct GNUNET_HashCode *trail_id;
826 826
827 /** 827 /**
828 * Next destination. In case of friend and my_identity , it is same as next_hop 828 * Next destination. In case of friend and my_identity , it is same as next_hop
@@ -851,7 +851,7 @@ struct Selected_Finger_Trail
851 /** 851 /**
852 * Identifier of this trail. 852 * Identifier of this trail.
853 */ 853 */
854 struct GNUNET_HashCode trail_id; 854 struct GNUNET_HashCode *trail_id;
855 855
856 /** 856 /**
857 * Total number of peers in this trail. 857 * Total number of peers in this trail.
@@ -1320,11 +1320,9 @@ GDS_NEIGHBOURS_send_trail_teardown (struct GNUNET_HashCode trail_id,
1320 GNUNET_break (0); 1320 GNUNET_break (0);
1321 return; 1321 return;
1322 } 1322 }
1323 struct GNUNET_PeerIdentity *test_peer; 1323
1324 test_peer = GNUNET_new (struct GNUNET_PeerIdentity);
1325 memcpy (test_peer, &peer, sizeof (struct GNUNET_PeerIdentity));
1326 GNUNET_assert (NULL != (target_friend = 1324 GNUNET_assert (NULL != (target_friend =
1327 GNUNET_CONTAINER_multipeermap_get (friend_peermap, test_peer))); 1325 GNUNET_CONTAINER_multipeermap_get (friend_peermap, &peer)));
1328 1326
1329 if (target_friend->pending_count >= MAXIMUM_PENDING_PER_FRIEND) 1327 if (target_friend->pending_count >= MAXIMUM_PENDING_PER_FRIEND)
1330 { 1328 {
@@ -1829,14 +1827,16 @@ select_finger_trail (struct FingerInfo *finger)
1829 flag = 1; 1827 flag = 1;
1830 finger_trail->trail_length = iterator->trail_length; 1828 finger_trail->trail_length = iterator->trail_length;
1831 finger_trail->friend = *friend; 1829 finger_trail->friend = *friend;
1832 finger_trail->trail_id = iterator->trail_id; 1830 finger_trail->trail_id = &iterator->trail_id;
1831 //memcmp (finger_trail->trail_id, &iterator->trail_id, sizeof (struct GNUNET_HashCode));
1833 } 1832 }
1834 else if (finger_trail->trail_length > iterator->trail_length) 1833 else if (finger_trail->trail_length > iterator->trail_length)
1835 { 1834 {
1836 /* Check if the trail length of this trail is least seen so far. If yes then 1835 /* Check if the trail length of this trail is least seen so far. If yes then
1837 set finger_trail to this trail.*/ 1836 set finger_trail to this trail.*/
1838 finger_trail->friend = *friend; 1837 finger_trail->friend = *friend;
1839 finger_trail->trail_id = iterator->trail_id; 1838 finger_trail->trail_id = &iterator->trail_id;
1839 //memcmp (finger_trail->trail_id, &iterator->trail_id, sizeof (struct GNUNET_HashCode));
1840 finger_trail->trail_length = iterator->trail_length; 1840 finger_trail->trail_length = iterator->trail_length;
1841 } 1841 }
1842 } 1842 }
@@ -1901,11 +1901,10 @@ test_finger_table_print()
1901 * @param current_successor[in/out] 1901 * @param current_successor[in/out]
1902 * @return 1902 * @return
1903 */ 1903 */
1904static struct Closest_Peer * 1904static void
1905compare_finger_and_current_successor (struct Closest_Peer *current_closest_peer) 1905compare_finger_and_current_successor (struct Closest_Peer *current_closest_peer)
1906{ 1906{
1907 struct FingerInfo *finger; 1907 struct FingerInfo *finger;
1908 struct FriendInfo *friend;
1909 struct GNUNET_PeerIdentity *closest_peer; 1908 struct GNUNET_PeerIdentity *closest_peer;
1910 struct Selected_Finger_Trail *finger_trail; 1909 struct Selected_Finger_Trail *finger_trail;
1911 int i; 1910 int i;
@@ -1932,8 +1931,7 @@ compare_finger_and_current_successor (struct Closest_Peer *current_closest_peer)
1932 1931
1933 /* If finger is a friend, then do nothing. As we have already checked 1932 /* If finger is a friend, then do nothing. As we have already checked
1934 * for each friend in compare_friend_and_current_successor(). */ 1933 * for each friend in compare_friend_and_current_successor(). */
1935 if (NULL != 1934 if (NULL != (GNUNET_CONTAINER_multipeermap_get (friend_peermap,
1936 (friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap,
1937 &finger->finger_identity))) 1935 &finger->finger_identity)))
1938 { 1936 {
1939 continue; 1937 continue;
@@ -1960,7 +1958,6 @@ compare_finger_and_current_successor (struct Closest_Peer *current_closest_peer)
1960 } 1958 }
1961 continue; 1959 continue;
1962 } 1960 }
1963 return current_closest_peer;
1964} 1961}
1965 1962
1966 1963
@@ -2025,7 +2022,8 @@ init_current_successor (struct GNUNET_PeerIdentity my_identity,
2025 struct Closest_Peer *current_closest_peer; 2022 struct Closest_Peer *current_closest_peer;
2026 2023
2027 current_closest_peer = GNUNET_new (struct Closest_Peer); 2024 current_closest_peer = GNUNET_new (struct Closest_Peer);
2028 memset (&current_closest_peer->trail_id, 0, sizeof (current_closest_peer->trail_id)); 2025 //memset (&current_closest_peer->trail_id, 0, sizeof (current_closest_peer->trail_id));
2026 current_closest_peer->trail_id = NULL;
2029 current_closest_peer->destination_finger_value = destination_finger_value; 2027 current_closest_peer->destination_finger_value = destination_finger_value;
2030 current_closest_peer->is_predecessor = is_predecessor; 2028 current_closest_peer->is_predecessor = is_predecessor;
2031 current_closest_peer->next_hop = my_identity; 2029 current_closest_peer->next_hop = my_identity;
@@ -2070,7 +2068,6 @@ find_successor (uint64_t destination_finger_value,
2070 current_closest_peer = init_current_successor (my_identity, 2068 current_closest_peer = init_current_successor (my_identity,
2071 destination_finger_value, 2069 destination_finger_value,
2072 is_predecessor); 2070 is_predecessor);
2073
2074 /* Compare each friend entry with current_successor and update current_successor 2071 /* Compare each friend entry with current_successor and update current_successor
2075 * with friend if its closest. */ 2072 * with friend if its closest. */
2076 GNUNET_assert 2073 GNUNET_assert
@@ -2082,12 +2079,12 @@ find_successor (uint64_t destination_finger_value,
2082 /* Compare each finger entry with current_successor and update current_successor 2079 /* Compare each finger entry with current_successor and update current_successor
2083 * with finger if its closest. */ 2080 * with finger if its closest. */
2084 compare_finger_and_current_successor (current_closest_peer); 2081 compare_finger_and_current_successor (current_closest_peer);
2085
2086 *local_best_known_destination = current_closest_peer->best_known_destination; 2082 *local_best_known_destination = current_closest_peer->best_known_destination;
2087 new_intermediate_trail_id = &current_closest_peer->trail_id; 2083 new_intermediate_trail_id = current_closest_peer->trail_id;
2088 next_hop = GNUNET_new (struct GNUNET_PeerIdentity); 2084 next_hop = GNUNET_new (struct GNUNET_PeerIdentity);
2089 *next_hop = current_closest_peer->next_hop; 2085 *next_hop = current_closest_peer->next_hop;
2090 2086
2087
2091 return next_hop; 2088 return next_hop;
2092} 2089}
2093 2090
@@ -3308,8 +3305,8 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity,
3308 struct FingerInfo *successor; 3305 struct FingerInfo *successor;
3309 int updated_finger_trail_length; 3306 int updated_finger_trail_length;
3310 unsigned int finger_table_index; 3307 unsigned int finger_table_index;
3308
3311 //GDS_ROUTING_test_print(); 3309 //GDS_ROUTING_test_print();
3312
3313 //test_friend_peermap_print(); 3310 //test_friend_peermap_print();
3314 //test_finger_table_print(); 3311 //test_finger_table_print();
3315 3312
@@ -3452,7 +3449,7 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer,
3452 GNUNET_break_op (0); 3449 GNUNET_break_op (0);
3453 return GNUNET_YES; 3450 return GNUNET_YES;
3454 } 3451 }
3455 3452
3456 best_known_dest = put->best_known_destination; 3453 best_known_dest = put->best_known_destination;
3457 put_path = (struct GNUNET_PeerIdentity *) &put[1]; 3454 put_path = (struct GNUNET_PeerIdentity *) &put[1];
3458 payload = &put_path[putlen]; 3455 payload = &put_path[putlen];
@@ -3660,16 +3657,15 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
3660 if (0 == GNUNET_CRYPTO_cmp_peer_identity(&my_identity, &best_known_dest)) 3657 if (0 == GNUNET_CRYPTO_cmp_peer_identity(&my_identity, &best_known_dest))
3661 { 3658 {
3662 struct GNUNET_PeerIdentity final_get_path[get_length+1]; 3659 struct GNUNET_PeerIdentity final_get_path[get_length+1];
3663 struct GNUNET_PeerIdentity next_hop;
3664 3660
3665 memcpy (final_get_path, gp, get_length * sizeof (struct GNUNET_PeerIdentity)); 3661 memcpy (final_get_path, gp, get_length * sizeof (struct GNUNET_PeerIdentity));
3666 memcpy (&final_get_path[get_length], &my_identity, sizeof (struct GNUNET_PeerIdentity)); 3662 memcpy (&final_get_path[get_length], &my_identity, sizeof (struct GNUNET_PeerIdentity));
3667 get_length = get_length + 1; 3663 get_length = get_length + 1;
3668 3664
3669 /* Get the next hop to pass the get result message. */
3670 memcpy (&next_hop, &final_get_path[get_length-2], sizeof (struct GNUNET_PeerIdentity));
3671 GDS_DATACACHE_handle_get (&(get->key),(get->block_type), NULL, 0, NULL, 0, 3665 GDS_DATACACHE_handle_get (&(get->key),(get->block_type), NULL, 0, NULL, 0,
3672 get_length, final_get_path, &next_hop, &my_identity); 3666 get_length, final_get_path,
3667 &final_get_path[get_length-2], &my_identity);
3668
3673 return GNUNET_YES; 3669 return GNUNET_YES;
3674 } 3670 }
3675 else 3671 else
@@ -3677,9 +3673,9 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
3677 GDS_NEIGHBOURS_send_get (&(get->key), get->block_type, get->options, 3673 GDS_NEIGHBOURS_send_get (&(get->key), get->block_type, get->options,
3678 get->desired_replication_level, &best_known_dest, 3674 get->desired_replication_level, &best_known_dest,
3679 &intermediate_trail_id, next_hop, 0, 3675 &intermediate_trail_id, next_hop, 0,
3680 get_length, gp); 3676 get_length, gp);
3677 GNUNET_free (next_hop);
3681 } 3678 }
3682 GNUNET_free_non_null (next_hop);
3683 return GNUNET_SYSERR; 3679 return GNUNET_SYSERR;
3684} 3680}
3685 3681
@@ -3790,13 +3786,13 @@ get_local_best_known_next_hop (uint64_t final_dest_finger_value,
3790 struct GNUNET_PeerIdentity *current_dest) 3786 struct GNUNET_PeerIdentity *current_dest)
3791{ 3787{
3792 struct GNUNET_PeerIdentity *next_hop_to_local_best_known_dest; 3788 struct GNUNET_PeerIdentity *next_hop_to_local_best_known_dest;
3793 3789
3794 /* Choose a local best known hop among your fingers, friends and you. */ 3790 /* Choose a local best known hop among your fingers, friends and you. */
3795 next_hop_to_local_best_known_dest = find_successor (final_dest_finger_value, 3791 next_hop_to_local_best_known_dest = find_successor (final_dest_finger_value,
3796 local_best_known_dest, 3792 local_best_known_dest,
3797 new_intermediate_trail_id, 3793 new_intermediate_trail_id,
3798 is_predecessor); 3794 is_predecessor);
3799 3795 //GDS_ROUTING_test_print();
3800 /* Are we just a part of a trail towards a finger (current_destination)? */ 3796 /* Are we just a part of a trail towards a finger (current_destination)? */
3801 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&my_identity, current_dest))) 3797 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&my_identity, current_dest)))
3802 { 3798 {
@@ -3859,7 +3855,7 @@ handle_dht_p2p_trail_setup (void *cls, const struct GNUNET_PeerIdentity *peer,
3859 struct FriendInfo *target_friend; 3855 struct FriendInfo *target_friend;
3860 struct GNUNET_PeerIdentity source; 3856 struct GNUNET_PeerIdentity source;
3861 uint64_t final_dest_finger_val; 3857 uint64_t final_dest_finger_val;
3862 struct GNUNET_HashCode new_intermediate_trail_id; 3858 struct GNUNET_HashCode *new_intermediate_trail_id;
3863 struct GNUNET_HashCode intermediate_trail_id; 3859 struct GNUNET_HashCode intermediate_trail_id;
3864 struct GNUNET_HashCode trail_id; 3860 struct GNUNET_HashCode trail_id;
3865 unsigned int is_predecessor; 3861 unsigned int is_predecessor;
@@ -3891,6 +3887,7 @@ handle_dht_p2p_trail_setup (void *cls, const struct GNUNET_PeerIdentity *peer,
3891 source = trail_setup->source_peer; 3887 source = trail_setup->source_peer;
3892 is_predecessor = ntohl (trail_setup->is_predecessor); 3888 is_predecessor = ntohl (trail_setup->is_predecessor);
3893 intermediate_trail_id = trail_setup->intermediate_trail_id; 3889 intermediate_trail_id = trail_setup->intermediate_trail_id;
3890 new_intermediate_trail_id = GNUNET_new (struct GNUNET_HashCode);
3894 3891
3895 /* Is my routing table full? */ 3892 /* Is my routing table full? */
3896 if (GNUNET_YES == GDS_ROUTING_threshold_reached()) 3893 if (GNUNET_YES == GDS_ROUTING_threshold_reached())
@@ -3914,19 +3911,18 @@ handle_dht_p2p_trail_setup (void *cls, const struct GNUNET_PeerIdentity *peer,
3914 next_hop_towards_local_best_known_dest = 3911 next_hop_towards_local_best_known_dest =
3915 get_local_best_known_next_hop (final_dest_finger_val, 3912 get_local_best_known_next_hop (final_dest_finger_val,
3916 local_best_known_dest, 3913 local_best_known_dest,
3917 &new_intermediate_trail_id, 3914 new_intermediate_trail_id,
3918 intermediate_trail_id, 3915 intermediate_trail_id,
3919 is_predecessor, 3916 is_predecessor,
3920 &current_dest); 3917 &current_dest);
3921 3918
3922 GNUNET_assert (NULL != local_best_known_dest); 3919 GNUNET_assert (NULL != local_best_known_dest);
3923 GNUNET_assert (NULL != next_hop_towards_local_best_known_dest); 3920 GNUNET_assert (NULL != next_hop_towards_local_best_known_dest);
3921
3924 /* Am I the final destination? */ 3922 /* Am I the final destination? */
3925 if (0 == (GNUNET_CRYPTO_cmp_peer_identity (local_best_known_dest, 3923 if (0 == (GNUNET_CRYPTO_cmp_peer_identity (local_best_known_dest,
3926 &my_identity))) 3924 &my_identity)))
3927 { 3925 {
3928 /* FIXME: check that you always add trail entry even if your finger is
3929 friend. */
3930 /* If I was not the source of this message for which now I am destination */ 3926 /* If I was not the source of this message for which now I am destination */
3931 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&source, &my_identity)) 3927 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&source, &my_identity))
3932 { 3928 {
@@ -3955,12 +3951,14 @@ handle_dht_p2p_trail_setup (void *cls, const struct GNUNET_PeerIdentity *peer,
3955 (target_friend = 3951 (target_friend =
3956 GNUNET_CONTAINER_multipeermap_get (friend_peermap, 3952 GNUNET_CONTAINER_multipeermap_get (friend_peermap,
3957 next_hop_towards_local_best_known_dest))); 3953 next_hop_towards_local_best_known_dest)));
3954 /* FIXME; CHECK IF INTERMEDIATE TRAIL ID is 0 thne pas null. */
3955
3958 GDS_NEIGHBOURS_send_trail_setup (source, 3956 GDS_NEIGHBOURS_send_trail_setup (source,
3959 final_dest_finger_val, 3957 final_dest_finger_val,
3960 *local_best_known_dest, 3958 *local_best_known_dest,
3961 target_friend, trail_length + 1, peer_list, 3959 target_friend, trail_length + 1, peer_list,
3962 is_predecessor, trail_id, 3960 is_predecessor, trail_id,
3963 &new_intermediate_trail_id); 3961 new_intermediate_trail_id);
3964 } 3962 }
3965 GNUNET_free (local_best_known_dest); 3963 GNUNET_free (local_best_known_dest);
3966 GNUNET_free (next_hop_towards_local_best_known_dest); 3964 GNUNET_free (next_hop_towards_local_best_known_dest);
@@ -4111,8 +4109,6 @@ handle_dht_p2p_trail_setup_result(void *cls, const struct GNUNET_PeerIdentity *p
4111 /* If I am not my own finger identity, then add routing table entry. */ 4109 /* If I am not my own finger identity, then add routing table entry. */
4112 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &finger_identity)) 4110 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &finger_identity))
4113 { 4111 {
4114 /* FIXME: check that you always add trail entry even if your finger is
4115 friend. */
4116 GDS_ROUTING_add (trail_id, my_identity, *peer); 4112 GDS_ROUTING_add (trail_id, my_identity, *peer);
4117 } 4113 }
4118 4114
@@ -4142,8 +4138,6 @@ handle_dht_p2p_trail_setup_result(void *cls, const struct GNUNET_PeerIdentity *p
4142 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&(trail_result->querying_peer), 4138 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&(trail_result->querying_peer),
4143 &(trail_result->finger_identity)))) 4139 &(trail_result->finger_identity))))
4144 { 4140 {
4145 /* FIXME: check that you always add trail entry even if your finger is
4146 friend. */
4147 GDS_ROUTING_add (trail_id, next_hop, *peer); 4141 GDS_ROUTING_add (trail_id, next_hop, *peer);
4148 } 4142 }
4149 4143
@@ -4290,6 +4284,7 @@ update_predecessor (struct GNUNET_PeerIdentity finger,
4290 trail_to_new_predecessor = invert_trail (trail, trail_length); 4284 trail_to_new_predecessor = invert_trail (trail, trail_length);
4291 /* FIXME: check that you always add trail entry even if your finger is 4285 /* FIXME: check that you always add trail entry even if your finger is
4292 friend. */ 4286 friend. */
4287
4293 /* Add an entry in your routing table. */ 4288 /* Add an entry in your routing table. */
4294 GDS_ROUTING_add (trail_to_new_predecessor_id, 4289 GDS_ROUTING_add (trail_to_new_predecessor_id,
4295 trail_to_new_predecessor[trail_length - 1], 4290 trail_to_new_predecessor[trail_length - 1],
@@ -5045,16 +5040,19 @@ handle_dht_p2p_trail_compression (void *cls, const struct GNUNET_PeerIdentity *p
5045 //trail teardown make a generic function. 5040 //trail teardown make a generic function.
5046 5041
5047 /* Am I the new first friend to reach to finger of this trail. */ 5042 /* Am I the new first friend to reach to finger of this trail. */
5048 if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&(trail_compression->new_first_friend), 5043 if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&trail_compression->new_first_friend,
5049 &my_identity))) 5044 &my_identity)))
5050 { 5045 {
5051 GNUNET_assert (NULL != GNUNET_CONTAINER_multipeermap_get (friend_peermap, &trail_compression->source_peer)); 5046 GNUNET_assert (NULL !=
5047 (GNUNET_CONTAINER_multipeermap_get (friend_peermap,
5048 &trail_compression->source_peer)));
5052 /* Update your prev hop to source of this message. */ 5049 /* Update your prev hop to source of this message. */
5053 GNUNET_assert (GNUNET_SYSERR != 5050 GNUNET_assert (GNUNET_SYSERR !=
5054 (GDS_ROUTING_update_trail_prev_hop (trail_id, 5051 (GDS_ROUTING_update_trail_prev_hop (trail_id,
5055 trail_compression->source_peer))); 5052 trail_compression->source_peer)));
5056 return GNUNET_OK; 5053 return GNUNET_OK;
5057 } 5054 }
5055
5058 //GDS_ROUTING_test_print(); 5056 //GDS_ROUTING_test_print();
5059 /* Pass the message to next hop to finally reach to new_first_friend. */ 5057 /* Pass the message to next hop to finally reach to new_first_friend. */
5060 next_hop = GDS_ROUTING_get_next_hop (trail_id, GDS_ROUTING_SRC_TO_DEST); 5058 next_hop = GDS_ROUTING_get_next_hop (trail_id, GDS_ROUTING_SRC_TO_DEST);
@@ -5064,8 +5062,11 @@ handle_dht_p2p_trail_compression (void *cls, const struct GNUNET_PeerIdentity *p
5064 return GNUNET_OK; 5062 return GNUNET_OK;
5065 } 5063 }
5066 5064
5067 GNUNET_assert (NULL != (target_friend = 5065 GNUNET_assert (NULL !=
5068 GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop))); 5066 (target_friend =
5067 GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop)));
5068
5069 GDS_ROUTING_remove_trail (trail_id);
5069 GDS_NEIGHBOURS_send_trail_compression (trail_compression->source_peer, 5070 GDS_NEIGHBOURS_send_trail_compression (trail_compression->source_peer,
5070 trail_id, 5071 trail_id,
5071 trail_compression->new_first_friend, 5072 trail_compression->new_first_friend,
@@ -5118,7 +5119,7 @@ handle_dht_p2p_trail_teardown (void *cls, const struct GNUNET_PeerIdentity *peer
5118 return GNUNET_SYSERR; 5119 return GNUNET_SYSERR;
5119 } 5120 }
5120#endif 5121#endif
5121 5122
5122 next_hop = GDS_ROUTING_get_next_hop (trail_id, trail_direction); 5123 next_hop = GDS_ROUTING_get_next_hop (trail_id, trail_direction);
5123 5124
5124 if (NULL == next_hop) 5125 if (NULL == next_hop)
@@ -5127,17 +5128,17 @@ handle_dht_p2p_trail_teardown (void *cls, const struct GNUNET_PeerIdentity *peer
5127 return GNUNET_SYSERR; 5128 return GNUNET_SYSERR;
5128 } 5129 }
5129 5130
5130 GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (trail_id));
5131
5132 /* I am the next hop, which means I am the final destination. */ 5131 /* I am the next hop, which means I am the final destination. */
5133 if (0 == GNUNET_CRYPTO_cmp_peer_identity (next_hop, &my_identity)) 5132 if (0 == GNUNET_CRYPTO_cmp_peer_identity (next_hop, &my_identity))
5134 { 5133 {
5134 GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (trail_id));
5135 return GNUNET_OK; 5135 return GNUNET_OK;
5136 } 5136 }
5137 else 5137 else
5138 { 5138 {
5139 /* If not final destination, then send a trail teardown message to next hop.*/ 5139 /* If not final destination, then send a trail teardown message to next hop.*/
5140 GNUNET_assert (NULL != GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop)); 5140 GNUNET_assert (NULL != GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop));
5141 GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (trail_id));
5141 GDS_NEIGHBOURS_send_trail_teardown (trail_id, trail_direction, *next_hop); 5142 GDS_NEIGHBOURS_send_trail_teardown (trail_id, trail_direction, *next_hop);
5142 } 5143 }
5143 5144
@@ -5274,8 +5275,10 @@ remove_matching_trails (const struct GNUNET_PeerIdentity *disconnected_friend,
5274 struct GNUNET_PeerIdentity *next_hop; 5275 struct GNUNET_PeerIdentity *next_hop;
5275 struct FriendInfo *remove_friend; 5276 struct FriendInfo *remove_friend;
5276 5277
5277 remove_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap, 5278 GNUNET_assert (NULL !=
5278 disconnected_friend); 5279 (remove_friend =
5280 GNUNET_CONTAINER_multipeermap_get (friend_peermap,
5281 disconnected_friend)));
5279 remove_friend->trails_count--; 5282 remove_friend->trails_count--;
5280 next_hop = GDS_ROUTING_get_next_hop (trail->trail_id, GDS_ROUTING_SRC_TO_DEST); 5283 next_hop = GDS_ROUTING_get_next_hop (trail->trail_id, GDS_ROUTING_SRC_TO_DEST);
5281 GNUNET_assert (0 == (GNUNET_CRYPTO_cmp_peer_identity (disconnected_friend, 5284 GNUNET_assert (0 == (GNUNET_CRYPTO_cmp_peer_identity (disconnected_friend,
@@ -5348,8 +5351,10 @@ remove_matching_fingers (const struct GNUNET_PeerIdentity *disconnected_peer)
5348 (GNUNET_CRYPTO_cmp_peer_identity (next_hop, 5351 (GNUNET_CRYPTO_cmp_peer_identity (next_hop,
5349 &remove_finger->finger_identity))); 5352 &remove_finger->finger_identity)));
5350 GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (trail_id)); 5353 GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (trail_id));
5351 remove_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap, 5354 GNUNET_assert (NULL !=
5352 disconnected_peer); 5355 (remove_friend =
5356 GNUNET_CONTAINER_multipeermap_get (friend_peermap,
5357 disconnected_peer)));
5353 remove_friend->trails_count--; 5358 remove_friend->trails_count--;
5354 remove_finger->is_present = GNUNET_NO; 5359 remove_finger->is_present = GNUNET_NO;
5355 memset ((void *)&finger_table[i], 0, sizeof (finger_table[i])); 5360 memset ((void *)&finger_table[i], 0, sizeof (finger_table[i]));