diff options
Diffstat (limited to 'src/dht/gnunet-service-dht.c')
-rw-r--r-- | src/dht/gnunet-service-dht.c | 88 |
1 files changed, 38 insertions, 50 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index da82ac841..52e10320c 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c | |||
@@ -755,10 +755,6 @@ static struct GNUNET_DATACACHE_Handle *datacache; | |||
755 | */ | 755 | */ |
756 | struct GNUNET_STATISTICS_Handle *stats; | 756 | struct GNUNET_STATISTICS_Handle *stats; |
757 | 757 | ||
758 | /** | ||
759 | * The main scheduler to use for the DHT service | ||
760 | */ | ||
761 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
762 | 758 | ||
763 | /** | 759 | /** |
764 | * The configuration the DHT service is running with | 760 | * The configuration the DHT service is running with |
@@ -1094,7 +1090,7 @@ forward_result_message (const struct GNUNET_MessageHeader *msg, | |||
1094 | #endif | 1090 | #endif |
1095 | GNUNET_CONTAINER_DLL_insert_after(peer->head, peer->tail, peer->tail, pending); | 1091 | GNUNET_CONTAINER_DLL_insert_after(peer->head, peer->tail, peer->tail, pending); |
1096 | if (peer->send_task == GNUNET_SCHEDULER_NO_TASK) | 1092 | if (peer->send_task == GNUNET_SCHEDULER_NO_TASK) |
1097 | peer->send_task = GNUNET_SCHEDULER_add_now(sched, &try_core_send, peer); | 1093 | peer->send_task = GNUNET_SCHEDULER_add_now(&try_core_send, peer); |
1098 | } | 1094 | } |
1099 | 1095 | ||
1100 | 1096 | ||
@@ -1164,7 +1160,7 @@ core_transmit_notify (void *cls, | |||
1164 | } | 1160 | } |
1165 | #endif | 1161 | #endif |
1166 | if ((peer->head != NULL) && (peer->send_task == GNUNET_SCHEDULER_NO_TASK)) | 1162 | if ((peer->head != NULL) && (peer->send_task == GNUNET_SCHEDULER_NO_TASK)) |
1167 | peer->send_task = GNUNET_SCHEDULER_add_now(sched, &try_core_send, peer); | 1163 | peer->send_task = GNUNET_SCHEDULER_add_now(&try_core_send, peer); |
1168 | #if DEBUG_DHT > 1 | 1164 | #if DEBUG_DHT > 1 |
1169 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "`%s:%s' : transmit_notify (core) called with size %d, available %d, returning %d\n", my_short_id, "dht service", msize, size, off); | 1165 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "`%s:%s' : transmit_notify (core) called with size %d, available %d, returning %d\n", my_short_id, "dht service", msize, size, off); |
1170 | #endif | 1166 | #endif |
@@ -1401,7 +1397,7 @@ update_core_preference_finish (void *cls, | |||
1401 | { | 1397 | { |
1402 | struct PeerInfo *peer_info = cls; | 1398 | struct PeerInfo *peer_info = cls; |
1403 | peer_info->info_ctx = NULL; | 1399 | peer_info->info_ctx = NULL; |
1404 | GNUNET_SCHEDULER_add_delayed(sched, DHT_DEFAULT_PREFERENCE_INTERVAL, &update_core_preference, peer_info); | 1400 | GNUNET_SCHEDULER_add_delayed(DHT_DEFAULT_PREFERENCE_INTERVAL, &update_core_preference, peer_info); |
1405 | } | 1401 | } |
1406 | 1402 | ||
1407 | static void | 1403 | static void |
@@ -1422,7 +1418,7 @@ update_core_preference (void *cls, | |||
1422 | matching = 63; | 1418 | matching = 63; |
1423 | } | 1419 | } |
1424 | preference = 1LL << matching; | 1420 | preference = 1LL << matching; |
1425 | peer->info_ctx = GNUNET_CORE_peer_change_preference (sched, cfg, | 1421 | peer->info_ctx = GNUNET_CORE_peer_change_preference (cfg, |
1426 | &peer->id, | 1422 | &peer->id, |
1427 | GNUNET_TIME_relative_get_forever(), | 1423 | GNUNET_TIME_relative_get_forever(), |
1428 | GNUNET_BANDWIDTH_value_init (UINT32_MAX), | 1424 | GNUNET_BANDWIDTH_value_init (UINT32_MAX), |
@@ -1468,7 +1464,7 @@ add_peer(const struct GNUNET_PeerIdentity *peer, | |||
1468 | if ((GNUNET_CRYPTO_hash_matching_bits(&my_identity.hashPubKey, &peer->hashPubKey) > 0) && (k_buckets[bucket].peers_size <= bucket_size)) | 1464 | if ((GNUNET_CRYPTO_hash_matching_bits(&my_identity.hashPubKey, &peer->hashPubKey) > 0) && (k_buckets[bucket].peers_size <= bucket_size)) |
1469 | { | 1465 | { |
1470 | #if DO_UPDATE_PREFERENCE | 1466 | #if DO_UPDATE_PREFERENCE |
1471 | new_peer->preference_task = GNUNET_SCHEDULER_add_now(sched, &update_core_preference, new_peer); | 1467 | new_peer->preference_task = GNUNET_SCHEDULER_add_now(&update_core_preference, new_peer); |
1472 | #endif | 1468 | #endif |
1473 | } | 1469 | } |
1474 | 1470 | ||
@@ -1527,7 +1523,7 @@ static void delete_peer (struct PeerInfo *peer, | |||
1527 | remove_peer(peer, bucket); /* First remove the peer from its bucket */ | 1523 | remove_peer(peer, bucket); /* First remove the peer from its bucket */ |
1528 | 1524 | ||
1529 | if (peer->send_task != GNUNET_SCHEDULER_NO_TASK) | 1525 | if (peer->send_task != GNUNET_SCHEDULER_NO_TASK) |
1530 | GNUNET_SCHEDULER_cancel(sched, peer->send_task); | 1526 | GNUNET_SCHEDULER_cancel(peer->send_task); |
1531 | if (peer->th != NULL) | 1527 | if (peer->th != NULL) |
1532 | GNUNET_CORE_notify_transmit_ready_cancel(peer->th); | 1528 | GNUNET_CORE_notify_transmit_ready_cancel(peer->th); |
1533 | 1529 | ||
@@ -1700,7 +1696,7 @@ static void forward_message (const struct GNUNET_MessageHeader *msg, | |||
1700 | #endif | 1696 | #endif |
1701 | GNUNET_CONTAINER_DLL_insert_after(peer->head, peer->tail, peer->tail, pending); | 1697 | GNUNET_CONTAINER_DLL_insert_after(peer->head, peer->tail, peer->tail, pending); |
1702 | if (peer->send_task == GNUNET_SCHEDULER_NO_TASK) | 1698 | if (peer->send_task == GNUNET_SCHEDULER_NO_TASK) |
1703 | peer->send_task = GNUNET_SCHEDULER_add_now(sched, &try_core_send, peer); | 1699 | peer->send_task = GNUNET_SCHEDULER_add_now(&try_core_send, peer); |
1704 | } | 1700 | } |
1705 | 1701 | ||
1706 | #if DO_PING | 1702 | #if DO_PING |
@@ -1729,7 +1725,7 @@ periodic_ping_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1729 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s Sending periodic ping to %s\n", my_short_id, "DHT", GNUNET_i2s(&peer->id)); | 1725 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s Sending periodic ping to %s\n", my_short_id, "DHT", GNUNET_i2s(&peer->id)); |
1730 | #endif | 1726 | #endif |
1731 | forward_message(&ping_message, peer, &message_context); | 1727 | forward_message(&ping_message, peer, &message_context); |
1732 | peer->ping_task = GNUNET_SCHEDULER_add_delayed(sched, DHT_DEFAULT_PING_DELAY, &periodic_ping_task, peer); | 1728 | peer->ping_task = GNUNET_SCHEDULER_add_delayed(DHT_DEFAULT_PING_DELAY, &periodic_ping_task, peer); |
1733 | } | 1729 | } |
1734 | 1730 | ||
1735 | /** | 1731 | /** |
@@ -1748,10 +1744,10 @@ void schedule_ping_messages() | |||
1748 | while (pos != NULL) | 1744 | while (pos != NULL) |
1749 | { | 1745 | { |
1750 | if ((count < bucket_size) && (pos->ping_task == GNUNET_SCHEDULER_NO_TASK)) | 1746 | if ((count < bucket_size) && (pos->ping_task == GNUNET_SCHEDULER_NO_TASK)) |
1751 | GNUNET_SCHEDULER_add_now(sched, &periodic_ping_task, pos); | 1747 | GNUNET_SCHEDULER_add_now(&periodic_ping_task, pos); |
1752 | else if ((count >= bucket_size) && (pos->ping_task != GNUNET_SCHEDULER_NO_TASK)) | 1748 | else if ((count >= bucket_size) && (pos->ping_task != GNUNET_SCHEDULER_NO_TASK)) |
1753 | { | 1749 | { |
1754 | GNUNET_SCHEDULER_cancel(sched, pos->ping_task); | 1750 | GNUNET_SCHEDULER_cancel(pos->ping_task); |
1755 | pos->ping_task = GNUNET_SCHEDULER_NO_TASK; | 1751 | pos->ping_task = GNUNET_SCHEDULER_NO_TASK; |
1756 | } | 1752 | } |
1757 | pos = pos->next; | 1753 | pos = pos->next; |
@@ -1997,7 +1993,7 @@ static int route_result_message(struct GNUNET_MessageHeader *msg, | |||
1997 | { | 1993 | { |
1998 | increment_stats(STAT_HELLOS_PROVIDED); | 1994 | increment_stats(STAT_HELLOS_PROVIDED); |
1999 | GNUNET_TRANSPORT_offer_hello(transport_handle, hello_msg); | 1995 | GNUNET_TRANSPORT_offer_hello(transport_handle, hello_msg); |
2000 | GNUNET_CORE_peer_request_connect(sched, cfg, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), &new_peer, NULL, NULL); | 1996 | GNUNET_CORE_peer_request_connect(cfg, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), &new_peer, NULL, NULL); |
2001 | } | 1997 | } |
2002 | } | 1998 | } |
2003 | } | 1999 | } |
@@ -2426,7 +2422,7 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, | |||
2426 | { | 2422 | { |
2427 | increment_stats(STAT_HELLOS_PROVIDED); | 2423 | increment_stats(STAT_HELLOS_PROVIDED); |
2428 | GNUNET_TRANSPORT_offer_hello(transport_handle, other_hello); | 2424 | GNUNET_TRANSPORT_offer_hello(transport_handle, other_hello); |
2429 | GNUNET_CORE_peer_request_connect(sched, cfg, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), &peer_id, NULL, NULL); | 2425 | GNUNET_CORE_peer_request_connect(cfg, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), &peer_id, NULL, NULL); |
2430 | route_message (find_msg, message_context); | 2426 | route_message (find_msg, message_context); |
2431 | GNUNET_free (other_hello); | 2427 | GNUNET_free (other_hello); |
2432 | return; | 2428 | return; |
@@ -2507,7 +2503,7 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, | |||
2507 | { | 2503 | { |
2508 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding recent remove task for key `%s`!\n", GNUNET_h2s(&message_context->key)); | 2504 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding recent remove task for key `%s`!\n", GNUNET_h2s(&message_context->key)); |
2509 | /* Only add a task if there wasn't one for this key already! */ | 2505 | /* Only add a task if there wasn't one for this key already! */ |
2510 | GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30), | 2506 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30), |
2511 | &remove_recent_find_peer, recent_hash); | 2507 | &remove_recent_find_peer, recent_hash); |
2512 | } | 2508 | } |
2513 | else | 2509 | else |
@@ -2675,7 +2671,7 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, | |||
2675 | put_context = GNUNET_malloc(sizeof(struct RepublishContext)); | 2671 | put_context = GNUNET_malloc(sizeof(struct RepublishContext)); |
2676 | memcpy(&put_context->key, &message_context->key, sizeof(GNUNET_HashCode)); | 2672 | memcpy(&put_context->key, &message_context->key, sizeof(GNUNET_HashCode)); |
2677 | put_context->type = put_type; | 2673 | put_context->type = put_type; |
2678 | GNUNET_SCHEDULER_add_delayed (sched, dht_republish_frequency, &republish_content, put_context); | 2674 | GNUNET_SCHEDULER_add_delayed (dht_republish_frequency, &republish_content, put_context); |
2679 | } | 2675 | } |
2680 | } | 2676 | } |
2681 | else | 2677 | else |
@@ -3377,7 +3373,7 @@ static int cache_response(struct DHT_MessageContext *msg_ctx) | |||
3377 | GNUNET_free(record); | 3373 | GNUNET_free(record); |
3378 | } | 3374 | } |
3379 | if (source_info->delete_task != GNUNET_SCHEDULER_NO_TASK) | 3375 | if (source_info->delete_task != GNUNET_SCHEDULER_NO_TASK) |
3380 | GNUNET_SCHEDULER_cancel(sched, source_info->delete_task); | 3376 | GNUNET_SCHEDULER_cancel(source_info->delete_task); |
3381 | if (source_info->find_peers_responded != NULL) | 3377 | if (source_info->find_peers_responded != NULL) |
3382 | GNUNET_CONTAINER_bloomfilter_free(source_info->find_peers_responded); | 3378 | GNUNET_CONTAINER_bloomfilter_free(source_info->find_peers_responded); |
3383 | GNUNET_free(source_info); | 3379 | GNUNET_free(source_info); |
@@ -3409,7 +3405,7 @@ static int cache_response(struct DHT_MessageContext *msg_ctx) | |||
3409 | 3405 | ||
3410 | source_info = GNUNET_malloc(sizeof(struct DHTRouteSource)); | 3406 | source_info = GNUNET_malloc(sizeof(struct DHTRouteSource)); |
3411 | source_info->record = record; | 3407 | source_info->record = record; |
3412 | source_info->delete_task = GNUNET_SCHEDULER_add_delayed(sched, DHT_FORWARD_TIMEOUT, &remove_forward_entry, source_info); | 3408 | source_info->delete_task = GNUNET_SCHEDULER_add_delayed(DHT_FORWARD_TIMEOUT, &remove_forward_entry, source_info); |
3413 | source_info->find_peers_responded = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); | 3409 | source_info->find_peers_responded = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); |
3414 | memcpy(&source_info->source, msg_ctx->peer, sizeof(struct GNUNET_PeerIdentity)); | 3410 | memcpy(&source_info->source, msg_ctx->peer, sizeof(struct GNUNET_PeerIdentity)); |
3415 | GNUNET_CONTAINER_DLL_insert_after(record->head, record->tail, record->tail, source_info); | 3411 | GNUNET_CONTAINER_DLL_insert_after(record->head, record->tail, record->tail, source_info); |
@@ -3536,7 +3532,7 @@ route_message(const struct GNUNET_MessageHeader *msg, | |||
3536 | recent_req = GNUNET_malloc(sizeof(struct RecentRequest)); | 3532 | recent_req = GNUNET_malloc(sizeof(struct RecentRequest)); |
3537 | recent_req->uid = message_context->unique_id; | 3533 | recent_req->uid = message_context->unique_id; |
3538 | memcpy(&recent_req->key, &message_context->key, sizeof(GNUNET_HashCode)); | 3534 | memcpy(&recent_req->key, &message_context->key, sizeof(GNUNET_HashCode)); |
3539 | recent_req->remove_task = GNUNET_SCHEDULER_add_delayed(sched, DEFAULT_RECENT_REMOVAL, &remove_recent, recent_req); | 3535 | recent_req->remove_task = GNUNET_SCHEDULER_add_delayed(DEFAULT_RECENT_REMOVAL, &remove_recent, recent_req); |
3540 | recent_req->heap_node = GNUNET_CONTAINER_heap_insert(recent.minHeap, recent_req, GNUNET_TIME_absolute_get().abs_value); | 3536 | recent_req->heap_node = GNUNET_CONTAINER_heap_insert(recent.minHeap, recent_req, GNUNET_TIME_absolute_get().abs_value); |
3541 | recent_req->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); | 3537 | recent_req->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); |
3542 | GNUNET_CONTAINER_multihashmap_put(recent.hashmap, &unique_hash, recent_req, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 3538 | GNUNET_CONTAINER_multihashmap_put(recent.hashmap, &unique_hash, recent_req, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
@@ -3546,8 +3542,8 @@ route_message(const struct GNUNET_MessageHeader *msg, | |||
3546 | { | 3542 | { |
3547 | recent_req = GNUNET_CONTAINER_heap_peek(recent.minHeap); | 3543 | recent_req = GNUNET_CONTAINER_heap_peek(recent.minHeap); |
3548 | GNUNET_assert(recent_req != NULL); | 3544 | GNUNET_assert(recent_req != NULL); |
3549 | GNUNET_SCHEDULER_cancel(sched, recent_req->remove_task); | 3545 | GNUNET_SCHEDULER_cancel(recent_req->remove_task); |
3550 | GNUNET_SCHEDULER_add_now(sched, &remove_recent, recent_req); | 3546 | GNUNET_SCHEDULER_add_now(&remove_recent, recent_req); |
3551 | } | 3547 | } |
3552 | 3548 | ||
3553 | for (i = 0; i < forward_count; i++) | 3549 | for (i = 0; i < forward_count; i++) |
@@ -3727,7 +3723,7 @@ republish_content(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3727 | if (results == 0) /* Data must have expired */ | 3723 | if (results == 0) /* Data must have expired */ |
3728 | GNUNET_free(put_context); | 3724 | GNUNET_free(put_context); |
3729 | else /* Reschedule task for next time period */ | 3725 | else /* Reschedule task for next time period */ |
3730 | GNUNET_SCHEDULER_add_delayed(sched, dht_republish_frequency, &republish_content, put_context); | 3726 | GNUNET_SCHEDULER_add_delayed(dht_republish_frequency, &republish_content, put_context); |
3731 | 3727 | ||
3732 | } | 3728 | } |
3733 | 3729 | ||
@@ -3760,7 +3756,7 @@ static int find_client_records (void *cls, | |||
3760 | GNUNET_CONTAINER_DLL_remove(record->head, record->tail, pos); | 3756 | GNUNET_CONTAINER_DLL_remove(record->head, record->tail, pos); |
3761 | GNUNET_CONTAINER_heap_remove_node(forward_list.minHeap, pos->hnode); | 3757 | GNUNET_CONTAINER_heap_remove_node(forward_list.minHeap, pos->hnode); |
3762 | if (pos->delete_task != GNUNET_SCHEDULER_NO_TASK) | 3758 | if (pos->delete_task != GNUNET_SCHEDULER_NO_TASK) |
3763 | GNUNET_SCHEDULER_cancel(sched, pos->delete_task); | 3759 | GNUNET_SCHEDULER_cancel(pos->delete_task); |
3764 | 3760 | ||
3765 | if (pos->find_peers_responded != NULL) | 3761 | if (pos->find_peers_responded != NULL) |
3766 | GNUNET_CONTAINER_bloomfilter_free(pos->find_peers_responded); | 3762 | GNUNET_CONTAINER_bloomfilter_free(pos->find_peers_responded); |
@@ -3886,7 +3882,7 @@ malicious_put_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3886 | increment_stats(STAT_PUT_START); | 3882 | increment_stats(STAT_PUT_START); |
3887 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious PUT message with hash %s\n", my_short_id, "DHT", GNUNET_h2s(&key)); | 3883 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious PUT message with hash %s\n", my_short_id, "DHT", GNUNET_h2s(&key)); |
3888 | demultiplex_message(&put_message.header, &message_context); | 3884 | demultiplex_message(&put_message.header, &message_context); |
3889 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, malicious_put_frequency), &malicious_put_task, NULL); | 3885 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, malicious_put_frequency), &malicious_put_task, NULL); |
3890 | 3886 | ||
3891 | } | 3887 | } |
3892 | 3888 | ||
@@ -3929,7 +3925,7 @@ malicious_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3929 | increment_stats(STAT_GET_START); | 3925 | increment_stats(STAT_GET_START); |
3930 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious GET message with hash %s\n", my_short_id, "DHT", GNUNET_h2s(&key)); | 3926 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious GET message with hash %s\n", my_short_id, "DHT", GNUNET_h2s(&key)); |
3931 | demultiplex_message (&get_message.header, &message_context); | 3927 | demultiplex_message (&get_message.header, &message_context); |
3932 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, malicious_get_frequency), &malicious_get_task, NULL); | 3928 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, malicious_get_frequency), &malicious_get_task, NULL); |
3933 | } | 3929 | } |
3934 | 3930 | ||
3935 | /** | 3931 | /** |
@@ -3979,8 +3975,7 @@ send_find_peer_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc | |||
3979 | if ((newly_found_peers > bucket_size) && (GNUNET_YES == do_find_peer)) /* If we are finding peers already, no need to send out our request right now! */ | 3975 | if ((newly_found_peers > bucket_size) && (GNUNET_YES == do_find_peer)) /* If we are finding peers already, no need to send out our request right now! */ |
3980 | { | 3976 | { |
3981 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Have %d newly found peers since last find peer message sent!\n", newly_found_peers); | 3977 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Have %d newly found peers since last find peer message sent!\n", newly_found_peers); |
3982 | GNUNET_SCHEDULER_add_delayed (sched, | 3978 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, |
3983 | GNUNET_TIME_UNIT_MINUTES, | ||
3984 | &send_find_peer_message, NULL); | 3979 | &send_find_peer_message, NULL); |
3985 | newly_found_peers = 0; | 3980 | newly_found_peers = 0; |
3986 | return; | 3981 | return; |
@@ -4049,8 +4044,7 @@ send_find_peer_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc | |||
4049 | find_peer_context.start = GNUNET_TIME_absolute_get(); | 4044 | find_peer_context.start = GNUNET_TIME_absolute_get(); |
4050 | if (GNUNET_YES == do_find_peer) | 4045 | if (GNUNET_YES == do_find_peer) |
4051 | { | 4046 | { |
4052 | GNUNET_SCHEDULER_add_delayed (sched, | 4047 | GNUNET_SCHEDULER_add_delayed (next_send_time, |
4053 | next_send_time, | ||
4054 | &send_find_peer_message, NULL); | 4048 | &send_find_peer_message, NULL); |
4055 | } | 4049 | } |
4056 | } | 4050 | } |
@@ -4135,7 +4129,7 @@ handle_dht_control_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
4135 | { | 4129 | { |
4136 | case GNUNET_MESSAGE_TYPE_DHT_FIND_PEER: | 4130 | case GNUNET_MESSAGE_TYPE_DHT_FIND_PEER: |
4137 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending self seeking find peer request!\n"); | 4131 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending self seeking find peer request!\n"); |
4138 | GNUNET_SCHEDULER_add_now(sched, &send_find_peer_message, NULL); | 4132 | GNUNET_SCHEDULER_add_now(&send_find_peer_message, NULL); |
4139 | break; | 4133 | break; |
4140 | case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET: | 4134 | case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET: |
4141 | if (ntohs(dht_control_msg->variable) > 0) | 4135 | if (ntohs(dht_control_msg->variable) > 0) |
@@ -4143,7 +4137,7 @@ handle_dht_control_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
4143 | if (malicious_get_frequency == 0) | 4137 | if (malicious_get_frequency == 0) |
4144 | malicious_get_frequency = DEFAULT_MALICIOUS_GET_FREQUENCY; | 4138 | malicious_get_frequency = DEFAULT_MALICIOUS_GET_FREQUENCY; |
4145 | if (malicious_getter != GNUNET_YES) | 4139 | if (malicious_getter != GNUNET_YES) |
4146 | GNUNET_SCHEDULER_add_now(sched, &malicious_get_task, NULL); | 4140 | GNUNET_SCHEDULER_add_now(&malicious_get_task, NULL); |
4147 | malicious_getter = GNUNET_YES; | 4141 | malicious_getter = GNUNET_YES; |
4148 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 4142 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
4149 | "%s:%s Initiating malicious GET behavior, frequency %d\n", my_short_id, "DHT", malicious_get_frequency); | 4143 | "%s:%s Initiating malicious GET behavior, frequency %d\n", my_short_id, "DHT", malicious_get_frequency); |
@@ -4154,7 +4148,7 @@ handle_dht_control_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
4154 | if (malicious_put_frequency == 0) | 4148 | if (malicious_put_frequency == 0) |
4155 | malicious_put_frequency = DEFAULT_MALICIOUS_PUT_FREQUENCY; | 4149 | malicious_put_frequency = DEFAULT_MALICIOUS_PUT_FREQUENCY; |
4156 | if (malicious_putter != GNUNET_YES) | 4150 | if (malicious_putter != GNUNET_YES) |
4157 | GNUNET_SCHEDULER_add_now(sched, &malicious_put_task, NULL); | 4151 | GNUNET_SCHEDULER_add_now(&malicious_put_task, NULL); |
4158 | malicious_putter = GNUNET_YES; | 4152 | malicious_putter = GNUNET_YES; |
4159 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 4153 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
4160 | "%s:%s Initiating malicious PUT behavior, frequency %d\n", my_short_id, "DHT", malicious_put_frequency); | 4154 | "%s:%s Initiating malicious PUT behavior, frequency %d\n", my_short_id, "DHT", malicious_put_frequency); |
@@ -4211,9 +4205,9 @@ handle_dht_local_route_stop(void *cls, struct GNUNET_SERVER_Client *client, | |||
4211 | { | 4205 | { |
4212 | if ((pos->client != NULL) && (pos->client->client_handle == client)) | 4206 | if ((pos->client != NULL) && (pos->client->client_handle == client)) |
4213 | { | 4207 | { |
4214 | GNUNET_SCHEDULER_cancel(sched, pos->delete_task); | 4208 | GNUNET_SCHEDULER_cancel(pos->delete_task); |
4215 | pos->delete_task = GNUNET_SCHEDULER_NO_TASK; | 4209 | pos->delete_task = GNUNET_SCHEDULER_NO_TASK; |
4216 | GNUNET_SCHEDULER_add_now(sched, &remove_forward_entry, pos); | 4210 | GNUNET_SCHEDULER_add_now(&remove_forward_entry, pos); |
4217 | } | 4211 | } |
4218 | pos = pos->next; | 4212 | pos = pos->next; |
4219 | } | 4213 | } |
@@ -4431,8 +4425,8 @@ core_init (void *cls, | |||
4431 | "%s: Connection to core FAILED!\n", "dht", | 4425 | "%s: Connection to core FAILED!\n", "dht", |
4432 | GNUNET_i2s (identity)); | 4426 | GNUNET_i2s (identity)); |
4433 | #endif | 4427 | #endif |
4434 | GNUNET_SCHEDULER_cancel (sched, cleanup_task); | 4428 | GNUNET_SCHEDULER_cancel (cleanup_task); |
4435 | GNUNET_SCHEDULER_add_now (sched, &shutdown_task, NULL); | 4429 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); |
4436 | return; | 4430 | return; |
4437 | } | 4431 | } |
4438 | #if DEBUG_DHT | 4432 | #if DEBUG_DHT |
@@ -4546,13 +4540,11 @@ void handle_core_disconnect (void *cls, | |||
4546 | * Process dht requests. | 4540 | * Process dht requests. |
4547 | * | 4541 | * |
4548 | * @param cls closure | 4542 | * @param cls closure |
4549 | * @param scheduler scheduler to use | ||
4550 | * @param server the initialized server | 4543 | * @param server the initialized server |
4551 | * @param c configuration to use | 4544 | * @param c configuration to use |
4552 | */ | 4545 | */ |
4553 | static void | 4546 | static void |
4554 | run (void *cls, | 4547 | run (void *cls, |
4555 | struct GNUNET_SCHEDULER_Handle *scheduler, | ||
4556 | struct GNUNET_SERVER_Handle *server, | 4548 | struct GNUNET_SERVER_Handle *server, |
4557 | const struct GNUNET_CONFIGURATION_Handle *c) | 4549 | const struct GNUNET_CONFIGURATION_Handle *c) |
4558 | { | 4550 | { |
@@ -4560,13 +4552,11 @@ run (void *cls, | |||
4560 | unsigned long long temp_config_num; | 4552 | unsigned long long temp_config_num; |
4561 | char *converge_modifier_buf; | 4553 | char *converge_modifier_buf; |
4562 | 4554 | ||
4563 | sched = scheduler; | ||
4564 | cfg = c; | 4555 | cfg = c; |
4565 | datacache = GNUNET_DATACACHE_create (sched, cfg, "dhtcache"); | 4556 | datacache = GNUNET_DATACACHE_create (cfg, "dhtcache"); |
4566 | GNUNET_SERVER_add_handlers (server, plugin_handlers); | 4557 | GNUNET_SERVER_add_handlers (server, plugin_handlers); |
4567 | GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); | 4558 | GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); |
4568 | coreAPI = GNUNET_CORE_connect (sched, /* Main scheduler */ | 4559 | coreAPI = GNUNET_CORE_connect (cfg, /* Main configuration */ |
4569 | cfg, /* Main configuration */ | ||
4570 | GNUNET_TIME_UNIT_FOREVER_REL, | 4560 | GNUNET_TIME_UNIT_FOREVER_REL, |
4571 | NULL, /* Closure passed to DHT functions */ | 4561 | NULL, /* Closure passed to DHT functions */ |
4572 | &core_init, /* Call core_init once connected */ | 4562 | &core_init, /* Call core_init once connected */ |
@@ -4581,7 +4571,7 @@ run (void *cls, | |||
4581 | 4571 | ||
4582 | if (coreAPI == NULL) | 4572 | if (coreAPI == NULL) |
4583 | return; | 4573 | return; |
4584 | transport_handle = GNUNET_TRANSPORT_connect(sched, cfg, | 4574 | transport_handle = GNUNET_TRANSPORT_connect(cfg, |
4585 | NULL, NULL, NULL, NULL, NULL); | 4575 | NULL, NULL, NULL, NULL, NULL); |
4586 | if (transport_handle != NULL) | 4576 | if (transport_handle != NULL) |
4587 | GNUNET_TRANSPORT_get_hello (transport_handle, &process_hello, NULL); | 4577 | GNUNET_TRANSPORT_get_hello (transport_handle, &process_hello, NULL); |
@@ -4744,7 +4734,7 @@ run (void *cls, | |||
4744 | GNUNET_free(converge_modifier_buf); | 4734 | GNUNET_free(converge_modifier_buf); |
4745 | } | 4735 | } |
4746 | 4736 | ||
4747 | stats = GNUNET_STATISTICS_create(sched, "dht", cfg); | 4737 | stats = GNUNET_STATISTICS_create("dht", cfg); |
4748 | 4738 | ||
4749 | if (stats != NULL) | 4739 | if (stats != NULL) |
4750 | { | 4740 | { |
@@ -4778,14 +4768,12 @@ run (void *cls, | |||
4778 | GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, | 4768 | GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, |
4779 | (DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / 2) - DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value); | 4769 | (DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / 2) - DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value); |
4780 | find_peer_context.start = GNUNET_TIME_absolute_get(); | 4770 | find_peer_context.start = GNUNET_TIME_absolute_get(); |
4781 | GNUNET_SCHEDULER_add_delayed (sched, | 4771 | GNUNET_SCHEDULER_add_delayed (next_send_time, |
4782 | next_send_time, | ||
4783 | &send_find_peer_message, &find_peer_context); | 4772 | &send_find_peer_message, &find_peer_context); |
4784 | } | 4773 | } |
4785 | 4774 | ||
4786 | /* Scheduled the task to clean up when shutdown is called */ | 4775 | /* Scheduled the task to clean up when shutdown is called */ |
4787 | cleanup_task = GNUNET_SCHEDULER_add_delayed (sched, | 4776 | cleanup_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
4788 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
4789 | &shutdown_task, NULL); | 4777 | &shutdown_task, NULL); |
4790 | } | 4778 | } |
4791 | 4779 | ||