diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-09-29 23:27:30 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-09-29 23:27:30 +0000 |
commit | fd48e49b3fd6b78206165f2200020160a3a41566 (patch) | |
tree | 6d03a27933312186fe6e64ea767737951a501cbd /src/dht | |
parent | 17e99f4b0c90724f11dc998b2c7d23725a18d95e (diff) | |
download | gnunet-fd48e49b3fd6b78206165f2200020160a3a41566.tar.gz gnunet-fd48e49b3fd6b78206165f2200020160a3a41566.zip |
removing excessive logging, adding missing decrement (choice) to avoid assertion failure; fixing loop bounds in non-random peer selection
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/gnunet-service-dht_neighbours.c | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index 965321fd3..46220a855 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c | |||
@@ -412,6 +412,7 @@ static struct GNUNET_PeerIdentity my_identity; | |||
412 | static struct GNUNET_CORE_Handle *coreAPI; | 412 | static struct GNUNET_CORE_Handle *coreAPI; |
413 | 413 | ||
414 | 414 | ||
415 | |||
415 | /** | 416 | /** |
416 | * Find the optimal bucket for this key. | 417 | * Find the optimal bucket for this key. |
417 | * | 418 | * |
@@ -646,9 +647,6 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
646 | GNUNET_break (0); | 647 | GNUNET_break (0); |
647 | return; | 648 | return; |
648 | } | 649 | } |
649 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
650 | "Peer `%s' connected!\n", | ||
651 | GNUNET_i2s (peer)); | ||
652 | GNUNET_STATISTICS_update (GDS_stats, | 650 | GNUNET_STATISTICS_update (GDS_stats, |
653 | gettext_noop ("# Peers connected"), 1, | 651 | gettext_noop ("# Peers connected"), 1, |
654 | GNUNET_NO); | 652 | GNUNET_NO); |
@@ -707,9 +705,6 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
707 | GNUNET_break (0); | 705 | GNUNET_break (0); |
708 | return; | 706 | return; |
709 | } | 707 | } |
710 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
711 | "Peer `%s' disconnected!\n", | ||
712 | GNUNET_i2s (peer)); | ||
713 | GNUNET_STATISTICS_update (GDS_stats, | 708 | GNUNET_STATISTICS_update (GDS_stats, |
714 | gettext_noop ("# Peers connected"), -1, | 709 | gettext_noop ("# Peers connected"), -1, |
715 | GNUNET_NO); | 710 | GNUNET_NO); |
@@ -1021,7 +1016,7 @@ select_peer (const GNUNET_HashCode *key, | |||
1021 | /* greedy selection (closest peer that is not in bloomfilter) */ | 1016 | /* greedy selection (closest peer that is not in bloomfilter) */ |
1022 | smallest_distance = UINT_MAX; | 1017 | smallest_distance = UINT_MAX; |
1023 | chosen = NULL; | 1018 | chosen = NULL; |
1024 | for (bc = closest_bucket; bc < MAX_BUCKETS; bc++) | 1019 | for (bc = 0; bc < closest_bucket; bc++) |
1025 | { | 1020 | { |
1026 | pos = k_buckets[bc].head; | 1021 | pos = k_buckets[bc].head; |
1027 | count = 0; | 1022 | count = 0; |
@@ -1141,13 +1136,12 @@ get_target_peers (const GNUNET_HashCode *key, | |||
1141 | return 0; | 1136 | return 0; |
1142 | } | 1137 | } |
1143 | rtargets = GNUNET_malloc (sizeof (struct PeerInfo*) * ret); | 1138 | rtargets = GNUNET_malloc (sizeof (struct PeerInfo*) * ret); |
1144 | off = 0; | 1139 | for (off = 0; off < ret; off++) |
1145 | while (ret-- > 0) | ||
1146 | { | 1140 | { |
1147 | nxt = select_peer (key, bloom, hop_count); | 1141 | nxt = select_peer (key, bloom, hop_count); |
1148 | if (nxt == NULL) | 1142 | if (nxt == NULL) |
1149 | break; | 1143 | break; |
1150 | rtargets[off++] = nxt; | 1144 | rtargets[off] = nxt; |
1151 | GNUNET_break (GNUNET_NO == | 1145 | GNUNET_break (GNUNET_NO == |
1152 | GNUNET_CONTAINER_bloomfilter_test (bloom, &nxt->id.hashPubKey)); | 1146 | GNUNET_CONTAINER_bloomfilter_test (bloom, &nxt->id.hashPubKey)); |
1153 | GNUNET_CONTAINER_bloomfilter_add (bloom, &nxt->id.hashPubKey); | 1147 | GNUNET_CONTAINER_bloomfilter_add (bloom, &nxt->id.hashPubKey); |
@@ -1214,11 +1208,6 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type, | |||
1214 | &targets); | 1208 | &targets); |
1215 | if (0 == target_count) | 1209 | if (0 == target_count) |
1216 | { | 1210 | { |
1217 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1218 | "Not forwarding PUT for `%s' after %u hops (NSE: %f)!\n", | ||
1219 | GNUNET_h2s (key), | ||
1220 | hop_count, | ||
1221 | GDS_NSE_get()); | ||
1222 | return; | 1211 | return; |
1223 | } | 1212 | } |
1224 | msize = put_path_length * sizeof (struct GNUNET_PeerIdentity) + data_size + sizeof (struct PeerPutMessage); | 1213 | msize = put_path_length * sizeof (struct GNUNET_PeerIdentity) + data_size + sizeof (struct PeerPutMessage); |
@@ -1319,10 +1308,6 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type, | |||
1319 | &targets); | 1308 | &targets); |
1320 | if (0 == target_count) | 1309 | if (0 == target_count) |
1321 | { | 1310 | { |
1322 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1323 | "Not forwarding GET for `%s' after %u hops!\n", | ||
1324 | GNUNET_h2s (key), | ||
1325 | hop_count); | ||
1326 | return; | 1311 | return; |
1327 | } | 1312 | } |
1328 | reply_bf_size = GNUNET_CONTAINER_bloomfilter_get_size (reply_bf); | 1313 | reply_bf_size = GNUNET_CONTAINER_bloomfilter_get_size (reply_bf); |
@@ -1424,9 +1409,6 @@ GDS_NEIGHBOURS_handle_reply (const struct GNUNET_PeerIdentity *target, | |||
1424 | if (NULL == pi) | 1409 | if (NULL == pi) |
1425 | { | 1410 | { |
1426 | /* peer disconnected in the meantime, drop reply */ | 1411 | /* peer disconnected in the meantime, drop reply */ |
1427 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1428 | "Not forwarding REPLY for `%s' due to predecessor disconnect\n", | ||
1429 | GNUNET_h2s (key)); | ||
1430 | return; | 1412 | return; |
1431 | } | 1413 | } |
1432 | GNUNET_STATISTICS_update (GDS_stats, | 1414 | GNUNET_STATISTICS_update (GDS_stats, |
@@ -1667,6 +1649,7 @@ handle_find_peer (const struct GNUNET_PeerIdentity *sender, | |||
1667 | { | 1649 | { |
1668 | GNUNET_assert (peer != NULL); | 1650 | GNUNET_assert (peer != NULL); |
1669 | peer = peer->next; | 1651 | peer = peer->next; |
1652 | choice--; | ||
1670 | } | 1653 | } |
1671 | choice = bucket->peers_size; | 1654 | choice = bucket->peers_size; |
1672 | do | 1655 | do |