aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSupriti Singh <supritisingh08@gmail.com>2014-08-18 12:44:52 +0000
committerSupriti Singh <supritisingh08@gmail.com>2014-08-18 12:44:52 +0000
commitab1a779a7136f4ac45adc418feb0fbbacd066751 (patch)
tree27d458f1587e25019f1542cb11d992c4e05e4e88 /src
parent41c3bd8aabf10fd3e893319bc9c622c3d268cad9 (diff)
downloadgnunet-ab1a779a7136f4ac45adc418feb0fbbacd066751.tar.gz
gnunet-ab1a779a7136f4ac45adc418feb0fbbacd066751.zip
xvine:fixes
Diffstat (limited to 'src')
-rw-r--r--src/dht/gnunet-service-xdht_neighbours.c160
1 files changed, 71 insertions, 89 deletions
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c
index bb72eaf81..c30855665 100644
--- a/src/dht/gnunet-service-xdht_neighbours.c
+++ b/src/dht/gnunet-service-xdht_neighbours.c
@@ -80,7 +80,7 @@
80/** 80/**
81 * How long to wait before sending another verify successor message. 81 * How long to wait before sending another verify successor message.
82 */ 82 */
83#define DHT_SEND_VERIFY_SUCCESSOR_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 1) 83#define DHT_SEND_VERIFY_SUCCESSOR_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 5)
84 84
85/** 85/**
86 * How long at most to wait for transmission of a request to a friend ? 86 * How long at most to wait for transmission of a request to a friend ?
@@ -1242,7 +1242,8 @@ GDS_NEIGHBOURS_send_verify_successor_message (struct GNUNET_PeerIdentity source_
1242 size_t msize; 1242 size_t msize;
1243 1243
1244 msize = sizeof (struct PeerVerifySuccessorMessage) + 1244 msize = sizeof (struct PeerVerifySuccessorMessage) +
1245 (trail_length * sizeof (struct GNUNET_PeerIdentity));; 1245 (trail_length * sizeof (struct GNUNET_PeerIdentity));
1246
1246 if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE) 1247 if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
1247 { 1248 {
1248 GNUNET_break (0); 1249 GNUNET_break (0);
@@ -1448,7 +1449,6 @@ GDS_NEIGHBOURS_send_notify_new_successor (struct GNUNET_PeerIdentity source_peer
1448 nsm->new_successor = successor; 1449 nsm->new_successor = successor;
1449 nsm->source_peer = source_peer; 1450 nsm->source_peer = source_peer;
1450 nsm->trail_id = succesor_trail_id; 1451 nsm->trail_id = succesor_trail_id;
1451
1452 peer_list = (struct GNUNET_PeerIdentity *) &nsm[1]; 1452 peer_list = (struct GNUNET_PeerIdentity *) &nsm[1];
1453 memcpy (peer_list, successor_trail, 1453 memcpy (peer_list, successor_trail,
1454 successor_trail_length * sizeof (struct GNUNET_PeerIdentity)); 1454 successor_trail_length * sizeof (struct GNUNET_PeerIdentity));
@@ -2102,6 +2102,17 @@ find_successor (uint64_t destination_finger_value,
2102 * with finger if its closest. */ 2102 * with finger if its closest. */
2103 compare_finger_and_current_closest_peer (&current_closest_peer); 2103 compare_finger_and_current_closest_peer (&current_closest_peer);
2104 2104
2105 if(0 == GNUNET_CRYPTO_cmp_peer_identity (&current_closest_peer.next_hop,
2106 &current_closest_peer.best_known_destination))
2107 {
2108 FPRINTF (stderr,_("\nSUPU MUST BE 0 trailid = %s,%s, %s, %d,"),
2109 GNUNET_h2s(&current_closest_peer.trail_id),__FILE__, __func__,__LINE__);
2110 }
2111 else
2112 {
2113 FPRINTF (stderr,_("\nSUPU MUST NOT BE 0 trailid = %s,%s, %s, %d,"),
2114 GNUNET_h2s(&current_closest_peer.trail_id),__FILE__, __func__,__LINE__);
2115 }
2105 return current_closest_peer; 2116 return current_closest_peer;
2106} 2117}
2107 2118
@@ -2577,6 +2588,10 @@ send_find_finger_trail_message (void *cls,
2577 /* Schedule another send_find_finger_trail_message task. */ 2588 /* Schedule another send_find_finger_trail_message task. */
2578 find_finger_trail_task_next_send_time = 2589 find_finger_trail_task_next_send_time =
2579 GNUNET_TIME_STD_BACKOFF(find_finger_trail_task_next_send_time); 2590 GNUNET_TIME_STD_BACKOFF(find_finger_trail_task_next_send_time);
2591 find_finger_trail_task_next_send_time.rel_value_us =
2592 find_finger_trail_task_next_send_time.rel_value_us +
2593 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
2594 DHT_FIND_FINGER_TRAIL_INTERVAL.rel_value_us);
2580 find_finger_trail_task = 2595 find_finger_trail_task =
2581 GNUNET_SCHEDULER_add_delayed (find_finger_trail_task_next_send_time, 2596 GNUNET_SCHEDULER_add_delayed (find_finger_trail_task_next_send_time,
2582 &send_find_finger_trail_message, 2597 &send_find_finger_trail_message,
@@ -2700,7 +2715,7 @@ select_and_replace_trail (struct FingerInfo *finger,
2700 replace_trail->trail_tail, 2715 replace_trail->trail_tail,
2701 element); 2716 element);
2702 } 2717 }
2703 /* FIXME: Are we adding the trail back to the list. */ 2718 /* FIXME: URGENT Are we adding the trail back to the list. */
2704} 2719}
2705 2720
2706 2721
@@ -3064,11 +3079,12 @@ send_verify_successor_message (void *cls,
3064 3079
3065 verify_successor_next_send_time = 3080 verify_successor_next_send_time =
3066 GNUNET_TIME_STD_BACKOFF(verify_successor_next_send_time); 3081 GNUNET_TIME_STD_BACKOFF(verify_successor_next_send_time);
3067 /* Schedule another send_find_finger_trail_message task. */ 3082
3083 /* Schedule another send_find_finger_trail_message task.
3068 verify_successor_next_send_time.rel_value_us = 3084 verify_successor_next_send_time.rel_value_us =
3069 DHT_SEND_VERIFY_SUCCESSOR_INTERVAL.rel_value_us + 3085 verify_successor_next_send_time.rel_value_us +
3070 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 3086 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
3071 DHT_SEND_VERIFY_SUCCESSOR_INTERVAL.rel_value_us); 3087 DHT_SEND_VERIFY_SUCCESSOR_INTERVAL.rel_value_us);*/
3072 send_verify_successor_task = 3088 send_verify_successor_task =
3073 GNUNET_SCHEDULER_add_delayed (verify_successor_next_send_time, 3089 GNUNET_SCHEDULER_add_delayed (verify_successor_next_send_time,
3074 &send_verify_successor_message, 3090 &send_verify_successor_message,
@@ -3108,11 +3124,10 @@ send_verify_successor_message (void *cls,
3108 struct GNUNET_PeerIdentity peer_list[trail_length]; 3124 struct GNUNET_PeerIdentity peer_list[trail_length];
3109 3125
3110 element = trail->trail_head; 3126 element = trail->trail_head;
3111 while (j < trail_length) 3127 for(j = 0; j < trail_length; j++)
3112 { 3128 {
3113 peer_list[j] = element->peer; 3129 peer_list[j] = element->peer;
3114 element = element->next; 3130 element = element->next;
3115 j++;
3116 } 3131 }
3117 3132
3118 GNUNET_assert (NULL != (target_friend = 3133 GNUNET_assert (NULL != (target_friend =
@@ -4578,7 +4593,6 @@ compare_and_update_predecessor (struct GNUNET_PeerIdentity finger,
4578 unsigned int is_predecessor = 1; 4593 unsigned int is_predecessor = 1;
4579 4594
4580 current_predecessor = &finger_table[PREDECESSOR_FINGER_ID]; 4595 current_predecessor = &finger_table[PREDECESSOR_FINGER_ID];
4581
4582 GNUNET_assert (0 != GNUNET_CRYPTO_cmp_peer_identity (&finger, &my_identity)); 4596 GNUNET_assert (0 != GNUNET_CRYPTO_cmp_peer_identity (&finger, &my_identity));
4583 4597
4584 /* No predecessor. Add finger as your predecessor. */ 4598 /* No predecessor. Add finger as your predecessor. */
@@ -4664,7 +4678,6 @@ handle_dht_p2p_verify_successor(void *cls,
4664 successor = vsm->successor; 4678 successor = vsm->successor;
4665 trail = (struct GNUNET_PeerIdentity *)&vsm[1]; 4679 trail = (struct GNUNET_PeerIdentity *)&vsm[1];
4666 4680
4667
4668 /* I am NOT the successor of source_peer. Pass the message to next_hop on 4681 /* I am NOT the successor of source_peer. Pass the message to next_hop on
4669 * the trail. */ 4682 * the trail. */
4670 if(0 != (GNUNET_CRYPTO_cmp_peer_identity (&successor, &my_identity))) 4683 if(0 != (GNUNET_CRYPTO_cmp_peer_identity (&successor, &my_identity)))
@@ -4821,7 +4834,7 @@ compare_and_update_successor (struct GNUNET_PeerIdentity curr_succ,
4821 struct GNUNET_PeerIdentity *trail_me_to_probable_succ; 4834 struct GNUNET_PeerIdentity *trail_me_to_probable_succ;
4822 struct FriendInfo *target_friend; 4835 struct FriendInfo *target_friend;
4823 unsigned int trail_me_to_probable_succ_len; 4836 unsigned int trail_me_to_probable_succ_len;
4824 unsigned int is_predecessor = GNUNET_NO; 4837 unsigned int is_predecessor = 0;
4825 uint64_t successor_value; 4838 uint64_t successor_value;
4826 4839
4827 current_successor = &finger_table[0]; 4840 current_successor = &finger_table[0];
@@ -4829,7 +4842,7 @@ compare_and_update_successor (struct GNUNET_PeerIdentity curr_succ,
4829 4842
4830 /* If probable successor is same as current_successor, do nothing. */ 4843 /* If probable successor is same as current_successor, do nothing. */
4831 if(0 == GNUNET_CRYPTO_cmp_peer_identity (&probable_successor, 4844 if(0 == GNUNET_CRYPTO_cmp_peer_identity (&probable_successor,
4832 &current_successor->finger_identity)) 4845 &current_successor->finger_identity))
4833 return; 4846 return;
4834 4847
4835 closest_peer = select_closest_peer (&probable_successor, 4848 closest_peer = select_closest_peer (&probable_successor,
@@ -4840,8 +4853,6 @@ compare_and_update_successor (struct GNUNET_PeerIdentity curr_succ,
4840 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&closest_peer , 4853 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&closest_peer ,
4841 &current_successor->finger_identity)) 4854 &current_successor->finger_identity))
4842 { 4855 {
4843 /* Code for testing ONLY: Store the successor for path tracking */
4844// track_topology = 1;
4845 if ((NULL != GDS_stats)) 4856 if ((NULL != GDS_stats))
4846 { 4857 {
4847 char *my_id_str; 4858 char *my_id_str;
@@ -4878,9 +4889,6 @@ compare_and_update_successor (struct GNUNET_PeerIdentity curr_succ,
4878 4889
4879 /* Remove the existing successor. */ 4890 /* Remove the existing successor. */
4880 remove_existing_finger (current_successor, 0); 4891 remove_existing_finger (current_successor, 0);
4881
4882 /* TODO URGENT: Check if any peer is present more than once, if yes then shorten
4883 the trail. before sending it across the network. */
4884 /* Generate a new trail id to reach to your new successor. */ 4892 /* Generate a new trail id to reach to your new successor. */
4885 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, 4893 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,
4886 &trail_id, sizeof (trail_id)); 4894 &trail_id, sizeof (trail_id));
@@ -4972,7 +4980,6 @@ handle_dht_p2p_verify_successor_result(void *cls,
4972 probable_successor = vsrm->probable_successor; 4980 probable_successor = vsrm->probable_successor;
4973 current_successor = vsrm->current_successor; 4981 current_successor = vsrm->current_successor;
4974 4982
4975
4976 /* I am the querying_peer. */ 4983 /* I am the querying_peer. */
4977 if(0 == (GNUNET_CRYPTO_cmp_peer_identity (&querying_peer, &my_identity))) 4984 if(0 == (GNUNET_CRYPTO_cmp_peer_identity (&querying_peer, &my_identity)))
4978 { 4985 {
@@ -5057,10 +5064,7 @@ handle_dht_p2p_notify_new_successor(void *cls,
5057 source = nsm->source_peer; 5064 source = nsm->source_peer;
5058 new_successor = nsm->new_successor; 5065 new_successor = nsm->new_successor;
5059 trail_id = nsm->trail_id; 5066 trail_id = nsm->trail_id;
5060 5067
5061
5062 //FIXME: add a check to make sure peer is correct.
5063
5064 /* I am the new_successor to source_peer. */ 5068 /* I am the new_successor to source_peer. */
5065 if ( 0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &new_successor)) 5069 if ( 0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &new_successor))
5066 { 5070 {
@@ -5442,27 +5446,20 @@ handle_dht_p2p_add_trail (void *cls, const struct GNUNET_PeerIdentity *peer,
5442 */ 5446 */
5443static int 5447static int
5444remove_matching_trails (const struct GNUNET_PeerIdentity *disconnected_friend, 5448remove_matching_trails (const struct GNUNET_PeerIdentity *disconnected_friend,
5445 struct FingerInfo *remove_finger) 5449 struct FingerInfo *finger)
5446{ 5450{
5447 unsigned int matching_trails_count; 5451 unsigned int matching_trails_count = 0;
5448 int i; 5452 int i;
5449 5453
5450 /* Number of trails with disconnected_friend as the first hop in the trail
5451 * to reach from me to remove_finger, NOT including endpoints. */
5452 matching_trails_count = 0;
5453
5454 /* Iterate over all the trails of finger. */ 5454 /* Iterate over all the trails of finger. */
5455 for (i = 0; i < remove_finger->trails_count; i++) 5455 for (i = 0; i < finger->trails_count; i++)
5456 { 5456 {
5457 struct Trail *trail; 5457 struct Trail *current_trail;
5458 trail = &remove_finger->trail_list[i]; 5458 current_trail = &finger->trail_list[i];
5459 5459 //FIXME: This assertion fails if we have gap in trail list from o to trails count.
5460 /* This assertion is ensure that there are no gaps in the trail list. 5460 GNUNET_assert (GNUNET_YES == current_trail->is_present);
5461 REMOVE IT AFTERWARDS. */
5462 GNUNET_assert (GNUNET_YES == trail->is_present);
5463
5464 /* First friend to reach to finger is disconnected_peer. */ 5461 /* First friend to reach to finger is disconnected_peer. */
5465 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&trail->trail_head->peer, 5462 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&current_trail->trail_head->peer,
5466 disconnected_friend)) 5463 disconnected_friend))
5467 { 5464 {
5468 struct GNUNET_PeerIdentity *next_hop; 5465 struct GNUNET_PeerIdentity *next_hop;
@@ -5472,27 +5469,22 @@ remove_matching_trails (const struct GNUNET_PeerIdentity *disconnected_friend,
5472 (remove_friend = 5469 (remove_friend =
5473 GNUNET_CONTAINER_multipeermap_get (friend_peermap, 5470 GNUNET_CONTAINER_multipeermap_get (friend_peermap,
5474 disconnected_friend))); 5471 disconnected_friend)));
5475 /* FIXME: removing no but check it. */ 5472 next_hop = GDS_ROUTING_get_next_hop (current_trail->trail_id,
5476 //remove_friend->trails_count--;
5477 next_hop = GDS_ROUTING_get_next_hop (trail->trail_id,
5478 GDS_ROUTING_SRC_TO_DEST); 5473 GDS_ROUTING_SRC_TO_DEST);
5479 5474
5480 /* Here it may happen that as all the peers got disconnected, the entry in 5475 /* Here it may happen that as all the peers got disconnected, the entry in
5481 routing table for that particular trail has been removed, because the 5476 routing table for that particular trail has been removed, because the
5482 previously disconnected peer was either a next hop or prev hop of that 5477 previously disconnected peer was either a next hop or prev hop of that
5483 peer. */ 5478 peer. */
5484 if (NULL == next_hop) 5479 if (NULL != next_hop)
5485 { 5480 {
5486 //TODO UNDERSTAND why do you continue here? 5481 GNUNET_assert (0 == (GNUNET_CRYPTO_cmp_peer_identity (disconnected_friend,
5487 continue;
5488 }
5489 GNUNET_assert (0 == (GNUNET_CRYPTO_cmp_peer_identity (disconnected_friend,
5490 next_hop))); 5482 next_hop)));
5483 GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (current_trail->trail_id));
5484 }
5491 matching_trails_count++; 5485 matching_trails_count++;
5492 GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (trail->trail_id)); 5486 free_trail (current_trail);
5493 5487 current_trail->is_present = GNUNET_NO;
5494 free_trail (trail);
5495 trail->is_present = GNUNET_NO;
5496 } 5488 }
5497 } 5489 }
5498 return matching_trails_count; 5490 return matching_trails_count;
@@ -5514,7 +5506,7 @@ remove_matching_trails (const struct GNUNET_PeerIdentity *disconnected_friend,
5514static void 5506static void
5515remove_matching_fingers (const struct GNUNET_PeerIdentity *disconnected_peer) 5507remove_matching_fingers (const struct GNUNET_PeerIdentity *disconnected_peer)
5516{ 5508{
5517 struct FingerInfo *remove_finger; 5509 struct FingerInfo *current_finger;
5518 struct FriendInfo *remove_friend; 5510 struct FriendInfo *remove_friend;
5519 int removed_trails_count; 5511 int removed_trails_count;
5520 int i; 5512 int i;
@@ -5522,28 +5514,27 @@ remove_matching_fingers (const struct GNUNET_PeerIdentity *disconnected_peer)
5522 /* Iterate over finger table entries. */ 5514 /* Iterate over finger table entries. */
5523 for (i = 0; i < MAX_FINGERS; i++) 5515 for (i = 0; i < MAX_FINGERS; i++)
5524 { 5516 {
5525 remove_finger = &finger_table[i]; 5517 current_finger = &finger_table[i];
5526 5518
5527 /* No finger stored at this trail index. */ 5519 /* No finger stored at this trail index. */
5528 if (GNUNET_NO == remove_finger->is_present) 5520 if (GNUNET_NO == current_finger->is_present)
5529 continue; 5521 continue;
5530 5522
5531 /* I am my own finger, then ignore this finger. */ 5523 /* I am my own finger, then ignore this finger. */
5532 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&remove_finger->finger_identity, 5524 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&current_finger->finger_identity,
5533 &my_identity)) 5525 &my_identity))
5534 continue; 5526 continue;
5535 5527
5536 /* Is disconnected_peer a finger? */ 5528 /* Is disconnected_peer a finger? */
5537 if (0 == GNUNET_CRYPTO_cmp_peer_identity (disconnected_peer, 5529 if (0 == GNUNET_CRYPTO_cmp_peer_identity (disconnected_peer,
5538 &remove_finger->finger_identity)) 5530 &current_finger->finger_identity))
5539 { 5531 {
5540 struct GNUNET_PeerIdentity *next_hop; 5532 struct GNUNET_PeerIdentity *next_hop;
5541 struct GNUNET_HashCode trail_id; 5533 struct GNUNET_HashCode trail_id;
5542 /* FIXME: Just for check, remove it afterwards. Here finger is a friend. 5534
5543 hence trail length should be 0*/ 5535 GNUNET_assert (0 == current_finger->trail_list[0].trail_length);
5544 GNUNET_assert (0 == remove_finger->trail_list[0].trail_length); 5536 GNUNET_assert (GNUNET_YES == (current_finger->trail_list[0].is_present));
5545 GNUNET_assert (GNUNET_YES == (remove_finger->trail_list[0].is_present)); 5537 trail_id = current_finger->trail_list[0].trail_id;
5546 trail_id = remove_finger->trail_list[0].trail_id;
5547 5538
5548 if(NULL != 5539 if(NULL !=
5549 (next_hop = 5540 (next_hop =
@@ -5551,40 +5542,33 @@ remove_matching_fingers (const struct GNUNET_PeerIdentity *disconnected_peer)
5551 { 5542 {
5552 GNUNET_assert (0 == 5543 GNUNET_assert (0 ==
5553 (GNUNET_CRYPTO_cmp_peer_identity (next_hop, 5544 (GNUNET_CRYPTO_cmp_peer_identity (next_hop,
5554 &remove_finger->finger_identity))); 5545 &current_finger->finger_identity)));
5555 GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (trail_id)); 5546 GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (trail_id));
5556 GNUNET_assert (NULL != 5547 GNUNET_assert (NULL !=
5557 (remove_friend = 5548 (remove_friend =
5558 GNUNET_CONTAINER_multipeermap_get (friend_peermap, 5549 GNUNET_CONTAINER_multipeermap_get (friend_peermap,
5559 disconnected_peer))); 5550 disconnected_peer)));
5560 } 5551 }
5561 //TODO should we handle the else case. 5552 current_finger->trail_list[0].is_present = GNUNET_NO;
5562 5553 current_finger->is_present = GNUNET_NO;
5563
5564 remove_finger->trail_list[0].is_present = GNUNET_NO;
5565 //GNUNET_assert (0 != remove_friend->trails_count);
5566 //remove_friend->trails_count--; //FIXME; CHECK WHY IT FAILS AND THEN UNCOMMENT.
5567 remove_finger->is_present = GNUNET_NO;
5568 memset ((void *)&finger_table[i], 0, sizeof (finger_table[i])); 5554 memset ((void *)&finger_table[i], 0, sizeof (finger_table[i]));
5569 continue; 5555 continue;
5570 } 5556 }
5571 5557
5572 /* If finger is a friend but not disconnected_friend, then continue. */ 5558 /* If finger is a friend but not disconnected_friend, then continue. */
5573 if (NULL != GNUNET_CONTAINER_multipeermap_get (friend_peermap, 5559 if (NULL != GNUNET_CONTAINER_multipeermap_get (friend_peermap,
5574 &remove_finger->finger_identity)) 5560 &current_finger->finger_identity))
5575 continue; 5561 continue;
5576 5562
5577 /* Iterate over the list of trails to reach remove_finger. Check if 5563 /* Iterate over the list of trails to reach remove_finger. Check if
5578 * disconnected_friend is the first friend in any of the trail. */ 5564 * disconnected_friend is the first friend in any of the trail. */
5579 removed_trails_count = remove_matching_trails (disconnected_peer, 5565 removed_trails_count = remove_matching_trails (disconnected_peer,
5580 remove_finger); 5566 current_finger);
5581 remove_finger->trails_count = 5567 current_finger->trails_count =
5582 remove_finger->trails_count - removed_trails_count; 5568 current_finger->trails_count - removed_trails_count;
5583 /* All the finger trails had disconnected_friend as the first friend, 5569 if (0 == current_finger->trails_count)
5584 * so free the finger. */
5585 if (remove_finger->trails_count == 0)
5586 { 5570 {
5587 remove_finger->is_present = GNUNET_NO; 5571 current_finger->is_present = GNUNET_NO;
5588 memset ((void *)&finger_table[i], 0, sizeof (finger_table[i])); 5572 memset ((void *)&finger_table[i], 0, sizeof (finger_table[i]));
5589 } 5573 }
5590 } 5574 }
@@ -5614,16 +5598,8 @@ handle_core_disconnect (void *cls,
5614 { 5598 {
5615 DEBUG("\n friend already disconnected."); 5599 DEBUG("\n friend already disconnected.");
5616 } 5600 }
5617
5618 /* Remove fingers with peer as first friend or if peer is a finger. */
5619 remove_matching_fingers (peer); 5601 remove_matching_fingers (peer);
5620
5621 /* Remove any trail from routing table of which peer is a part of. This function
5622 * internally sends a trail teardown message in the direction of which
5623 * disconnected peer is not part of. */
5624 GNUNET_assert (GNUNET_SYSERR != GDS_ROUTING_remove_trail_by_peer (peer)); 5602 GNUNET_assert (GNUNET_SYSERR != GDS_ROUTING_remove_trail_by_peer (peer));
5625
5626 /* Remove peer from friend_peermap. */
5627 GNUNET_assert (GNUNET_YES == 5603 GNUNET_assert (GNUNET_YES ==
5628 GNUNET_CONTAINER_multipeermap_remove (friend_peermap, 5604 GNUNET_CONTAINER_multipeermap_remove (friend_peermap,
5629 peer, 5605 peer,
@@ -5700,10 +5676,6 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer_identity)
5700 if (GNUNET_SCHEDULER_NO_TASK == find_finger_trail_task) 5676 if (GNUNET_SCHEDULER_NO_TASK == find_finger_trail_task)
5701 { 5677 {
5702 DEBUG ("sCHEDULING FINGER TASK"); 5678 DEBUG ("sCHEDULING FINGER TASK");
5703 find_finger_trail_task_next_send_time.rel_value_us =
5704 DHT_FIND_FINGER_TRAIL_INTERVAL.rel_value_us +
5705 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
5706 DHT_FIND_FINGER_TRAIL_INTERVAL.rel_value_us);
5707 find_finger_trail_task = GNUNET_SCHEDULER_add_now (&send_find_finger_trail_message, NULL); 5679 find_finger_trail_task = GNUNET_SCHEDULER_add_now (&send_find_finger_trail_message, NULL);
5708 } 5680 }
5709} 5681}
@@ -5778,7 +5750,17 @@ GDS_NEIGHBOURS_init (void)
5778 //TODO: check size of this peer map? 5750 //TODO: check size of this peer map?
5779 friend_peermap = GNUNET_CONTAINER_multipeermap_create (256, GNUNET_NO); 5751 friend_peermap = GNUNET_CONTAINER_multipeermap_create (256, GNUNET_NO);
5780 finger_table_init (); 5752 finger_table_init ();
5781 5753
5754 find_finger_trail_task_next_send_time.rel_value_us =
5755 DHT_FIND_FINGER_TRAIL_INTERVAL.rel_value_us +
5756 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
5757 DHT_FIND_FINGER_TRAIL_INTERVAL.rel_value_us);
5758
5759 verify_successor_next_send_time.rel_value_us =
5760 DHT_SEND_VERIFY_SUCCESSOR_INTERVAL.rel_value_us +
5761 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
5762 DHT_FIND_FINGER_TRAIL_INTERVAL.rel_value_us);
5763
5782 return GNUNET_OK; 5764 return GNUNET_OK;
5783} 5765}
5784 5766