diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-09-13 11:54:44 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-09-13 11:54:44 +0000 |
commit | e82ae411a399b4c1089162c2ec7582caf652c010 (patch) | |
tree | a7dd695da243800317f9139e60a0ce4e208630a2 /src/dht/gnunet-service-dht.c | |
parent | 485e370d56f978a7261138d2fdca32be1bcbcd8c (diff) | |
download | gnunet-e82ae411a399b4c1089162c2ec7582caf652c010.tar.gz gnunet-e82ae411a399b4c1089162c2ec7582caf652c010.zip |
stuff
Diffstat (limited to 'src/dht/gnunet-service-dht.c')
-rw-r--r-- | src/dht/gnunet-service-dht.c | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index 1921063b7..a6211b39d 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2009, 2010 Christian Grothoff (and other contributing authors) | 3 | (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -26,7 +26,6 @@ | |||
26 | * | 26 | * |
27 | * TODO: | 27 | * TODO: |
28 | * - decide which 'benchmark'/test functions to keep (malicious code, kademlia, etc.) | 28 | * - decide which 'benchmark'/test functions to keep (malicious code, kademlia, etc.) |
29 | * - integrate properly with 'block' library (instead of manual bloomfiltering) | ||
30 | * - decide on 'stop_on_closest', 'stop_on_found', 'do_find_peer', 'paper_forwarding' | 29 | * - decide on 'stop_on_closest', 'stop_on_found', 'do_find_peer', 'paper_forwarding' |
31 | */ | 30 | */ |
32 | 31 | ||
@@ -4349,8 +4348,8 @@ handle_dht_p2p_route_result (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4349 | "`%s:%s': Received request from peer %s\n", my_short_id, "DHT", | 4348 | "`%s:%s': Received request from peer %s\n", my_short_id, "DHT", |
4350 | GNUNET_i2s (peer)); | 4349 | GNUNET_i2s (peer)); |
4351 | #endif | 4350 | #endif |
4352 | struct GNUNET_DHT_P2PRouteResultMessage *incoming = | 4351 | const struct GNUNET_DHT_P2PRouteResultMessage *incoming = |
4353 | (struct GNUNET_DHT_P2PRouteResultMessage *) message; | 4352 | (const struct GNUNET_DHT_P2PRouteResultMessage *) message; |
4354 | struct GNUNET_MessageHeader *enc_msg = | 4353 | struct GNUNET_MessageHeader *enc_msg = |
4355 | (struct GNUNET_MessageHeader *) &incoming[1]; | 4354 | (struct GNUNET_MessageHeader *) &incoming[1]; |
4356 | struct DHT_MessageContext msg_ctx; | 4355 | struct DHT_MessageContext msg_ctx; |
@@ -4381,7 +4380,6 @@ handle_dht_p2p_route_result (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4381 | } | 4380 | } |
4382 | 4381 | ||
4383 | memset (&msg_ctx, 0, sizeof (struct DHT_MessageContext)); | 4382 | memset (&msg_ctx, 0, sizeof (struct DHT_MessageContext)); |
4384 | // FIXME: call GNUNET_BLOCK_evaluate (...) -- instead of doing your own bloomfilter! | ||
4385 | memcpy (&msg_ctx.key, &incoming->key, sizeof (GNUNET_HashCode)); | 4383 | memcpy (&msg_ctx.key, &incoming->key, sizeof (GNUNET_HashCode)); |
4386 | msg_ctx.unique_id = GNUNET_ntohll (incoming->unique_id); | 4384 | msg_ctx.unique_id = GNUNET_ntohll (incoming->unique_id); |
4387 | msg_ctx.msg_options = ntohl (incoming->options); | 4385 | msg_ctx.msg_options = ntohl (incoming->options); |
@@ -4792,8 +4790,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
4792 | forward_list.minHeap = | 4790 | forward_list.minHeap = |
4793 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | 4791 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); |
4794 | all_known_peers = GNUNET_CONTAINER_multihashmap_create (MAX_BUCKETS / 8); | 4792 | all_known_peers = GNUNET_CONTAINER_multihashmap_create (MAX_BUCKETS / 8); |
4795 | recent_find_peer_requests = | ||
4796 | GNUNET_CONTAINER_multihashmap_create (MAX_BUCKETS / 8); | ||
4797 | GNUNET_assert (all_known_peers != NULL); | 4793 | GNUNET_assert (all_known_peers != NULL); |
4798 | if (GNUNET_YES == | 4794 | if (GNUNET_YES == |
4799 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", | 4795 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", |
@@ -4927,10 +4923,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
4927 | GNUNET_STATISTICS_set (stats, STAT_HELLOS_PROVIDED, 0, GNUNET_NO); | 4923 | GNUNET_STATISTICS_set (stats, STAT_HELLOS_PROVIDED, 0, GNUNET_NO); |
4928 | GNUNET_STATISTICS_set (stats, STAT_DISCONNECTS, 0, GNUNET_NO); | 4924 | GNUNET_STATISTICS_set (stats, STAT_DISCONNECTS, 0, GNUNET_NO); |
4929 | } | 4925 | } |
4930 | /* FIXME: if there are no recent requests then these never get freed, but alternative is _annoying_! */ | ||
4931 | recent.hashmap = GNUNET_CONTAINER_multihashmap_create (DHT_MAX_RECENT / 2); | ||
4932 | recent.minHeap = | ||
4933 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | ||
4934 | if (GNUNET_YES == do_find_peer) | 4926 | if (GNUNET_YES == do_find_peer) |
4935 | { | 4927 | { |
4936 | next_send_time.rel_value = | 4928 | next_send_time.rel_value = |
@@ -4950,6 +4942,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
4950 | &shutdown_task, NULL); | 4942 | &shutdown_task, NULL); |
4951 | } | 4943 | } |
4952 | 4944 | ||
4945 | |||
4953 | /** | 4946 | /** |
4954 | * The main function for the dht service. | 4947 | * The main function for the dht service. |
4955 | * | 4948 | * |
@@ -4962,26 +4955,23 @@ main (int argc, char *const *argv) | |||
4962 | { | 4955 | { |
4963 | int ret; | 4956 | int ret; |
4964 | 4957 | ||
4958 | recent.hashmap = GNUNET_CONTAINER_multihashmap_create (DHT_MAX_RECENT / 2); | ||
4959 | recent.minHeap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | ||
4960 | recent_find_peer_requests = | ||
4961 | GNUNET_CONTAINER_multihashmap_create (MAX_BUCKETS / 8); | ||
4965 | ret = | 4962 | ret = |
4966 | (GNUNET_OK == | 4963 | (GNUNET_OK == |
4967 | GNUNET_SERVICE_run (argc, argv, "dht", GNUNET_SERVICE_OPTION_NONE, &run, | 4964 | GNUNET_SERVICE_run (argc, argv, "dht", GNUNET_SERVICE_OPTION_NONE, &run, |
4968 | NULL)) ? 0 : 1; | 4965 | NULL)) ? 0 : 1; |
4969 | if (NULL != recent.hashmap) | 4966 | GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (recent.hashmap)); |
4970 | { | 4967 | GNUNET_CONTAINER_multihashmap_destroy (recent.hashmap); |
4971 | GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (recent.hashmap)); | 4968 | recent.hashmap = NULL; |
4972 | GNUNET_CONTAINER_multihashmap_destroy (recent.hashmap); | 4969 | GNUNET_assert (0 == GNUNET_CONTAINER_heap_get_size (recent.minHeap)); |
4973 | recent.hashmap = NULL; | 4970 | GNUNET_CONTAINER_heap_destroy (recent.minHeap); |
4974 | } | 4971 | recent.minHeap = NULL; |
4975 | if (NULL != recent.minHeap) | 4972 | GNUNET_CONTAINER_multihashmap_destroy (recent_find_peer_requests); |
4976 | { | 4973 | recent_find_peer_requests = NULL; |
4977 | GNUNET_assert (0 == GNUNET_CONTAINER_heap_get_size (recent.minHeap)); | ||
4978 | GNUNET_CONTAINER_heap_destroy (recent.minHeap); | ||
4979 | recent.minHeap = NULL; | ||
4980 | } | ||
4981 | if (NULL != recent_find_peer_requests) | ||
4982 | { | ||
4983 | GNUNET_CONTAINER_multihashmap_destroy (recent_find_peer_requests); | ||
4984 | recent_find_peer_requests = NULL; | ||
4985 | } | ||
4986 | return ret; | 4974 | return ret; |
4987 | } | 4975 | } |
4976 | |||
4977 | /* end of gnunet-service-dht.c */ | ||