diff options
Diffstat (limited to 'src/dht/gnunet-service-dht_neighbours.c')
-rw-r--r-- | src/dht/gnunet-service-dht_neighbours.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index 697e49442..acc8eaa27 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c | |||
@@ -76,12 +76,12 @@ | |||
76 | /** | 76 | /** |
77 | * How long at least to wait before sending another find peer request. | 77 | * How long at least to wait before sending another find peer request. |
78 | */ | 78 | */ |
79 | #define DHT_MINIMUM_FIND_PEER_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 2) | 79 | #define DHT_MINIMUM_FIND_PEER_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30) |
80 | 80 | ||
81 | /** | 81 | /** |
82 | * How long at most to wait before sending another find peer request. | 82 | * How long at most to wait before sending another find peer request. |
83 | */ | 83 | */ |
84 | #define DHT_MAXIMUM_FIND_PEER_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 8) | 84 | #define DHT_MAXIMUM_FIND_PEER_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 10) |
85 | 85 | ||
86 | /** | 86 | /** |
87 | * How long at most to wait for transmission of a GET request to another peer? | 87 | * How long at most to wait for transmission of a GET request to another peer? |
@@ -611,11 +611,11 @@ send_find_peer_message (void *cls, | |||
611 | GNUNET_CONTAINER_bloomfilter_free (peer_bf); | 611 | GNUNET_CONTAINER_bloomfilter_free (peer_bf); |
612 | GNUNET_CONTAINER_bloomfilter_free (bcc.bloom); | 612 | GNUNET_CONTAINER_bloomfilter_free (bcc.bloom); |
613 | /* schedule next round */ | 613 | /* schedule next round */ |
614 | newly_found_peers = 0; | ||
615 | next_send_time.rel_value = | 614 | next_send_time.rel_value = |
616 | (DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / 2) + | 615 | DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value + |
617 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, | 616 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, |
618 | DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / 2); | 617 | DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / (newly_found_peers+1)); |
618 | newly_found_peers = 0; | ||
619 | find_peer_task = GNUNET_SCHEDULER_add_delayed (next_send_time, | 619 | find_peer_task = GNUNET_SCHEDULER_add_delayed (next_send_time, |
620 | &send_find_peer_message, | 620 | &send_find_peer_message, |
621 | NULL); | 621 | NULL); |
@@ -646,6 +646,9 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
646 | GNUNET_break (0); | 646 | GNUNET_break (0); |
647 | return; | 647 | return; |
648 | } | 648 | } |
649 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
650 | "Peer `%s' connected!\n", | ||
651 | GNUNET_i2s (peer)); | ||
649 | GNUNET_STATISTICS_update (GDS_stats, | 652 | GNUNET_STATISTICS_update (GDS_stats, |
650 | gettext_noop ("# Peers connected"), 1, | 653 | gettext_noop ("# Peers connected"), 1, |
651 | GNUNET_NO); | 654 | GNUNET_NO); |
@@ -664,8 +667,10 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
664 | peer_bucket); | 667 | peer_bucket); |
665 | if ( (peer_bucket > 0) && | 668 | if ( (peer_bucket > 0) && |
666 | (k_buckets[peer_bucket].peers_size <= bucket_size) ) | 669 | (k_buckets[peer_bucket].peers_size <= bucket_size) ) |
670 | { | ||
667 | ret->preference_task = GNUNET_SCHEDULER_add_now (&update_core_preference, ret); | 671 | ret->preference_task = GNUNET_SCHEDULER_add_now (&update_core_preference, ret); |
668 | newly_found_peers++; | 672 | newly_found_peers++; |
673 | } | ||
669 | GNUNET_assert (GNUNET_OK == | 674 | GNUNET_assert (GNUNET_OK == |
670 | GNUNET_CONTAINER_multihashmap_put (all_known_peers, | 675 | GNUNET_CONTAINER_multihashmap_put (all_known_peers, |
671 | &peer->hashPubKey, ret, | 676 | &peer->hashPubKey, ret, |
@@ -692,9 +697,6 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
692 | int current_bucket; | 697 | int current_bucket; |
693 | struct P2PPendingMessage *pos; | 698 | struct P2PPendingMessage *pos; |
694 | 699 | ||
695 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
696 | "Peer `%s' disconnected!\n", | ||
697 | GNUNET_i2s (peer)); | ||
698 | /* Check for disconnect from self message */ | 700 | /* Check for disconnect from self message */ |
699 | if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity))) | 701 | if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity))) |
700 | return; | 702 | return; |
@@ -705,6 +707,9 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
705 | GNUNET_break (0); | 707 | GNUNET_break (0); |
706 | return; | 708 | return; |
707 | } | 709 | } |
710 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
711 | "Peer `%s' disconnected!\n", | ||
712 | GNUNET_i2s (peer)); | ||
708 | GNUNET_STATISTICS_update (GDS_stats, | 713 | GNUNET_STATISTICS_update (GDS_stats, |
709 | gettext_noop ("# Peers connected"), -1, | 714 | gettext_noop ("# Peers connected"), -1, |
710 | GNUNET_NO); | 715 | GNUNET_NO); |
@@ -1208,7 +1213,13 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type, | |||
1208 | desired_replication_level, | 1213 | desired_replication_level, |
1209 | &targets); | 1214 | &targets); |
1210 | if (0 == target_count) | 1215 | if (0 == target_count) |
1211 | return; | 1216 | { |
1217 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1218 | "Not forwarding PUT for `%s' after %u hops!\n", | ||
1219 | GNUNET_h2s (key), | ||
1220 | hop_count); | ||
1221 | return; | ||
1222 | } | ||
1212 | msize = put_path_length * sizeof (struct GNUNET_PeerIdentity) + data_size + sizeof (struct PeerPutMessage); | 1223 | msize = put_path_length * sizeof (struct GNUNET_PeerIdentity) + data_size + sizeof (struct PeerPutMessage); |
1213 | if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1224 | if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) |
1214 | { | 1225 | { |
@@ -1306,7 +1317,13 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type, | |||
1306 | desired_replication_level, | 1317 | desired_replication_level, |
1307 | &targets); | 1318 | &targets); |
1308 | if (0 == target_count) | 1319 | if (0 == target_count) |
1309 | return; | 1320 | { |
1321 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1322 | "Not forwarding PUT for `%s' after %u hops!\n", | ||
1323 | GNUNET_h2s (key), | ||
1324 | hop_count); | ||
1325 | return; | ||
1326 | } | ||
1310 | reply_bf_size = GNUNET_CONTAINER_bloomfilter_get_size (reply_bf); | 1327 | reply_bf_size = GNUNET_CONTAINER_bloomfilter_get_size (reply_bf); |
1311 | msize = xquery_size + sizeof (struct PeerGetMessage) + reply_bf_size; | 1328 | msize = xquery_size + sizeof (struct PeerGetMessage) + reply_bf_size; |
1312 | if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1329 | if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) |
@@ -1406,6 +1423,9 @@ GDS_NEIGHBOURS_handle_reply (const struct GNUNET_PeerIdentity *target, | |||
1406 | if (NULL == pi) | 1423 | if (NULL == pi) |
1407 | { | 1424 | { |
1408 | /* peer disconnected in the meantime, drop reply */ | 1425 | /* peer disconnected in the meantime, drop reply */ |
1426 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1427 | "Not forwarding REPLY for `%s' due to predecessor disconnect\n", | ||
1428 | GNUNET_h2s (key)); | ||
1409 | return; | 1429 | return; |
1410 | } | 1430 | } |
1411 | GNUNET_STATISTICS_update (GDS_stats, | 1431 | GNUNET_STATISTICS_update (GDS_stats, |