aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSupriti Singh <supritisingh08@gmail.com>2014-08-19 20:22:08 +0000
committerSupriti Singh <supritisingh08@gmail.com>2014-08-19 20:22:08 +0000
commit41b260fd0f3db3daf54c5e03ccb07af4b1fc5859 (patch)
tree3847dd6d13689dc72be7dafe76392ea2af1dde6f /src
parentd12dbffd9053a339bcc8d5ec8eb2c921614668b6 (diff)
downloadgnunet-41b260fd0f3db3daf54c5e03ccb07af4b1fc5859.tar.gz
gnunet-41b260fd0f3db3daf54c5e03ccb07af4b1fc5859.zip
trail rejection fixes
Diffstat (limited to 'src')
-rw-r--r--src/dht/gnunet-service-xdht_neighbours.c44
1 files changed, 10 insertions, 34 deletions
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c
index 7f136b7d1..3257c63ac 100644
--- a/src/dht/gnunet-service-xdht_neighbours.c
+++ b/src/dht/gnunet-service-xdht_neighbours.c
@@ -2950,7 +2950,6 @@ add_new_finger (struct GNUNET_PeerIdentity finger_identity,
2950 if (NULL != GNUNET_CONTAINER_multipeermap_get (friend_peermap, 2950 if (NULL != GNUNET_CONTAINER_multipeermap_get (friend_peermap,
2951 &finger_identity)) 2951 &finger_identity))
2952 { 2952 {
2953 GNUNET_assert (finger_trail_length == 0);
2954 new_entry->trail_list[0].trail_id = trail_id; 2953 new_entry->trail_list[0].trail_id = trail_id;
2955 new_entry->trails_count = 1; 2954 new_entry->trails_count = 1;
2956 new_entry->trail_list[0].is_present = GNUNET_YES; 2955 new_entry->trail_list[0].is_present = GNUNET_YES;
@@ -5083,7 +5082,6 @@ handle_dht_p2p_trail_setup_rejection (void *cls,
5083 struct GNUNET_HashCode trail_id; 5082 struct GNUNET_HashCode trail_id;
5084 struct GNUNET_PeerIdentity next_peer; 5083 struct GNUNET_PeerIdentity next_peer;
5085 struct GNUNET_PeerIdentity source; 5084 struct GNUNET_PeerIdentity source;
5086 struct GNUNET_PeerIdentity *next_hop;
5087 uint64_t ultimate_destination_finger_value; 5085 uint64_t ultimate_destination_finger_value;
5088 unsigned int is_predecessor; 5086 unsigned int is_predecessor;
5089 size_t msize; 5087 size_t msize;
@@ -5135,36 +5133,19 @@ handle_dht_p2p_trail_setup_rejection (void *cls,
5135 /* If I am congested then pass this message to peer before me in trail. */ 5133 /* If I am congested then pass this message to peer before me in trail. */
5136 if(GNUNET_YES == GDS_ROUTING_threshold_reached()) 5134 if(GNUNET_YES == GDS_ROUTING_threshold_reached())
5137 { 5135 {
5138 struct GNUNET_PeerIdentity *new_trail; 5136 if (0 == trail_length)
5139 unsigned int new_trail_length; 5137 next_peer = source;
5140
5141 /* Remove yourself from the trail setup so far. */
5142 if (trail_length == 1)
5143 {
5144 new_trail = NULL;
5145 new_trail_length = 0;
5146 next_hop = &source;
5147 }
5148 else 5138 else
5149 { 5139 next_peer = trail_peer_list[trail_length-1];
5150 memcpy (&next_hop , &trail_peer_list[trail_length - 2], 5140
5151 sizeof (struct GNUNET_PeerIdentity));
5152
5153 /* Remove myself from the trail. */
5154 new_trail_length = trail_length -1;
5155 new_trail = GNUNET_malloc (new_trail_length * sizeof (struct GNUNET_PeerIdentity));
5156 memcpy (new_trail, trail_peer_list, new_trail_length * sizeof (struct GNUNET_PeerIdentity));
5157 }
5158
5159 GNUNET_assert (NULL != 5141 GNUNET_assert (NULL !=
5160 (target_friend = 5142 (target_friend =
5161 GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop))); 5143 GNUNET_CONTAINER_multipeermap_get (friend_peermap, &next_peer)));
5162 GDS_NEIGHBOURS_send_trail_rejection (source, 5144 GDS_NEIGHBOURS_send_trail_rejection (source,
5163 ultimate_destination_finger_value, 5145 ultimate_destination_finger_value,
5164 my_identity, is_predecessor, 5146 my_identity, is_predecessor,
5165 new_trail,new_trail_length,trail_id, 5147 trail_peer_list,trail_length,trail_id,
5166 target_friend, CONGESTION_TIMEOUT); 5148 target_friend, CONGESTION_TIMEOUT);
5167 GNUNET_free (new_trail);
5168 return GNUNET_OK; 5149 return GNUNET_OK;
5169 } 5150 }
5170 5151
@@ -5201,7 +5182,8 @@ handle_dht_p2p_trail_setup_rejection (void *cls,
5201 5182
5202 GNUNET_assert (NULL != 5183 GNUNET_assert (NULL !=
5203 (target_friend = 5184 (target_friend =
5204 GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop))); 5185 GNUNET_CONTAINER_multipeermap_get (friend_peermap,
5186 &successor.next_hop)));
5205 GDS_NEIGHBOURS_send_trail_setup (source, 5187 GDS_NEIGHBOURS_send_trail_setup (source,
5206 ultimate_destination_finger_value, 5188 ultimate_destination_finger_value,
5207 successor.best_known_destination, 5189 successor.best_known_destination,
@@ -5440,7 +5422,6 @@ remove_matching_trails (const struct GNUNET_PeerIdentity *disconnected_friend,
5440} 5422}
5441 5423
5442 5424
5443
5444/** 5425/**
5445 * Iterate over finger_table entries. 5426 * Iterate over finger_table entries.
5446 * 0. Ignore finger which is my_identity or if no valid entry present at 5427 * 0. Ignore finger which is my_identity or if no valid entry present at
@@ -5487,9 +5468,6 @@ remove_matching_fingers (const struct GNUNET_PeerIdentity *disconnected_peer)
5487 (next_hop = 5468 (next_hop =
5488 GDS_ROUTING_get_next_hop (trail_id, GDS_ROUTING_SRC_TO_DEST))) 5469 GDS_ROUTING_get_next_hop (trail_id, GDS_ROUTING_SRC_TO_DEST)))
5489 { 5470 {
5490 GNUNET_assert (0 ==
5491 (GNUNET_CRYPTO_cmp_peer_identity (next_hop,
5492 &current_finger->finger_identity)));
5493 GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (trail_id)); 5471 GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (trail_id));
5494 GNUNET_assert (NULL != 5472 GNUNET_assert (NULL !=
5495 (remove_friend = 5473 (remove_friend =
@@ -5615,7 +5593,7 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer_identity)
5615 5593
5616 friend = GNUNET_new (struct FriendInfo); 5594 friend = GNUNET_new (struct FriendInfo);
5617 friend->id = *peer_identity; 5595 friend->id = *peer_identity;
5618 friend->congestion_timestamp = GNUNET_TIME_relative_to_absolute(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 50)); 5596
5619 GNUNET_assert (GNUNET_OK == 5597 GNUNET_assert (GNUNET_OK ==
5620 GNUNET_CONTAINER_multipeermap_put (friend_peermap, 5598 GNUNET_CONTAINER_multipeermap_put (friend_peermap,
5621 peer_identity, friend, 5599 peer_identity, friend,
@@ -5624,9 +5602,7 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer_identity)
5624 /* got a first connection, good time to start with FIND FINGER TRAIL requests...*/ 5602 /* got a first connection, good time to start with FIND FINGER TRAIL requests...*/
5625 if (GNUNET_SCHEDULER_NO_TASK == find_finger_trail_task) 5603 if (GNUNET_SCHEDULER_NO_TASK == find_finger_trail_task)
5626 { 5604 {
5627 // find_finger_trail_task = GNUNET_SCHEDULER_add_now (&send_find_finger_trail_message, NULL); 5605 find_finger_trail_task = GNUNET_SCHEDULER_add_now (&send_find_finger_trail_message, NULL);
5628 find_finger_trail_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 60),
5629 &send_find_finger_trail_message, NULL);
5630 } 5606 }
5631} 5607}
5632 5608