diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-11-14 13:05:28 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-11-14 13:05:28 +0000 |
commit | c4907c3ed9b170a97b7c1498a70546a85f77aab1 (patch) | |
tree | 7ad457eb6771442da032f9b30cda2794379ef4ff | |
parent | 0b1fb75c9b87c9edfac4256ae57790508b8d6b1a (diff) | |
download | gnunet-c4907c3ed9b170a97b7c1498a70546a85f77aab1.tar.gz gnunet-c4907c3ed9b170a97b7c1498a70546a85f77aab1.zip |
-extra logging, minor code cleanup
-rw-r--r-- | src/dht/gnunet-service-dht_neighbours.c | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index f865d9042..5d11e55ae 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c | |||
@@ -94,6 +94,11 @@ | |||
94 | */ | 94 | */ |
95 | #define GET_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 2) | 95 | #define GET_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 2) |
96 | 96 | ||
97 | /** | ||
98 | * Should routing details be logged to stderr (for debugging)? | ||
99 | */ | ||
100 | #define LOG_ROUTE_DETAILS_STDERR GNUNET_NO | ||
101 | |||
97 | 102 | ||
98 | GNUNET_NETWORK_STRUCT_BEGIN | 103 | GNUNET_NETWORK_STRUCT_BEGIN |
99 | 104 | ||
@@ -816,7 +821,7 @@ process_peer_queue (struct PeerInfo *peer) | |||
816 | return; | 821 | return; |
817 | GNUNET_STATISTICS_update (GDS_stats, | 822 | GNUNET_STATISTICS_update (GDS_stats, |
818 | gettext_noop | 823 | gettext_noop |
819 | ("# Bytes of bandwdith requested from core"), | 824 | ("# Bytes of bandwidth requested from core"), |
820 | ntohs (pending->msg->size), GNUNET_NO); | 825 | ntohs (pending->msg->size), GNUNET_NO); |
821 | peer->th = | 826 | peer->th = |
822 | GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES, | 827 | GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES, |
@@ -1090,19 +1095,16 @@ select_peer (const struct GNUNET_HashCode * key, | |||
1090 | count = 0; | 1095 | count = 0; |
1091 | for (bc = 0; bc <= closest_bucket; bc++) | 1096 | for (bc = 0; bc <= closest_bucket; bc++) |
1092 | { | 1097 | { |
1093 | pos = k_buckets[bc].head; | 1098 | for (pos = k_buckets[bc].head; ((pos != NULL) && (count < bucket_size)); pos = pos->next) |
1094 | while ((pos != NULL) && (count < bucket_size)) | ||
1095 | { | 1099 | { |
1096 | if ((bloom != NULL) && | 1100 | if ((bloom != NULL) && |
1097 | (GNUNET_YES == | 1101 | (GNUNET_YES == |
1098 | GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey))) | 1102 | GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey))) |
1099 | { | 1103 | { |
1100 | pos = pos->next; | ||
1101 | continue; /* Ignore bloomfiltered peers */ | 1104 | continue; /* Ignore bloomfiltered peers */ |
1102 | } | 1105 | } |
1103 | if (0 == selected--) | 1106 | if (0 == selected--) |
1104 | return pos; | 1107 | return pos; |
1105 | pos = pos->next; | ||
1106 | } | 1108 | } |
1107 | } | 1109 | } |
1108 | GNUNET_break (0); | 1110 | GNUNET_break (0); |
@@ -1124,7 +1126,7 @@ select_peer (const struct GNUNET_HashCode * key, | |||
1124 | * @return number of peers returned in 'targets'. | 1126 | * @return number of peers returned in 'targets'. |
1125 | */ | 1127 | */ |
1126 | static unsigned int | 1128 | static unsigned int |
1127 | get_target_peers (const struct GNUNET_HashCode * key, | 1129 | get_target_peers (const struct GNUNET_HashCode *key, |
1128 | struct GNUNET_CONTAINER_BloomFilter *bloom, | 1130 | struct GNUNET_CONTAINER_BloomFilter *bloom, |
1129 | uint32_t hop_count, uint32_t target_replication, | 1131 | uint32_t hop_count, uint32_t target_replication, |
1130 | struct PeerInfo ***targets) | 1132 | struct PeerInfo ***targets) |
@@ -1135,7 +1137,7 @@ get_target_peers (const struct GNUNET_HashCode * key, | |||
1135 | struct PeerInfo *nxt; | 1137 | struct PeerInfo *nxt; |
1136 | 1138 | ||
1137 | GNUNET_assert (NULL != bloom); | 1139 | GNUNET_assert (NULL != bloom); |
1138 | ret = get_forward_count (hop_count, target_replication); | 1140 | ret = get_forward_count (hop_count, target_replication); |
1139 | if (ret == 0) | 1141 | if (ret == 0) |
1140 | { | 1142 | { |
1141 | *targets = NULL; | 1143 | *targets = NULL; |
@@ -1164,6 +1166,11 @@ get_target_peers (const struct GNUNET_HashCode * key, | |||
1164 | return 0; | 1166 | return 0; |
1165 | } | 1167 | } |
1166 | *targets = rtargets; | 1168 | *targets = rtargets; |
1169 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1170 | "Forwarding query `%s' to %u peers (goal was %u peers)\n", | ||
1171 | GNUNET_h2s (key), | ||
1172 | off, | ||
1173 | ret); | ||
1167 | return off; | 1174 | return off; |
1168 | } | 1175 | } |
1169 | 1176 | ||
@@ -1585,6 +1592,17 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1585 | } | 1592 | } |
1586 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PUT for `%s' from %s\n", | 1593 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PUT for `%s' from %s\n", |
1587 | GNUNET_h2s (&put->key), GNUNET_i2s (peer)); | 1594 | GNUNET_h2s (&put->key), GNUNET_i2s (peer)); |
1595 | |||
1596 | if (LOG_ROUTE_DETAILS_STDERR) | ||
1597 | { | ||
1598 | char *tmp; | ||
1599 | |||
1600 | tmp = GNUNET_strdup (GNUNET_i2s (&my_identity)); | ||
1601 | fprintf (stderr, "XDHT PUT %s: %s<-%s\n", GNUNET_h2s (&put->key), tmp, GNUNET_i2s (peer)); | ||
1602 | GNUNET_free (tmp); | ||
1603 | } | ||
1604 | |||
1605 | |||
1588 | bf = GNUNET_CONTAINER_bloomfilter_init (put->bloomfilter, DHT_BLOOM_SIZE, | 1606 | bf = GNUNET_CONTAINER_bloomfilter_init (put->bloomfilter, DHT_BLOOM_SIZE, |
1589 | GNUNET_CONSTANTS_BLOOMFILTER_K); | 1607 | GNUNET_CONSTANTS_BLOOMFILTER_K); |
1590 | GNUNET_break_op (GNUNET_YES == | 1608 | GNUNET_break_op (GNUNET_YES == |
@@ -1832,6 +1850,17 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1832 | 1, GNUNET_NO); | 1850 | 1, GNUNET_NO); |
1833 | } | 1851 | } |
1834 | 1852 | ||
1853 | if (LOG_ROUTE_DETAILS_STDERR) | ||
1854 | { | ||
1855 | char *tmp; | ||
1856 | |||
1857 | tmp = GNUNET_strdup (GNUNET_i2s (&my_identity)); | ||
1858 | fprintf (stderr, "XDHT GET %s: %s<-%s\n", GNUNET_h2s (&get->key), tmp, GNUNET_i2s (peer)); | ||
1859 | GNUNET_free (tmp); | ||
1860 | } | ||
1861 | |||
1862 | |||
1863 | |||
1835 | /* FIXME Path */ | 1864 | /* FIXME Path */ |
1836 | GDS_CLIENTS_process_get (options, | 1865 | GDS_CLIENTS_process_get (options, |
1837 | type, | 1866 | type, |
@@ -1954,6 +1983,16 @@ handle_dht_p2p_result (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1954 | } | 1983 | } |
1955 | } | 1984 | } |
1956 | 1985 | ||
1986 | |||
1987 | if (LOG_ROUTE_DETAILS_STDERR) | ||
1988 | { | ||
1989 | char *tmp; | ||
1990 | |||
1991 | tmp = GNUNET_strdup (GNUNET_i2s (&my_identity)); | ||
1992 | fprintf (stderr, "XDHT RESULT %s: %s<-%s\n", GNUNET_h2s (&prm->key), tmp, GNUNET_i2s (peer)); | ||
1993 | GNUNET_free (tmp); | ||
1994 | } | ||
1995 | |||
1957 | /* append 'peer' to 'get_path' */ | 1996 | /* append 'peer' to 'get_path' */ |
1958 | { | 1997 | { |
1959 | struct GNUNET_PeerIdentity xget_path[get_path_length + 1]; | 1998 | struct GNUNET_PeerIdentity xget_path[get_path_length + 1]; |