diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-06-21 16:21:19 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-06-21 16:21:19 +0000 |
commit | 1bf55b33a415d584ae338a0afea5b51d059f11ab (patch) | |
tree | afc648b9ae3fb53854d8331cfebfccf88ab3c01e /src | |
parent | b50484f5af8f9a33ecea9cef21621cd71d78b25d (diff) | |
download | gnunet-1bf55b33a415d584ae338a0afea5b51d059f11ab.tar.gz gnunet-1bf55b33a415d584ae338a0afea5b51d059f11ab.zip |
codesonar fixes, some other changes
Diffstat (limited to 'src')
-rw-r--r-- | src/dv/dv_api.c | 11 | ||||
-rw-r--r-- | src/dv/gnunet-service-dv.c | 217 | ||||
-rw-r--r-- | src/dv/plugin_transport_dv.c | 1 |
3 files changed, 106 insertions, 123 deletions
diff --git a/src/dv/dv_api.c b/src/dv/dv_api.c index 12801dcd7..9ab15ea62 100644 --- a/src/dv/dv_api.c +++ b/src/dv/dv_api.c | |||
@@ -200,6 +200,7 @@ finish (struct GNUNET_DV_Handle *handle, int code) | |||
200 | handle->current = NULL; | 200 | handle->current = NULL; |
201 | process_pending_message (handle); | 201 | process_pending_message (handle); |
202 | 202 | ||
203 | GNUNET_free(pos->msg); | ||
203 | GNUNET_free (pos); | 204 | GNUNET_free (pos); |
204 | } | 205 | } |
205 | 206 | ||
@@ -312,12 +313,10 @@ static void add_pending(struct GNUNET_DV_Handle *handle, struct GNUNET_DV_SendMe | |||
312 | last = pos; | 313 | last = pos; |
313 | pos = pos->next; | 314 | pos = pos->next; |
314 | } | 315 | } |
315 | new_message->next = last->next; /* Should always be null */ | ||
316 | last->next = new_message; | 316 | last->next = new_message; |
317 | } | 317 | } |
318 | else | 318 | else |
319 | { | 319 | { |
320 | new_message->next = handle->pending_list; /* Will always be null */ | ||
321 | handle->pending_list = new_message; | 320 | handle->pending_list = new_message; |
322 | } | 321 | } |
323 | 322 | ||
@@ -445,14 +444,16 @@ int GNUNET_DV_send (struct GNUNET_DV_Handle *dv_handle, | |||
445 | struct SendCallbackContext *send_ctx; | 444 | struct SendCallbackContext *send_ctx; |
446 | char *end_of_message; | 445 | char *end_of_message; |
447 | GNUNET_HashCode uidhash; | 446 | GNUNET_HashCode uidhash; |
447 | int msize; | ||
448 | #if DEBUG_DV_MESSAGES | 448 | #if DEBUG_DV_MESSAGES |
449 | dv_handle->uid_gen = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, UINT32_MAX); | 449 | dv_handle->uid_gen = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, UINT32_MAX); |
450 | #else | 450 | #else |
451 | dv_handle->uid_gen++; | 451 | dv_handle->uid_gen++; |
452 | #endif | 452 | #endif |
453 | 453 | ||
454 | msg = GNUNET_malloc(sizeof(struct GNUNET_DV_SendMessage) + addrlen + msgbuf_size); | 454 | msize = sizeof(struct GNUNET_DV_SendMessage) + addrlen + msgbuf_size; |
455 | msg->header.size = htons(sizeof(struct GNUNET_DV_SendMessage) + addrlen + msgbuf_size); | 455 | msg = GNUNET_malloc(msize); |
456 | msg->header.size = htons(msize); | ||
456 | msg->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_DV_SEND); | 457 | msg->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_DV_SEND); |
457 | memcpy(&msg->target, target, sizeof(struct GNUNET_PeerIdentity)); | 458 | memcpy(&msg->target, target, sizeof(struct GNUNET_PeerIdentity)); |
458 | msg->msgbuf_size = htonl(msgbuf_size); | 459 | msg->msgbuf_size = htonl(msgbuf_size); |
@@ -497,6 +498,8 @@ transmit_start (void *cls, size_t size, void *buf) | |||
497 | if (size >= tsize) | 498 | if (size >= tsize) |
498 | { | 499 | { |
499 | memcpy(buf, start_context->message, tsize); | 500 | memcpy(buf, start_context->message, tsize); |
501 | GNUNET_free(start_context->message); | ||
502 | GNUNET_free(start_context); | ||
500 | return tsize; | 503 | return tsize; |
501 | } | 504 | } |
502 | 505 | ||
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c index 72dc40288..9cad3dca2 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c | |||
@@ -49,7 +49,7 @@ | |||
49 | * For testing mostly, remember only the | 49 | * For testing mostly, remember only the |
50 | * shortest path to a distant neighbor. | 50 | * shortest path to a distant neighbor. |
51 | */ | 51 | */ |
52 | #define AT_MOST_ONE GNUNET_YES | 52 | #define AT_MOST_ONE GNUNET_NO |
53 | 53 | ||
54 | #define USE_PEER_ID GNUNET_YES | 54 | #define USE_PEER_ID GNUNET_YES |
55 | 55 | ||
@@ -146,22 +146,11 @@ static struct GNUNET_SERVER_Client * client_handle; | |||
146 | /** | 146 | /** |
147 | * Task to run when we shut down, cleaning up all our trash | 147 | * Task to run when we shut down, cleaning up all our trash |
148 | */ | 148 | */ |
149 | GNUNET_SCHEDULER_TaskIdentifier cleanup_task; | 149 | static GNUNET_SCHEDULER_TaskIdentifier cleanup_task; |
150 | |||
151 | /** | ||
152 | * Task to run to gossip about peers. Will reschedule itself forever until shutdown! | ||
153 | */ | ||
154 | GNUNET_SCHEDULER_TaskIdentifier gossip_task; | ||
155 | |||
156 | /** | ||
157 | * Struct where neighbor information is stored. | ||
158 | */ | ||
159 | struct DistantNeighbor *referees; | ||
160 | 150 | ||
161 | static size_t default_dv_priority = 0; | 151 | static size_t default_dv_priority = 0; |
162 | 152 | ||
163 | char *my_short_id; | 153 | static char *my_short_id; |
164 | |||
165 | 154 | ||
166 | /** | 155 | /** |
167 | * Linked list of messages to send to clients. | 156 | * Linked list of messages to send to clients. |
@@ -213,37 +202,37 @@ struct PendingMessage | |||
213 | /** | 202 | /** |
214 | * Transmit handle to the plugin. | 203 | * Transmit handle to the plugin. |
215 | */ | 204 | */ |
216 | struct GNUNET_CONNECTION_TransmitHandle * plugin_transmit_handle; | 205 | static struct GNUNET_CONNECTION_TransmitHandle * plugin_transmit_handle; |
217 | 206 | ||
218 | /** | 207 | /** |
219 | * Head of DLL for client messages | 208 | * Head of DLL for client messages |
220 | */ | 209 | */ |
221 | struct PendingMessage *plugin_pending_head; | 210 | static struct PendingMessage *plugin_pending_head; |
222 | 211 | ||
223 | /** | 212 | /** |
224 | * Tail of DLL for client messages | 213 | * Tail of DLL for client messages |
225 | */ | 214 | */ |
226 | struct PendingMessage *plugin_pending_tail; | 215 | static struct PendingMessage *plugin_pending_tail; |
227 | 216 | ||
228 | /** | 217 | /** |
229 | * Handle to the peerinfo service | 218 | * Handle to the peerinfo service |
230 | */ | 219 | */ |
231 | struct GNUNET_PEERINFO_Handle *peerinfo_handle; | 220 | static struct GNUNET_PEERINFO_Handle *peerinfo_handle; |
232 | 221 | ||
233 | /** | 222 | /** |
234 | * Transmit handle to core service. | 223 | * Transmit handle to core service. |
235 | */ | 224 | */ |
236 | struct GNUNET_CORE_TransmitHandle * core_transmit_handle; | 225 | static struct GNUNET_CORE_TransmitHandle * core_transmit_handle; |
237 | 226 | ||
238 | /** | 227 | /** |
239 | * Head of DLL for core messages | 228 | * Head of DLL for core messages |
240 | */ | 229 | */ |
241 | struct PendingMessage *core_pending_head; | 230 | static struct PendingMessage *core_pending_head; |
242 | 231 | ||
243 | /** | 232 | /** |
244 | * Tail of DLL for core messages | 233 | * Tail of DLL for core messages |
245 | */ | 234 | */ |
246 | struct PendingMessage *core_pending_tail; | 235 | static struct PendingMessage *core_pending_tail; |
247 | 236 | ||
248 | 237 | ||
249 | struct FastGossipNeighborList | 238 | struct FastGossipNeighborList |
@@ -530,49 +519,38 @@ struct DV_SendContext | |||
530 | #endif | 519 | #endif |
531 | }; | 520 | }; |
532 | 521 | ||
522 | |||
533 | /** | 523 | /** |
534 | * Global construct | 524 | * Map of PeerIdentifiers to 'struct GNUNET_dv_neighbor*'s for all |
525 | * directly connected peers. | ||
535 | */ | 526 | */ |
536 | struct GNUNET_DV_Context | 527 | static struct GNUNET_CONTAINER_MultiHashMap *direct_neighbors; |
537 | { | ||
538 | /** | ||
539 | * Map of PeerIdentifiers to 'struct GNUNET_dv_neighbor*'s for all | ||
540 | * directly connected peers. | ||
541 | */ | ||
542 | struct GNUNET_CONTAINER_MultiHashMap *direct_neighbors; | ||
543 | |||
544 | /** | ||
545 | * Map of PeerIdentifiers to 'struct GNUNET_dv_neighbor*'s for | ||
546 | * peers connected via DV (extended neighborhood). Does ALSO | ||
547 | * include any peers that are in 'direct_neighbors'; for those | ||
548 | * peers, the cost will be zero and the referrer all zeros. | ||
549 | */ | ||
550 | struct GNUNET_CONTAINER_MultiHashMap *extended_neighbors; | ||
551 | 528 | ||
552 | /** | 529 | /** |
553 | * We use the min heap (min refers to cost) to prefer | 530 | * Map of PeerIdentifiers to 'struct GNUNET_dv_neighbor*'s for |
554 | * gossipping about peers with small costs. | 531 | * peers connected via DV (extended neighborhood). Does ALSO |
555 | */ | 532 | * include any peers that are in 'direct_neighbors'; for those |
556 | struct GNUNET_CONTAINER_Heap *neighbor_min_heap; | 533 | * peers, the cost will be zero and the referrer all zeros. |
557 | 534 | */ | |
558 | /** | 535 | static struct GNUNET_CONTAINER_MultiHashMap *extended_neighbors; |
559 | * We use the max heap (max refers to cost) for general | ||
560 | * iterations over all peers and to remove the most costly | ||
561 | * connection if we have too many. | ||
562 | */ | ||
563 | struct GNUNET_CONTAINER_Heap *neighbor_max_heap; | ||
564 | |||
565 | unsigned long long fisheye_depth; | ||
566 | 536 | ||
567 | unsigned long long max_table_size; | 537 | /** |
538 | * We use the min heap (min refers to cost) to prefer | ||
539 | * gossipping about peers with small costs. | ||
540 | */ | ||
541 | static struct GNUNET_CONTAINER_Heap *neighbor_min_heap; | ||
568 | 542 | ||
569 | unsigned int neighbor_id_loc; | 543 | /** |
544 | * We use the max heap (max refers to cost) for general | ||
545 | * iterations over all peers and to remove the most costly | ||
546 | * connection if we have too many. | ||
547 | */ | ||
548 | static struct GNUNET_CONTAINER_Heap *neighbor_max_heap; | ||
570 | 549 | ||
571 | int closing; | 550 | static unsigned long long fisheye_depth; |
572 | 551 | ||
573 | }; | 552 | static unsigned long long max_table_size; |
574 | 553 | ||
575 | static struct GNUNET_DV_Context ctx; | ||
576 | 554 | ||
577 | struct FindDestinationContext | 555 | struct FindDestinationContext |
578 | { | 556 | { |
@@ -917,10 +895,10 @@ send_message_via (const struct GNUNET_PeerIdentity *sender, | |||
917 | find_context.dest = send_context->distant_peer; | 895 | find_context.dest = send_context->distant_peer; |
918 | find_context.via = recipient; | 896 | find_context.via = recipient; |
919 | find_context.tid = 0; | 897 | find_context.tid = 0; |
920 | //specific_neighbor = GNUNET_CONTAINER_multihashmap_get(ctx.extended_neighbors, &send_context->distant_peer->hashPubKey); | 898 | //specific_neighbor = GNUNET_CONTAINER_multihashmap_get(extended_neighbors, &send_context->distant_peer->hashPubKey); |
921 | 899 | ||
922 | //GNUNET_CONTAINER_multihashmap_iterate(ctx.extended_neighbors, &find_specific_id, &find_context); | 900 | //GNUNET_CONTAINER_multihashmap_iterate(extended_neighbors, &find_specific_id, &find_context); |
923 | GNUNET_CONTAINER_multihashmap_get_multiple (ctx.extended_neighbors, &send_context->distant_peer->hashPubKey, | 901 | GNUNET_CONTAINER_multihashmap_get_multiple (extended_neighbors, &send_context->distant_peer->hashPubKey, |
924 | &find_specific_id, &find_context); | 902 | &find_specific_id, &find_context); |
925 | 903 | ||
926 | if (find_context.tid == 0) | 904 | if (find_context.tid == 0) |
@@ -935,14 +913,14 @@ send_message_via (const struct GNUNET_PeerIdentity *sender, | |||
935 | sender, sizeof (struct GNUNET_PeerIdentity)))) | 913 | sender, sizeof (struct GNUNET_PeerIdentity)))) |
936 | { | 914 | { |
937 | sender_id = 0; | 915 | sender_id = 0; |
938 | source = GNUNET_CONTAINER_multihashmap_get (ctx.extended_neighbors, | 916 | source = GNUNET_CONTAINER_multihashmap_get (extended_neighbors, |
939 | &sender->hashPubKey); | 917 | &sender->hashPubKey); |
940 | if (source != NULL) | 918 | if (source != NULL) |
941 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s: send_message_via found %s, myself in extended peer list???\n", my_short_id, GNUNET_i2s(&source->identity)); | 919 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s: send_message_via found %s, myself in extended peer list???\n", my_short_id, GNUNET_i2s(&source->identity)); |
942 | } | 920 | } |
943 | else | 921 | else |
944 | { | 922 | { |
945 | source = GNUNET_CONTAINER_multihashmap_get (ctx.extended_neighbors, | 923 | source = GNUNET_CONTAINER_multihashmap_get (extended_neighbors, |
946 | &sender->hashPubKey); | 924 | &sender->hashPubKey); |
947 | if (source == NULL) | 925 | if (source == NULL) |
948 | { | 926 | { |
@@ -1093,7 +1071,7 @@ send_message (const struct GNUNET_PeerIdentity * recipient, | |||
1093 | * in messages looping forever. Relatively cheap, we don't iterate | 1071 | * in messages looping forever. Relatively cheap, we don't iterate |
1094 | * over all known peers, just those that apply. | 1072 | * over all known peers, just those that apply. |
1095 | */ | 1073 | */ |
1096 | GNUNET_CONTAINER_multihashmap_get_multiple (ctx.extended_neighbors, | 1074 | GNUNET_CONTAINER_multihashmap_get_multiple (extended_neighbors, |
1097 | &recipient->hashPubKey, &find_least_cost_peer, &find_least_ctx); | 1075 | &recipient->hashPubKey, &find_least_cost_peer, &find_least_ctx); |
1098 | target = find_least_ctx.target; | 1076 | target = find_least_ctx.target; |
1099 | 1077 | ||
@@ -1104,7 +1082,7 @@ send_message (const struct GNUNET_PeerIdentity * recipient, | |||
1104 | } | 1082 | } |
1105 | recipient_id = target->referrer_id; | 1083 | recipient_id = target->referrer_id; |
1106 | 1084 | ||
1107 | source = GNUNET_CONTAINER_multihashmap_get (ctx.extended_neighbors, | 1085 | source = GNUNET_CONTAINER_multihashmap_get (extended_neighbors, |
1108 | &sender->hashPubKey); | 1086 | &sender->hashPubKey); |
1109 | if (source == NULL) | 1087 | if (source == NULL) |
1110 | { | 1088 | { |
@@ -1129,7 +1107,7 @@ send_message (const struct GNUNET_PeerIdentity * recipient, | |||
1129 | encPeerFrom.encoding[4] = '\0'; | 1107 | encPeerFrom.encoding[4] = '\0'; |
1130 | encPeerVia.encoding[4] = '\0'; | 1108 | encPeerVia.encoding[4] = '\0'; |
1131 | #endif | 1109 | #endif |
1132 | if (0 == memcmp(&source->identity, &target->referrer->identity, sizeof(struct GNUNET_PeerIdentity))) | 1110 | if ((sender_id != 0) && (0 == memcmp(&source->identity, &target->referrer->identity, sizeof(struct GNUNET_PeerIdentity)))) |
1133 | { | 1111 | { |
1134 | return 0; | 1112 | return 0; |
1135 | } | 1113 | } |
@@ -1266,7 +1244,7 @@ static int handle_dv_data_message (void *cls, | |||
1266 | return GNUNET_SYSERR; | 1244 | return GNUNET_SYSERR; |
1267 | } | 1245 | } |
1268 | 1246 | ||
1269 | dn = GNUNET_CONTAINER_multihashmap_get (ctx.direct_neighbors, | 1247 | dn = GNUNET_CONTAINER_multihashmap_get (direct_neighbors, |
1270 | &peer->hashPubKey); | 1248 | &peer->hashPubKey); |
1271 | if (dn == NULL) | 1249 | if (dn == NULL) |
1272 | { | 1250 | { |
@@ -1282,12 +1260,12 @@ static int handle_dv_data_message (void *cls, | |||
1282 | { | 1260 | { |
1283 | checkPeerCtx.sender_id = sid; | 1261 | checkPeerCtx.sender_id = sid; |
1284 | checkPeerCtx.peer = NULL; | 1262 | checkPeerCtx.peer = NULL; |
1285 | GNUNET_CONTAINER_multihashmap_iterate(ctx.extended_neighbors, &checkPeerID, &checkPeerCtx); | 1263 | GNUNET_CONTAINER_multihashmap_iterate(extended_neighbors, &checkPeerID, &checkPeerCtx); |
1286 | pos = checkPeerCtx.peer; | 1264 | pos = checkPeerCtx.peer; |
1287 | } | 1265 | } |
1288 | else | 1266 | else |
1289 | { | 1267 | { |
1290 | pos = GNUNET_CONTAINER_multihashmap_get (ctx.extended_neighbors, | 1268 | pos = GNUNET_CONTAINER_multihashmap_get (extended_neighbors, |
1291 | &peer->hashPubKey); | 1269 | &peer->hashPubKey); |
1292 | } | 1270 | } |
1293 | #else | 1271 | #else |
@@ -1361,7 +1339,7 @@ static int handle_dv_data_message (void *cls, | |||
1361 | issue) */ | 1339 | issue) */ |
1362 | fdc.tid = tid; | 1340 | fdc.tid = tid; |
1363 | fdc.dest = NULL; | 1341 | fdc.dest = NULL; |
1364 | GNUNET_CONTAINER_heap_iterate (ctx.neighbor_max_heap, | 1342 | GNUNET_CONTAINER_heap_iterate (neighbor_max_heap, |
1365 | &find_destination, &fdc); | 1343 | &find_destination, &fdc); |
1366 | 1344 | ||
1367 | #if DEBUG_DV | 1345 | #if DEBUG_DV |
@@ -1514,7 +1492,7 @@ neighbor_send_task (void *cls, | |||
1514 | * | 1492 | * |
1515 | * NOTE: probably fixed once we decided send rate based on allowed bandwidth. | 1493 | * NOTE: probably fixed once we decided send rate based on allowed bandwidth. |
1516 | */ | 1494 | */ |
1517 | about = GNUNET_CONTAINER_heap_walk_get_next (ctx.neighbor_min_heap); | 1495 | about = GNUNET_CONTAINER_heap_walk_get_next (neighbor_min_heap); |
1518 | } | 1496 | } |
1519 | to = send_context->toNeighbor; | 1497 | to = send_context->toNeighbor; |
1520 | 1498 | ||
@@ -1772,7 +1750,7 @@ void handle_dv_send_message (void *cls, | |||
1772 | 1750 | ||
1773 | /* In bizarro world GNUNET_SYSERR indicates that we succeeded */ | 1751 | /* In bizarro world GNUNET_SYSERR indicates that we succeeded */ |
1774 | #if UNSIMPLER | 1752 | #if UNSIMPLER |
1775 | if (GNUNET_SYSERR != GNUNET_CONTAINER_multihashmap_get_multiple(ctx.extended_neighbors, &destination->hashPubKey, &send_iterator, send_context)) | 1753 | if (GNUNET_SYSERR != GNUNET_CONTAINER_multihashmap_get_multiple(extended_neighbors, &destination->hashPubKey, &send_iterator, send_context)) |
1776 | { | 1754 | { |
1777 | send_result_msg->result = htons(1); | 1755 | send_result_msg->result = htons(1); |
1778 | pending_message = GNUNET_malloc(sizeof(struct PendingMessage) + sizeof(struct GNUNET_DV_SendResultMessage)); | 1756 | pending_message = GNUNET_malloc(sizeof(struct PendingMessage) + sizeof(struct GNUNET_DV_SendResultMessage)); |
@@ -1862,9 +1840,9 @@ distant_neighbor_free (struct DistantNeighbor *referee) | |||
1862 | GNUNET_CONTAINER_DLL_remove (referrer->referee_head, | 1840 | GNUNET_CONTAINER_DLL_remove (referrer->referee_head, |
1863 | referrer->referee_tail, referee); | 1841 | referrer->referee_tail, referee); |
1864 | } | 1842 | } |
1865 | GNUNET_CONTAINER_heap_remove_node (ctx.neighbor_max_heap, referee->max_loc); | 1843 | GNUNET_CONTAINER_heap_remove_node (neighbor_max_heap, referee->max_loc); |
1866 | GNUNET_CONTAINER_heap_remove_node (ctx.neighbor_min_heap, referee->min_loc); | 1844 | GNUNET_CONTAINER_heap_remove_node (neighbor_min_heap, referee->min_loc); |
1867 | GNUNET_CONTAINER_multihashmap_remove_all (ctx.extended_neighbors, | 1845 | GNUNET_CONTAINER_multihashmap_remove_all (extended_neighbors, |
1868 | &referee->identity.hashPubKey); | 1846 | &referee->identity.hashPubKey); |
1869 | GNUNET_free_non_null (referee->pkey); | 1847 | GNUNET_free_non_null (referee->pkey); |
1870 | GNUNET_free (referee); | 1848 | GNUNET_free (referee); |
@@ -1992,15 +1970,15 @@ shutdown_task (void *cls, | |||
1992 | { | 1970 | { |
1993 | #if DEBUG_DV | 1971 | #if DEBUG_DV |
1994 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "calling CORE_DISCONNECT\n"); | 1972 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "calling CORE_DISCONNECT\n"); |
1995 | GNUNET_CONTAINER_multihashmap_iterate(ctx.extended_neighbors, &print_neighbors, NULL); | 1973 | GNUNET_CONTAINER_multihashmap_iterate(extended_neighbors, &print_neighbors, NULL); |
1996 | #endif | 1974 | #endif |
1997 | GNUNET_CONTAINER_multihashmap_iterate(ctx.extended_neighbors, &free_extended_neighbors, NULL); | 1975 | GNUNET_CONTAINER_multihashmap_iterate(extended_neighbors, &free_extended_neighbors, NULL); |
1998 | GNUNET_CONTAINER_multihashmap_destroy(ctx.extended_neighbors); | 1976 | GNUNET_CONTAINER_multihashmap_destroy(extended_neighbors); |
1999 | GNUNET_CONTAINER_multihashmap_iterate(ctx.direct_neighbors, &free_direct_neighbors, NULL); | 1977 | GNUNET_CONTAINER_multihashmap_iterate(direct_neighbors, &free_direct_neighbors, NULL); |
2000 | GNUNET_CONTAINER_multihashmap_destroy(ctx.direct_neighbors); | 1978 | GNUNET_CONTAINER_multihashmap_destroy(direct_neighbors); |
2001 | 1979 | ||
2002 | GNUNET_CONTAINER_heap_destroy(ctx.neighbor_max_heap); | 1980 | GNUNET_CONTAINER_heap_destroy(neighbor_max_heap); |
2003 | GNUNET_CONTAINER_heap_destroy(ctx.neighbor_min_heap); | 1981 | GNUNET_CONTAINER_heap_destroy(neighbor_min_heap); |
2004 | 1982 | ||
2005 | GNUNET_CORE_disconnect (coreAPI); | 1983 | GNUNET_CORE_disconnect (coreAPI); |
2006 | GNUNET_PEERINFO_disconnect(peerinfo_handle); | 1984 | GNUNET_PEERINFO_disconnect(peerinfo_handle); |
@@ -2084,9 +2062,9 @@ static int update_matching_neighbors (void *cls, | |||
2084 | if (update_info->referrer == distant_neighbor->referrer) /* Direct neighbor matches, update it's info and return GNUNET_NO */ | 2062 | if (update_info->referrer == distant_neighbor->referrer) /* Direct neighbor matches, update it's info and return GNUNET_NO */ |
2085 | { | 2063 | { |
2086 | /* same referrer, cost change! */ | 2064 | /* same referrer, cost change! */ |
2087 | GNUNET_CONTAINER_heap_update_cost (ctx.neighbor_max_heap, | 2065 | GNUNET_CONTAINER_heap_update_cost (neighbor_max_heap, |
2088 | update_info->neighbor->max_loc, update_info->cost); | 2066 | update_info->neighbor->max_loc, update_info->cost); |
2089 | GNUNET_CONTAINER_heap_update_cost (ctx.neighbor_min_heap, | 2067 | GNUNET_CONTAINER_heap_update_cost (neighbor_min_heap, |
2090 | update_info->neighbor->min_loc, update_info->cost); | 2068 | update_info->neighbor->min_loc, update_info->cost); |
2091 | update_info->neighbor->last_activity = update_info->now; | 2069 | update_info->neighbor->last_activity = update_info->now; |
2092 | update_info->neighbor->cost = update_info->cost; | 2070 | update_info->neighbor->cost = update_info->cost; |
@@ -2192,7 +2170,7 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity * peer, struct GNUNET_CRYPTO | |||
2192 | #endif | 2170 | #endif |
2193 | 2171 | ||
2194 | now = GNUNET_TIME_absolute_get (); | 2172 | now = GNUNET_TIME_absolute_get (); |
2195 | neighbor = GNUNET_CONTAINER_multihashmap_get (ctx.extended_neighbors, | 2173 | neighbor = GNUNET_CONTAINER_multihashmap_get (extended_neighbors, |
2196 | &peer->hashPubKey); | 2174 | &peer->hashPubKey); |
2197 | neighbor_update = GNUNET_malloc(sizeof(struct NeighborUpdateInfo)); | 2175 | neighbor_update = GNUNET_malloc(sizeof(struct NeighborUpdateInfo)); |
2198 | neighbor_update->neighbor = neighbor; | 2176 | neighbor_update->neighbor = neighbor; |
@@ -2220,7 +2198,7 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity * peer, struct GNUNET_CRYPTO | |||
2220 | 2198 | ||
2221 | /* Either we do not know this peer, or we already do but via a different immediate peer */ | 2199 | /* Either we do not know this peer, or we already do but via a different immediate peer */ |
2222 | if ((neighbor == NULL) || | 2200 | if ((neighbor == NULL) || |
2223 | (GNUNET_CONTAINER_multihashmap_get_multiple(ctx.extended_neighbors, | 2201 | (GNUNET_CONTAINER_multihashmap_get_multiple(extended_neighbors, |
2224 | &peer->hashPubKey, | 2202 | &peer->hashPubKey, |
2225 | &update_matching_neighbors, | 2203 | &update_matching_neighbors, |
2226 | neighbor_update) != GNUNET_SYSERR)) | 2204 | neighbor_update) != GNUNET_SYSERR)) |
@@ -2231,13 +2209,13 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity * peer, struct GNUNET_CRYPTO | |||
2231 | { | 2209 | { |
2232 | distant_neighbor_free(neighbor); | 2210 | distant_neighbor_free(neighbor); |
2233 | } | 2211 | } |
2234 | else if ((neighbor != NULL) && (cost >= neighbor->cost)) /* Only allow one DV connection to each peer */ | 2212 | else if (neighbor != NULL) /* Only allow one DV connection to each peer */ |
2235 | { | 2213 | { |
2236 | return NULL; | 2214 | return NULL; |
2237 | } | 2215 | } |
2238 | #endif | 2216 | #endif |
2239 | /* new neighbor! */ | 2217 | /* new neighbor! */ |
2240 | if (cost > ctx.fisheye_depth) | 2218 | if (cost > fisheye_depth) |
2241 | { | 2219 | { |
2242 | /* too costly */ | 2220 | /* too costly */ |
2243 | GNUNET_free(neighbor_update); | 2221 | GNUNET_free(neighbor_update); |
@@ -2251,11 +2229,12 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity * peer, struct GNUNET_CRYPTO | |||
2251 | GNUNET_free(encAbout); | 2229 | GNUNET_free(encAbout); |
2252 | #endif | 2230 | #endif |
2253 | 2231 | ||
2254 | if (ctx.max_table_size <= | 2232 | if (max_table_size <= |
2255 | GNUNET_CONTAINER_multihashmap_size (ctx.extended_neighbors)) | 2233 | GNUNET_CONTAINER_multihashmap_size (extended_neighbors)) |
2256 | { | 2234 | { |
2257 | /* remove most expensive entry */ | 2235 | /* remove most expensive entry */ |
2258 | max = GNUNET_CONTAINER_heap_peek (ctx.neighbor_max_heap); | 2236 | max = GNUNET_CONTAINER_heap_peek (neighbor_max_heap); |
2237 | GNUNET_assert(max != NULL); | ||
2259 | if (cost > max->cost) | 2238 | if (cost > max->cost) |
2260 | { | 2239 | { |
2261 | /* new entry most expensive, don't create */ | 2240 | /* new entry most expensive, don't create */ |
@@ -2274,9 +2253,9 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity * peer, struct GNUNET_CRYPTO | |||
2274 | neighbor = GNUNET_malloc (sizeof (struct DistantNeighbor)); | 2253 | neighbor = GNUNET_malloc (sizeof (struct DistantNeighbor)); |
2275 | GNUNET_CONTAINER_DLL_insert (referrer->referee_head, | 2254 | GNUNET_CONTAINER_DLL_insert (referrer->referee_head, |
2276 | referrer->referee_tail, neighbor); | 2255 | referrer->referee_tail, neighbor); |
2277 | neighbor->max_loc = GNUNET_CONTAINER_heap_insert (ctx.neighbor_max_heap, | 2256 | neighbor->max_loc = GNUNET_CONTAINER_heap_insert (neighbor_max_heap, |
2278 | neighbor, cost); | 2257 | neighbor, cost); |
2279 | neighbor->min_loc = GNUNET_CONTAINER_heap_insert (ctx.neighbor_min_heap, | 2258 | neighbor->min_loc = GNUNET_CONTAINER_heap_insert (neighbor_min_heap, |
2280 | neighbor, cost); | 2259 | neighbor, cost); |
2281 | neighbor->referrer = referrer; | 2260 | neighbor->referrer = referrer; |
2282 | memcpy (&neighbor->identity, peer, sizeof (struct GNUNET_PeerIdentity)); | 2261 | memcpy (&neighbor->identity, peer, sizeof (struct GNUNET_PeerIdentity)); |
@@ -2296,7 +2275,7 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity * peer, struct GNUNET_CRYPTO | |||
2296 | (cost == DIRECT_NEIGHBOR_COST) ? (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 4) == | 2275 | (cost == DIRECT_NEIGHBOR_COST) ? (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 4) == |
2297 | 0) : GNUNET_NO; | 2276 | 0) : GNUNET_NO; |
2298 | 2277 | ||
2299 | GNUNET_CONTAINER_multihashmap_put (ctx.extended_neighbors, &peer->hashPubKey, | 2278 | GNUNET_CONTAINER_multihashmap_put (extended_neighbors, &peer->hashPubKey, |
2300 | neighbor, | 2279 | neighbor, |
2301 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 2280 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
2302 | 2281 | ||
@@ -2310,7 +2289,7 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity * peer, struct GNUNET_CRYPTO | |||
2310 | } | 2289 | } |
2311 | #if DEBUG_DV | 2290 | #if DEBUG_DV |
2312 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2291 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2313 | "%s: Size of extended_neighbors is %d\n", "dv", GNUNET_CONTAINER_multihashmap_size(ctx.extended_neighbors)); | 2292 | "%s: Size of extended_neighbors is %d\n", "dv", GNUNET_CONTAINER_multihashmap_size(extended_neighbors)); |
2314 | #endif | 2293 | #endif |
2315 | 2294 | ||
2316 | GNUNET_free(neighbor_update); | 2295 | GNUNET_free(neighbor_update); |
@@ -2388,7 +2367,7 @@ static int handle_dv_disconnect_message (void *cls, | |||
2388 | return GNUNET_SYSERR; /* invalid message */ | 2367 | return GNUNET_SYSERR; /* invalid message */ |
2389 | } | 2368 | } |
2390 | 2369 | ||
2391 | referrer = GNUNET_CONTAINER_multihashmap_get (ctx.direct_neighbors, | 2370 | referrer = GNUNET_CONTAINER_multihashmap_get (direct_neighbors, |
2392 | &peer->hashPubKey); | 2371 | &peer->hashPubKey); |
2393 | if (referrer == NULL) | 2372 | if (referrer == NULL) |
2394 | return GNUNET_OK; | 2373 | return GNUNET_OK; |
@@ -2448,7 +2427,7 @@ static int handle_dv_gossip_message (void *cls, | |||
2448 | GNUNET_free(encPeerFrom); | 2427 | GNUNET_free(encPeerFrom); |
2449 | #endif | 2428 | #endif |
2450 | 2429 | ||
2451 | referrer = GNUNET_CONTAINER_multihashmap_get (ctx.direct_neighbors, | 2430 | referrer = GNUNET_CONTAINER_multihashmap_get (direct_neighbors, |
2452 | &peer->hashPubKey); | 2431 | &peer->hashPubKey); |
2453 | if (referrer == NULL) | 2432 | if (referrer == NULL) |
2454 | return GNUNET_OK; | 2433 | return GNUNET_OK; |
@@ -2524,7 +2503,7 @@ static int gossip_all_to_all_iterator (void *cls, | |||
2524 | { | 2503 | { |
2525 | struct DirectNeighbor *direct = value; | 2504 | struct DirectNeighbor *direct = value; |
2526 | 2505 | ||
2527 | GNUNET_CONTAINER_multihashmap_iterate (ctx.extended_neighbors, &add_all_extended_peers, direct->send_context); | 2506 | GNUNET_CONTAINER_multihashmap_iterate (extended_neighbors, &add_all_extended_peers, direct->send_context); |
2528 | 2507 | ||
2529 | if (direct->send_context->task != GNUNET_SCHEDULER_NO_TASK) | 2508 | if (direct->send_context->task != GNUNET_SCHEDULER_NO_TASK) |
2530 | GNUNET_SCHEDULER_cancel(sched, direct->send_context->task); | 2509 | GNUNET_SCHEDULER_cancel(sched, direct->send_context->task); |
@@ -2543,7 +2522,7 @@ static void | |||
2543 | gossip_all_to_all (void *cls, | 2522 | gossip_all_to_all (void *cls, |
2544 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 2523 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
2545 | { | 2524 | { |
2546 | GNUNET_CONTAINER_multihashmap_iterate (ctx.direct_neighbors, &gossip_all_to_all_iterator, NULL); | 2525 | GNUNET_CONTAINER_multihashmap_iterate (direct_neighbors, &gossip_all_to_all_iterator, NULL); |
2547 | 2526 | ||
2548 | GNUNET_SCHEDULER_add_delayed (sched, | 2527 | GNUNET_SCHEDULER_add_delayed (sched, |
2549 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), | 2528 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), |
@@ -2575,7 +2554,7 @@ static int add_all_direct_neighbors (void *cls, | |||
2575 | char *direct_id; | 2554 | char *direct_id; |
2576 | 2555 | ||
2577 | 2556 | ||
2578 | distant = GNUNET_CONTAINER_multihashmap_get(ctx.extended_neighbors, &to->identity.hashPubKey); | 2557 | distant = GNUNET_CONTAINER_multihashmap_get(extended_neighbors, &to->identity.hashPubKey); |
2579 | if (distant == NULL) | 2558 | if (distant == NULL) |
2580 | { | 2559 | { |
2581 | return GNUNET_YES; | 2560 | return GNUNET_YES; |
@@ -2666,18 +2645,18 @@ process_peerinfo (void *cls, | |||
2666 | } | 2645 | } |
2667 | 2646 | ||
2668 | /* Why do it this way, now we have the distant neighbor! */ | 2647 | /* Why do it this way, now we have the distant neighbor! */ |
2669 | /*GNUNET_CONTAINER_multihashmap_get_multiple(ctx.extended_neighbors, | 2648 | /*GNUNET_CONTAINER_multihashmap_get_multiple(extended_neighbors, |
2670 | &peer->hashPubKey, | 2649 | &peer->hashPubKey, |
2671 | &add_pkey_to_extended, | 2650 | &add_pkey_to_extended, |
2672 | &neighbor->pkey);*/ | 2651 | &neighbor->pkey);*/ |
2673 | 2652 | ||
2674 | sent = GNUNET_CONTAINER_multihashmap_iterate (ctx.extended_neighbors, &add_all_extended_peers, neighbor->send_context); | 2653 | sent = GNUNET_CONTAINER_multihashmap_iterate (extended_neighbors, &add_all_extended_peers, neighbor->send_context); |
2675 | 2654 | ||
2676 | #if DEBUG_DV_PEER_NUMBERS | 2655 | #if DEBUG_DV_PEER_NUMBERS |
2677 | neighbor_pid = GNUNET_strdup(GNUNET_i2s(&neighbor->identity)); | 2656 | neighbor_pid = GNUNET_strdup(GNUNET_i2s(&neighbor->identity)); |
2678 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Gossipped %d extended peers to %s\n", GNUNET_i2s(&my_identity), sent, neighbor_pid); | 2657 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Gossipped %d extended peers to %s\n", GNUNET_i2s(&my_identity), sent, neighbor_pid); |
2679 | #endif | 2658 | #endif |
2680 | sent = GNUNET_CONTAINER_multihashmap_iterate (ctx.direct_neighbors, &add_all_direct_neighbors, neighbor); | 2659 | sent = GNUNET_CONTAINER_multihashmap_iterate (direct_neighbors, &add_all_direct_neighbors, neighbor); |
2681 | #if DEBUG_DV_PEER_NUMBERS | 2660 | #if DEBUG_DV_PEER_NUMBERS |
2682 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Gossipped about %s to %d direct peers\n", GNUNET_i2s(&my_identity), neighbor_pid, sent); | 2661 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Gossipped about %s to %d direct peers\n", GNUNET_i2s(&my_identity), neighbor_pid, sent); |
2683 | GNUNET_free(neighbor_pid); | 2662 | GNUNET_free(neighbor_pid); |
@@ -2709,7 +2688,7 @@ void handle_core_connect (void *cls, | |||
2709 | "%s: Receives core connect message for peer %s distance %d!\n", "dv", GNUNET_i2s(peer), distance); | 2688 | "%s: Receives core connect message for peer %s distance %d!\n", "dv", GNUNET_i2s(peer), distance); |
2710 | #endif | 2689 | #endif |
2711 | 2690 | ||
2712 | if ((distance == DIRECT_NEIGHBOR_COST) && (GNUNET_CONTAINER_multihashmap_get(ctx.direct_neighbors, &peer->hashPubKey) == NULL)) | 2691 | if ((distance == DIRECT_NEIGHBOR_COST) && (GNUNET_CONTAINER_multihashmap_get(direct_neighbors, &peer->hashPubKey) == NULL)) |
2713 | { | 2692 | { |
2714 | peerinfo_iterator = GNUNET_malloc(sizeof(struct PeerIteratorContext)); | 2693 | peerinfo_iterator = GNUNET_malloc(sizeof(struct PeerIteratorContext)); |
2715 | neighbor = GNUNET_malloc (sizeof (struct DirectNeighbor)); | 2694 | neighbor = GNUNET_malloc (sizeof (struct DirectNeighbor)); |
@@ -2717,7 +2696,7 @@ void handle_core_connect (void *cls, | |||
2717 | neighbor->send_context->toNeighbor = neighbor; | 2696 | neighbor->send_context->toNeighbor = neighbor; |
2718 | memcpy (&neighbor->identity, peer, sizeof (struct GNUNET_PeerIdentity)); | 2697 | memcpy (&neighbor->identity, peer, sizeof (struct GNUNET_PeerIdentity)); |
2719 | 2698 | ||
2720 | GNUNET_assert(GNUNET_SYSERR != GNUNET_CONTAINER_multihashmap_put (ctx.direct_neighbors, | 2699 | GNUNET_assert(GNUNET_SYSERR != GNUNET_CONTAINER_multihashmap_put (direct_neighbors, |
2721 | &peer->hashPubKey, | 2700 | &peer->hashPubKey, |
2722 | neighbor, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 2701 | neighbor, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
2723 | about = addUpdateNeighbor (peer, NULL, 0, neighbor, DIRECT_NEIGHBOR_COST); | 2702 | about = addUpdateNeighbor (peer, NULL, 0, neighbor, DIRECT_NEIGHBOR_COST); |
@@ -2743,9 +2722,9 @@ void handle_core_connect (void *cls, | |||
2743 | } | 2722 | } |
2744 | else | 2723 | else |
2745 | { | 2724 | { |
2746 | about = GNUNET_CONTAINER_multihashmap_get(ctx.extended_neighbors, &peer->hashPubKey); | 2725 | about = GNUNET_CONTAINER_multihashmap_get(extended_neighbors, &peer->hashPubKey); |
2747 | if ((GNUNET_CONTAINER_multihashmap_get(ctx.direct_neighbors, &peer->hashPubKey) == NULL) && (about != NULL)) | 2726 | if ((GNUNET_CONTAINER_multihashmap_get(direct_neighbors, &peer->hashPubKey) == NULL) && (about != NULL)) |
2748 | sent = GNUNET_CONTAINER_multihashmap_iterate(ctx.direct_neighbors, &add_distant_all_direct_neighbors, about); | 2727 | sent = GNUNET_CONTAINER_multihashmap_iterate(direct_neighbors, &add_distant_all_direct_neighbors, about); |
2749 | #if DEBUG_DV | 2728 | #if DEBUG_DV |
2750 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2729 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2751 | "%s: Distance (%d) greater than %d or already know about peer (%s), not re-adding!\n", "dv", distance, DIRECT_NEIGHBOR_COST, GNUNET_i2s(peer)); | 2730 | "%s: Distance (%d) greater than %d or already know about peer (%s), not re-adding!\n", "dv", distance, DIRECT_NEIGHBOR_COST, GNUNET_i2s(peer)); |
@@ -2774,7 +2753,7 @@ void handle_core_disconnect (void *cls, | |||
2774 | #endif | 2753 | #endif |
2775 | 2754 | ||
2776 | neighbor = | 2755 | neighbor = |
2777 | GNUNET_CONTAINER_multihashmap_get (ctx.direct_neighbors, &peer->hashPubKey); | 2756 | GNUNET_CONTAINER_multihashmap_get (direct_neighbors, &peer->hashPubKey); |
2778 | if (neighbor == NULL) | 2757 | if (neighbor == NULL) |
2779 | { | 2758 | { |
2780 | return; | 2759 | return; |
@@ -2785,17 +2764,17 @@ void handle_core_disconnect (void *cls, | |||
2785 | fdc.dest = NULL; | 2764 | fdc.dest = NULL; |
2786 | fdc.tid = 0; | 2765 | fdc.tid = 0; |
2787 | 2766 | ||
2788 | GNUNET_CONTAINER_multihashmap_iterate (ctx.extended_neighbors, &find_distant_peer, &fdc); | 2767 | GNUNET_CONTAINER_multihashmap_iterate (extended_neighbors, &find_distant_peer, &fdc); |
2789 | 2768 | ||
2790 | if (fdc.dest != NULL) | 2769 | if (fdc.dest != NULL) |
2791 | { | 2770 | { |
2792 | disconnect_context.direct = neighbor; | 2771 | disconnect_context.direct = neighbor; |
2793 | disconnect_context.distant = fdc.dest; | 2772 | disconnect_context.distant = fdc.dest; |
2794 | GNUNET_CONTAINER_multihashmap_iterate (ctx.direct_neighbors, &schedule_disconnect_messages, &disconnect_context); | 2773 | GNUNET_CONTAINER_multihashmap_iterate (direct_neighbors, &schedule_disconnect_messages, &disconnect_context); |
2795 | } | 2774 | } |
2796 | 2775 | ||
2797 | GNUNET_assert (neighbor->referee_tail == NULL); | 2776 | GNUNET_assert (neighbor->referee_tail == NULL); |
2798 | if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_remove (ctx.direct_neighbors, | 2777 | if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_remove (direct_neighbors, |
2799 | &peer->hashPubKey, neighbor)) | 2778 | &peer->hashPubKey, neighbor)) |
2800 | { | 2779 | { |
2801 | GNUNET_break(0); | 2780 | GNUNET_break(0); |
@@ -2826,27 +2805,27 @@ run (void *cls, | |||
2826 | 2805 | ||
2827 | /* FIXME: Read from config, or calculate, or something other than this! */ | 2806 | /* FIXME: Read from config, or calculate, or something other than this! */ |
2828 | max_hosts = DEFAULT_DIRECT_CONNECTIONS; | 2807 | max_hosts = DEFAULT_DIRECT_CONNECTIONS; |
2829 | ctx.max_table_size = DEFAULT_DV_SIZE; | 2808 | max_table_size = DEFAULT_DV_SIZE; |
2830 | ctx.fisheye_depth = DEFAULT_FISHEYE_DEPTH; | 2809 | fisheye_depth = DEFAULT_FISHEYE_DEPTH; |
2831 | 2810 | ||
2832 | if (GNUNET_CONFIGURATION_have_value(cfg, "dv", "max_direct_connections")) | 2811 | if (GNUNET_CONFIGURATION_have_value(cfg, "dv", "max_direct_connections")) |
2833 | GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(cfg, "dv", "max_direct_connections", &max_hosts)); | 2812 | GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(cfg, "dv", "max_direct_connections", &max_hosts)); |
2834 | 2813 | ||
2835 | if (GNUNET_CONFIGURATION_have_value(cfg, "dv", "max_total_connections")) | 2814 | if (GNUNET_CONFIGURATION_have_value(cfg, "dv", "max_total_connections")) |
2836 | GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(cfg, "dv", "max_total_connections", &ctx.max_table_size)); | 2815 | GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(cfg, "dv", "max_total_connections", &max_table_size)); |
2837 | 2816 | ||
2838 | 2817 | ||
2839 | if (GNUNET_CONFIGURATION_have_value(cfg, "dv", "fisheye_depth")) | 2818 | if (GNUNET_CONFIGURATION_have_value(cfg, "dv", "fisheye_depth")) |
2840 | GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(cfg, "dv", "fisheye_depth", &ctx.fisheye_depth)); | 2819 | GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(cfg, "dv", "fisheye_depth", &fisheye_depth)); |
2841 | 2820 | ||
2842 | ctx.neighbor_min_heap = | 2821 | neighbor_min_heap = |
2843 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | 2822 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); |
2844 | ctx.neighbor_max_heap = | 2823 | neighbor_max_heap = |
2845 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MAX); | 2824 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MAX); |
2846 | 2825 | ||
2847 | ctx.direct_neighbors = GNUNET_CONTAINER_multihashmap_create (max_hosts); | 2826 | direct_neighbors = GNUNET_CONTAINER_multihashmap_create (max_hosts); |
2848 | ctx.extended_neighbors = | 2827 | extended_neighbors = |
2849 | GNUNET_CONTAINER_multihashmap_create (ctx.max_table_size * 3); | 2828 | GNUNET_CONTAINER_multihashmap_create (max_table_size * 3); |
2850 | 2829 | ||
2851 | GNUNET_SERVER_add_handlers (server, plugin_handlers); | 2830 | GNUNET_SERVER_add_handlers (server, plugin_handlers); |
2852 | coreAPI = | 2831 | coreAPI = |
diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c index c35380bd0..f4811bbe9 100644 --- a/src/dv/plugin_transport_dv.c +++ b/src/dv/plugin_transport_dv.c | |||
@@ -317,6 +317,7 @@ dv_plugin_address_pretty_printer (void *cls, | |||
317 | GNUNET_asprintf(&print_string, "DV Peer `%s' via peer`%s'", dest_peer, via_peer); | 317 | GNUNET_asprintf(&print_string, "DV Peer `%s' via peer`%s'", dest_peer, via_peer); |
318 | asc (asc_cls, print_string); | 318 | asc (asc_cls, print_string); |
319 | asc (asc_cls, NULL); | 319 | asc (asc_cls, NULL); |
320 | GNUNET_free(via_peer); | ||
320 | GNUNET_free(dest_peer); | 321 | GNUNET_free(dest_peer); |
321 | GNUNET_free(print_string); | 322 | GNUNET_free(print_string); |
322 | } | 323 | } |