diff options
author | Supriti Singh <supritisingh08@gmail.com> | 2014-08-14 10:34:52 +0000 |
---|---|---|
committer | Supriti Singh <supritisingh08@gmail.com> | 2014-08-14 10:34:52 +0000 |
commit | 8c137ccab68368a3cf5ee36d97b31b3d1d962f54 (patch) | |
tree | d4260e79852310157621f69ac3d2ed22c19e1c81 | |
parent | 3889e3c1941394df561ad4cb0b16a4e6b0eb69d9 (diff) | |
download | gnunet-8c137ccab68368a3cf5ee36d97b31b3d1d962f54.tar.gz gnunet-8c137ccab68368a3cf5ee36d97b31b3d1d962f54.zip |
xvine: fixes
-rw-r--r-- | src/dht/gnunet-service-xdht_neighbours.c | 76 |
1 files changed, 53 insertions, 23 deletions
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c index b1435f248..1f2a87da0 100644 --- a/src/dht/gnunet-service-xdht_neighbours.c +++ b/src/dht/gnunet-service-xdht_neighbours.c | |||
@@ -1865,6 +1865,9 @@ select_closest_peer (const struct GNUNET_PeerIdentity *peer1, | |||
1865 | uint64_t value, | 1865 | uint64_t value, |
1866 | unsigned int is_predecessor) | 1866 | unsigned int is_predecessor) |
1867 | { | 1867 | { |
1868 | /* This check is here to ensure that calling function never sends | ||
1869 | same peer value in peer1 and peer2. Remove it later. */ | ||
1870 | GNUNET_assert(0 != GNUNET_CRYPTO_cmp_peer_identity (peer1, peer2)); | ||
1868 | if (1 == is_predecessor) | 1871 | if (1 == is_predecessor) |
1869 | return select_closest_predecessor (peer1, peer2, value); | 1872 | return select_closest_predecessor (peer1, peer2, value); |
1870 | 1873 | ||
@@ -2746,29 +2749,28 @@ is_new_trail_unique (struct FingerInfo *existing_finger, | |||
2746 | /* Iterate over list of trails. */ | 2749 | /* Iterate over list of trails. */ |
2747 | for (i = 0; i < existing_finger->trails_count; i++) | 2750 | for (i = 0; i < existing_finger->trails_count; i++) |
2748 | { | 2751 | { |
2749 | trail_list_iterator = &existing_finger->trail_list[i]; | 2752 | trail_list_iterator = &(existing_finger->trail_list[i]); |
2750 | GNUNET_assert (GNUNET_YES == trail_list_iterator->is_present); | 2753 | GNUNET_assert (GNUNET_YES == trail_list_iterator->is_present); |
2751 | 2754 | ||
2752 | /* New trail and existing trail length are not same. */ | 2755 | /* New trail and existing trail length are not same. */ |
2753 | if (trail_list_iterator->trail_length != trail_length) | 2756 | if (trail_list_iterator->trail_length != trail_length) |
2754 | { | 2757 | { |
2755 | trail_unique = GNUNET_YES; | 2758 | trail_unique = GNUNET_YES; |
2756 | continue; | 2759 | break; |
2757 | } | 2760 | } |
2758 | 2761 | ||
2759 | trail_element = trail_list_iterator->trail_head; | 2762 | trail_element = trail_list_iterator->trail_head; |
2763 | GNUNET_assert (trail_element != NULL); | ||
2760 | for (j = 0; j < trail_list_iterator->trail_length; j++) | 2764 | for (j = 0; j < trail_list_iterator->trail_length; j++) |
2761 | { | 2765 | { |
2762 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&new_trail[j], | 2766 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&new_trail[j], |
2763 | &trail_element->peer)) | 2767 | &trail_element->peer)) |
2764 | { | 2768 | { |
2765 | trail_unique = GNUNET_YES; | 2769 | trail_unique = GNUNET_YES; |
2766 | continue; | 2770 | break; |
2767 | } | 2771 | } |
2768 | trail_element = trail_element->next; | 2772 | trail_element = trail_element->next; |
2769 | } | 2773 | } |
2770 | |||
2771 | trail_unique = GNUNET_NO; | ||
2772 | } | 2774 | } |
2773 | 2775 | ||
2774 | return trail_unique; | 2776 | return trail_unique; |
@@ -4786,7 +4788,7 @@ handle_dht_p2p_verify_successor(void *cls, | |||
4786 | //in notify successor. | 4788 | //in notify successor. |
4787 | return GNUNET_OK; | 4789 | return GNUNET_OK; |
4788 | } | 4790 | } |
4789 | 4791 | ||
4790 | target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop); | 4792 | target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop); |
4791 | 4793 | ||
4792 | if(NULL == target_friend) | 4794 | if(NULL == target_friend) |
@@ -4909,10 +4911,14 @@ check_trail_me_to_probable_succ (struct GNUNET_PeerIdentity probable_successor, | |||
4909 | * In case probable successor is the correct successor, remove the existing | 4911 | * In case probable successor is the correct successor, remove the existing |
4910 | * successor. Add probable successor as new successor. Send notify new successor | 4912 | * successor. Add probable successor as new successor. Send notify new successor |
4911 | * message to new successor. | 4913 | * message to new successor. |
4912 | * @param curr_succ | 4914 | * @param curr_succ Peer to which we sent the verify successor message. It may |
4913 | * @param probable_successor | 4915 | * or may not be our real current successor, as we may have few iterations of |
4914 | * @param trail | 4916 | * find finger trail task. |
4915 | * @param trail_length | 4917 | * @param probable_successor Peer which should be our successor accroding to @a |
4918 | * curr_succ | ||
4919 | * @param trail List of peers to reach from me to @a probable successor, NOT including | ||
4920 | * endpoints. | ||
4921 | * @param trail_length Total number of peers in @a trail. | ||
4916 | */ | 4922 | */ |
4917 | static void | 4923 | static void |
4918 | compare_and_update_successor (struct GNUNET_PeerIdentity curr_succ, | 4924 | compare_and_update_successor (struct GNUNET_PeerIdentity curr_succ, |
@@ -4932,6 +4938,11 @@ compare_and_update_successor (struct GNUNET_PeerIdentity curr_succ, | |||
4932 | current_successor = &finger_table[0]; | 4938 | current_successor = &finger_table[0]; |
4933 | successor_value = compute_finger_identity_value(0); | 4939 | successor_value = compute_finger_identity_value(0); |
4934 | 4940 | ||
4941 | /* If probable successor is same as current_successor, do nothing. */ | ||
4942 | if(0 == GNUNET_CRYPTO_cmp_peer_identity (&probable_successor, | ||
4943 | ¤t_successor->finger_identity)) | ||
4944 | return; | ||
4945 | |||
4935 | closest_peer = select_closest_peer (&probable_successor, | 4946 | closest_peer = select_closest_peer (&probable_successor, |
4936 | ¤t_successor->finger_identity, | 4947 | ¤t_successor->finger_identity, |
4937 | successor_value, is_predecessor); | 4948 | successor_value, is_predecessor); |
@@ -4956,6 +4967,7 @@ compare_and_update_successor (struct GNUNET_PeerIdentity curr_succ, | |||
4956 | } | 4967 | } |
4957 | return; | 4968 | return; |
4958 | } | 4969 | } |
4970 | |||
4959 | /* Probable successor is the closest peer.*/ | 4971 | /* Probable successor is the closest peer.*/ |
4960 | if(trail_length > 0) | 4972 | if(trail_length > 0) |
4961 | { | 4973 | { |
@@ -5080,11 +5092,18 @@ handle_dht_p2p_verify_successor_result(void *cls, | |||
5080 | } | 5092 | } |
5081 | 5093 | ||
5082 | /*If you are not the querying peer then pass on the message */ | 5094 | /*If you are not the querying peer then pass on the message */ |
5083 | GNUNET_assert (NULL != (next_hop = | 5095 | if(NULL == (next_hop = |
5084 | GDS_ROUTING_get_next_hop (trail_id, trail_direction))); | 5096 | GDS_ROUTING_get_next_hop (trail_id, trail_direction))) |
5085 | GNUNET_assert (NULL != | 5097 | { |
5086 | (target_friend = | 5098 | GNUNET_break_op(0); |
5087 | GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop))); | 5099 | return GNUNET_OK; |
5100 | } | ||
5101 | if (NULL == (target_friend = | ||
5102 | GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop))) | ||
5103 | { | ||
5104 | GNUNET_break_op(0); | ||
5105 | return GNUNET_OK; | ||
5106 | } | ||
5088 | GDS_NEIGHBOURS_send_verify_successor_result (querying_peer, | 5107 | GDS_NEIGHBOURS_send_verify_successor_result (querying_peer, |
5089 | vsrm->current_successor, | 5108 | vsrm->current_successor, |
5090 | probable_successor, trail_id, | 5109 | probable_successor, trail_id, |
@@ -5385,14 +5404,22 @@ handle_dht_p2p_trail_compression (void *cls, const struct GNUNET_PeerIdentity *p | |||
5385 | if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&trail_compression->new_first_friend, | 5404 | if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&trail_compression->new_first_friend, |
5386 | &my_identity))) | 5405 | &my_identity))) |
5387 | { | 5406 | { |
5388 | GNUNET_assert (NULL != | 5407 | if (NULL == |
5389 | (GNUNET_CONTAINER_multipeermap_get (friend_peermap, | 5408 | (GNUNET_CONTAINER_multipeermap_get (friend_peermap, |
5390 | &trail_compression->source_peer))); | 5409 | &trail_compression->source_peer))) |
5410 | { | ||
5411 | GNUNET_break_op(0); | ||
5412 | return GNUNET_OK; | ||
5413 | } | ||
5391 | 5414 | ||
5392 | /* Update your prev hop to source of this message. */ | 5415 | /* Update your prev hop to source of this message. */ |
5393 | GNUNET_assert (GNUNET_SYSERR != | 5416 | if(GNUNET_SYSERR == |
5394 | (GDS_ROUTING_update_trail_prev_hop (trail_id, | 5417 | (GDS_ROUTING_update_trail_prev_hop (trail_id, |
5395 | trail_compression->source_peer))); | 5418 | trail_compression->source_peer))) |
5419 | { | ||
5420 | GNUNET_break(0); | ||
5421 | return GNUNET_OK; | ||
5422 | } | ||
5396 | return GNUNET_OK; | 5423 | return GNUNET_OK; |
5397 | } | 5424 | } |
5398 | 5425 | ||
@@ -5405,9 +5432,12 @@ handle_dht_p2p_trail_compression (void *cls, const struct GNUNET_PeerIdentity *p | |||
5405 | return GNUNET_OK; | 5432 | return GNUNET_OK; |
5406 | } | 5433 | } |
5407 | 5434 | ||
5408 | GNUNET_assert (NULL != | 5435 | if( NULL == (target_friend = |
5409 | (target_friend = | 5436 | GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop))) |
5410 | GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop))); | 5437 | { |
5438 | GNUNET_break_op(0); | ||
5439 | return GNUNET_OK; | ||
5440 | } | ||
5411 | 5441 | ||
5412 | GDS_ROUTING_remove_trail (trail_id); | 5442 | GDS_ROUTING_remove_trail (trail_id); |
5413 | 5443 | ||