aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-xdht_neighbours.c
diff options
context:
space:
mode:
authorSupriti Singh <supritisingh08@gmail.com>2014-08-22 18:52:32 +0000
committerSupriti Singh <supritisingh08@gmail.com>2014-08-22 18:52:32 +0000
commit2a6e6217e5ffb1470bd0db7c7841231f9b3d0af8 (patch)
treec35b260d2055d47bd309b71ab215e46b72ac6df4 /src/dht/gnunet-service-xdht_neighbours.c
parent58a5314f452ed35b7a71988efca8c9419e6ca5ba (diff)
downloadgnunet-2a6e6217e5ffb1470bd0db7c7841231f9b3d0af8.tar.gz
gnunet-2a6e6217e5ffb1470bd0db7c7841231f9b3d0af8.zip
Waiting for verify successor result and timing out if result not received in some time
Diffstat (limited to 'src/dht/gnunet-service-xdht_neighbours.c')
-rw-r--r--src/dht/gnunet-service-xdht_neighbours.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c
index dd6dc93fc..70d3e74d2 100644
--- a/src/dht/gnunet-service-xdht_neighbours.c
+++ b/src/dht/gnunet-service-xdht_neighbours.c
@@ -83,6 +83,11 @@
83#define DHT_SEND_VERIFY_SUCCESSOR_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) 83#define DHT_SEND_VERIFY_SUCCESSOR_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
84 84
85/** 85/**
86 * How long to wait before sending another verify successor message.
87 */
88#define DHT_SEND_VERIFY_SUCCESSOR_RETRY_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
89
90/**
86 * How long at most to wait for transmission of a request to a friend ? 91 * How long at most to wait for transmission of a request to a friend ?
87 */ 92 */
88#define PENDING_MESSAGE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2) 93#define PENDING_MESSAGE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2)
@@ -854,6 +859,12 @@ static GNUNET_SCHEDULER_TaskIdentifier find_finger_trail_task;
854static GNUNET_SCHEDULER_TaskIdentifier send_verify_successor_task; 859static GNUNET_SCHEDULER_TaskIdentifier send_verify_successor_task;
855 860
856/** 861/**
862 * Task that sends verify successor message. This task is started when we get
863 * our successor for the first time.
864 */
865static GNUNET_SCHEDULER_TaskIdentifier send_verify_successor_retry_task;
866
867/**
857 * Identity of this peer. 868 * Identity of this peer.
858 */ 869 */
859static struct GNUNET_PeerIdentity my_identity; 870static struct GNUNET_PeerIdentity my_identity;
@@ -897,6 +908,11 @@ static struct GNUNET_TIME_Relative find_finger_trail_task_next_send_time;
897static struct GNUNET_TIME_Relative verify_successor_next_send_time; 908static struct GNUNET_TIME_Relative verify_successor_next_send_time;
898 909
899/** 910/**
911 * Time duration to send verify successor again, if result was not received in time.
912 */
913static struct GNUNET_TIME_Relative verify_successor_retry_time;
914
915/**
900 * Are we waiting for confirmation from our new successor that it got the 916 * Are we waiting for confirmation from our new successor that it got the
901 * message 917 * message
902 */ 918 */
@@ -2701,7 +2717,6 @@ select_and_replace_trail (struct FingerInfo *finger,
2701 /* Send trail teardown message across the replaced trail. */ 2717 /* Send trail teardown message across the replaced trail. */
2702 struct Trail *replace_trail = &finger->trail_list[largest_trail_index]; 2718 struct Trail *replace_trail = &finger->trail_list[largest_trail_index];
2703 next_hop = GDS_ROUTING_get_next_hop (replace_trail->trail_id, GDS_ROUTING_SRC_TO_DEST); 2719 next_hop = GDS_ROUTING_get_next_hop (replace_trail->trail_id, GDS_ROUTING_SRC_TO_DEST);
2704 FPRINTF (stderr,_("\nSUPU %s, %s, %d, REMOVE trail id = %s"),__FILE__, __func__,__LINE__,GNUNET_h2s(&replace_trail->trail_id));
2705 GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (replace_trail->trail_id)); 2720 GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (replace_trail->trail_id));
2706 GDS_NEIGHBOURS_send_trail_teardown (replace_trail->trail_id, 2721 GDS_NEIGHBOURS_send_trail_teardown (replace_trail->trail_id,
2707 GDS_ROUTING_SRC_TO_DEST, 2722 GDS_ROUTING_SRC_TO_DEST,
@@ -3154,8 +3169,8 @@ send_verify_successor_message (void *cls,
3154 struct FingerInfo *successor; 3169 struct FingerInfo *successor;
3155 3170
3156 /* After one round of verify successor, we do back off. */ 3171 /* After one round of verify successor, we do back off. */
3157 send_verify_successor_task = 3172 send_verify_successor_retry_task =
3158 GNUNET_SCHEDULER_add_delayed (verify_successor_next_send_time, 3173 GNUNET_SCHEDULER_add_delayed (verify_successor_retry_time,
3159 &send_verify_successor_message, 3174 &send_verify_successor_message,
3160 NULL); 3175 NULL);
3161 successor = &finger_table[0]; 3176 successor = &finger_table[0];
@@ -3645,7 +3660,8 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer,
3645 3660
3646 /* Add yourself to the list. */ 3661 /* Add yourself to the list. */
3647 struct GNUNET_PeerIdentity pp[putlen + 1]; 3662 struct GNUNET_PeerIdentity pp[putlen + 1];
3648 if (0 != (options & GNUNET_DHT_RO_RECORD_ROUTE)) 3663 //if (0 != (options & GNUNET_DHT_RO_RECORD_ROUTE))
3664 if (1)
3649 { 3665 {
3650 memcpy (pp, put_path, putlen * sizeof (struct GNUNET_PeerIdentity)); 3666 memcpy (pp, put_path, putlen * sizeof (struct GNUNET_PeerIdentity));
3651 pp[putlen] = my_identity; 3667 pp[putlen] = my_identity;
@@ -4806,6 +4822,8 @@ handle_dht_p2p_verify_successor(void *cls,
4806// } 4822// }
4807// else 4823// else
4808// *next_hop = trail[my_index + 1]; 4824// *next_hop = trail[my_index + 1];
4825
4826 return GNUNET_OK;
4809 } 4827 }
4810 4828
4811 target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop); 4829 target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop);
@@ -5070,7 +5088,7 @@ handle_dht_p2p_verify_successor_result(void *cls,
5070 const struct GNUNET_PeerIdentity *trail; 5088 const struct GNUNET_PeerIdentity *trail;
5071 unsigned int trail_length; 5089 unsigned int trail_length;
5072 size_t msize; 5090 size_t msize;
5073 5091
5074 msize = ntohs (message->size); 5092 msize = ntohs (message->size);
5075 if (msize < sizeof (struct PeerVerifySuccessorResultMessage)) 5093 if (msize < sizeof (struct PeerVerifySuccessorResultMessage))
5076 { 5094 {
@@ -5106,8 +5124,17 @@ handle_dht_p2p_verify_successor_result(void *cls,
5106 /* As we completed one round of verify successor, we can do backoff. */ 5124 /* As we completed one round of verify successor, we can do backoff. */
5107// verify_successor_next_send_time = 5125// verify_successor_next_send_time =
5108// GNUNET_TIME_STD_BACKOFF(verify_successor_next_send_time); 5126// GNUNET_TIME_STD_BACKOFF(verify_successor_next_send_time);
5127
5128 // Cancel Retry Task
5129 GNUNET_SCHEDULER_cancel(send_verify_successor_retry_task);
5130
5109 compare_and_update_successor (current_successor, 5131 compare_and_update_successor (current_successor,
5110 probable_successor, trail, trail_length); 5132 probable_successor, trail, trail_length);
5133
5134 // Schedule send_verify_successor_task in appropriate time.
5135 send_verify_successor_task = GNUNET_SCHEDULER_add_delayed(verify_successor_next_send_time,
5136 send_verify_successor_message, NULL);
5137
5111 return GNUNET_OK; 5138 return GNUNET_OK;
5112 } 5139 }
5113 5140
@@ -5939,6 +5966,11 @@ GDS_NEIGHBOURS_init (void)
5939 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 5966 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
5940 DHT_SEND_VERIFY_SUCCESSOR_INTERVAL.rel_value_us); 5967 DHT_SEND_VERIFY_SUCCESSOR_INTERVAL.rel_value_us);
5941 5968
5969 verify_successor_retry_time.rel_value_us =
5970 DHT_SEND_VERIFY_SUCCESSOR_RETRY_INTERVAL.rel_value_us +
5971 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
5972 DHT_SEND_VERIFY_SUCCESSOR_RETRY_INTERVAL.rel_value_us);
5973
5942 return GNUNET_OK; 5974 return GNUNET_OK;
5943} 5975}
5944 5976