diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-05-04 22:16:24 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-05-04 22:16:24 +0200 |
commit | 80f480c752fd8dfa1be51d78fce314d9f0650b50 (patch) | |
tree | 459c21a3fde3b5f66194ac9960632de53586c5f0 /src/topology | |
parent | 3d2a951fa12546c09809f0a4d7e789ef8e971b03 (diff) | |
download | gnunet-80f480c752fd8dfa1be51d78fce314d9f0650b50.tar.gz gnunet-80f480c752fd8dfa1be51d78fce314d9f0650b50.zip |
simplify MQ logic to always carry the same kinds of flags, and extend transport API to pass them to (TNG) service
Diffstat (limited to 'src/topology')
-rw-r--r-- | src/topology/gnunet-daemon-topology.c | 377 |
1 files changed, 140 insertions, 237 deletions
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index e5734abb4..5a22ee0d2 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -51,12 +51,14 @@ | |||
51 | /** | 51 | /** |
52 | * At what frequency do we sent HELLOs to a peer? | 52 | * At what frequency do we sent HELLOs to a peer? |
53 | */ | 53 | */ |
54 | #define HELLO_ADVERTISEMENT_MIN_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) | 54 | #define HELLO_ADVERTISEMENT_MIN_FREQUENCY \ |
55 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) | ||
55 | 56 | ||
56 | /** | 57 | /** |
57 | * After what time period do we expire the HELLO Bloom filter? | 58 | * After what time period do we expire the HELLO Bloom filter? |
58 | */ | 59 | */ |
59 | #define HELLO_ADVERTISEMENT_MIN_REPEAT_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4) | 60 | #define HELLO_ADVERTISEMENT_MIN_REPEAT_FREQUENCY \ |
61 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4) | ||
60 | 62 | ||
61 | 63 | ||
62 | /** | 64 | /** |
@@ -116,7 +118,6 @@ struct Peer | |||
116 | * Is this peer listed here because it is a friend? | 118 | * Is this peer listed here because it is a friend? |
117 | */ | 119 | */ |
118 | int is_friend; | 120 | int is_friend; |
119 | |||
120 | }; | 121 | }; |
121 | 122 | ||
122 | 123 | ||
@@ -216,15 +217,12 @@ static unsigned int friend_count; | |||
216 | * @return #GNUNET_OK if the connection is allowed | 217 | * @return #GNUNET_OK if the connection is allowed |
217 | */ | 218 | */ |
218 | static int | 219 | static int |
219 | blacklist_check (void *cls, | 220 | blacklist_check (void *cls, const struct GNUNET_PeerIdentity *pid) |
220 | const struct GNUNET_PeerIdentity *pid) | ||
221 | { | 221 | { |
222 | struct Peer *pos; | 222 | struct Peer *pos; |
223 | 223 | ||
224 | pos = GNUNET_CONTAINER_multipeermap_get (peers, | 224 | pos = GNUNET_CONTAINER_multipeermap_get (peers, pid); |
225 | pid); | 225 | if ((NULL != pos) && (GNUNET_YES == pos->is_friend)) |
226 | if ( (NULL != pos) && | ||
227 | (GNUNET_YES == pos->is_friend)) | ||
228 | return GNUNET_OK; | 226 | return GNUNET_OK; |
229 | GNUNET_STATISTICS_update (stats, | 227 | GNUNET_STATISTICS_update (stats, |
230 | gettext_noop ("# peers blacklisted"), | 228 | gettext_noop ("# peers blacklisted"), |
@@ -258,17 +256,13 @@ whitelist_peers () | |||
258 | * @return #GNUNET_YES (always: continue to iterate) | 256 | * @return #GNUNET_YES (always: continue to iterate) |
259 | */ | 257 | */ |
260 | static int | 258 | static int |
261 | free_peer (void *cls, | 259 | free_peer (void *cls, const struct GNUNET_PeerIdentity *pid, void *value) |
262 | const struct GNUNET_PeerIdentity * pid, | ||
263 | void *value) | ||
264 | { | 260 | { |
265 | struct Peer *pos = value; | 261 | struct Peer *pos = value; |
266 | 262 | ||
267 | GNUNET_break (NULL == pos->mq); | 263 | GNUNET_break (NULL == pos->mq); |
268 | GNUNET_break (GNUNET_OK == | 264 | GNUNET_break (GNUNET_OK == |
269 | GNUNET_CONTAINER_multipeermap_remove (peers, | 265 | GNUNET_CONTAINER_multipeermap_remove (peers, pid, pos)); |
270 | pid, | ||
271 | pos)); | ||
272 | if (NULL != pos->hello_delay_task) | 266 | if (NULL != pos->hello_delay_task) |
273 | { | 267 | { |
274 | GNUNET_SCHEDULER_cancel (pos->hello_delay_task); | 268 | GNUNET_SCHEDULER_cancel (pos->hello_delay_task); |
@@ -305,16 +299,13 @@ attempt_connect (struct Peer *pos) | |||
305 | { | 299 | { |
306 | uint32_t strength; | 300 | uint32_t strength; |
307 | 301 | ||
308 | if (0 == | 302 | if (0 == GNUNET_memcmp (&my_identity, &pos->pid)) |
309 | GNUNET_memcmp (&my_identity, | ||
310 | &pos->pid)) | ||
311 | return; /* This is myself, nothing to do. */ | 303 | return; /* This is myself, nothing to do. */ |
312 | if (connection_count < target_connection_count) | 304 | if (connection_count < target_connection_count) |
313 | strength = 1; | 305 | strength = 1; |
314 | else | 306 | else |
315 | strength = 0; | 307 | strength = 0; |
316 | if ( (friend_count < minimum_friend_count) || | 308 | if ((friend_count < minimum_friend_count) || (GNUNET_YES == friends_only)) |
317 | (GNUNET_YES == friends_only) ) | ||
318 | { | 309 | { |
319 | if (pos->is_friend) | 310 | if (pos->is_friend) |
320 | strength += 10; /* urgently needed */ | 311 | strength += 10; /* urgently needed */ |
@@ -343,9 +334,7 @@ attempt_connect (struct Peer *pos) | |||
343 | gettext_noop ("# connect requests issued to ATS"), | 334 | gettext_noop ("# connect requests issued to ATS"), |
344 | 1, | 335 | 1, |
345 | GNUNET_NO); | 336 | GNUNET_NO); |
346 | pos->sh = GNUNET_ATS_connectivity_suggest (ats, | 337 | pos->sh = GNUNET_ATS_connectivity_suggest (ats, &pos->pid, strength); |
347 | &pos->pid, | ||
348 | strength); | ||
349 | } | 338 | } |
350 | } | 339 | } |
351 | 340 | ||
@@ -371,15 +360,14 @@ make_peer (const struct GNUNET_PeerIdentity *peer, | |||
371 | if (NULL != hello) | 360 | if (NULL != hello) |
372 | { | 361 | { |
373 | ret->hello = GNUNET_malloc (GNUNET_HELLO_size (hello)); | 362 | ret->hello = GNUNET_malloc (GNUNET_HELLO_size (hello)); |
374 | GNUNET_memcpy (ret->hello, | 363 | GNUNET_memcpy (ret->hello, hello, GNUNET_HELLO_size (hello)); |
375 | hello, | ||
376 | GNUNET_HELLO_size (hello)); | ||
377 | } | 364 | } |
378 | GNUNET_break (GNUNET_OK == | 365 | GNUNET_break (GNUNET_OK == |
379 | GNUNET_CONTAINER_multipeermap_put (peers, | 366 | GNUNET_CONTAINER_multipeermap_put ( |
380 | peer, | 367 | peers, |
381 | ret, | 368 | peer, |
382 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 369 | ret, |
370 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
383 | return ret; | 371 | return ret; |
384 | } | 372 | } |
385 | 373 | ||
@@ -403,12 +391,9 @@ setup_filter (struct Peer *peer) | |||
403 | * any case; hence 64, 5 as bloomfilter parameters. */ | 391 | * any case; hence 64, 5 as bloomfilter parameters. */ |
404 | peer->filter = GNUNET_CONTAINER_bloomfilter_init (NULL, 64, 5); | 392 | peer->filter = GNUNET_CONTAINER_bloomfilter_init (NULL, 64, 5); |
405 | peer->filter_expiration = | 393 | peer->filter_expiration = |
406 | GNUNET_TIME_relative_to_absolute | 394 | GNUNET_TIME_relative_to_absolute (HELLO_ADVERTISEMENT_MIN_REPEAT_FREQUENCY); |
407 | (HELLO_ADVERTISEMENT_MIN_REPEAT_FREQUENCY); | ||
408 | /* never send a peer its own HELLO */ | 395 | /* never send a peer its own HELLO */ |
409 | GNUNET_CRYPTO_hash (&peer->pid, | 396 | GNUNET_CRYPTO_hash (&peer->pid, sizeof (struct GNUNET_PeerIdentity), &hc); |
410 | sizeof (struct GNUNET_PeerIdentity), | ||
411 | &hc); | ||
412 | GNUNET_CONTAINER_bloomfilter_add (peer->filter, &hc); | 397 | GNUNET_CONTAINER_bloomfilter_add (peer->filter, &hc); |
413 | } | 398 | } |
414 | 399 | ||
@@ -473,10 +458,9 @@ find_advertisable_hello (void *cls, | |||
473 | if (hs > fah->max_size) | 458 | if (hs > fah->max_size) |
474 | return GNUNET_YES; | 459 | return GNUNET_YES; |
475 | GNUNET_CRYPTO_hash (&fah->peer->pid, | 460 | GNUNET_CRYPTO_hash (&fah->peer->pid, |
476 | sizeof (struct GNUNET_PeerIdentity), &hc); | 461 | sizeof (struct GNUNET_PeerIdentity), |
477 | if (GNUNET_NO == | 462 | &hc); |
478 | GNUNET_CONTAINER_bloomfilter_test (pos->filter, | 463 | if (GNUNET_NO == GNUNET_CONTAINER_bloomfilter_test (pos->filter, &hc)) |
479 | &hc)) | ||
480 | fah->result = pos; | 464 | fah->result = pos; |
481 | return GNUNET_YES; | 465 | return GNUNET_YES; |
482 | } | 466 | } |
@@ -505,13 +489,9 @@ schedule_next_hello (void *cls) | |||
505 | fah.result = NULL; | 489 | fah.result = NULL; |
506 | fah.max_size = GNUNET_MAX_MESSAGE_SIZE - 1; | 490 | fah.max_size = GNUNET_MAX_MESSAGE_SIZE - 1; |
507 | fah.next_adv = GNUNET_TIME_UNIT_FOREVER_REL; | 491 | fah.next_adv = GNUNET_TIME_UNIT_FOREVER_REL; |
508 | GNUNET_CONTAINER_multipeermap_iterate (peers, | 492 | GNUNET_CONTAINER_multipeermap_iterate (peers, &find_advertisable_hello, &fah); |
509 | &find_advertisable_hello, | ||
510 | &fah); | ||
511 | pl->hello_delay_task = | 493 | pl->hello_delay_task = |
512 | GNUNET_SCHEDULER_add_delayed (fah.next_adv, | 494 | GNUNET_SCHEDULER_add_delayed (fah.next_adv, &schedule_next_hello, pl); |
513 | &schedule_next_hello, | ||
514 | pl); | ||
515 | if (NULL == fah.result) | 495 | if (NULL == fah.result) |
516 | return; | 496 | return; |
517 | delay = GNUNET_TIME_absolute_get_remaining (pl->next_hello_allowed); | 497 | delay = GNUNET_TIME_absolute_get_remaining (pl->next_hello_allowed); |
@@ -520,31 +500,25 @@ schedule_next_hello (void *cls) | |||
520 | 500 | ||
521 | want = GNUNET_HELLO_size (fah.result->hello); | 501 | want = GNUNET_HELLO_size (fah.result->hello); |
522 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 502 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
523 | "Sending HELLO with %u bytes", | 503 | "Sending HELLO with %u bytes", |
524 | (unsigned int) want); | 504 | (unsigned int) want); |
525 | env = GNUNET_MQ_msg_copy (&fah.result->hello->header); | 505 | env = GNUNET_MQ_msg_copy (&fah.result->hello->header); |
526 | GNUNET_MQ_send (pl->mq, | 506 | GNUNET_MQ_send (pl->mq, env); |
527 | env); | ||
528 | 507 | ||
529 | /* avoid sending this one again soon */ | 508 | /* avoid sending this one again soon */ |
530 | GNUNET_CRYPTO_hash (&pl->pid, | 509 | GNUNET_CRYPTO_hash (&pl->pid, sizeof (struct GNUNET_PeerIdentity), &hc); |
531 | sizeof (struct GNUNET_PeerIdentity), | 510 | GNUNET_CONTAINER_bloomfilter_add (fah.result->filter, &hc); |
532 | &hc); | ||
533 | GNUNET_CONTAINER_bloomfilter_add (fah.result->filter, | ||
534 | &hc); | ||
535 | 511 | ||
536 | GNUNET_STATISTICS_update (stats, | 512 | GNUNET_STATISTICS_update (stats, |
537 | gettext_noop ("# HELLO messages gossipped"), | 513 | gettext_noop ("# HELLO messages gossipped"), |
538 | 1, | 514 | 1, |
539 | GNUNET_NO); | 515 | GNUNET_NO); |
540 | /* prepare to send the next one */ | 516 | /* prepare to send the next one */ |
541 | pl->next_hello_allowed | 517 | pl->next_hello_allowed = |
542 | = GNUNET_TIME_relative_to_absolute (HELLO_ADVERTISEMENT_MIN_FREQUENCY); | 518 | GNUNET_TIME_relative_to_absolute (HELLO_ADVERTISEMENT_MIN_FREQUENCY); |
543 | if (NULL != pl->hello_delay_task) | 519 | if (NULL != pl->hello_delay_task) |
544 | GNUNET_SCHEDULER_cancel (pl->hello_delay_task); | 520 | GNUNET_SCHEDULER_cancel (pl->hello_delay_task); |
545 | pl->hello_delay_task | 521 | pl->hello_delay_task = GNUNET_SCHEDULER_add_now (&schedule_next_hello, pl); |
546 | = GNUNET_SCHEDULER_add_now (&schedule_next_hello, | ||
547 | pl); | ||
548 | } | 522 | } |
549 | 523 | ||
550 | 524 | ||
@@ -576,7 +550,7 @@ reschedule_hellos (void *cls, | |||
576 | peer->hello_delay_task = NULL; | 550 | peer->hello_delay_task = NULL; |
577 | } | 551 | } |
578 | peer->hello_delay_task = | 552 | peer->hello_delay_task = |
579 | GNUNET_SCHEDULER_add_now (&schedule_next_hello, peer); | 553 | GNUNET_SCHEDULER_add_now (&schedule_next_hello, peer); |
580 | return GNUNET_YES; | 554 | return GNUNET_YES; |
581 | } | 555 | } |
582 | 556 | ||
@@ -592,36 +566,25 @@ reschedule_hellos (void *cls, | |||
592 | static void * | 566 | static void * |
593 | connect_notify (void *cls, | 567 | connect_notify (void *cls, |
594 | const struct GNUNET_PeerIdentity *peer, | 568 | const struct GNUNET_PeerIdentity *peer, |
595 | struct GNUNET_MQ_Handle *mq) | 569 | struct GNUNET_MQ_Handle *mq) |
596 | { | 570 | { |
597 | struct Peer *pos; | 571 | struct Peer *pos; |
598 | uint64_t flags; | ||
599 | const void *extra; | ||
600 | 572 | ||
601 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 573 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
602 | "Core told us that we are connecting to `%s'\n", | 574 | "Core told us that we are connecting to `%s'\n", |
603 | GNUNET_i2s (peer)); | 575 | GNUNET_i2s (peer)); |
604 | if (0 == GNUNET_memcmp (&my_identity, | 576 | if (0 == GNUNET_memcmp (&my_identity, peer)) |
605 | peer)) | ||
606 | return NULL; | 577 | return NULL; |
607 | extra = GNUNET_CORE_get_mq_options (GNUNET_YES, | 578 | GNUNET_MQ_set_options (mq, GNUNET_MQ_PRIO_BEST_EFFORT); |
608 | GNUNET_CORE_PRIO_BEST_EFFORT, | ||
609 | &flags); | ||
610 | GNUNET_MQ_set_options (mq, | ||
611 | flags, | ||
612 | extra); | ||
613 | connection_count++; | 579 | connection_count++; |
614 | GNUNET_STATISTICS_set (stats, | 580 | GNUNET_STATISTICS_set (stats, |
615 | gettext_noop ("# peers connected"), | 581 | gettext_noop ("# peers connected"), |
616 | connection_count, | 582 | connection_count, |
617 | GNUNET_NO); | 583 | GNUNET_NO); |
618 | pos = GNUNET_CONTAINER_multipeermap_get (peers, | 584 | pos = GNUNET_CONTAINER_multipeermap_get (peers, peer); |
619 | peer); | ||
620 | if (NULL == pos) | 585 | if (NULL == pos) |
621 | { | 586 | { |
622 | pos = make_peer (peer, | 587 | pos = make_peer (peer, NULL, GNUNET_NO); |
623 | NULL, | ||
624 | GNUNET_NO); | ||
625 | } | 588 | } |
626 | else | 589 | else |
627 | { | 590 | { |
@@ -631,17 +594,14 @@ connect_notify (void *cls, | |||
631 | if (pos->is_friend) | 594 | if (pos->is_friend) |
632 | { | 595 | { |
633 | friend_count++; | 596 | friend_count++; |
634 | if ( (friend_count == minimum_friend_count) && | 597 | if ((friend_count == minimum_friend_count) && (GNUNET_YES != friends_only)) |
635 | (GNUNET_YES != friends_only) ) | ||
636 | whitelist_peers (); | 598 | whitelist_peers (); |
637 | GNUNET_STATISTICS_set (stats, | 599 | GNUNET_STATISTICS_set (stats, |
638 | gettext_noop ("# friends connected"), | 600 | gettext_noop ("# friends connected"), |
639 | friend_count, | 601 | friend_count, |
640 | GNUNET_NO); | 602 | GNUNET_NO); |
641 | } | 603 | } |
642 | reschedule_hellos (NULL, | 604 | reschedule_hellos (NULL, peer, pos); |
643 | peer, | ||
644 | pos); | ||
645 | return pos; | 605 | return pos; |
646 | } | 606 | } |
647 | 607 | ||
@@ -655,9 +615,7 @@ connect_notify (void *cls, | |||
655 | * @return #GNUNET_YES (continue to iterate) | 615 | * @return #GNUNET_YES (continue to iterate) |
656 | */ | 616 | */ |
657 | static int | 617 | static int |
658 | try_add_peers (void *cls, | 618 | try_add_peers (void *cls, const struct GNUNET_PeerIdentity *pid, void *value) |
659 | const struct GNUNET_PeerIdentity *pid, | ||
660 | void *value) | ||
661 | { | 619 | { |
662 | struct Peer *pos = value; | 620 | struct Peer *pos = value; |
663 | 621 | ||
@@ -676,9 +634,7 @@ add_peer_task (void *cls) | |||
676 | { | 634 | { |
677 | add_task = NULL; | 635 | add_task = NULL; |
678 | 636 | ||
679 | GNUNET_CONTAINER_multipeermap_iterate (peers, | 637 | GNUNET_CONTAINER_multipeermap_iterate (peers, &try_add_peers, NULL); |
680 | &try_add_peers, | ||
681 | NULL); | ||
682 | } | 638 | } |
683 | 639 | ||
684 | 640 | ||
@@ -692,7 +648,7 @@ add_peer_task (void *cls) | |||
692 | static void | 648 | static void |
693 | disconnect_notify (void *cls, | 649 | disconnect_notify (void *cls, |
694 | const struct GNUNET_PeerIdentity *peer, | 650 | const struct GNUNET_PeerIdentity *peer, |
695 | void *internal_cls) | 651 | void *internal_cls) |
696 | { | 652 | { |
697 | struct Peer *pos = internal_cls; | 653 | struct Peer *pos = internal_cls; |
698 | 654 | ||
@@ -725,16 +681,12 @@ disconnect_notify (void *cls, | |||
725 | friend_count, | 681 | friend_count, |
726 | GNUNET_NO); | 682 | GNUNET_NO); |
727 | } | 683 | } |
728 | if ( ( (connection_count < target_connection_count) || | 684 | if (((connection_count < target_connection_count) || |
729 | (friend_count < minimum_friend_count)) && | 685 | (friend_count < minimum_friend_count)) && |
730 | (NULL == add_task) ) | 686 | (NULL == add_task)) |
731 | add_task = GNUNET_SCHEDULER_add_now (&add_peer_task, | 687 | add_task = GNUNET_SCHEDULER_add_now (&add_peer_task, NULL); |
732 | NULL); | 688 | if ((friend_count < minimum_friend_count) && (NULL == blacklist)) |
733 | if ( (friend_count < minimum_friend_count) && | 689 | blacklist = GNUNET_TRANSPORT_blacklist (cfg, &blacklist_check, NULL); |
734 | (NULL == blacklist)) | ||
735 | blacklist = GNUNET_TRANSPORT_blacklist (cfg, | ||
736 | &blacklist_check, | ||
737 | NULL); | ||
738 | } | 690 | } |
739 | 691 | ||
740 | 692 | ||
@@ -779,38 +731,32 @@ consider_for_advertising (const struct GNUNET_HELLO_Message *hello) | |||
779 | GNUNET_break (0); | 731 | GNUNET_break (0); |
780 | return; | 732 | return; |
781 | } | 733 | } |
782 | if (0 == GNUNET_memcmp (&pid, | 734 | if (0 == GNUNET_memcmp (&pid, &my_identity)) |
783 | &my_identity)) | 735 | return; /* that's me! */ |
784 | return; /* that's me! */ | ||
785 | have_address = GNUNET_NO; | 736 | have_address = GNUNET_NO; |
786 | GNUNET_HELLO_iterate_addresses (hello, | 737 | GNUNET_HELLO_iterate_addresses (hello, |
787 | GNUNET_NO, | 738 | GNUNET_NO, |
788 | &address_iterator, | 739 | &address_iterator, |
789 | &have_address); | 740 | &have_address); |
790 | if (GNUNET_NO == have_address) | 741 | if (GNUNET_NO == have_address) |
791 | return; /* no point in advertising this one... */ | 742 | return; /* no point in advertising this one... */ |
792 | peer = GNUNET_CONTAINER_multipeermap_get (peers, &pid); | 743 | peer = GNUNET_CONTAINER_multipeermap_get (peers, &pid); |
793 | if (NULL == peer) | 744 | if (NULL == peer) |
794 | { | 745 | { |
795 | peer = make_peer (&pid, | 746 | peer = make_peer (&pid, hello, GNUNET_NO); |
796 | hello, | ||
797 | GNUNET_NO); | ||
798 | } | 747 | } |
799 | else if (NULL != peer->hello) | 748 | else if (NULL != peer->hello) |
800 | { | 749 | { |
801 | dt = GNUNET_HELLO_equals (peer->hello, | 750 | dt = GNUNET_HELLO_equals (peer->hello, hello, GNUNET_TIME_absolute_get ()); |
802 | hello, | ||
803 | GNUNET_TIME_absolute_get ()); | ||
804 | if (dt.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us) | 751 | if (dt.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us) |
805 | return; /* nothing new here */ | 752 | return; /* nothing new here */ |
806 | } | 753 | } |
807 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 754 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
808 | "Found HELLO from peer `%s' for advertising\n", | 755 | "Found HELLO from peer `%s' for advertising\n", |
809 | GNUNET_i2s (&pid)); | 756 | GNUNET_i2s (&pid)); |
810 | if (NULL != peer->hello) | 757 | if (NULL != peer->hello) |
811 | { | 758 | { |
812 | nh = GNUNET_HELLO_merge (peer->hello, | 759 | nh = GNUNET_HELLO_merge (peer->hello, hello); |
813 | hello); | ||
814 | GNUNET_free (peer->hello); | 760 | GNUNET_free (peer->hello); |
815 | peer->hello = nh; | 761 | peer->hello = nh; |
816 | } | 762 | } |
@@ -818,9 +764,7 @@ consider_for_advertising (const struct GNUNET_HELLO_Message *hello) | |||
818 | { | 764 | { |
819 | size = GNUNET_HELLO_size (hello); | 765 | size = GNUNET_HELLO_size (hello); |
820 | peer->hello = GNUNET_malloc (size); | 766 | peer->hello = GNUNET_malloc (size); |
821 | GNUNET_memcpy (peer->hello, | 767 | GNUNET_memcpy (peer->hello, hello, size); |
822 | hello, | ||
823 | size); | ||
824 | } | 768 | } |
825 | if (NULL != peer->filter) | 769 | if (NULL != peer->filter) |
826 | { | 770 | { |
@@ -830,9 +774,7 @@ consider_for_advertising (const struct GNUNET_HELLO_Message *hello) | |||
830 | setup_filter (peer); | 774 | setup_filter (peer); |
831 | /* since we have a new HELLO to pick from, re-schedule all | 775 | /* since we have a new HELLO to pick from, re-schedule all |
832 | * HELLO requests that are not bound by the HELLO send rate! */ | 776 | * HELLO requests that are not bound by the HELLO send rate! */ |
833 | GNUNET_CONTAINER_multipeermap_iterate (peers, | 777 | GNUNET_CONTAINER_multipeermap_iterate (peers, &reschedule_hellos, peer); |
834 | &reschedule_hellos, | ||
835 | peer); | ||
836 | } | 778 | } |
837 | 779 | ||
838 | 780 | ||
@@ -856,24 +798,20 @@ process_peer (void *cls, | |||
856 | if (NULL != err_msg) | 798 | if (NULL != err_msg) |
857 | { | 799 | { |
858 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 800 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
859 | _("Error in communication with PEERINFO service: %s\n"), | 801 | _ ("Error in communication with PEERINFO service: %s\n"), |
860 | err_msg); | 802 | err_msg); |
861 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify); | 803 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify); |
862 | peerinfo_notify = GNUNET_PEERINFO_notify (cfg, | 804 | peerinfo_notify = |
863 | GNUNET_NO, | 805 | GNUNET_PEERINFO_notify (cfg, GNUNET_NO, &process_peer, NULL); |
864 | &process_peer, | ||
865 | NULL); | ||
866 | return; | 806 | return; |
867 | } | 807 | } |
868 | GNUNET_assert (NULL != peer); | 808 | GNUNET_assert (NULL != peer); |
869 | if (0 == GNUNET_memcmp (&my_identity, | 809 | if (0 == GNUNET_memcmp (&my_identity, peer)) |
870 | peer)) | 810 | return; /* that's me! */ |
871 | return; /* that's me! */ | ||
872 | if (NULL == hello) | 811 | if (NULL == hello) |
873 | { | 812 | { |
874 | /* free existing HELLO, if any */ | 813 | /* free existing HELLO, if any */ |
875 | pos = GNUNET_CONTAINER_multipeermap_get (peers, | 814 | pos = GNUNET_CONTAINER_multipeermap_get (peers, peer); |
876 | peer); | ||
877 | if (NULL != pos) | 815 | if (NULL != pos) |
878 | { | 816 | { |
879 | GNUNET_free_non_null (pos->hello); | 817 | GNUNET_free_non_null (pos->hello); |
@@ -883,21 +821,15 @@ process_peer (void *cls, | |||
883 | GNUNET_CONTAINER_bloomfilter_free (pos->filter); | 821 | GNUNET_CONTAINER_bloomfilter_free (pos->filter); |
884 | pos->filter = NULL; | 822 | pos->filter = NULL; |
885 | } | 823 | } |
886 | if ( (NULL == pos->mq) && | 824 | if ((NULL == pos->mq) && (GNUNET_NO == pos->is_friend)) |
887 | (GNUNET_NO == pos->is_friend) ) | 825 | free_peer (NULL, &pos->pid, pos); |
888 | free_peer (NULL, | ||
889 | &pos->pid, | ||
890 | pos); | ||
891 | } | 826 | } |
892 | return; | 827 | return; |
893 | } | 828 | } |
894 | consider_for_advertising (hello); | 829 | consider_for_advertising (hello); |
895 | pos = GNUNET_CONTAINER_multipeermap_get (peers, | 830 | pos = GNUNET_CONTAINER_multipeermap_get (peers, peer); |
896 | peer); | ||
897 | if (NULL == pos) | 831 | if (NULL == pos) |
898 | pos = make_peer (peer, | 832 | pos = make_peer (peer, hello, GNUNET_NO); |
899 | hello, | ||
900 | GNUNET_NO); | ||
901 | attempt_connect (pos); | 833 | attempt_connect (pos); |
902 | } | 834 | } |
903 | 835 | ||
@@ -910,24 +842,20 @@ process_peer (void *cls, | |||
910 | * @param my_id ID of this peer, NULL if we failed | 842 | * @param my_id ID of this peer, NULL if we failed |
911 | */ | 843 | */ |
912 | static void | 844 | static void |
913 | core_init (void *cls, | 845 | core_init (void *cls, const struct GNUNET_PeerIdentity *my_id) |
914 | const struct GNUNET_PeerIdentity *my_id) | ||
915 | { | 846 | { |
916 | if (NULL == my_id) | 847 | if (NULL == my_id) |
917 | { | 848 | { |
918 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 849 | GNUNET_log ( |
919 | _("Failed to connect to core service, can not manage topology!\n")); | 850 | GNUNET_ERROR_TYPE_ERROR, |
851 | _ ("Failed to connect to core service, can not manage topology!\n")); | ||
920 | GNUNET_SCHEDULER_shutdown (); | 852 | GNUNET_SCHEDULER_shutdown (); |
921 | return; | 853 | return; |
922 | } | 854 | } |
923 | my_identity = *my_id; | 855 | my_identity = *my_id; |
924 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 856 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "I am peer `%s'\n", GNUNET_i2s (my_id)); |
925 | "I am peer `%s'\n", | 857 | peerinfo_notify = |
926 | GNUNET_i2s (my_id)); | 858 | GNUNET_PEERINFO_notify (cfg, GNUNET_NO, &process_peer, NULL); |
927 | peerinfo_notify = GNUNET_PEERINFO_notify (cfg, | ||
928 | GNUNET_NO, | ||
929 | &process_peer, | ||
930 | NULL); | ||
931 | } | 859 | } |
932 | 860 | ||
933 | 861 | ||
@@ -938,24 +866,22 @@ core_init (void *cls, | |||
938 | * @param pid identity of the friend | 866 | * @param pid identity of the friend |
939 | */ | 867 | */ |
940 | static void | 868 | static void |
941 | handle_friend (void *cls, | 869 | handle_friend (void *cls, const struct GNUNET_PeerIdentity *pid) |
942 | const struct GNUNET_PeerIdentity *pid) | ||
943 | { | 870 | { |
944 | unsigned int *entries_found = cls; | 871 | unsigned int *entries_found = cls; |
945 | struct Peer *fl; | 872 | struct Peer *fl; |
946 | 873 | ||
947 | if (0 == GNUNET_memcmp (pid, | 874 | if (0 == GNUNET_memcmp (pid, &my_identity)) |
948 | &my_identity)) | ||
949 | { | 875 | { |
950 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 876 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
951 | _("Found myself `%s' in friend list (useless, ignored)\n"), | 877 | _ ("Found myself `%s' in friend list (useless, ignored)\n"), |
952 | GNUNET_i2s (pid)); | 878 | GNUNET_i2s (pid)); |
953 | return; | 879 | return; |
954 | } | 880 | } |
955 | (*entries_found)++; | 881 | (*entries_found)++; |
956 | fl = make_peer (pid, NULL, GNUNET_YES); | 882 | fl = make_peer (pid, NULL, GNUNET_YES); |
957 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 883 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
958 | _("Found friend `%s' in configuration\n"), | 884 | _ ("Found friend `%s' in configuration\n"), |
959 | GNUNET_i2s (&fl->pid)); | 885 | GNUNET_i2s (&fl->pid)); |
960 | } | 886 | } |
961 | 887 | ||
@@ -969,31 +895,30 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
969 | unsigned int entries_found; | 895 | unsigned int entries_found; |
970 | 896 | ||
971 | entries_found = 0; | 897 | entries_found = 0; |
972 | if (GNUNET_OK != | 898 | if (GNUNET_OK != GNUNET_FRIENDS_parse (cfg, &handle_friend, &entries_found)) |
973 | GNUNET_FRIENDS_parse (cfg, | ||
974 | &handle_friend, | ||
975 | &entries_found)) | ||
976 | { | 899 | { |
977 | if ( (GNUNET_YES == friends_only) || | 900 | if ((GNUNET_YES == friends_only) || (minimum_friend_count > 0)) |
978 | (minimum_friend_count > 0)) | ||
979 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 901 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
980 | _("Encountered errors parsing friends list!\n")); | 902 | _ ("Encountered errors parsing friends list!\n")); |
981 | } | 903 | } |
982 | GNUNET_STATISTICS_update (stats, | 904 | GNUNET_STATISTICS_update (stats, |
983 | gettext_noop ("# friends in configuration"), | 905 | gettext_noop ("# friends in configuration"), |
984 | entries_found, | 906 | entries_found, |
985 | GNUNET_NO); | 907 | GNUNET_NO); |
986 | if ( (minimum_friend_count > entries_found) && | 908 | if ((minimum_friend_count > entries_found) && (GNUNET_NO == friends_only)) |
987 | (GNUNET_NO == friends_only) ) | ||
988 | { | 909 | { |
989 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 910 | GNUNET_log ( |
990 | _("Fewer friends specified than required by minimum friend count. Will only connect to friends.\n")); | 911 | GNUNET_ERROR_TYPE_WARNING, |
912 | _ ( | ||
913 | "Fewer friends specified than required by minimum friend count. Will only connect to friends.\n")); | ||
991 | } | 914 | } |
992 | if ( (minimum_friend_count > target_connection_count) && | 915 | if ((minimum_friend_count > target_connection_count) && |
993 | (GNUNET_NO == friends_only)) | 916 | (GNUNET_NO == friends_only)) |
994 | { | 917 | { |
995 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 918 | GNUNET_log ( |
996 | _("More friendly connections required than target total number of connections.\n")); | 919 | GNUNET_ERROR_TYPE_WARNING, |
920 | _ ( | ||
921 | "More friendly connections required than target total number of connections.\n")); | ||
997 | } | 922 | } |
998 | } | 923 | } |
999 | 924 | ||
@@ -1008,14 +933,11 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1008 | * #GNUNET_SYSERR if @a message is invalid | 933 | * #GNUNET_SYSERR if @a message is invalid |
1009 | */ | 934 | */ |
1010 | static int | 935 | static int |
1011 | check_hello (void *cls, | 936 | check_hello (void *cls, const struct GNUNET_HELLO_Message *message) |
1012 | const struct GNUNET_HELLO_Message *message) | ||
1013 | { | 937 | { |
1014 | struct GNUNET_PeerIdentity pid; | 938 | struct GNUNET_PeerIdentity pid; |
1015 | 939 | ||
1016 | if (GNUNET_OK != | 940 | if (GNUNET_OK != GNUNET_HELLO_get_id (message, &pid)) |
1017 | GNUNET_HELLO_get_id (message, | ||
1018 | &pid)) | ||
1019 | { | 941 | { |
1020 | GNUNET_break_op (0); | 942 | GNUNET_break_op (0); |
1021 | return GNUNET_SYSERR; | 943 | return GNUNET_SYSERR; |
@@ -1032,8 +954,7 @@ check_hello (void *cls, | |||
1032 | * @param message the actual HELLO message | 954 | * @param message the actual HELLO message |
1033 | */ | 955 | */ |
1034 | static void | 956 | static void |
1035 | handle_hello (void *cls, | 957 | handle_hello (void *cls, const struct GNUNET_HELLO_Message *message) |
1036 | const struct GNUNET_HELLO_Message *message) | ||
1037 | { | 958 | { |
1038 | const struct GNUNET_PeerIdentity *other = cls; | 959 | const struct GNUNET_PeerIdentity *other = cls; |
1039 | struct Peer *peer; | 960 | struct Peer *peer; |
@@ -1042,34 +963,26 @@ handle_hello (void *cls, | |||
1042 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 963 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1043 | "Received encrypted HELLO from peer `%s'", | 964 | "Received encrypted HELLO from peer `%s'", |
1044 | GNUNET_i2s (other)); | 965 | GNUNET_i2s (other)); |
1045 | GNUNET_assert (GNUNET_OK == | 966 | GNUNET_assert (GNUNET_OK == GNUNET_HELLO_get_id (message, &pid)); |
1046 | GNUNET_HELLO_get_id (message, | ||
1047 | &pid)); | ||
1048 | GNUNET_STATISTICS_update (stats, | 967 | GNUNET_STATISTICS_update (stats, |
1049 | gettext_noop ("# HELLO messages received"), | 968 | gettext_noop ("# HELLO messages received"), |
1050 | 1, | 969 | 1, |
1051 | GNUNET_NO); | 970 | GNUNET_NO); |
1052 | peer = GNUNET_CONTAINER_multipeermap_get (peers, | 971 | peer = GNUNET_CONTAINER_multipeermap_get (peers, &pid); |
1053 | &pid); | ||
1054 | if (NULL == peer) | 972 | if (NULL == peer) |
1055 | { | 973 | { |
1056 | if ( (GNUNET_YES == friends_only) || | 974 | if ((GNUNET_YES == friends_only) || (friend_count < minimum_friend_count)) |
1057 | (friend_count < minimum_friend_count) ) | ||
1058 | return; | 975 | return; |
1059 | } | 976 | } |
1060 | else | 977 | else |
1061 | { | 978 | { |
1062 | if ( (GNUNET_YES != peer->is_friend) && | 979 | if ((GNUNET_YES != peer->is_friend) && (GNUNET_YES == friends_only)) |
1063 | (GNUNET_YES == friends_only) ) | ||
1064 | return; | 980 | return; |
1065 | if ((GNUNET_YES != peer->is_friend) && | 981 | if ((GNUNET_YES != peer->is_friend) && |
1066 | (friend_count < minimum_friend_count)) | 982 | (friend_count < minimum_friend_count)) |
1067 | return; | 983 | return; |
1068 | } | 984 | } |
1069 | (void) GNUNET_PEERINFO_add_peer (pi, | 985 | (void) GNUNET_PEERINFO_add_peer (pi, message, NULL, NULL); |
1070 | message, | ||
1071 | NULL, | ||
1072 | NULL); | ||
1073 | } | 986 | } |
1074 | 987 | ||
1075 | 988 | ||
@@ -1103,9 +1016,7 @@ cleaning_task (void *cls) | |||
1103 | GNUNET_TRANSPORT_offer_hello_cancel (oh); | 1016 | GNUNET_TRANSPORT_offer_hello_cancel (oh); |
1104 | oh = NULL; | 1017 | oh = NULL; |
1105 | } | 1018 | } |
1106 | GNUNET_CONTAINER_multipeermap_iterate (peers, | 1019 | GNUNET_CONTAINER_multipeermap_iterate (peers, &free_peer, NULL); |
1107 | &free_peer, | ||
1108 | NULL); | ||
1109 | GNUNET_CONTAINER_multipeermap_destroy (peers); | 1020 | GNUNET_CONTAINER_multipeermap_destroy (peers); |
1110 | peers = NULL; | 1021 | peers = NULL; |
1111 | if (NULL != ats) | 1022 | if (NULL != ats) |
@@ -1140,26 +1051,22 @@ run (void *cls, | |||
1140 | const char *cfgfile, | 1051 | const char *cfgfile, |
1141 | const struct GNUNET_CONFIGURATION_Handle *c) | 1052 | const struct GNUNET_CONFIGURATION_Handle *c) |
1142 | { | 1053 | { |
1143 | struct GNUNET_MQ_MessageHandler handlers[] = { | 1054 | struct GNUNET_MQ_MessageHandler handlers[] = |
1144 | GNUNET_MQ_hd_var_size (hello, | 1055 | {GNUNET_MQ_hd_var_size (hello, |
1145 | GNUNET_MESSAGE_TYPE_HELLO, | 1056 | GNUNET_MESSAGE_TYPE_HELLO, |
1146 | struct GNUNET_HELLO_Message, | 1057 | struct GNUNET_HELLO_Message, |
1147 | NULL), | 1058 | NULL), |
1148 | GNUNET_MQ_handler_end () | 1059 | GNUNET_MQ_handler_end ()}; |
1149 | }; | ||
1150 | unsigned long long opt; | 1060 | unsigned long long opt; |
1151 | 1061 | ||
1152 | cfg = c; | 1062 | cfg = c; |
1153 | stats = GNUNET_STATISTICS_create ("topology", cfg); | 1063 | stats = GNUNET_STATISTICS_create ("topology", cfg); |
1154 | friends_only = | 1064 | friends_only = |
1155 | GNUNET_CONFIGURATION_get_value_yesno (cfg, | 1065 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "TOPOLOGY", "FRIENDS-ONLY"); |
1156 | "TOPOLOGY", | 1066 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, |
1157 | "FRIENDS-ONLY"); | 1067 | "TOPOLOGY", |
1158 | if (GNUNET_OK != | 1068 | "MINIMUM-FRIENDS", |
1159 | GNUNET_CONFIGURATION_get_value_number (cfg, | 1069 | &opt)) |
1160 | "TOPOLOGY", | ||
1161 | "MINIMUM-FRIENDS", | ||
1162 | &opt)) | ||
1163 | opt = 0; | 1070 | opt = 0; |
1164 | minimum_friend_count = (unsigned int) opt; | 1071 | minimum_friend_count = (unsigned int) opt; |
1165 | if (GNUNET_OK != | 1072 | if (GNUNET_OK != |
@@ -1176,25 +1083,21 @@ run (void *cls, | |||
1176 | "Topology would like %u connections with at least %u friends\n", | 1083 | "Topology would like %u connections with at least %u friends\n", |
1177 | target_connection_count, | 1084 | target_connection_count, |
1178 | minimum_friend_count); | 1085 | minimum_friend_count); |
1179 | if ( (GNUNET_YES == friends_only) || | 1086 | if ((GNUNET_YES == friends_only) || (minimum_friend_count > 0)) |
1180 | (minimum_friend_count > 0)) | 1087 | blacklist = GNUNET_TRANSPORT_blacklist (cfg, &blacklist_check, NULL); |
1181 | blacklist = GNUNET_TRANSPORT_blacklist (cfg, | ||
1182 | &blacklist_check, | ||
1183 | NULL); | ||
1184 | ats = GNUNET_ATS_connectivity_init (cfg); | 1088 | ats = GNUNET_ATS_connectivity_init (cfg); |
1185 | pi = GNUNET_PEERINFO_connect (cfg); | 1089 | pi = GNUNET_PEERINFO_connect (cfg); |
1186 | handle = GNUNET_CORE_connect (cfg, | 1090 | handle = GNUNET_CORE_connect (cfg, |
1187 | NULL, | 1091 | NULL, |
1188 | &core_init, | 1092 | &core_init, |
1189 | &connect_notify, | 1093 | &connect_notify, |
1190 | &disconnect_notify, | 1094 | &disconnect_notify, |
1191 | handlers); | 1095 | handlers); |
1192 | GNUNET_SCHEDULER_add_shutdown (&cleaning_task, | 1096 | GNUNET_SCHEDULER_add_shutdown (&cleaning_task, NULL); |
1193 | NULL); | ||
1194 | if (NULL == handle) | 1097 | if (NULL == handle) |
1195 | { | 1098 | { |
1196 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1099 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1197 | _("Failed to connect to `%s' service.\n"), | 1100 | _ ("Failed to connect to `%s' service.\n"), |
1198 | "core"); | 1101 | "core"); |
1199 | GNUNET_SCHEDULER_shutdown (); | 1102 | GNUNET_SCHEDULER_shutdown (); |
1200 | return; | 1103 | return; |
@@ -1210,24 +1113,25 @@ run (void *cls, | |||
1210 | * @return 0 ok, 1 on error | 1113 | * @return 0 ok, 1 on error |
1211 | */ | 1114 | */ |
1212 | int | 1115 | int |
1213 | main (int argc, | 1116 | main (int argc, char *const *argv) |
1214 | char *const *argv) | ||
1215 | { | 1117 | { |
1216 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 1118 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { |
1217 | GNUNET_GETOPT_OPTION_END | 1119 | GNUNET_GETOPT_OPTION_END}; |
1218 | }; | ||
1219 | int ret; | 1120 | int ret; |
1220 | 1121 | ||
1221 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 1122 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
1222 | return 2; | 1123 | return 2; |
1223 | 1124 | ||
1224 | ret = | 1125 | ret = (GNUNET_OK == GNUNET_PROGRAM_run (argc, |
1225 | (GNUNET_OK == | 1126 | argv, |
1226 | GNUNET_PROGRAM_run (argc, argv, | 1127 | "gnunet-daemon-topology", |
1227 | "gnunet-daemon-topology", | 1128 | _ ("GNUnet topology control"), |
1228 | _("GNUnet topology control"), | 1129 | options, |
1229 | options, &run, NULL)) ? 0 : 1; | 1130 | &run, |
1230 | GNUNET_free ((void*) argv); | 1131 | NULL)) |
1132 | ? 0 | ||
1133 | : 1; | ||
1134 | GNUNET_free ((void *) argv); | ||
1231 | return ret; | 1135 | return ret; |
1232 | } | 1136 | } |
1233 | 1137 | ||
@@ -1238,8 +1142,7 @@ main (int argc, | |||
1238 | /** | 1142 | /** |
1239 | * MINIMIZE heap size (way below 128k) since this process doesn't need much. | 1143 | * MINIMIZE heap size (way below 128k) since this process doesn't need much. |
1240 | */ | 1144 | */ |
1241 | void __attribute__ ((constructor)) | 1145 | void __attribute__ ((constructor)) GNUNET_ARM_memory_init () |
1242 | GNUNET_ARM_memory_init () | ||
1243 | { | 1146 | { |
1244 | mallopt (M_TRIM_THRESHOLD, 4 * 1024); | 1147 | mallopt (M_TRIM_THRESHOLD, 4 * 1024); |
1245 | mallopt (M_TOP_PAD, 1 * 1024); | 1148 | mallopt (M_TOP_PAD, 1 * 1024); |