aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSupriti Singh <supritisingh08@gmail.com>2014-08-06 14:15:17 +0000
committerSupriti Singh <supritisingh08@gmail.com>2014-08-06 14:15:17 +0000
commit00239344e5b07d76ab19b842c69eaf9fef881127 (patch)
tree94381a3e494f6c98638302b21c6c1376f2dc57fe /src
parent6c6e08344363cf61ce0baef3cc5afba38a247d7a (diff)
downloadgnunet-00239344e5b07d76ab19b842c69eaf9fef881127.tar.gz
gnunet-00239344e5b07d76ab19b842c69eaf9fef881127.zip
xvine: fixes
Diffstat (limited to 'src')
-rw-r--r--src/dht/gnunet-service-xdht_neighbours.c95
-rw-r--r--src/dht/gnunet-service-xdht_routing.c1
2 files changed, 66 insertions, 30 deletions
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c
index c12ce9fa7..77389d1b3 100644
--- a/src/dht/gnunet-service-xdht_neighbours.c
+++ b/src/dht/gnunet-service-xdht_neighbours.c
@@ -1431,7 +1431,7 @@ GDS_NEIGHBOURS_send_notify_new_successor (struct GNUNET_PeerIdentity source_peer
1431 GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# P2P messages dropped due to full queue"), 1431 GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# P2P messages dropped due to full queue"),
1432 1, GNUNET_NO); 1432 1, GNUNET_NO);
1433 } 1433 }
1434 1434
1435 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize); 1435 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
1436 pending->importance = 0; /* FIXME */ 1436 pending->importance = 0; /* FIXME */
1437 pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT); 1437 pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT);
@@ -3051,6 +3051,24 @@ scan_and_compress_trail (struct GNUNET_PeerIdentity finger_identity,
3051 return new_trail; 3051 return new_trail;
3052} 3052}
3053 3053
3054#if 0
3055/* Store the successor for path tracking */
3056 if (track_topology && (NULL != GDS_stats))
3057 {
3058 char *my_id_str;
3059 char *succ_id_str;
3060 char *key;
3061
3062 my_id_str = GNUNET_strdup (GNUNET_i2s (&my_identity));
3063 succ_id_str = GNUNET_strdup (GNUNET_i2s
3064 (&successor->finger_identity));
3065 GNUNET_asprintf (&key, "XDHT:0:%.4s:%.4s", my_id_str, succ_id_str);
3066 GNUNET_free (my_id_str);
3067 GNUNET_free (succ_id_str);
3068 GNUNET_STATISTICS_update (GDS_stats, "key", 1, 0);
3069 GNUNET_free (key);
3070 }
3071#endif
3054 3072
3055/** 3073/**
3056 * Periodic task to verify current successor. There can be multiple trails to reach 3074 * Periodic task to verify current successor. There can be multiple trails to reach
@@ -3083,26 +3101,16 @@ send_verify_successor_message (void *cls,
3083 NULL); 3101 NULL);
3084 3102
3085 successor = &finger_table[0]; 3103 successor = &finger_table[0];
3086 i = 0; 3104 for (i = 0; i < successor->trails_count; i++)
3087 trail = &successor->trail_list[i];
3088
3089 /* Store the successor for path tracking */
3090 if (track_topology && (NULL != GDS_stats))
3091 { 3105 {
3092 char *my_id_str; 3106 trail = &successor->trail_list[i];
3093 char *succ_id_str; 3107 if(GNUNET_YES == trail->is_present)
3094 char *key; 3108 break;
3095
3096 my_id_str = GNUNET_strdup (GNUNET_i2s (&my_identity));
3097 succ_id_str = GNUNET_strdup (GNUNET_i2s
3098 (&successor->finger_identity));
3099 GNUNET_asprintf (&key, "XDHT:0:%.4s:%.4s", my_id_str, succ_id_str);
3100 GNUNET_free (my_id_str);
3101 GNUNET_free (succ_id_str);
3102 GNUNET_STATISTICS_update (GDS_stats, "key", 1, 0);
3103 GNUNET_free (key);
3104 } 3109 }
3105 3110
3111 if (i == successor->trails_count)
3112 return;
3113
3106 GNUNET_assert(0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity, 3114 GNUNET_assert(0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity,
3107 &successor->finger_identity)); 3115 &successor->finger_identity));
3108 3116
@@ -4202,7 +4210,6 @@ handle_dht_p2p_trail_setup_result(void *cls, const struct GNUNET_PeerIdentity *p
4202 4210
4203 /*TODO:URGENT Check if I am already present in the trail. If yes then its an error, 4211 /*TODO:URGENT Check if I am already present in the trail. If yes then its an error,
4204 as in trail setup we ensure that it should never happen. */ 4212 as in trail setup we ensure that it should never happen. */
4205
4206 /* Am I the one who initiated the query? */ 4213 /* Am I the one who initiated the query? */
4207 if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&querying_peer, &my_identity))) 4214 if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&querying_peer, &my_identity)))
4208 { 4215 {
@@ -4377,7 +4384,7 @@ check_for_duplicate_entries (const struct GNUNET_PeerIdentity *trail_1,
4377 if(0 != GNUNET_CRYPTO_cmp_peer_identity (&trail_1[i],&trail_2[j])) 4384 if(0 != GNUNET_CRYPTO_cmp_peer_identity (&trail_1[i],&trail_2[j]))
4378 continue; 4385 continue;
4379 4386
4380 *joined_trail_len = i + (trail_2_len - j); 4387 *joined_trail_len = i + (trail_2_len - j) + 1;
4381 joined_trail = GNUNET_malloc (*joined_trail_len * 4388 joined_trail = GNUNET_malloc (*joined_trail_len *
4382 sizeof(struct GNUNET_PeerIdentity)); 4389 sizeof(struct GNUNET_PeerIdentity));
4383 4390
@@ -4679,8 +4686,7 @@ handle_dht_p2p_verify_successor(void *cls,
4679 * the trail. */ 4686 * the trail. */
4680 if(0 != (GNUNET_CRYPTO_cmp_peer_identity (&successor, &my_identity))) 4687 if(0 != (GNUNET_CRYPTO_cmp_peer_identity (&successor, &my_identity)))
4681 { 4688 {
4682 next_hop = GDS_ROUTING_get_next_hop (trail_id, GDS_ROUTING_SRC_TO_DEST); 4689 next_hop = GDS_ROUTING_get_next_hop (trail_id, GDS_ROUTING_SRC_TO_DEST);
4683
4684 if (NULL == next_hop) 4690 if (NULL == next_hop)
4685 { 4691 {
4686 GNUNET_break_op (0); 4692 GNUNET_break_op (0);
@@ -4706,15 +4712,39 @@ handle_dht_p2p_verify_successor(void *cls,
4706 * it. */ 4712 * it. */
4707 compare_and_update_predecessor (source_peer, trail, trail_length); 4713 compare_and_update_predecessor (source_peer, trail, trail_length);
4708 current_predecessor = finger_table[PREDECESSOR_FINGER_ID]; 4714 current_predecessor = finger_table[PREDECESSOR_FINGER_ID];
4709 4715 unsigned int flag = 0;
4710 /* Is source of this message NOT my predecessor. */ 4716 /* Is source of this message NOT my predecessor. */
4711 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&current_predecessor.finger_identity, 4717 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&current_predecessor.finger_identity,
4712 &source_peer))) 4718 &source_peer)))
4713 { 4719 {
4714 trail_src_to_curr_pred = get_trail_src_to_curr_pred (source_peer, 4720 /* Check if trail contains current_predecessor. */
4715 trail, 4721 unsigned int i;
4716 trail_length, 4722 for (i = 0; i < trail_length; i++)
4717 &trail_src_to_curr_pred_len); 4723 {
4724 if(0 != GNUNET_CRYPTO_cmp_peer_identity(&trail[i],
4725 &current_predecessor.finger_identity))
4726 continue;
4727
4728 flag = 1;
4729 trail_src_to_curr_pred_len = i;
4730 trail_src_to_curr_pred = GNUNET_malloc (trail_src_to_curr_pred_len *
4731 sizeof(struct GNUNET_PeerIdentity));
4732 unsigned int k = 0;
4733
4734 while(k < i)
4735 {
4736 trail_src_to_curr_pred[k] = trail[k];
4737 k++;
4738 }
4739 }
4740
4741 if(0 == flag)
4742 {
4743 trail_src_to_curr_pred = get_trail_src_to_curr_pred (source_peer,
4744 trail,
4745 trail_length,
4746 &trail_src_to_curr_pred_len);
4747 }
4718 } 4748 }
4719 else 4749 else
4720 { 4750 {
@@ -4979,6 +5009,7 @@ handle_dht_p2p_verify_successor_result(void *cls,
4979 trail_id = vsrm->trail_id; 5009 trail_id = vsrm->trail_id;
4980 probable_successor = vsrm->probable_successor; 5010 probable_successor = vsrm->probable_successor;
4981 current_successor = vsrm->current_successor; 5011 current_successor = vsrm->current_successor;
5012
4982 5013
4983 /* I am the querying_peer. */ 5014 /* I am the querying_peer. */
4984 if(0 == (GNUNET_CRYPTO_cmp_peer_identity (&querying_peer, &my_identity))) 5015 if(0 == (GNUNET_CRYPTO_cmp_peer_identity (&querying_peer, &my_identity)))
@@ -5050,13 +5081,18 @@ handle_dht_p2p_notify_new_successor(void *cls,
5050 source = nsm->source_peer; 5081 source = nsm->source_peer;
5051 new_successor = nsm->new_successor; 5082 new_successor = nsm->new_successor;
5052 trail_id = nsm->trail_id; 5083 trail_id = nsm->trail_id;
5084
5053 5085
5054 //FIXME: add a check to make sure peer is correct. 5086 //FIXME: add a check to make sure peer is correct.
5055 5087
5056 /* I am the new_successor to source_peer. */ 5088 /* I am the new_successor to source_peer. */
5057 if ( 0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &new_successor)) 5089 if ( 0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &new_successor))
5058 { 5090 {
5059 GDS_ROUTING_add (trail_id, *peer, my_identity); 5091 if(trail_length > 0)
5092 GNUNET_assert(0 == GNUNET_CRYPTO_cmp_peer_identity(&trail[trail_length - 1],
5093 peer));
5094 else
5095 GNUNET_assert(0 == GNUNET_CRYPTO_cmp_peer_identity(&source, peer));
5060 compare_and_update_predecessor (source, trail, trail_length); 5096 compare_and_update_predecessor (source, trail, trail_length);
5061 return GNUNET_OK; 5097 return GNUNET_OK;
5062 } 5098 }
@@ -5078,7 +5114,6 @@ handle_dht_p2p_notify_new_successor(void *cls,
5078 5114
5079 /* Add an entry in routing table for trail from source to its new successor. */ 5115 /* Add an entry in routing table for trail from source to its new successor. */
5080 GNUNET_assert (GNUNET_OK == GDS_ROUTING_add (trail_id, *peer, next_hop)); 5116 GNUNET_assert (GNUNET_OK == GDS_ROUTING_add (trail_id, *peer, next_hop));
5081
5082 GNUNET_assert (NULL != 5117 GNUNET_assert (NULL !=
5083 (target_friend = 5118 (target_friend =
5084 GNUNET_CONTAINER_multipeermap_get (friend_peermap, &next_hop))); 5119 GNUNET_CONTAINER_multipeermap_get (friend_peermap, &next_hop)));
diff --git a/src/dht/gnunet-service-xdht_routing.c b/src/dht/gnunet-service-xdht_routing.c
index b096e5ef3..841234bf5 100644
--- a/src/dht/gnunet-service-xdht_routing.c
+++ b/src/dht/gnunet-service-xdht_routing.c
@@ -220,6 +220,7 @@ static int remove_matching_trails (void *cls,
220 disconnected_peer)) 220 disconnected_peer))
221 { 221 {
222 my_identity = GDS_NEIGHBOURS_get_my_id (); 222 my_identity = GDS_NEIGHBOURS_get_my_id ();
223
223 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity, 224 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity,
224 &remove_trail->next_hop)) 225 &remove_trail->next_hop))
225 { 226 {