aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSupriti Singh <supritisingh08@gmail.com>2014-08-17 16:54:24 +0000
committerSupriti Singh <supritisingh08@gmail.com>2014-08-17 16:54:24 +0000
commitd063099eef60dcebfeedb188a4d8c59ce36c8ed9 (patch)
tree78a2b1c868d397f8e2123e0e35e57f0a3423096e
parent9f2753334e665b88b33e91ae32a1ecee2175dd85 (diff)
downloadgnunet-d063099eef60dcebfeedb188a4d8c59ce36c8ed9.tar.gz
gnunet-d063099eef60dcebfeedb188a4d8c59ce36c8ed9.zip
- Return value in select_closest_peer() instead of pointer
- Handle no trail found in routing table
-rw-r--r--src/dht/gnunet-service-xdht_neighbours.c259
1 files changed, 125 insertions, 134 deletions
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c
index 9434bb3bd..2212093e1 100644
--- a/src/dht/gnunet-service-xdht_neighbours.c
+++ b/src/dht/gnunet-service-xdht_neighbours.c
@@ -78,7 +78,7 @@
78/** 78/**
79 * How long at most to wait for transmission of a request to a friend ? 79 * How long at most to wait for transmission of a request to a friend ?
80 */ 80 */
81#define GET_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2) 81#define PENDING_MESSAGE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2)
82 82
83/** 83/**
84 * Duration for which I may remain congested. 84 * Duration for which I may remain congested.
@@ -872,6 +872,16 @@ unsigned int track_topology;
872unsigned int act_malicious; 872unsigned int act_malicious;
873 873
874/** 874/**
875 * Time duration to schedule find finger trail task.
876 */
877static struct GNUNET_TIME_Relative find_finger_trail_task_next_send_time;
878
879/**
880 * Time duration to schedule verify successor task.
881 */
882static struct GNUNET_TIME_Relative verify_successor_next_send_time;
883
884/**
875 * Called when core is ready to send a message we asked for 885 * Called when core is ready to send a message we asked for
876 * out to the destination. 886 * out to the destination.
877 * 887 *
@@ -1033,8 +1043,7 @@ GDS_NEIGHBOURS_send_trail_setup (struct GNUNET_PeerIdentity source_peer,
1033 } 1043 }
1034 1044
1035 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize); 1045 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
1036 // TODO: Create a new macro for timeout value of pending messages 1046 pending->timeout = GNUNET_TIME_relative_to_absolute (PENDING_MESSAGE_TIMEOUT);
1037 pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT);
1038 tsm = (struct PeerTrailSetupMessage *) &pending[1]; 1047 tsm = (struct PeerTrailSetupMessage *) &pending[1];
1039 pending->msg = &(tsm->header); 1048 pending->msg = &(tsm->header);
1040 tsm->header.size = htons (msize); 1049 tsm->header.size = htons (msize);
@@ -1105,7 +1114,7 @@ GDS_NEIGHBOURS_send_trail_setup_result (struct GNUNET_PeerIdentity querying_peer
1105 1114
1106 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize); 1115 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
1107 pending->importance = 0; 1116 pending->importance = 0;
1108 pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT); //TODO: Change it 1117 pending->timeout = GNUNET_TIME_relative_to_absolute (PENDING_MESSAGE_TIMEOUT);
1109 tsrm = (struct PeerTrailSetupResultMessage *) &pending[1]; 1118 tsrm = (struct PeerTrailSetupResultMessage *) &pending[1];
1110 pending->msg = &tsrm->header; 1119 pending->msg = &tsrm->header;
1111 tsrm->header.size = htons (msize); 1120 tsrm->header.size = htons (msize);
@@ -1175,7 +1184,7 @@ GDS_NEIGHBOURS_send_trail_rejection (struct GNUNET_PeerIdentity source_peer,
1175 1184
1176 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize); 1185 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
1177 pending->importance = 0; 1186 pending->importance = 0;
1178 pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT); 1187 pending->timeout = GNUNET_TIME_relative_to_absolute (PENDING_MESSAGE_TIMEOUT);
1179 trm = (struct PeerTrailRejectionMessage *)&pending[1]; 1188 trm = (struct PeerTrailRejectionMessage *)&pending[1];
1180 pending->msg = &trm->header; 1189 pending->msg = &trm->header;
1181 trm->header.size = htons (msize); 1190 trm->header.size = htons (msize);
@@ -1241,7 +1250,7 @@ GDS_NEIGHBOURS_send_verify_successor_message (struct GNUNET_PeerIdentity source_
1241 1250
1242 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize); 1251 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
1243 pending->importance = 0; /* FIXME */ 1252 pending->importance = 0; /* FIXME */
1244 pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT); 1253 pending->timeout = GNUNET_TIME_relative_to_absolute (PENDING_MESSAGE_TIMEOUT);
1245 vsm = (struct PeerVerifySuccessorMessage *) &pending[1]; 1254 vsm = (struct PeerVerifySuccessorMessage *) &pending[1];
1246 pending->msg = &vsm->header; 1255 pending->msg = &vsm->header;
1247 vsm->header.size = htons (msize); 1256 vsm->header.size = htons (msize);
@@ -1300,7 +1309,7 @@ GDS_NEIGHBOURS_send_trail_teardown (struct GNUNET_HashCode trail_id,
1300 1309
1301 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize); 1310 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
1302 pending->importance = 0; /* FIXME */ 1311 pending->importance = 0; /* FIXME */
1303 pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT); 1312 pending->timeout = GNUNET_TIME_relative_to_absolute (PENDING_MESSAGE_TIMEOUT);
1304 ttdm = (struct PeerTrailTearDownMessage *) &pending[1]; 1313 ttdm = (struct PeerTrailTearDownMessage *) &pending[1];
1305 pending->msg = &ttdm->header; 1314 pending->msg = &ttdm->header;
1306 ttdm->header.size = htons (msize); 1315 ttdm->header.size = htons (msize);
@@ -1362,7 +1371,7 @@ GDS_NEIGHBOURS_send_verify_successor_result (struct GNUNET_PeerIdentity querying
1362 1371
1363 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize); 1372 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
1364 pending->importance = 0; /* FIXME */ 1373 pending->importance = 0; /* FIXME */
1365 pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT); 1374 pending->timeout = GNUNET_TIME_relative_to_absolute (PENDING_MESSAGE_TIMEOUT);
1366 vsmr = (struct PeerVerifySuccessorResultMessage *) &pending[1]; 1375 vsmr = (struct PeerVerifySuccessorResultMessage *) &pending[1];
1367 pending->msg = &vsmr->header; 1376 pending->msg = &vsmr->header;
1368 vsmr->header.size = htons (msize); 1377 vsmr->header.size = htons (msize);
@@ -1424,7 +1433,7 @@ GDS_NEIGHBOURS_send_notify_new_successor (struct GNUNET_PeerIdentity source_peer
1424 1433
1425 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize); 1434 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
1426 pending->importance = 0; /* FIXME */ 1435 pending->importance = 0; /* FIXME */
1427 pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT); 1436 pending->timeout = GNUNET_TIME_relative_to_absolute (PENDING_MESSAGE_TIMEOUT);
1428 nsm = (struct PeerNotifyNewSuccessorMessage *) &pending[1]; 1437 nsm = (struct PeerNotifyNewSuccessorMessage *) &pending[1];
1429 pending->msg = &nsm->header; 1438 pending->msg = &nsm->header;
1430 nsm->header.size = htons (msize); 1439 nsm->header.size = htons (msize);
@@ -1485,7 +1494,7 @@ GDS_NEIGHBOURS_send_add_trail (struct GNUNET_PeerIdentity source_peer,
1485 1494
1486 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize); 1495 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
1487 pending->importance = 0; /* FIXME */ 1496 pending->importance = 0; /* FIXME */
1488 pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT); 1497 pending->timeout = GNUNET_TIME_relative_to_absolute (PENDING_MESSAGE_TIMEOUT);
1489 adm = (struct PeerAddTrailMessage *) &pending[1]; 1498 adm = (struct PeerAddTrailMessage *) &pending[1];
1490 pending->msg = &adm->header; 1499 pending->msg = &adm->header;
1491 adm->header.size = htons (msize); 1500 adm->header.size = htons (msize);
@@ -1568,7 +1577,7 @@ is_friend_congested (struct FriendInfo *friend)
1568 * @param value Value to be compare 1577 * @param value Value to be compare
1569 * @return Closest peer 1578 * @return Closest peer
1570 */ 1579 */
1571const static struct GNUNET_PeerIdentity * 1580static struct GNUNET_PeerIdentity
1572select_closest_finger (const struct GNUNET_PeerIdentity *peer1, 1581select_closest_finger (const struct GNUNET_PeerIdentity *peer1,
1573 const struct GNUNET_PeerIdentity *peer2, 1582 const struct GNUNET_PeerIdentity *peer2,
1574 uint64_t value) 1583 uint64_t value)
@@ -1582,43 +1591,41 @@ select_closest_finger (const struct GNUNET_PeerIdentity *peer1,
1582 peer2_value = GNUNET_ntohll (peer2_value); 1591 peer2_value = GNUNET_ntohll (peer2_value);
1583 1592
1584 // TODO: Can use a simpler (to understand) idea here! 1593 // TODO: Can use a simpler (to understand) idea here!
1585
1586 if (peer1_value == value) 1594 if (peer1_value == value)
1587 { 1595 {
1588 return peer1; 1596 return *peer1;
1589 } 1597 }
1590 1598
1591 if (peer2_value == value) 1599 if (peer2_value == value)
1592 { 1600 {
1593 return peer2; 1601 return *peer2;
1594 } 1602 }
1595 1603
1596 if (peer2_value < peer1_value) 1604 if (peer2_value < peer1_value)
1597 { 1605 {
1598 if ((peer2_value < value) && (value < peer1_value)) 1606 if ((peer2_value < value) && (value < peer1_value))
1599 { 1607 {
1600 return peer1; 1608 return *peer1;
1601 } 1609 }
1602 else if (((peer1_value < value) && (value < PEER_IDENTITES_WRAP_AROUND)) || 1610 else if (((peer1_value < value) && (value < PEER_IDENTITES_WRAP_AROUND)) ||
1603 ((0 < value) && (value < peer2_value))) 1611 ((0 < value) && (value < peer2_value)))
1604 { 1612 {
1605 return peer2; 1613 return *peer2;
1606 } 1614 }
1607 } 1615 }
1608 1616
1609 if (peer1_value < peer2_value) 1617 //if (peer1_value < peer2_value)
1610 { 1618 //{
1611 if ((peer1_value < value) && (value < peer2_value)) 1619 if ((peer1_value < value) && (value < peer2_value))
1612 { 1620 {
1613 return peer2; 1621 return *peer2;
1614 } 1622 }
1615 else if (((peer2_value < value) && (value < PEER_IDENTITES_WRAP_AROUND)) || 1623 //else if (((peer2_value < value) && (value < PEER_IDENTITES_WRAP_AROUND)) ||
1616 ((0 < value) && (value < peer1_value))) 1624 // ((0 < value) && (value < peer1_value)))
1617 { 1625 //{
1618 return peer1; 1626 return *peer1;
1619 } 1627 //}
1620 } 1628 // }
1621 return NULL;
1622} 1629}
1623 1630
1624 1631
@@ -1629,7 +1636,7 @@ select_closest_finger (const struct GNUNET_PeerIdentity *peer1,
1629 * @param value Value to be compare 1636 * @param value Value to be compare
1630 * @return Peer which precedes value in the network. 1637 * @return Peer which precedes value in the network.
1631 */ 1638 */
1632const static struct GNUNET_PeerIdentity * 1639static struct GNUNET_PeerIdentity
1633select_closest_predecessor (const struct GNUNET_PeerIdentity *peer1, 1640select_closest_predecessor (const struct GNUNET_PeerIdentity *peer1,
1634 const struct GNUNET_PeerIdentity *peer2, 1641 const struct GNUNET_PeerIdentity *peer2,
1635 uint64_t value) 1642 uint64_t value)
@@ -1643,37 +1650,36 @@ select_closest_predecessor (const struct GNUNET_PeerIdentity *peer1,
1643 peer2_value = GNUNET_ntohll (peer2_value); 1650 peer2_value = GNUNET_ntohll (peer2_value);
1644 1651
1645 if (peer1_value == value) 1652 if (peer1_value == value)
1646 return peer1; 1653 return *peer1;
1647 1654
1648 if (peer2_value == value) 1655 if (peer2_value == value)
1649 return peer2; 1656 return *peer2;
1650 1657
1651 if (peer1_value < peer2_value) 1658 if (peer1_value < peer2_value)
1652 { 1659 {
1653 if ((peer1_value < value) && (value < peer2_value)) 1660 if ((peer1_value < value) && (value < peer2_value))
1654 { 1661 {
1655 return peer1; 1662 return *peer1;
1656 } 1663 }
1657 else if (((peer2_value < value) && (value < PEER_IDENTITES_WRAP_AROUND)) || 1664 else if (((peer2_value < value) && (value < PEER_IDENTITES_WRAP_AROUND)) ||
1658 ((PEER_IDENTITES_WRAP_AROUND > value) && (value < peer1_value))) 1665 ((PEER_IDENTITES_WRAP_AROUND > value) && (value < peer1_value)))
1659 { 1666 {
1660 return peer2; 1667 return *peer2;
1661 } 1668 }
1662 } 1669 }
1663 1670
1664 if (peer2_value < peer1_value) 1671 // if (peer2_value < peer1_value)
1665 { 1672 //{
1666 if ((peer2_value < value) && (value < peer1_value)) 1673 if ((peer2_value < value) && (value < peer1_value))
1667 { 1674 {
1668 return peer2; 1675 return *peer2;
1669 }
1670 else if (((peer1_value < value) && (value < PEER_IDENTITES_WRAP_AROUND)) ||
1671 ((PEER_IDENTITES_WRAP_AROUND > value) && (value < peer2_value)))
1672 {
1673 return peer1;
1674 } 1676 }
1675 } 1677 //else if (((peer1_value < value) && (value < PEER_IDENTITES_WRAP_AROUND)) ||
1676 return NULL; 1678 // ((PEER_IDENTITES_WRAP_AROUND > value) && (value < peer2_value)))
1679 //{
1680 return *peer1;
1681 //}
1682 // }
1677} 1683}
1678 1684
1679#if 0 1685#if 0
@@ -1785,9 +1791,7 @@ test_finger_table_print()
1785 * @param is_predecessor Is value a predecessor or any other finger. 1791 * @param is_predecessor Is value a predecessor or any other finger.
1786 * @return Closest peer among two peers. 1792 * @return Closest peer among two peers.
1787 */ 1793 */
1788 1794static struct GNUNET_PeerIdentity
1789// TODO: URGENT! Change return type to value instead of pointer
1790const static struct GNUNET_PeerIdentity *
1791select_closest_peer (const struct GNUNET_PeerIdentity *peer1, 1795select_closest_peer (const struct GNUNET_PeerIdentity *peer1,
1792 const struct GNUNET_PeerIdentity *peer2, 1796 const struct GNUNET_PeerIdentity *peer2,
1793 uint64_t value, 1797 uint64_t value,
@@ -1920,16 +1924,13 @@ select_finger_trail (struct FingerInfo *finger)
1920 * @return 1924 * @return
1921 */ 1925 */
1922static void 1926static void
1923compare_finger_and_current_successor (struct Closest_Peer *current_closest_peer) 1927compare_finger_and_current_closest_peer (struct Closest_Peer *current_closest_peer)
1924{ 1928{
1925 struct FingerInfo *finger; 1929 struct FingerInfo *finger;
1926 const struct GNUNET_PeerIdentity *closest_peer; 1930 struct GNUNET_PeerIdentity closest_peer;
1927 struct Trail *finger_trail; 1931 struct Trail *finger_trail;
1928 int i; 1932 int i;
1929 1933
1930 // TODO: Instead of iterating over all fingers, calculate the finger index
1931 // using "value" of my id and current closest peer id.
1932
1933 /* Iterate over finger table. */ 1934 /* Iterate over finger table. */
1934 for (i = 0; i < MAX_FINGERS; i++) 1935 for (i = 0; i < MAX_FINGERS; i++)
1935 { 1936 {
@@ -1967,7 +1968,7 @@ compare_finger_and_current_successor (struct Closest_Peer *current_closest_peer)
1967 current_closest_peer->destination_finger_value, 1968 current_closest_peer->destination_finger_value,
1968 current_closest_peer->is_predecessor); 1969 current_closest_peer->is_predecessor);
1969 1970
1970 if (&finger->finger_identity == closest_peer) 1971 if (0 == GNUNET_CRYPTO_cmp_peer_identity(&finger->finger_identity, &closest_peer))
1971 { 1972 {
1972 /* Choose one of the trail to reach to finger. */ 1973 /* Choose one of the trail to reach to finger. */
1973 finger_trail = select_finger_trail (finger); 1974 finger_trail = select_finger_trail (finger);
@@ -1976,7 +1977,7 @@ compare_finger_and_current_successor (struct Closest_Peer *current_closest_peer)
1976 if (NULL == finger_trail) 1977 if (NULL == finger_trail)
1977 continue; 1978 continue;
1978 1979
1979 current_closest_peer->best_known_destination = *closest_peer; 1980 current_closest_peer->best_known_destination = closest_peer;
1980 current_closest_peer->next_hop = finger_trail->trail_head->peer; 1981 current_closest_peer->next_hop = finger_trail->trail_head->peer;
1981 current_closest_peer->trail_id = finger_trail->trail_id; 1982 current_closest_peer->trail_id = finger_trail->trail_id;
1982 } 1983 }
@@ -2004,7 +2005,7 @@ compare_friend_and_current_closest_peer (void *cls,
2004{ 2005{
2005 struct FriendInfo *friend = value; 2006 struct FriendInfo *friend = value;
2006 struct Closest_Peer *current_closest_peer = cls; 2007 struct Closest_Peer *current_closest_peer = cls;
2007 const struct GNUNET_PeerIdentity *closest_peer; 2008 struct GNUNET_PeerIdentity closest_peer;
2008 2009
2009 /* Friend is either congested or has crossed threshold. */ 2010 /* Friend is either congested or has crossed threshold. */
2010 if (GNUNET_YES == is_friend_congested (friend)) 2011 if (GNUNET_YES == is_friend_congested (friend))
@@ -2024,7 +2025,7 @@ compare_friend_and_current_closest_peer (void *cls,
2024 current_closest_peer->is_predecessor); 2025 current_closest_peer->is_predecessor);
2025 2026
2026 /* Is friend the closest successor? */ 2027 /* Is friend the closest successor? */
2027 if (&friend->id == closest_peer) 2028 if (0 == GNUNET_CRYPTO_cmp_peer_identity(&friend->id, &closest_peer))
2028 { 2029 {
2029 current_closest_peer->best_known_destination = friend->id; 2030 current_closest_peer->best_known_destination = friend->id;
2030 current_closest_peer->next_hop = friend->id; 2031 current_closest_peer->next_hop = friend->id;
@@ -2092,8 +2093,7 @@ find_successor (uint64_t destination_finger_value,
2092 2093
2093 /* Compare each finger entry with current_successor and update current_successor 2094 /* Compare each finger entry with current_successor and update current_successor
2094 * with finger if its closest. */ 2095 * with finger if its closest. */
2095 // TODO: Change function name to "compare_finger_and_current_closest_peer" 2096 compare_finger_and_current_closest_peer (&current_closest_peer);
2096 compare_finger_and_current_successor (&current_closest_peer);
2097 2097
2098 return current_closest_peer; 2098 return current_closest_peer;
2099} 2099}
@@ -2331,7 +2331,7 @@ GDS_NEIGHBOURS_send_get (const struct GNUNET_HashCode *key,
2331 } 2331 }
2332 2332
2333 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize); 2333 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
2334 pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT); 2334 pending->timeout = GNUNET_TIME_relative_to_absolute (PENDING_MESSAGE_TIMEOUT);
2335 pending->importance = 0; /* FIXME */ 2335 pending->importance = 0; /* FIXME */
2336 pgm = (struct PeerGetMessage *) &pending[1]; 2336 pgm = (struct PeerGetMessage *) &pending[1];
2337 pending->msg = &pgm->header; 2337 pending->msg = &pgm->header;
@@ -2430,7 +2430,7 @@ GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *key,
2430 } 2430 }
2431 2431
2432 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize); 2432 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
2433 pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT); 2433 pending->timeout = GNUNET_TIME_relative_to_absolute (PENDING_MESSAGE_TIMEOUT);
2434 pending->importance = 0; 2434 pending->importance = 0;
2435 get_result = (struct PeerGetResultMessage *)&pending[1]; 2435 get_result = (struct PeerGetResultMessage *)&pending[1];
2436 pending->msg = &get_result->header; 2436 pending->msg = &get_result->header;
@@ -2536,7 +2536,6 @@ compute_finger_identity_value (unsigned int finger_index)
2536 uint64_t my_id64; 2536 uint64_t my_id64;
2537 2537
2538 memcpy (&my_id64, &my_identity, sizeof (uint64_t)); 2538 memcpy (&my_id64, &my_identity, sizeof (uint64_t));
2539 // TODO: Check how and if to use ntohll
2540 my_id64 = GNUNET_ntohll (my_id64); 2539 my_id64 = GNUNET_ntohll (my_id64);
2541 2540
2542 /* Are we looking for immediate predecessor? */ 2541 /* Are we looking for immediate predecessor? */
@@ -2549,9 +2548,6 @@ compute_finger_identity_value (unsigned int finger_index)
2549 } 2548 }
2550} 2549}
2551 2550
2552//TODO move at top, write comment.
2553static struct GNUNET_TIME_Relative next_send_time;
2554
2555 2551
2556/* 2552/*
2557 * Choose a random friend. Calculate the next finger identity to search,from 2553 * Choose a random friend. Calculate the next finger identity to search,from
@@ -2573,7 +2569,7 @@ send_find_finger_trail_message (void *cls,
2573 2569
2574 /* Schedule another send_find_finger_trail_message task. */ 2570 /* Schedule another send_find_finger_trail_message task. */
2575 find_finger_trail_task = 2571 find_finger_trail_task =
2576 GNUNET_SCHEDULER_add_delayed (next_send_time, 2572 GNUNET_SCHEDULER_add_delayed (find_finger_trail_task_next_send_time,
2577 &send_find_finger_trail_message, 2573 &send_find_finger_trail_message,
2578 NULL); 2574 NULL);
2579 2575
@@ -2828,6 +2824,8 @@ send_trail_teardown (struct FingerInfo *finger,
2828 2824
2829 if (NULL == next_hop) 2825 if (NULL == next_hop)
2830 { 2826 {
2827 DEBUG(" NO ENTRY FOUND IN %s ROUTING TABLE for trail id %s, line",
2828 GNUNET_i2s(&my_identity), GNUNET_h2s(&trail->trail_id), __LINE__);
2831 GNUNET_break(0); 2829 GNUNET_break(0);
2832 return; 2830 return;
2833 } 2831 }
@@ -2953,10 +2951,8 @@ add_new_finger (struct GNUNET_PeerIdentity finger_identity,
2953 struct FingerInfo *new_entry; 2951 struct FingerInfo *new_entry;
2954 struct FriendInfo *first_trail_hop; 2952 struct FriendInfo *first_trail_hop;
2955 struct Trail *trail; 2953 struct Trail *trail;
2956 int i = 0; 2954 int i;
2957 2955
2958 if(0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &finger_identity))
2959 GNUNET_assert (NULL != GDS_ROUTING_get_next_hop(trail_id,GDS_ROUTING_SRC_TO_DEST));
2960 new_entry = GNUNET_new (struct FingerInfo); 2956 new_entry = GNUNET_new (struct FingerInfo);
2961 new_entry->finger_identity = finger_identity; 2957 new_entry->finger_identity = finger_identity;
2962 new_entry->finger_table_index = finger_table_index; 2958 new_entry->finger_table_index = finger_table_index;
@@ -3003,7 +2999,7 @@ add_new_finger (struct GNUNET_PeerIdentity finger_identity,
3003 2999
3004 /* Copy the finger trail into trail. */ 3000 /* Copy the finger trail into trail. */
3005 trail = GNUNET_new (struct Trail); 3001 trail = GNUNET_new (struct Trail);
3006 while (i < finger_trail_length) 3002 for(i = 0; i < finger_trail_length; i++)
3007 { 3003 {
3008 struct Trail_Element *element = GNUNET_new (struct Trail_Element); 3004 struct Trail_Element *element = GNUNET_new (struct Trail_Element);
3009 3005
@@ -3013,8 +3009,8 @@ add_new_finger (struct GNUNET_PeerIdentity finger_identity,
3013 GNUNET_CONTAINER_DLL_insert_tail (trail->trail_head, 3009 GNUNET_CONTAINER_DLL_insert_tail (trail->trail_head,
3014 trail->trail_tail, 3010 trail->trail_tail,
3015 element); 3011 element);
3016 i++;
3017 } 3012 }
3013
3018 3014
3019 /* Add trail to trail list. */ 3015 /* Add trail to trail list. */
3020 new_entry->trail_list[0].trail_head = trail->trail_head; 3016 new_entry->trail_list[0].trail_head = trail->trail_head;
@@ -3042,7 +3038,6 @@ send_verify_successor_message (void *cls,
3042 struct FriendInfo *target_friend; 3038 struct FriendInfo *target_friend;
3043 struct GNUNET_HashCode trail_id; 3039 struct GNUNET_HashCode trail_id;
3044 int i; 3040 int i;
3045 struct GNUNET_TIME_Relative next_send_time;
3046 struct Trail *trail; 3041 struct Trail *trail;
3047 struct Trail_Element *element; 3042 struct Trail_Element *element;
3048 unsigned int trail_length; 3043 unsigned int trail_length;
@@ -3050,12 +3045,13 @@ send_verify_successor_message (void *cls,
3050 struct FingerInfo *successor; 3045 struct FingerInfo *successor;
3051 3046
3052 /* Schedule another send_find_finger_trail_message task. */ 3047 /* Schedule another send_find_finger_trail_message task. */
3053 next_send_time.rel_value_us = 3048 verify_successor_next_send_time.rel_value_us =
3054 DHT_FIND_FINGER_TRAIL_INTERVAL.rel_value_us + 3049 DHT_SEND_VERIFY_SUCCESSOR_INTERVAL.rel_value_us +
3055 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 3050 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
3056 DHT_FIND_FINGER_TRAIL_INTERVAL.rel_value_us); 3051 DHT_SEND_VERIFY_SUCCESSOR_INTERVAL.rel_value_us);
3057 send_verify_successor_task = 3052 send_verify_successor_task =
3058 GNUNET_SCHEDULER_add_delayed (next_send_time, &send_verify_successor_message, 3053 GNUNET_SCHEDULER_add_delayed (verify_successor_next_send_time,
3054 &send_verify_successor_message,
3059 NULL); 3055 NULL);
3060 3056
3061 successor = &finger_table[0]; 3057 successor = &finger_table[0];
@@ -3066,6 +3062,7 @@ send_verify_successor_message (void *cls,
3066 break; 3062 break;
3067 } 3063 }
3068 3064
3065 /* No valid trail found to reach to successor. */
3069 if (i == successor->trails_count) 3066 if (i == successor->trails_count)
3070 return; 3067 return;
3071 3068
@@ -3076,8 +3073,13 @@ send_verify_successor_message (void *cls,
3076 GNUNET_assert (GNUNET_YES == trail->is_present); 3073 GNUNET_assert (GNUNET_YES == trail->is_present);
3077 3074
3078 trail_id = trail->trail_id; 3075 trail_id = trail->trail_id;
3079 3076 if (NULL == GDS_ROUTING_get_next_hop(trail_id,GDS_ROUTING_SRC_TO_DEST))
3080 GNUNET_assert (NULL != GDS_ROUTING_get_next_hop(trail_id,GDS_ROUTING_SRC_TO_DEST)); 3077 {
3078 DEBUG(" NO ENTRY FOUND IN %s ROUTING TABLE for trail id %s, line",
3079 GNUNET_i2s(&my_identity), GNUNET_h2s(&trail->trail_id), __LINE__);
3080 GNUNET_break(0);
3081 return;
3082 }
3081 trail_length = trail->trail_length; 3083 trail_length = trail->trail_length;
3082 3084
3083 if (trail_length > 0) 3085 if (trail_length > 0)
@@ -3144,9 +3146,16 @@ update_current_search_finger_index (struct GNUNET_PeerIdentity finger_identity,
3144 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &finger_identity)) 3146 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &finger_identity))
3145 { 3147 {
3146 if (GNUNET_SCHEDULER_NO_TASK == send_verify_successor_task) 3148 if (GNUNET_SCHEDULER_NO_TASK == send_verify_successor_task)
3147 send_verify_successor_task = GNUNET_SCHEDULER_add_now (&send_verify_successor_message, NULL); 3149 send_verify_successor_task =
3150 GNUNET_SCHEDULER_add_now (&send_verify_successor_message, NULL);
3151 else
3152 {
3153 /* we already have scheduled a send_verify_sucessor_task, we should slow
3154 it down now. */
3155 verify_successor_next_send_time =
3156 GNUNET_TIME_STD_BACKOFF(verify_successor_next_send_time);
3157 }
3148 } 3158 }
3149
3150 return; 3159 return;
3151 } 3160 }
3152 3161
@@ -3235,21 +3244,16 @@ static void
3235remove_existing_finger (struct FingerInfo *existing_finger, 3244remove_existing_finger (struct FingerInfo *existing_finger,
3236 unsigned int finger_table_index) 3245 unsigned int finger_table_index)
3237{ 3246{
3238 struct FingerInfo *finger; 3247 if(0 == GNUNET_CRYPTO_cmp_peer_identity (&existing_finger->finger_identity,
3239 3248 &my_identity));
3240 finger = &finger_table[finger_table_index];
3241 GNUNET_assert (0 == GNUNET_CRYPTO_cmp_peer_identity (&finger->finger_identity,
3242 &existing_finger->finger_identity));
3243 if(0 == GNUNET_CRYPTO_cmp_peer_identity (&finger->finger_identity,
3244 &my_identity));
3245 return; 3249 return;
3246 GNUNET_assert (GNUNET_YES == finger->is_present); 3250 GNUNET_assert (GNUNET_YES == existing_finger->is_present);
3247 3251
3248 /* If I am my own finger, then we have no trails. */ 3252 /* If I am my own finger, then we have no trails. */
3249 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&finger->finger_identity, 3253 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&existing_finger->finger_identity,
3250 &my_identity)) 3254 &my_identity))
3251 { 3255 {
3252 finger->is_present = GNUNET_NO; 3256 existing_finger->is_present = GNUNET_NO;
3253 memset ((void *)&finger_table[finger_table_index], 0, 3257 memset ((void *)&finger_table[finger_table_index], 0,
3254 sizeof (finger_table[finger_table_index])); 3258 sizeof (finger_table[finger_table_index]));
3255 return; 3259 return;
@@ -3257,8 +3261,8 @@ remove_existing_finger (struct FingerInfo *existing_finger,
3257 3261
3258 /* For all other fingers, send trail teardown across all the trails to reach 3262 /* For all other fingers, send trail teardown across all the trails to reach
3259 finger, and free the finger. */ 3263 finger, and free the finger. */
3260 send_all_finger_trails_teardown (finger); 3264 send_all_finger_trails_teardown (existing_finger);
3261 free_finger (finger, finger_table_index); 3265 free_finger (existing_finger, finger_table_index);
3262 return; 3266 return;
3263} 3267}
3264 3268
@@ -3293,9 +3297,8 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity,
3293 struct GNUNET_HashCode finger_trail_id) 3297 struct GNUNET_HashCode finger_trail_id)
3294{ 3298{
3295 struct FingerInfo *existing_finger; 3299 struct FingerInfo *existing_finger;
3296 const struct GNUNET_PeerIdentity *closest_peer; 3300 struct GNUNET_PeerIdentity closest_peer;
3297 struct FingerInfo *successor; 3301 struct FingerInfo *successor;
3298 //int updated_finger_trail_length;
3299 unsigned int finger_table_index; 3302 unsigned int finger_table_index;
3300 3303
3301 /* Get the finger_table_index corresponding to finger_value we got from network.*/ 3304 /* Get the finger_table_index corresponding to finger_value we got from network.*/
@@ -3315,7 +3318,7 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity,
3315 successor = &finger_table[0]; 3318 successor = &finger_table[0];
3316 if (GNUNET_NO == successor->is_present) 3319 if (GNUNET_NO == successor->is_present)
3317 { 3320 {
3318 GNUNET_break_op (0); 3321 GNUNET_break (0);
3319 return; 3322 return;
3320 } 3323 }
3321 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&finger_identity, 3324 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&finger_identity,
@@ -3323,8 +3326,8 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity,
3323 { 3326 {
3324 current_search_finger_index = 0; 3327 current_search_finger_index = 0;
3325 /* We slow down the find_finger_trail_task as we have completed the circle. */ 3328 /* We slow down the find_finger_trail_task as we have completed the circle. */
3326 next_send_time = GNUNET_TIME_STD_BACKOFF(next_send_time); 3329 find_finger_trail_task_next_send_time =
3327 3330 GNUNET_TIME_STD_BACKOFF(find_finger_trail_task_next_send_time);
3328 return; 3331 return;
3329 } 3332 }
3330 3333
@@ -3343,18 +3346,9 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity,
3343 /* No entry present in finger_table for given finger map index. */ 3346 /* No entry present in finger_table for given finger map index. */
3344 if (GNUNET_NO == existing_finger->is_present) 3347 if (GNUNET_NO == existing_finger->is_present)
3345 { 3348 {
3346 //struct GNUNET_PeerIdentity *updated_trail;
3347
3348 /* Shorten the trail if possible.
3349 updated_finger_trail_length = finger_trail_length;
3350 updated_trail = scan_and_compress_trail (finger_identity, finger_trail,
3351 finger_trail_length,
3352 finger_trail_id,
3353 &updated_finger_trail_length);*/
3354 add_new_finger (finger_identity, finger_trail, 3349 add_new_finger (finger_identity, finger_trail,
3355 finger_trail_length, 3350 finger_trail_length,
3356 finger_trail_id, finger_table_index); 3351 finger_trail_id, finger_table_index);
3357 //GNUNET_free_non_null(updated_trail);
3358 update_current_search_finger_index (finger_identity, 3352 update_current_search_finger_index (finger_identity,
3359 finger_table_index); 3353 finger_table_index);
3360 return; 3354 return;
@@ -3371,19 +3365,11 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity,
3371 is_predecessor); 3365 is_predecessor);
3372 3366
3373 /* If the new finger is the closest peer. */ 3367 /* If the new finger is the closest peer. */
3374 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&finger_identity, closest_peer)) 3368 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&finger_identity, &closest_peer))
3375 { 3369 {
3376 //struct GNUNET_PeerIdentity *updated_trail;
3377 /* Shorten the trail if possible.
3378 updated_finger_trail_length = finger_trail_length;
3379 updated_trail =
3380 scan_and_compress_trail (finger_identity, finger_trail,
3381 finger_trail_length, finger_trail_id,
3382 &updated_finger_trail_length);*/
3383 remove_existing_finger (existing_finger, finger_table_index); 3370 remove_existing_finger (existing_finger, finger_table_index);
3384 add_new_finger (finger_identity, finger_trail, finger_trail_length, 3371 add_new_finger (finger_identity, finger_trail, finger_trail_length,
3385 finger_trail_id, finger_table_index); 3372 finger_trail_id, finger_table_index);
3386 //GNUNET_free_non_null((struct GNUNET_PeerIdentity *)updated_trail);
3387 } 3373 }
3388 else 3374 else
3389 { 3375 {
@@ -3415,14 +3401,6 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity,
3415 GNUNET_CONTAINER_multipeermap_get (friend_peermap, 3401 GNUNET_CONTAINER_multipeermap_get (friend_peermap,
3416 &existing_finger->finger_identity)) 3402 &existing_finger->finger_identity))
3417 { 3403 {
3418 //struct GNUNET_PeerIdentity *updated_trail;
3419
3420 /* Shorten the trail if possible.
3421 updated_finger_trail_length = finger_trail_length;
3422 updated_trail =
3423 scan_and_compress_trail (finger_identity, finger_trail,
3424 finger_trail_length, finger_trail_id,
3425 &updated_finger_trail_length);*/
3426 /* If there is space to store more trails. */ 3404 /* If there is space to store more trails. */
3427 if (existing_finger->trails_count < MAXIMUM_TRAILS_PER_FINGER) 3405 if (existing_finger->trails_count < MAXIMUM_TRAILS_PER_FINGER)
3428 add_new_trail (existing_finger, finger_trail, 3406 add_new_trail (existing_finger, finger_trail,
@@ -3587,11 +3565,14 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer,
3587 GDS_ROUTING_SRC_TO_DEST); 3565 GDS_ROUTING_SRC_TO_DEST);
3588 if (NULL == next_hop) 3566 if (NULL == next_hop)
3589 { 3567 {
3568 DEBUG(" NO ENTRY FOUND IN %s ROUTING TABLE for trail id %s, line",
3569 GNUNET_i2s(&my_identity), GNUNET_h2s(&intermediate_trail_id), __LINE__);
3590 GNUNET_STATISTICS_update (GDS_stats, 3570 GNUNET_STATISTICS_update (GDS_stats,
3591 gettext_noop ("# Next hop to forward the packet not found " 3571 gettext_noop ("# Next hop to forward the packet not found "
3592 "trail setup request, packet dropped."), 3572 "trail setup request, packet dropped."),
3593 1, GNUNET_NO); 3573 1, GNUNET_NO);
3594 return GNUNET_SYSERR; 3574 GNUNET_break_op (0);
3575 return GNUNET_OK;
3595 } 3576 }
3596 } 3577 }
3597 else 3578 else
@@ -3714,11 +3695,14 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
3714 GDS_ROUTING_SRC_TO_DEST); 3695 GDS_ROUTING_SRC_TO_DEST);
3715 if (NULL == next_hop) 3696 if (NULL == next_hop)
3716 { 3697 {
3698 DEBUG(" NO ENTRY FOUND IN %s ROUTING TABLE for trail id %s, line",
3699 GNUNET_i2s(&my_identity), GNUNET_h2s(&intermediate_trail_id), __LINE__);
3717 GNUNET_STATISTICS_update (GDS_stats, 3700 GNUNET_STATISTICS_update (GDS_stats,
3718 gettext_noop ("# Next hop to forward the packet not found " 3701 gettext_noop ("# Next hop to forward the packet not found "
3719 "GET request, packet dropped."), 3702 "GET request, packet dropped."),
3720 1, GNUNET_NO); 3703 1, GNUNET_NO);
3721 return GNUNET_SYSERR; 3704 GNUNET_break (0);
3705 return GNUNET_OK;
3722 } 3706 }
3723 } 3707 }
3724 else 3708 else
@@ -3884,7 +3868,7 @@ get_local_best_known_next_hop (uint64_t final_dest_finger_val,
3884 0 != GNUNET_CRYPTO_cmp_peer_identity (&peer.best_known_destination, 3868 0 != GNUNET_CRYPTO_cmp_peer_identity (&peer.best_known_destination,
3885 current_dest)) 3869 current_dest))
3886 { 3870 {
3887 const struct GNUNET_PeerIdentity *closest_peer; 3871 struct GNUNET_PeerIdentity closest_peer;
3888 3872
3889 closest_peer = select_closest_peer (&peer.best_known_destination, 3873 closest_peer = select_closest_peer (&peer.best_known_destination,
3890 current_dest, 3874 current_dest,
@@ -3892,7 +3876,7 @@ get_local_best_known_next_hop (uint64_t final_dest_finger_val,
3892 is_predecessor); 3876 is_predecessor);
3893 3877
3894 /* Is current dest (end point of the trail of which I am a part) closest_peer? */ 3878 /* Is current dest (end point of the trail of which I am a part) closest_peer? */
3895 if (0 == GNUNET_CRYPTO_cmp_peer_identity (current_dest, closest_peer)) 3879 if (0 == GNUNET_CRYPTO_cmp_peer_identity (current_dest, &closest_peer))
3896 { 3880 {
3897 struct GNUNET_PeerIdentity *next_hop; 3881 struct GNUNET_PeerIdentity *next_hop;
3898 3882
@@ -4577,7 +4561,7 @@ compare_and_update_predecessor (struct GNUNET_PeerIdentity finger,
4577 unsigned int trail_length) 4561 unsigned int trail_length)
4578{ 4562{
4579 struct FingerInfo *current_predecessor; 4563 struct FingerInfo *current_predecessor;
4580 const struct GNUNET_PeerIdentity *closest_peer; 4564 struct GNUNET_PeerIdentity closest_peer;
4581 uint64_t predecessor_value; 4565 uint64_t predecessor_value;
4582 unsigned int is_predecessor = 1; 4566 unsigned int is_predecessor = 1;
4583 4567
@@ -4605,7 +4589,7 @@ compare_and_update_predecessor (struct GNUNET_PeerIdentity finger,
4605 4589
4606 /* Finger is the closest predecessor. Remove the existing one and add the new 4590 /* Finger is the closest predecessor. Remove the existing one and add the new
4607 one. */ 4591 one. */
4608 if (closest_peer == &finger) 4592 if (0 == GNUNET_CRYPTO_cmp_peer_identity(&closest_peer, &finger))
4609 { 4593 {
4610 remove_existing_finger (current_predecessor, PREDECESSOR_FINGER_ID); 4594 remove_existing_finger (current_predecessor, PREDECESSOR_FINGER_ID);
4611 update_predecessor (finger, trail, trail_length); 4595 update_predecessor (finger, trail, trail_length);
@@ -4676,10 +4660,9 @@ handle_dht_p2p_verify_successor(void *cls,
4676 next_hop = GDS_ROUTING_get_next_hop (trail_id, GDS_ROUTING_SRC_TO_DEST); 4660 next_hop = GDS_ROUTING_get_next_hop (trail_id, GDS_ROUTING_SRC_TO_DEST);
4677 if (NULL == next_hop) 4661 if (NULL == next_hop)
4678 { 4662 {
4679// GNUNET_break_op (0); 4663 DEBUG(" NO ENTRY FOUND IN %s ROUTING TABLE for trail id %s, line",
4680// return GNUNET_SYSERR; 4664 GNUNET_i2s(&my_identity), GNUNET_h2s(&trail_id), __LINE__);
4681 //FIXME: Here it may happen that trail has not yet been added 4665 GNUNET_break_op (0);
4682 //in notify successor.
4683 return GNUNET_OK; 4666 return GNUNET_OK;
4684 } 4667 }
4685 4668
@@ -4821,7 +4804,7 @@ compare_and_update_successor (struct GNUNET_PeerIdentity curr_succ,
4821 unsigned int trail_length) 4804 unsigned int trail_length)
4822{ 4805{
4823 struct FingerInfo *current_successor; 4806 struct FingerInfo *current_successor;
4824 const struct GNUNET_PeerIdentity *closest_peer; 4807 struct GNUNET_PeerIdentity closest_peer;
4825 struct GNUNET_HashCode trail_id; 4808 struct GNUNET_HashCode trail_id;
4826 struct GNUNET_PeerIdentity *trail_me_to_probable_succ; 4809 struct GNUNET_PeerIdentity *trail_me_to_probable_succ;
4827 struct FriendInfo *target_friend; 4810 struct FriendInfo *target_friend;
@@ -4842,7 +4825,8 @@ compare_and_update_successor (struct GNUNET_PeerIdentity curr_succ,
4842 successor_value, is_predecessor); 4825 successor_value, is_predecessor);
4843 4826
4844 /* If the current_successor in the finger table is closest, then do nothing. */ 4827 /* If the current_successor in the finger table is closest, then do nothing. */
4845 if (closest_peer == &current_successor->finger_identity) 4828 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&closest_peer ,
4829 &current_successor->finger_identity))
4846 { 4830 {
4847 /* Code for testing ONLY: Store the successor for path tracking */ 4831 /* Code for testing ONLY: Store the successor for path tracking */
4848// track_topology = 1; 4832// track_topology = 1;
@@ -4989,6 +4973,8 @@ handle_dht_p2p_verify_successor_result(void *cls,
4989 if(NULL == (next_hop = 4973 if(NULL == (next_hop =
4990 GDS_ROUTING_get_next_hop (trail_id, trail_direction))) 4974 GDS_ROUTING_get_next_hop (trail_id, trail_direction)))
4991 { 4975 {
4976 DEBUG(" NO ENTRY FOUND IN %s ROUTING TABLE for trail id %s, line",
4977 GNUNET_i2s(&my_identity), GNUNET_h2s(&trail_id), __LINE__);
4992 GNUNET_break_op(0); 4978 GNUNET_break_op(0);
4993 return GNUNET_OK; 4979 return GNUNET_OK;
4994 } 4980 }
@@ -5309,9 +5295,10 @@ handle_dht_p2p_trail_teardown (void *cls, const struct GNUNET_PeerIdentity *peer
5309#endif 5295#endif
5310 5296
5311 next_hop = GDS_ROUTING_get_next_hop (trail_id, trail_direction); 5297 next_hop = GDS_ROUTING_get_next_hop (trail_id, trail_direction);
5312
5313 if (NULL == next_hop) 5298 if (NULL == next_hop)
5314 { 5299 {
5300 DEBUG(" NO ENTRY FOUND IN %s ROUTING TABLE for trail id %s, line",
5301 GNUNET_i2s(&my_identity), GNUNET_h2s(&trail_id), __LINE__);
5315 GNUNET_break (0); 5302 GNUNET_break (0);
5316 return GNUNET_SYSERR; 5303 return GNUNET_SYSERR;
5317 } 5304 }
@@ -5483,8 +5470,10 @@ remove_matching_trails (const struct GNUNET_PeerIdentity *disconnected_friend,
5483 previously disconnected peer was either a next hop or prev hop of that 5470 previously disconnected peer was either a next hop or prev hop of that
5484 peer. */ 5471 peer. */
5485 if (NULL == next_hop) 5472 if (NULL == next_hop)
5473 {
5474 //TODO UNDERSTAND why do you continue here?
5486 continue; 5475 continue;
5487 5476 }
5488 GNUNET_assert (0 == (GNUNET_CRYPTO_cmp_peer_identity (disconnected_friend, 5477 GNUNET_assert (0 == (GNUNET_CRYPTO_cmp_peer_identity (disconnected_friend,
5489 next_hop))); 5478 next_hop)));
5490 matching_trails_count++; 5479 matching_trails_count++;
@@ -5557,6 +5546,8 @@ remove_matching_fingers (const struct GNUNET_PeerIdentity *disconnected_peer)
5557 GNUNET_CONTAINER_multipeermap_get (friend_peermap, 5546 GNUNET_CONTAINER_multipeermap_get (friend_peermap,
5558 disconnected_peer))); 5547 disconnected_peer)));
5559 } 5548 }
5549 //TODO should we handle the else case.
5550
5560 5551
5561 remove_finger->trail_list[0].is_present = GNUNET_NO; 5552 remove_finger->trail_list[0].is_present = GNUNET_NO;
5562 //GNUNET_assert (0 != remove_friend->trails_count); 5553 //GNUNET_assert (0 != remove_friend->trails_count);
@@ -5696,7 +5687,7 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer_identity)
5696 /* got a first connection, good time to start with FIND FINGER TRAIL requests...*/ 5687 /* got a first connection, good time to start with FIND FINGER TRAIL requests...*/
5697 if (GNUNET_SCHEDULER_NO_TASK == find_finger_trail_task) 5688 if (GNUNET_SCHEDULER_NO_TASK == find_finger_trail_task)
5698 { 5689 {
5699 next_send_time.rel_value_us = 5690 find_finger_trail_task_next_send_time.rel_value_us =
5700 DHT_FIND_FINGER_TRAIL_INTERVAL.rel_value_us + 5691 DHT_FIND_FINGER_TRAIL_INTERVAL.rel_value_us +
5701 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 5692 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
5702 DHT_FIND_FINGER_TRAIL_INTERVAL.rel_value_us); 5693 DHT_FIND_FINGER_TRAIL_INTERVAL.rel_value_us);