diff options
Diffstat (limited to 'src/dht/gnunet-dht-driver.c')
-rw-r--r-- | src/dht/gnunet-dht-driver.c | 101 |
1 files changed, 50 insertions, 51 deletions
diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c index d58e49e3b..4f411f4a9 100644 --- a/src/dht/gnunet-dht-driver.c +++ b/src/dht/gnunet-dht-driver.c | |||
@@ -1244,12 +1244,14 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1244 | /** | 1244 | /** |
1245 | * Forward declaration. | 1245 | * Forward declaration. |
1246 | */ | 1246 | */ |
1247 | static void do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 1247 | static void |
1248 | do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
1248 | 1249 | ||
1249 | /** | 1250 | /** |
1250 | * Forward declaration. | 1251 | * Forward declaration. |
1251 | */ | 1252 | */ |
1252 | static void do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 1253 | static void |
1254 | do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
1253 | 1255 | ||
1254 | /** | 1256 | /** |
1255 | * Iterator over hash map entries. | 1257 | * Iterator over hash map entries. |
@@ -1465,8 +1467,8 @@ iterate_min_heap_peers (void *cls, struct GNUNET_CONTAINER_HeapNode *node, | |||
1465 | GNUNET_TESTING_daemons_connect (d1, d2, timeout, DEFAULT_RECONNECT_ATTEMPTS, | 1467 | GNUNET_TESTING_daemons_connect (d1, d2, timeout, DEFAULT_RECONNECT_ATTEMPTS, |
1466 | GNUNET_YES, NULL, NULL); | 1468 | GNUNET_YES, NULL, NULL); |
1467 | } | 1469 | } |
1468 | if (GNUNET_TIME_absolute_get_remaining (find_peer_context->endtime). | 1470 | if (GNUNET_TIME_absolute_get_remaining (find_peer_context->endtime).rel_value |
1469 | rel_value > 0) | 1471 | > 0) |
1470 | return GNUNET_YES; | 1472 | return GNUNET_YES; |
1471 | else | 1473 | else |
1472 | return GNUNET_NO; | 1474 | return GNUNET_NO; |
@@ -1475,10 +1477,10 @@ iterate_min_heap_peers (void *cls, struct GNUNET_CONTAINER_HeapNode *node, | |||
1475 | /** | 1477 | /** |
1476 | * Forward declaration. | 1478 | * Forward declaration. |
1477 | */ | 1479 | */ |
1478 | static void schedule_churn_find_peer_requests (void *cls, | 1480 | static void |
1479 | const struct | 1481 | schedule_churn_find_peer_requests (void *cls, |
1480 | GNUNET_SCHEDULER_TaskContext | 1482 | const struct GNUNET_SCHEDULER_TaskContext |
1481 | *tc); | 1483 | *tc); |
1482 | 1484 | ||
1483 | /** | 1485 | /** |
1484 | * Callback for iterating over all the peer connections of a peer group. | 1486 | * Callback for iterating over all the peer connections of a peer group. |
@@ -1555,12 +1557,11 @@ count_peers_churn_cb (void *cls, const struct GNUNET_PeerIdentity *first, | |||
1555 | */ | 1557 | */ |
1556 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1558 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1557 | "Out of %u peers, fewest connections is %d\n", | 1559 | "Out of %u peers, fewest connections is %d\n", |
1558 | GNUNET_CONTAINER_heap_get_size (find_peer_context-> | 1560 | GNUNET_CONTAINER_heap_get_size |
1559 | peer_min_heap), | 1561 | (find_peer_context->peer_min_heap), peer_count->count); |
1560 | peer_count->count); | ||
1561 | if ((peer_count->count == 0) && | 1562 | if ((peer_count->count == 0) && |
1562 | (GNUNET_TIME_absolute_get_remaining (find_peer_context->endtime). | 1563 | (GNUNET_TIME_absolute_get_remaining |
1563 | rel_value > 0)) | 1564 | (find_peer_context->endtime).rel_value > 0)) |
1564 | { | 1565 | { |
1565 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1566 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1566 | "Found peer with no connections, will choose some peer(s) at random to connect to!\n"); | 1567 | "Found peer with no connections, will choose some peer(s) at random to connect to!\n"); |
@@ -1570,8 +1571,9 @@ count_peers_churn_cb (void *cls, const struct GNUNET_PeerIdentity *first, | |||
1570 | GNUNET_SCHEDULER_add_now (&schedule_churn_find_peer_requests, | 1571 | GNUNET_SCHEDULER_add_now (&schedule_churn_find_peer_requests, |
1571 | find_peer_context); | 1572 | find_peer_context); |
1572 | } | 1573 | } |
1573 | else if ((GNUNET_TIME_absolute_get_remaining (find_peer_context->endtime). | 1574 | else if ((GNUNET_TIME_absolute_get_remaining |
1574 | rel_value > 0) && (find_peer_context->last_sent != 0)) | 1575 | (find_peer_context->endtime).rel_value > 0) && |
1576 | (find_peer_context->last_sent != 0)) | ||
1575 | { | 1577 | { |
1576 | GNUNET_SCHEDULER_add_now (&schedule_churn_find_peer_requests, | 1578 | GNUNET_SCHEDULER_add_now (&schedule_churn_find_peer_requests, |
1577 | find_peer_context); | 1579 | find_peer_context); |
@@ -1772,8 +1774,8 @@ churn_complete (void *cls, const char *emsg) | |||
1772 | } | 1774 | } |
1773 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1775 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1774 | "Added %d peers to heap, total size %d\n", count_added, | 1776 | "Added %d peers to heap, total size %d\n", count_added, |
1775 | GNUNET_CONTAINER_heap_get_size (find_peer_context-> | 1777 | GNUNET_CONTAINER_heap_get_size |
1776 | peer_min_heap)); | 1778 | (find_peer_context->peer_min_heap)); |
1777 | GNUNET_SCHEDULER_add_delayed (DEFAULT_PEER_DISCONNECT_TIMEOUT, | 1779 | GNUNET_SCHEDULER_add_delayed (DEFAULT_PEER_DISCONNECT_TIMEOUT, |
1778 | &schedule_churn_get_topology, | 1780 | &schedule_churn_get_topology, |
1779 | find_peer_context); | 1781 | find_peer_context); |
@@ -2262,14 +2264,14 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2262 | test_put->next); | 2264 | test_put->next); |
2263 | } | 2265 | } |
2264 | 2266 | ||
2265 | static void schedule_find_peer_requests (void *cls, | 2267 | static void |
2266 | const struct | 2268 | schedule_find_peer_requests (void *cls, |
2267 | GNUNET_SCHEDULER_TaskContext *tc); | 2269 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
2268 | 2270 | ||
2269 | #if HAVE_MALICIOUS | 2271 | #if HAVE_MALICIOUS |
2270 | static void setup_malicious_peers (void *cls, | 2272 | static void |
2271 | const struct GNUNET_SCHEDULER_TaskContext | 2273 | setup_malicious_peers (void *cls, |
2272 | *tc); | 2274 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
2273 | #endif | 2275 | #endif |
2274 | 2276 | ||
2275 | /** | 2277 | /** |
@@ -2322,8 +2324,8 @@ count_peers_cb (void *cls, const struct GNUNET_PeerIdentity *first, | |||
2322 | if ((find_peer_context->last_sent < 8) || | 2324 | if ((find_peer_context->last_sent < 8) || |
2323 | ((find_peer_context->current_peers < | 2325 | ((find_peer_context->current_peers < |
2324 | 2 * connection_estimate (num_peers, DEFAULT_BUCKET_SIZE)) && | 2326 | 2 * connection_estimate (num_peers, DEFAULT_BUCKET_SIZE)) && |
2325 | (GNUNET_TIME_absolute_get_remaining (find_peer_context->endtime). | 2327 | (GNUNET_TIME_absolute_get_remaining |
2326 | rel_value > 0) && | 2328 | (find_peer_context->endtime).rel_value > 0) && |
2327 | (find_peer_context->current_peers < target_total_connections))) | 2329 | (find_peer_context->current_peers < target_total_connections))) |
2328 | { | 2330 | { |
2329 | GNUNET_SCHEDULER_add_now (&schedule_find_peer_requests, | 2331 | GNUNET_SCHEDULER_add_now (&schedule_find_peer_requests, |
@@ -2424,11 +2426,9 @@ schedule_find_peer_requests (void *cls, | |||
2424 | peer_count = | 2426 | peer_count = |
2425 | GNUNET_CONTAINER_heap_remove_root (find_peer_ctx->peer_min_heap); | 2427 | GNUNET_CONTAINER_heap_remove_root (find_peer_ctx->peer_min_heap); |
2426 | GNUNET_assert (GNUNET_YES == | 2428 | GNUNET_assert (GNUNET_YES == |
2427 | GNUNET_CONTAINER_multihashmap_remove (find_peer_ctx-> | 2429 | GNUNET_CONTAINER_multihashmap_remove |
2428 | peer_hash, | 2430 | (find_peer_ctx->peer_hash, &peer_count->peer_id.hashPubKey, |
2429 | &peer_count->peer_id. | 2431 | peer_count)); |
2430 | hashPubKey, | ||
2431 | peer_count)); | ||
2432 | test_find_peer->daemon = | 2432 | test_find_peer->daemon = |
2433 | GNUNET_TESTING_daemon_get_by_id (pg, &peer_count->peer_id); | 2433 | GNUNET_TESTING_daemon_get_by_id (pg, &peer_count->peer_id); |
2434 | GNUNET_assert (test_find_peer->daemon != NULL); | 2434 | GNUNET_assert (test_find_peer->daemon != NULL); |
@@ -2879,17 +2879,14 @@ setup_malicious_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2879 | 2879 | ||
2880 | #if ONLY_TESTING | 2880 | #if ONLY_TESTING |
2881 | /* Forward declaration */ | 2881 | /* Forward declaration */ |
2882 | static void topology_callback (void *cls, | 2882 | static void |
2883 | const struct GNUNET_PeerIdentity *first, | 2883 | topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, |
2884 | const struct GNUNET_PeerIdentity *second, | 2884 | const struct GNUNET_PeerIdentity *second, uint32_t distance, |
2885 | uint32_t distance, | 2885 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, |
2886 | const struct GNUNET_CONFIGURATION_Handle | 2886 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, |
2887 | *first_cfg, | 2887 | struct GNUNET_TESTING_Daemon *first_daemon, |
2888 | const struct GNUNET_CONFIGURATION_Handle | 2888 | struct GNUNET_TESTING_Daemon *second_daemon, |
2889 | *second_cfg, | 2889 | const char *emsg); |
2890 | struct GNUNET_TESTING_Daemon *first_daemon, | ||
2891 | struct GNUNET_TESTING_Daemon *second_daemon, | ||
2892 | const char *emsg); | ||
2893 | 2890 | ||
2894 | /** | 2891 | /** |
2895 | * Retry connecting two specific peers until they connect, | 2892 | * Retry connecting two specific peers until they connect, |
@@ -2993,12 +2990,12 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, | |||
2993 | /* Get duration in seconds */ | 2990 | /* Get duration in seconds */ |
2994 | duration = | 2991 | duration = |
2995 | GNUNET_TIME_absolute_get_difference (connect_last_time, | 2992 | GNUNET_TIME_absolute_get_difference (connect_last_time, |
2996 | GNUNET_TIME_absolute_get ()). | 2993 | GNUNET_TIME_absolute_get |
2997 | rel_value / 1000; | 2994 | ()).rel_value / 1000; |
2998 | total_duration = | 2995 | total_duration = |
2999 | GNUNET_TIME_absolute_get_difference (connect_start_time, | 2996 | GNUNET_TIME_absolute_get_difference (connect_start_time, |
3000 | GNUNET_TIME_absolute_get ()). | 2997 | GNUNET_TIME_absolute_get |
3001 | rel_value / 1000; | 2998 | ()).rel_value / 1000; |
3002 | 2999 | ||
3003 | failed_conns_per_sec_recent = | 3000 | failed_conns_per_sec_recent = |
3004 | (double) new_failed_connections / (double) duration; | 3001 | (double) new_failed_connections / (double) duration; |
@@ -3086,8 +3083,8 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, | |||
3086 | 3083 | ||
3087 | total_duration = | 3084 | total_duration = |
3088 | GNUNET_TIME_absolute_get_difference (connect_start_time, | 3085 | GNUNET_TIME_absolute_get_difference (connect_start_time, |
3089 | GNUNET_TIME_absolute_get ()). | 3086 | GNUNET_TIME_absolute_get |
3090 | rel_value / 1000; | 3087 | ()).rel_value / 1000; |
3091 | failed_conns_per_sec_total = | 3088 | failed_conns_per_sec_total = |
3092 | (long double) failed_connections / total_duration; | 3089 | (long double) failed_connections / total_duration; |
3093 | conns_per_sec_total = (long double) total_connections / total_duration; | 3090 | conns_per_sec_total = (long double) total_connections / total_duration; |
@@ -3299,14 +3296,16 @@ hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, | |||
3299 | GNUNET_CONFIGURATION_have_value (config, "TESTING", "HOSTKEYSFILE")) | 3296 | GNUNET_CONFIGURATION_have_value (config, "TESTING", "HOSTKEYSFILE")) |
3300 | { | 3297 | { |
3301 | GAUGER_ID ("DHT_TESTING", "HOSTKEY_GENERATION", | 3298 | GAUGER_ID ("DHT_TESTING", "HOSTKEY_GENERATION", |
3302 | GNUNET_TIME_absolute_get_duration (hostkey_start_time). | 3299 | GNUNET_TIME_absolute_get_duration |
3303 | rel_value / (double) num_peers, "ms/hostkey", revision_str); | 3300 | (hostkey_start_time).rel_value / (double) num_peers, |
3301 | "ms/hostkey", revision_str); | ||
3304 | } | 3302 | } |
3305 | else | 3303 | else |
3306 | { | 3304 | { |
3307 | GAUGER_ID ("DHT_TESTING", "HOSTKEY_GENERATION_REAL", | 3305 | GAUGER_ID ("DHT_TESTING", "HOSTKEY_GENERATION_REAL", |
3308 | GNUNET_TIME_absolute_get_duration (hostkey_start_time). | 3306 | GNUNET_TIME_absolute_get_duration |
3309 | rel_value / (double) num_peers, "ms/hostkey", revision_str); | 3307 | (hostkey_start_time).rel_value / (double) num_peers, |
3308 | "ms/hostkey", revision_str); | ||
3310 | } | 3309 | } |
3311 | } | 3310 | } |
3312 | 3311 | ||