aboutsummaryrefslogtreecommitdiff
path: root/src/dht
diff options
context:
space:
mode:
authorSupriti Singh <supritisingh08@gmail.com>2014-05-13 09:51:26 +0000
committerSupriti Singh <supritisingh08@gmail.com>2014-05-13 09:51:26 +0000
commitb1856eb6106acf8bb75491b8c595ad2e482b561b (patch)
tree1cc9bdcb323d05dbef3f8b111b3fa21e2683cdb0 /src/dht
parentabcbf9e80d3e702dc225bd4a78a100c14a3826c1 (diff)
downloadgnunet-b1856eb6106acf8bb75491b8c595ad2e482b561b.tar.gz
gnunet-b1856eb6106acf8bb75491b8c595ad2e482b561b.zip
- Changing send_verify_successor_message to a function call from a periodic task
- Fixing the return value in case I am destination in find_successor() - Refactoring of finger_table_add()
Diffstat (limited to 'src/dht')
-rw-r--r--src/dht/gnunet-service-xdht_neighbours.c316
1 files changed, 143 insertions, 173 deletions
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c
index 309e1287c..77eba79d3 100644
--- a/src/dht/gnunet-service-xdht_neighbours.c
+++ b/src/dht/gnunet-service-xdht_neighbours.c
@@ -712,12 +712,6 @@ struct Sorting_List
712static GNUNET_SCHEDULER_TaskIdentifier find_finger_trail_task; 712static GNUNET_SCHEDULER_TaskIdentifier find_finger_trail_task;
713 713
714/** 714/**
715 * Task that periodically verifies my successor. This task is started when we
716 * have found our successor.
717 */
718static GNUNET_SCHEDULER_TaskIdentifier verify_successor;
719
720/**
721 * Identity of this peer. 715 * Identity of this peer.
722 */ 716 */
723static struct GNUNET_PeerIdentity my_identity; 717static struct GNUNET_PeerIdentity my_identity;
@@ -1457,16 +1451,11 @@ compute_predecessor_identity()
1457 1451
1458 1452
1459/** 1453/**
1460 * Periodically ping your successor to ask its current predecessor 1454 * Ping your successor to verify if it is still your successor or not.
1461 *
1462 * @param cls closure for this task
1463 * @param tc the context under which the task is running
1464 */ 1455 */
1465static void 1456static void
1466send_verify_successor_message (void *cls, 1457send_verify_successor_message()
1467 const struct GNUNET_SCHEDULER_TaskContext *tc )
1468{ 1458{
1469 struct GNUNET_TIME_Relative next_send_time;
1470 struct GNUNET_CONTAINER_MultiPeerMapIterator *finger_iter; 1459 struct GNUNET_CONTAINER_MultiPeerMapIterator *finger_iter;
1471 struct GNUNET_PeerIdentity key_ret; 1460 struct GNUNET_PeerIdentity key_ret;
1472 struct FriendInfo *target_friend; 1461 struct FriendInfo *target_friend;
@@ -1492,9 +1481,12 @@ send_verify_successor_message (void *cls,
1492 } 1481 }
1493 GNUNET_CONTAINER_multipeermap_iterator_destroy (finger_iter); 1482 GNUNET_CONTAINER_multipeermap_iterator_destroy (finger_iter);
1494 1483
1495 if( flag == 0) 1484 /* Either you don't have a successor or you are your own successor, then don't
1485 send a successor message. */
1486 if(( flag == 0) ||
1487 (0 == GNUNET_CRYPTO_cmp_peer_identity(&my_identity, &(finger->finger_identity))))
1496 { 1488 {
1497 goto send_new_request; 1489 return;
1498 } 1490 }
1499 1491
1500 if (finger->first_trail_length > 0) 1492 if (finger->first_trail_length > 0)
@@ -1526,17 +1518,7 @@ send_verify_successor_message (void *cls,
1526 &(finger->finger_identity), 1518 &(finger->finger_identity),
1527 target_friend, 1519 target_friend,
1528 peer_list, 1520 peer_list,
1529 finger->first_trail_length); 1521 finger->first_trail_length);
1530
1531 send_new_request:
1532 next_send_time.rel_value_us =
1533 DHT_FIND_FINGER_TRAIL_INTERVAL.rel_value_us +
1534 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
1535 DHT_FIND_FINGER_TRAIL_INTERVAL.rel_value_us);
1536
1537 verify_successor =
1538 GNUNET_SCHEDULER_add_delayed (next_send_time, &send_verify_successor_message,
1539 NULL);
1540} 1522}
1541 1523
1542 1524
@@ -1591,7 +1573,7 @@ send_find_finger_trail_message (void *cls,
1591 { 1573 {
1592 finger_identity = compute_finger_identity(); 1574 finger_identity = compute_finger_identity();
1593 } 1575 }
1594 1576
1595 finger_map_index = current_search_finger_index; 1577 finger_map_index = current_search_finger_index;
1596 GDS_NEIGHBOURS_send_trail_setup (&my_identity, finger_identity, &(target_friend->id), 1578 GDS_NEIGHBOURS_send_trail_setup (&my_identity, finger_identity, &(target_friend->id),
1597 &my_identity, target_friend, 0, NULL, finger_map_index); 1579 &my_identity, target_friend, 0, NULL, finger_map_index);
@@ -1986,7 +1968,6 @@ int select_closest_finger (struct FingerInfo *existing_finger,
1986 unsigned int trail_length, 1968 unsigned int trail_length,
1987 unsigned int finger_map_index) 1969 unsigned int finger_map_index)
1988{ 1970{
1989
1990 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&(existing_finger->finger_identity), new_finger)) 1971 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&(existing_finger->finger_identity), new_finger))
1991 { 1972 {
1992 /* Both the new entry and existing entry are same. */ 1973 /* Both the new entry and existing entry are same. */
@@ -2082,7 +2063,7 @@ compare_and_update_predecessor (const struct GNUNET_PeerIdentity *peer,
2082 } 2063 }
2083 } 2064 }
2084 GNUNET_CONTAINER_multipeermap_iterator_destroy (finger_iter); 2065 GNUNET_CONTAINER_multipeermap_iterator_destroy (finger_iter);
2085 2066
2086 new_finger_entry = GNUNET_malloc (sizeof (struct FingerInfo)); 2067 new_finger_entry = GNUNET_malloc (sizeof (struct FingerInfo));
2087 memcpy (&(new_finger_entry->finger_identity), peer, sizeof (struct GNUNET_PeerIdentity)); 2068 memcpy (&(new_finger_entry->finger_identity), peer, sizeof (struct GNUNET_PeerIdentity));
2088 new_finger_entry->finger_map_index = PREDECESSOR_FINGER_ID; 2069 new_finger_entry->finger_map_index = PREDECESSOR_FINGER_ID;
@@ -2186,56 +2167,23 @@ compare_new_entry_and_successor (const struct GNUNET_PeerIdentity *new_finger,
2186 2167
2187 2168
2188/** 2169/**
2189 * FIXME: ensure that function sending finger_table_add checks if source and your 2170 * Add a new entry in finger table.
2190 * identity is same, if yes then set trail_list to NULL and trail length = 0. 2171 * @param finger_identity PeerIdentity of the new finger
2191 * Add an entry in the finger table. If there is already an existing entry in 2172 * @param finger_trail Trail to reach to the finger, can be NULL in case I am my own
2192 * the finger peermap for given finger map index, then choose the closest one. 2173 * finger.
2193 * In case both the new entry and old entry are same, store both of them. (Redundant 2174 * @param finger_trail_length Number of peers in the trail, can be 0 in case finger
2194 * routing). 2175 * is a friend or I am my own finger.
2195 * @param finger_identity 2176 * @param finger_map_index Index in finger map.
2196 * @param finger_trail
2197 * @param finger_trail_length
2198 * @param finger_map_index
2199 * @return #GNUNET_YES if the new entry is added.
2200 * #GNUNET_NO if the new entry is discarded.
2201 */ 2177 */
2202static 2178static int
2203int finger_table_add (const struct GNUNET_PeerIdentity *finger_identity, 2179add_new_entry (const struct GNUNET_PeerIdentity *finger_identity,
2204 struct GNUNET_PeerIdentity *finger_trail, 2180 struct GNUNET_PeerIdentity *finger_trail,
2205 uint32_t finger_trail_length, 2181 uint32_t finger_trail_length,
2206 uint32_t finger_map_index) 2182 uint32_t finger_map_index)
2207{ 2183{
2208 struct FingerInfo *new_finger_entry;
2209 struct FingerInfo *existing_finger;
2210 struct FriendInfo *first_friend_trail; 2184 struct FriendInfo *first_friend_trail;
2211 struct GNUNET_CONTAINER_MultiPeerMapIterator *finger_iter; 2185 struct FingerInfo *new_finger_entry;
2212 int new_entry_added_flag = 0;
2213 int i; 2186 int i;
2214
2215 if (PREDECESSOR_FINGER_ID == finger_map_index)
2216 {
2217 compare_and_update_predecessor (finger_identity, finger_trail, finger_trail_length);
2218 goto update_current_search_finger_index;
2219 }
2220
2221 /* Check if there is already an entry for the finger map index in the finger peer map. */
2222 finger_iter = GNUNET_CONTAINER_multipeermap_iterator_create (finger_peermap);
2223 for (i= 0; i < GNUNET_CONTAINER_multipeermap_size (finger_peermap); i++)
2224 {
2225 if(GNUNET_YES == GNUNET_CONTAINER_multipeermap_iterator_next (finger_iter, NULL,
2226 (const void **)&existing_finger))
2227 {
2228 if (existing_finger->finger_map_index == finger_map_index)
2229 {
2230 if ( GNUNET_NO == select_closest_finger (existing_finger, finger_identity,
2231 finger_trail, finger_trail_length,finger_map_index))
2232 goto update_current_search_finger_index;
2233 else
2234 break;
2235 }
2236 }
2237 }
2238 GNUNET_CONTAINER_multipeermap_iterator_destroy (finger_iter);
2239 2187
2240 /* Add a new entry. */ 2188 /* Add a new entry. */
2241 new_finger_entry = GNUNET_malloc (sizeof (struct FingerInfo)); 2189 new_finger_entry = GNUNET_malloc (sizeof (struct FingerInfo));
@@ -2246,8 +2194,6 @@ int finger_table_add (const struct GNUNET_PeerIdentity *finger_identity,
2246 2194
2247 if (finger_trail != NULL) /* finger_trail is NULL in case I am my own finger identity. */ 2195 if (finger_trail != NULL) /* finger_trail is NULL in case I am my own finger identity. */
2248 { 2196 {
2249 /* FIXME: Currently we are not handling the second trail. In that case, finger
2250 trail count = min (first_friend, second_friend) trail count. */
2251 /* Incrementing the friend trails count. */ 2197 /* Incrementing the friend trails count. */
2252 if (finger_trail_length > 0) 2198 if (finger_trail_length > 0)
2253 { 2199 {
@@ -2276,21 +2222,74 @@ int finger_table_add (const struct GNUNET_PeerIdentity *finger_identity,
2276 i++; 2222 i++;
2277 } 2223 }
2278 } 2224 }
2225
2226 return GNUNET_CONTAINER_multipeermap_put (finger_peermap,
2227 &(new_finger_entry->finger_identity),
2228 new_finger_entry,
2229 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
2230}
2231
2232
2233/**
2234 * 1. removed predecessor_finger_id check as in select_closest_finger we check it
2235 * and handle it accordingly.
2236 * 2. you don't handle the second trail here as in new entry you will have only
2237 * one trail to reach to the finger.
2238 * 3. check how do you handle the return value of this function.
2239 * FIXME: Functions calling finger_table_add will not check if finger identity
2240 * and my identity are same, it should be done in this function.
2241 * Add an entry in the finger table. If there is already an existing entry in
2242 * the finger peermap for given finger map index, then choose the closest one.
2243 * In case both the new entry and old entry are same, store both of them. (Redundant
2244 * routing).
2245 * @param finger_identity
2246 * @param finger_trail
2247 * @param finger_trail_length
2248 * @param finger_map_index
2249 * @return #GNUNET_YES if the new entry is added.
2250 * #GNUNET_NO if the new entry is discarded.
2251 */
2252static
2253int finger_table_add (const struct GNUNET_PeerIdentity *finger_identity,
2254 struct GNUNET_PeerIdentity *finger_trail,
2255 uint32_t finger_trail_length,
2256 uint32_t finger_map_index)
2257{
2258 struct FingerInfo *existing_finger;
2259 struct GNUNET_CONTAINER_MultiPeerMapIterator *finger_iter;
2260 int i;
2261 int new_entry_added = GNUNET_NO;
2262
2263 /* Check if there is already an entry for the finger map index in the finger peer map. */
2264 finger_iter = GNUNET_CONTAINER_multipeermap_iterator_create (finger_peermap);
2265 for (i= 0; i < GNUNET_CONTAINER_multipeermap_size (finger_peermap); i++)
2266 {
2267 if(GNUNET_YES == GNUNET_CONTAINER_multipeermap_iterator_next (finger_iter, NULL,
2268 (const void **)&existing_finger))
2269 {
2270 if (existing_finger->finger_map_index == finger_map_index)
2271 {
2272 if ( GNUNET_NO == select_closest_finger (existing_finger, finger_identity,
2273 finger_trail, finger_trail_length,finger_map_index))
2274 goto update_current_search_finger_index;
2275 else
2276 break;
2277 }
2278 }
2279 }
2280 GNUNET_CONTAINER_multipeermap_iterator_destroy (finger_iter);
2279 2281
2280 new_entry_added_flag = 1; 2282 if(GNUNET_OK == add_new_entry (finger_identity,finger_trail,finger_trail_length, finger_map_index))
2281 GNUNET_assert (GNUNET_OK == 2283 new_entry_added = GNUNET_YES;
2282 GNUNET_CONTAINER_multipeermap_put (finger_peermap, 2284 else
2283 &(new_finger_entry->finger_identity), 2285 return GNUNET_NO;
2284 new_finger_entry,
2285 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
2286 2286
2287 /* Update the value of current_search_finger_index. */
2288 update_current_search_finger_index: 2287 update_current_search_finger_index:
2289 if (0 == finger_map_index ) 2288 if (0 == finger_map_index)
2290 { 2289 {
2291 current_search_finger_index = PREDECESSOR_FINGER_ID; 2290 current_search_finger_index = PREDECESSOR_FINGER_ID;
2292 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity,&(new_finger_entry->finger_identity))) 2291 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity,finger_identity))
2293 verify_successor = GNUNET_SCHEDULER_add_now (&send_verify_successor_message, NULL); 2292 send_verify_successor_message();
2294 } 2293 }
2295 else if (GNUNET_YES == compare_new_entry_and_successor (finger_identity,finger_map_index)) 2294 else if (GNUNET_YES == compare_new_entry_and_successor (finger_identity,finger_map_index))
2296 { 2295 {
@@ -2302,10 +2301,7 @@ int finger_table_add (const struct GNUNET_PeerIdentity *finger_identity,
2302 current_search_finger_index = current_search_finger_index - 1; 2301 current_search_finger_index = current_search_finger_index - 1;
2303 } 2302 }
2304 2303
2305 if (1 == new_entry_added_flag) 2304 return new_entry_added;
2306 return GNUNET_YES;
2307 else
2308 return GNUNET_NO;
2309} 2305}
2310 2306
2311 2307
@@ -2403,7 +2399,7 @@ find_successor (uint64_t value, struct GNUNET_PeerIdentity *current_destination,
2403 if (successor->type == MY_ID) 2399 if (successor->type == MY_ID)
2404 { 2400 {
2405 memcpy (current_destination, &my_identity, sizeof (struct GNUNET_PeerIdentity)); 2401 memcpy (current_destination, &my_identity, sizeof (struct GNUNET_PeerIdentity));
2406 return NULL; 2402 return &my_identity;
2407 } 2403 }
2408 else if (successor->type == FRIEND) 2404 else if (successor->type == FRIEND)
2409 { 2405 {
@@ -3172,13 +3168,6 @@ handle_dht_p2p_trail_setup (void *cls, const struct GNUNET_PeerIdentity *peer,
3172 memcpy (&source, &(trail_setup->source_peer), sizeof (struct GNUNET_PeerIdentity)); 3168 memcpy (&source, &(trail_setup->source_peer), sizeof (struct GNUNET_PeerIdentity));
3173 finger_map_index = ntohl (trail_setup->finger_map_index); 3169 finger_map_index = ntohl (trail_setup->finger_map_index);
3174 destination_finger_value = ntohl (trail_setup->destination_finger); 3170 destination_finger_value = ntohl (trail_setup->destination_finger);
3175
3176 /* Trail setup request looped back to me. */
3177 if(0 == GNUNET_CRYPTO_cmp_peer_identity (&source, &my_identity))
3178 {
3179 finger_table_add (&my_identity, NULL, 0, finger_map_index);
3180 return GNUNET_OK;
3181 }
3182 3171
3183#if 0 3172#if 0
3184 /* FIXME: Here we need to check 3 things 3173 /* FIXME: Here we need to check 3 things
@@ -3197,6 +3186,7 @@ handle_dht_p2p_trail_setup (void *cls, const struct GNUNET_PeerIdentity *peer,
3197 } 3186 }
3198#endif 3187#endif
3199 3188
3189
3200 /* Check if you are current_destination or not. */ 3190 /* Check if you are current_destination or not. */
3201 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&current_destination, &my_identity))) 3191 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&current_destination, &my_identity)))
3202 { 3192 {
@@ -3219,54 +3209,56 @@ handle_dht_p2p_trail_setup (void *cls, const struct GNUNET_PeerIdentity *peer,
3219 else 3209 else
3220 { 3210 {
3221 next_hop = find_successor (destination_finger_value, &current_destination, &current_source); 3211 next_hop = find_successor (destination_finger_value, &current_destination, &current_source);
3222 3212 }
3223 if (NULL == next_hop) 3213
3224 return GNUNET_SYSERR; 3214 if (NULL == next_hop)
3225 3215 {
3226 if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&current_destination, &my_identity))) /* This means I am the final destination */ 3216 return GNUNET_SYSERR;
3217 }
3218 else if (0 == (GNUNET_CRYPTO_cmp_peer_identity (next_hop, &my_identity)))/* This means I am the final destination */
3219 {
3220 if (trail_length == 0)
3227 { 3221 {
3228 if (trail_length == 0) 3222 memcpy (&next_peer, &source, sizeof (struct GNUNET_PeerIdentity));
3229 { 3223 }
3230 memcpy (&next_peer, &source, sizeof (struct GNUNET_PeerIdentity)); 3224 else
3231 } 3225 {
3232 else 3226 memcpy (&next_peer, &trail_peer_list[trail_length-1], sizeof (struct GNUNET_PeerIdentity));
3233 { 3227 }
3234 memcpy (&next_peer, &trail_peer_list[trail_length-1], sizeof (struct GNUNET_PeerIdentity));
3235 }
3236
3237 target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap, &next_peer);
3238 3228
3239 /* ! HAVE A PREDECESSOR || (source_peer closer than existing PREDECESOR) */ 3229 target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap, &next_peer);
3240 if (PREDECESSOR_FINGER_ID != finger_map_index)
3241 {
3242 /* FIXME: Is this correct assumption? A peer which think I am its predecessor,
3243 then I am not its predecessor. */
3244 compare_and_update_predecessor (&source, trail_peer_list, trail_length );
3245 }
3246 3230
3247 GDS_NEIGHBOURS_send_trail_setup_result (&source, 3231 /* ! HAVE A PREDECESSOR || (source_peer closer than existing PREDECESOR) */
3248 &(my_identity), 3232 if (PREDECESSOR_FINGER_ID != finger_map_index)
3249 target_friend, trail_length, 3233 {
3250 trail_peer_list, 3234 /* FIXME: Is this correct assumption? A peer which think I am its predecessor,
3251 finger_map_index); 3235 then I am not its predecessor. */
3252 return GNUNET_OK; 3236 compare_and_update_predecessor (&source, trail_peer_list, trail_length );
3253 } 3237 }
3238 GDS_NEIGHBOURS_send_trail_setup_result (&source,
3239 &(my_identity),
3240 target_friend, trail_length,
3241 trail_peer_list,
3242 finger_map_index);
3243 return GNUNET_OK;
3254 } 3244 }
3255 3245 else
3256 /* Now add yourself to the trail. */ 3246 {
3257 struct GNUNET_PeerIdentity peer_list[trail_length + 1]; 3247 /* Now add yourself to the trail. */
3258 if (trail_length != 0) 3248 struct GNUNET_PeerIdentity peer_list[trail_length + 1];
3259 memcpy (peer_list, trail_peer_list, trail_length * sizeof (struct GNUNET_PeerIdentity)); 3249 if (trail_length != 0)
3260 peer_list[trail_length] = my_identity; 3250 memcpy (peer_list, trail_peer_list, trail_length * sizeof (struct GNUNET_PeerIdentity));
3261 trail_length++; 3251 peer_list[trail_length] = my_identity;
3252 trail_length++;
3262 3253
3263 target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop); 3254 target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop);
3264 GDS_NEIGHBOURS_send_trail_setup (&source, 3255 GDS_NEIGHBOURS_send_trail_setup (&source,
3265 destination_finger_value, 3256 destination_finger_value,
3266 &current_destination, &current_source, 3257 &current_destination, &current_source,
3267 target_friend, trail_length, peer_list, 3258 target_friend, trail_length, peer_list,
3268 finger_map_index); 3259 finger_map_index);
3269 return GNUNET_OK; 3260 return GNUNET_OK;
3261 }
3270} 3262}
3271 3263
3272 3264
@@ -3309,13 +3301,10 @@ handle_dht_p2p_trail_setup_result(void *cls, const struct GNUNET_PeerIdentity *p
3309 3301
3310 finger_map_index = htonl (trail_result->finger_map_index); 3302 finger_map_index = htonl (trail_result->finger_map_index);
3311 trail_peer_list = (struct GNUNET_PeerIdentity *) &trail_result[1]; 3303 trail_peer_list = (struct GNUNET_PeerIdentity *) &trail_result[1];
3312 3304
3313 if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&(trail_result->destination_peer), 3305 if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&(trail_result->destination_peer),
3314 &my_identity))) 3306 &my_identity)))
3315 { 3307 {
3316 /* FIXME: Is it important to check here if source and my identity is same or not.
3317 we are already checking it in handle_dht_p2p_trail_setup. And if we got that
3318 message then we will not get it here. */
3319 finger_table_add (&(trail_result->finger_identity), trail_peer_list, trail_length, 3308 finger_table_add (&(trail_result->finger_identity), trail_peer_list, trail_length,
3320 finger_map_index); 3309 finger_map_index);
3321 return GNUNET_YES; 3310 return GNUNET_YES;
@@ -3326,18 +3315,19 @@ handle_dht_p2p_trail_setup_result(void *cls, const struct GNUNET_PeerIdentity *p
3326 struct FriendInfo *target_friend; 3315 struct FriendInfo *target_friend;
3327 int my_index; 3316 int my_index;
3328 3317
3329 /* FIXME: handle the case when current_path_index = GNUNET_SYSERR;*/
3330 /* FIXME: Make sure you are passing the current length */
3331 my_index = search_my_index (trail_peer_list, trail_length); 3318 my_index = search_my_index (trail_peer_list, trail_length);
3319 if (my_index == GNUNET_SYSERR)
3320 return GNUNET_SYSERR;
3321
3332 if (my_index == 0) 3322 if (my_index == 0)
3333 { 3323 {
3334 next_hop = trail_result->destination_peer; 3324 next_hop = trail_result->destination_peer;
3335 } 3325 }
3336 else 3326 else
3337 next_hop = trail_peer_list[my_index - 1]; 3327 next_hop = trail_peer_list[my_index - 1];
3338 3328
3339 /* Finger table of destination peer will not contain any trail for the case 3329 /* Finger table of destination peer will not contain any trail for the case
3340 * where destination peer is its own finger identity. */ 3330 * where destination peer is its own finger identity.*/
3341 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&(trail_result->destination_peer), 3331 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&(trail_result->destination_peer),
3342 &(trail_result->finger_identity)))) 3332 &(trail_result->finger_identity))))
3343 { 3333 {
@@ -3472,14 +3462,14 @@ handle_dht_p2p_verify_successor(void *cls, const struct GNUNET_PeerIdentity *pee
3472 struct TrailPeerList *iterator; 3462 struct TrailPeerList *iterator;
3473 int new_trail_length; 3463 int new_trail_length;
3474 int i; 3464 int i;
3475 3465
3476 new_trail_length = trail_length + my_predecessor->first_trail_length + 1; 3466 new_trail_length = trail_length + my_predecessor->first_trail_length + 1;
3477 new_successor_trail = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity) * new_trail_length); 3467 new_successor_trail = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity) * new_trail_length);
3478 if (trail_length > 0) 3468 if (trail_length > 0)
3479 memcpy (new_successor_trail, trail_peer_list, (trail_length) * sizeof (struct GNUNET_PeerIdentity)); 3469 memcpy (new_successor_trail, trail_peer_list, (trail_length) * sizeof (struct GNUNET_PeerIdentity));
3480 3470
3481 memcpy (&new_successor_trail[trail_length], &my_identity, sizeof (struct GNUNET_PeerIdentity)); 3471 memcpy (&new_successor_trail[trail_length], &my_identity, sizeof (struct GNUNET_PeerIdentity));
3482 3472
3483 if (my_predecessor->first_trail_length) 3473 if (my_predecessor->first_trail_length)
3484 { 3474 {
3485 iterator = GNUNET_malloc (sizeof (struct TrailPeerList)); 3475 iterator = GNUNET_malloc (sizeof (struct TrailPeerList));
@@ -3492,7 +3482,7 @@ handle_dht_p2p_verify_successor(void *cls, const struct GNUNET_PeerIdentity *pee
3492 i++; 3482 i++;
3493 } 3483 }
3494 } 3484 }
3495 3485
3496 GDS_NEIGHBOURS_send_verify_successor_result (&source_peer, 3486 GDS_NEIGHBOURS_send_verify_successor_result (&source_peer,
3497 &(my_identity), 3487 &(my_identity),
3498 &(my_predecessor->finger_identity), 3488 &(my_predecessor->finger_identity),
@@ -3521,6 +3511,7 @@ handle_dht_p2p_verify_successor(void *cls, const struct GNUNET_PeerIdentity *pee
3521 memcpy (&next_hop, &trail_peer_list[my_index + 1], sizeof (struct GNUNET_PeerIdentity)); 3511 memcpy (&next_hop, &trail_peer_list[my_index + 1], sizeof (struct GNUNET_PeerIdentity));
3522 target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap, &next_hop); 3512 target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap, &next_hop);
3523 } 3513 }
3514
3524 GDS_NEIGHBOURS_send_verify_successor (&(vsm->source_peer), &(vsm->successor),target_friend, 3515 GDS_NEIGHBOURS_send_verify_successor (&(vsm->source_peer), &(vsm->successor),target_friend,
3525 trail_peer_list, trail_length); 3516 trail_peer_list, trail_length);
3526 } 3517 }
@@ -4053,12 +4044,6 @@ handle_core_disconnect (void *cls,
4053 } 4044 }
4054 else 4045 else
4055 GNUNET_break (0); 4046 GNUNET_break (0);
4056
4057 if (GNUNET_SCHEDULER_NO_TASK != verify_successor)
4058 {
4059 GNUNET_SCHEDULER_cancel (verify_successor);
4060 verify_successor = GNUNET_SCHEDULER_NO_TASK;
4061 }
4062} 4047}
4063 4048
4064 4049
@@ -4115,9 +4100,6 @@ core_init (void *cls,
4115 const struct GNUNET_PeerIdentity *identity) 4100 const struct GNUNET_PeerIdentity *identity)
4116{ 4101{
4117 my_identity = *identity; 4102 my_identity = *identity;
4118
4119 FPRINTF (stderr,_("\nSUPU %s, %s, %d, my_identity = %s"),
4120 __FILE__, __func__,__LINE__, GNUNET_i2s(&my_identity));
4121} 4103}
4122 4104
4123 4105
@@ -4189,22 +4171,10 @@ GDS_NEIGHBOURS_done (void)
4189 GNUNET_SCHEDULER_cancel (find_finger_trail_task); 4171 GNUNET_SCHEDULER_cancel (find_finger_trail_task);
4190 find_finger_trail_task = GNUNET_SCHEDULER_NO_TASK; 4172 find_finger_trail_task = GNUNET_SCHEDULER_NO_TASK;
4191 } 4173 }
4192
4193 if (GNUNET_SCHEDULER_NO_TASK != verify_successor)
4194 {
4195 GNUNET_break (0);
4196 GNUNET_SCHEDULER_cancel (verify_successor);
4197 verify_successor = GNUNET_SCHEDULER_NO_TASK;
4198 }
4199} 4174}
4200 4175
4201 4176
4202/** 4177/**
4203 * URGENT
4204 * FIXME: Here I want to send only the value not the address. Initially
4205 * I wanted to make it const struct * so that no other function can change it.
4206 * then in client file, i make a copy and send that copy. now I have made this
4207 * as only struct.
4208 * Get my identity 4178 * Get my identity
4209 * 4179 *
4210 * @return my identity 4180 * @return my identity