diff options
author | Supriti Singh <supritisingh08@gmail.com> | 2014-08-04 16:43:15 +0000 |
---|---|---|
committer | Supriti Singh <supritisingh08@gmail.com> | 2014-08-04 16:43:15 +0000 |
commit | 3384da8393563ad9a441df1b63b810a5bb68ce8e (patch) | |
tree | d5ebecdf3bb7fa257588162ed1648fc28a12796c /src | |
parent | 8e5e995d112c5bfb200ed7bf343dfccf010f1680 (diff) | |
download | gnunet-3384da8393563ad9a441df1b63b810a5bb68ce8e.tar.gz gnunet-3384da8393563ad9a441df1b63b810a5bb68ce8e.zip |
xvine:fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/dht/gnunet-service-xdht_neighbours.c | 81 | ||||
-rw-r--r-- | src/dht/gnunet-service-xdht_routing.c | 4 |
2 files changed, 60 insertions, 25 deletions
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c index 9782c3e9c..90e89af08 100644 --- a/src/dht/gnunet-service-xdht_neighbours.c +++ b/src/dht/gnunet-service-xdht_neighbours.c | |||
@@ -93,7 +93,7 @@ | |||
93 | /** | 93 | /** |
94 | * Maximum number of trails stored per finger. | 94 | * Maximum number of trails stored per finger. |
95 | */ | 95 | */ |
96 | #define MAXIMUM_TRAILS_PER_FINGER 4 | 96 | #define MAXIMUM_TRAILS_PER_FINGER 1 |
97 | 97 | ||
98 | /** | 98 | /** |
99 | * Finger map index for predecessor entry in finger table. | 99 | * Finger map index for predecessor entry in finger table. |
@@ -1935,8 +1935,11 @@ compare_finger_and_current_successor (struct Closest_Peer *current_closest_peer) | |||
1935 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&finger->finger_identity, | 1935 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&finger->finger_identity, |
1936 | &my_identity)) | 1936 | &my_identity)) |
1937 | { | 1937 | { |
1938 | GNUNET_break (0); | 1938 | /* FIXME: I think a peer should not select itself as its own identity ever. |
1939 | continue; | 1939 | But it does select. Find out why??*/ |
1940 | //GNUNET_break (0); | ||
1941 | //continue; | ||
1942 | return; | ||
1940 | } | 1943 | } |
1941 | 1944 | ||
1942 | /* If finger is a friend, then do nothing. As we have already checked | 1945 | /* If finger is a friend, then do nothing. As we have already checked |
@@ -2764,10 +2767,14 @@ send_trail_teardown (struct FingerInfo *finger, | |||
2764 | struct FriendInfo *friend; | 2767 | struct FriendInfo *friend; |
2765 | struct GNUNET_PeerIdentity *next_hop; | 2768 | struct GNUNET_PeerIdentity *next_hop; |
2766 | 2769 | ||
2767 | GNUNET_assert (NULL != | 2770 | next_hop = GDS_ROUTING_get_next_hop (trail->trail_id, |
2768 | (next_hop = GDS_ROUTING_get_next_hop (trail->trail_id, | 2771 | GDS_ROUTING_SRC_TO_DEST); |
2769 | GDS_ROUTING_SRC_TO_DEST))); | 2772 | |
2770 | 2773 | if (NULL == next_hop) | |
2774 | { | ||
2775 | GNUNET_break(0); | ||
2776 | return; | ||
2777 | } | ||
2771 | GNUNET_assert (0 != GNUNET_CRYPTO_cmp_peer_identity (&finger->finger_identity, | 2778 | GNUNET_assert (0 != GNUNET_CRYPTO_cmp_peer_identity (&finger->finger_identity, |
2772 | &my_identity)); | 2779 | &my_identity)); |
2773 | 2780 | ||
@@ -3880,13 +3887,18 @@ get_local_best_known_next_hop (uint64_t final_dest_finger_val, | |||
3880 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (current_dest, closest_peer)) | 3887 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (current_dest, closest_peer)) |
3881 | { | 3888 | { |
3882 | struct GNUNET_PeerIdentity *next_hop; | 3889 | struct GNUNET_PeerIdentity *next_hop; |
3890 | |||
3883 | next_hop = GDS_ROUTING_get_next_hop (intermediate_trail_id, | 3891 | next_hop = GDS_ROUTING_get_next_hop (intermediate_trail_id, |
3884 | GDS_ROUTING_SRC_TO_DEST); | 3892 | GDS_ROUTING_SRC_TO_DEST); |
3885 | GNUNET_assert (NULL != next_hop); | 3893 | /* It may happen that trail teardown message got delayed and hence, |
3886 | 3894 | the previous hop sent the message over intermediate trail id.In that | |
3887 | peer.next_hop = *next_hop; | 3895 | case next_hop could be NULL. */ |
3888 | peer.best_known_destination = *current_dest; | 3896 | if(NULL != next_hop) |
3889 | peer.trail_id = intermediate_trail_id; | 3897 | { |
3898 | peer.next_hop = *next_hop; | ||
3899 | peer.best_known_destination = *current_dest; | ||
3900 | peer.trail_id = intermediate_trail_id; | ||
3901 | } | ||
3890 | } | 3902 | } |
3891 | } | 3903 | } |
3892 | return peer; | 3904 | return peer; |
@@ -4367,10 +4379,18 @@ get_trail_src_to_curr_pred (struct GNUNET_PeerIdentity source_peer, | |||
4367 | trail_me_to_curr_pred = get_shortest_trail (current_predecessor, | 4379 | trail_me_to_curr_pred = get_shortest_trail (current_predecessor, |
4368 | &trail_me_to_curr_pred_length); | 4380 | &trail_me_to_curr_pred_length); |
4369 | 4381 | ||
4382 | if ((trail_me_to_curr_pred_length == 1) && | ||
4383 | (0 == GNUNET_CRYPTO_cmp_peer_identity (&source_peer, | ||
4384 | &trail_me_to_curr_pred[0]))) | ||
4385 | { | ||
4386 | *trail_src_to_curr_pred_length = 0; | ||
4387 | return NULL; | ||
4388 | } | ||
4389 | |||
4370 | /* Check if trail_me_to_curr_pred contains source. */ | 4390 | /* Check if trail_me_to_curr_pred contains source. */ |
4371 | if (trail_me_to_curr_pred_length > 0) | 4391 | if (trail_me_to_curr_pred_length > 1) |
4372 | { | 4392 | { |
4373 | for(i = trail_me_to_curr_pred_length - 1; i >= 0; i--) | 4393 | for(i = trail_me_to_curr_pred_length - 1; i > 0; i--) |
4374 | { | 4394 | { |
4375 | if(0 != GNUNET_CRYPTO_cmp_peer_identity (&source_peer, | 4395 | if(0 != GNUNET_CRYPTO_cmp_peer_identity (&source_peer, |
4376 | &trail_me_to_curr_pred[i])) | 4396 | &trail_me_to_curr_pred[i])) |
@@ -4385,7 +4405,8 @@ get_trail_src_to_curr_pred (struct GNUNET_PeerIdentity source_peer, | |||
4385 | *trail_src_to_curr_pred_length = 0; | 4405 | *trail_src_to_curr_pred_length = 0; |
4386 | return NULL; | 4406 | return NULL; |
4387 | } | 4407 | } |
4388 | 4408 | ||
4409 | |||
4389 | *trail_src_to_curr_pred_length = trail_me_to_curr_pred_length - i; | 4410 | *trail_src_to_curr_pred_length = trail_me_to_curr_pred_length - i; |
4390 | trail_src_to_curr_pred = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity)* | 4411 | trail_src_to_curr_pred = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity)* |
4391 | *trail_src_to_curr_pred_length); | 4412 | *trail_src_to_curr_pred_length); |
@@ -4393,7 +4414,6 @@ get_trail_src_to_curr_pred (struct GNUNET_PeerIdentity source_peer, | |||
4393 | { | 4414 | { |
4394 | trail_src_to_curr_pred[j] = trail_me_to_curr_pred[i]; | 4415 | trail_src_to_curr_pred[j] = trail_me_to_curr_pred[i]; |
4395 | } | 4416 | } |
4396 | |||
4397 | return trail_src_to_curr_pred; | 4417 | return trail_src_to_curr_pred; |
4398 | } | 4418 | } |
4399 | } | 4419 | } |
@@ -4594,15 +4614,20 @@ handle_dht_p2p_verify_successor(void *cls, | |||
4594 | if(0 != (GNUNET_CRYPTO_cmp_peer_identity (&successor, &my_identity))) | 4614 | if(0 != (GNUNET_CRYPTO_cmp_peer_identity (&successor, &my_identity))) |
4595 | { | 4615 | { |
4596 | next_hop = GDS_ROUTING_get_next_hop (trail_id, GDS_ROUTING_SRC_TO_DEST); | 4616 | next_hop = GDS_ROUTING_get_next_hop (trail_id, GDS_ROUTING_SRC_TO_DEST); |
4617 | |||
4597 | if (NULL == next_hop) | 4618 | if (NULL == next_hop) |
4598 | { | 4619 | { |
4599 | GNUNET_break (0); | 4620 | GNUNET_break_op (0); |
4600 | return GNUNET_SYSERR; | 4621 | return GNUNET_SYSERR; |
4601 | } | 4622 | } |
4602 | GNUNET_assert (NULL != | ||
4603 | (target_friend = | ||
4604 | GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop))); | ||
4605 | 4623 | ||
4624 | target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop); | ||
4625 | |||
4626 | if(NULL == target_friend) | ||
4627 | { | ||
4628 | GNUNET_break_op(0); | ||
4629 | return GNUNET_OK; | ||
4630 | } | ||
4606 | GDS_NEIGHBOURS_send_verify_successor_message (source_peer, successor, | 4631 | GDS_NEIGHBOURS_send_verify_successor_message (source_peer, successor, |
4607 | trail_id, trail, trail_length, | 4632 | trail_id, trail, trail_length, |
4608 | target_friend); | 4633 | target_friend); |
@@ -4636,7 +4661,7 @@ handle_dht_p2p_verify_successor(void *cls, | |||
4636 | } | 4661 | } |
4637 | 4662 | ||
4638 | } | 4663 | } |
4639 | 4664 | ||
4640 | GNUNET_assert (NULL != | 4665 | GNUNET_assert (NULL != |
4641 | (target_friend = | 4666 | (target_friend = |
4642 | GNUNET_CONTAINER_multipeermap_get (friend_peermap, peer))); | 4667 | GNUNET_CONTAINER_multipeermap_get (friend_peermap, peer))); |
@@ -4747,6 +4772,7 @@ compare_and_update_successor (struct GNUNET_PeerIdentity curr_succ, | |||
4747 | * | 4772 | * |
4748 | * FIXME closest_peer is being overwritten just after the if | 4773 | * FIXME closest_peer is being overwritten just after the if |
4749 | */ | 4774 | */ |
4775 | #if 0 | ||
4750 | if(0 != GNUNET_CRYPTO_cmp_peer_identity(&curr_succ, ¤t_successor->finger_identity)) | 4776 | if(0 != GNUNET_CRYPTO_cmp_peer_identity(&curr_succ, ¤t_successor->finger_identity)) |
4751 | { | 4777 | { |
4752 | /* We could have added this new successor, only if it was closer the old one. */ | 4778 | /* We could have added this new successor, only if it was closer the old one. */ |
@@ -4761,6 +4787,7 @@ compare_and_update_successor (struct GNUNET_PeerIdentity curr_succ, | |||
4761 | ¤t_successor->finger_identity));*/ | 4787 | ¤t_successor->finger_identity));*/ |
4762 | 4788 | ||
4763 | } | 4789 | } |
4790 | #endif | ||
4764 | 4791 | ||
4765 | closest_peer = select_closest_peer (&probable_successor, | 4792 | closest_peer = select_closest_peer (&probable_successor, |
4766 | ¤t_successor->finger_identity, | 4793 | ¤t_successor->finger_identity, |
@@ -4772,12 +4799,16 @@ compare_and_update_successor (struct GNUNET_PeerIdentity curr_succ, | |||
4772 | 4799 | ||
4773 | /* Probable successor is the closest peer.*/ | 4800 | /* Probable successor is the closest peer.*/ |
4774 | if(trail_length > 0) | 4801 | if(trail_length > 0) |
4802 | { | ||
4775 | GNUNET_assert(NULL != GNUNET_CONTAINER_multipeermap_get(friend_peermap, | 4803 | GNUNET_assert(NULL != GNUNET_CONTAINER_multipeermap_get(friend_peermap, |
4776 | &trail[0])); | 4804 | &trail[0])); |
4805 | } | ||
4777 | else | 4806 | else |
4807 | { | ||
4778 | GNUNET_assert(NULL != GNUNET_CONTAINER_multipeermap_get(friend_peermap, | 4808 | GNUNET_assert(NULL != GNUNET_CONTAINER_multipeermap_get(friend_peermap, |
4779 | &probable_successor)); | 4809 | &probable_successor)); |
4780 | 4810 | } | |
4811 | |||
4781 | trail_me_to_probable_succ_len = 0; | 4812 | trail_me_to_probable_succ_len = 0; |
4782 | /* TODO: Check if the path to reach to probable successor contains a friend. */ | 4813 | /* TODO: Check if the path to reach to probable successor contains a friend. */ |
4783 | trail_me_to_probable_succ = | 4814 | trail_me_to_probable_succ = |
@@ -4822,6 +4853,8 @@ compare_and_update_successor (struct GNUNET_PeerIdentity curr_succ, | |||
4822 | 4853 | ||
4823 | 4854 | ||
4824 | /* | 4855 | /* |
4856 | * FIXME: Check for duplicate elements everywhere when you are making | ||
4857 | * trails. | ||
4825 | * Core handle for p2p verify successor result messages. | 4858 | * Core handle for p2p verify successor result messages. |
4826 | * @param cls closure | 4859 | * @param cls closure |
4827 | * @param message message | 4860 | * @param message message |
@@ -4879,7 +4912,7 @@ handle_dht_p2p_verify_successor_result(void *cls, | |||
4879 | probable_successor, trail, trail_length); | 4912 | probable_successor, trail, trail_length); |
4880 | return GNUNET_OK; | 4913 | return GNUNET_OK; |
4881 | } | 4914 | } |
4882 | 4915 | ||
4883 | /*If you are not the querying peer then pass on the message */ | 4916 | /*If you are not the querying peer then pass on the message */ |
4884 | GNUNET_assert (NULL != (next_hop = | 4917 | GNUNET_assert (NULL != (next_hop = |
4885 | GDS_ROUTING_get_next_hop (trail_id, trail_direction))); | 4918 | GDS_ROUTING_get_next_hop (trail_id, trail_direction))); |
diff --git a/src/dht/gnunet-service-xdht_routing.c b/src/dht/gnunet-service-xdht_routing.c index eaaa606bb..de5255cb7 100644 --- a/src/dht/gnunet-service-xdht_routing.c +++ b/src/dht/gnunet-service-xdht_routing.c | |||
@@ -251,7 +251,9 @@ GDS_ROUTING_test_print (void) | |||
251 | struct GNUNET_HashCode key_ret; | 251 | struct GNUNET_HashCode key_ret; |
252 | int i; | 252 | int i; |
253 | 253 | ||
254 | FPRINTF (stderr,_("\nSUPU ***PRINTING ROUTING TABLE *****")); | 254 | struct GNUNET_PeerIdentity my_identity = GDS_NEIGHBOURS_get_my_id(); |
255 | print_peer = my_identity; | ||
256 | FPRINTF (stderr,_("\nSUPU ***PRINTING ROUTING TABLE ***** of =%s"),GNUNET_i2s(&print_peer)); | ||
255 | iter =GNUNET_CONTAINER_multihashmap_iterator_create (routing_table); | 257 | iter =GNUNET_CONTAINER_multihashmap_iterator_create (routing_table); |
256 | for (i = 0; i < GNUNET_CONTAINER_multihashmap_size(routing_table); i++) | 258 | for (i = 0; i < GNUNET_CONTAINER_multihashmap_size(routing_table); i++) |
257 | { | 259 | { |