diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
commit | 5746309cb4be2073d550ad7a6885e918631dbc38 (patch) | |
tree | 89455bc4aadf977816b38df13f990372cd81d71a /src/fs/gnunet-service-fs_cp.c | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/fs/gnunet-service-fs_cp.c')
-rw-r--r-- | src/fs/gnunet-service-fs_cp.c | 220 |
1 files changed, 98 insertions, 122 deletions
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index 4e57455b2..1e93a475e 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c | |||
@@ -400,13 +400,12 @@ static size_t peer_transmit_ready_cb (void *cls, size_t size, void *buf); | |||
400 | * long should the client wait until re-trying? | 400 | * long should the client wait until re-trying? |
401 | * @param preference current traffic preference for the given peer | 401 | * @param preference current traffic preference for the given peer |
402 | */ | 402 | */ |
403 | static void | 403 | static void core_reserve_callback (void *cls, |
404 | core_reserve_callback (void *cls, | 404 | const struct GNUNET_PeerIdentity *peer, |
405 | const struct GNUNET_PeerIdentity *peer, | 405 | struct GNUNET_BANDWIDTH_Value32NBO |
406 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 406 | bandwidth_out, int32_t amount, |
407 | int32_t amount, | 407 | struct GNUNET_TIME_Relative res_delay, |
408 | struct GNUNET_TIME_Relative res_delay, | 408 | uint64_t preference); |
409 | uint64_t preference); | ||
410 | 409 | ||
411 | 410 | ||
412 | /** | 411 | /** |
@@ -437,23 +436,20 @@ schedule_transmission (struct GSF_PeerTransmitHandle *pth) | |||
437 | pth->was_reserved = GNUNET_YES; | 436 | pth->was_reserved = GNUNET_YES; |
438 | ip = cp->inc_preference; | 437 | ip = cp->inc_preference; |
439 | cp->inc_preference = 0; | 438 | cp->inc_preference = 0; |
440 | cp->irc = GNUNET_CORE_peer_change_preference (GSF_core, | 439 | cp->irc = |
441 | &target, | 440 | GNUNET_CORE_peer_change_preference (GSF_core, &target, |
442 | GNUNET_TIME_UNIT_FOREVER_REL, | 441 | GNUNET_TIME_UNIT_FOREVER_REL, |
443 | GNUNET_BANDWIDTH_VALUE_MAX, | 442 | GNUNET_BANDWIDTH_VALUE_MAX, |
444 | DBLOCK_SIZE, | 443 | DBLOCK_SIZE, ip, |
445 | ip, | 444 | &core_reserve_callback, cp); |
446 | &core_reserve_callback, cp); | ||
447 | } | 445 | } |
448 | GNUNET_assert (pth->cth == NULL); | 446 | GNUNET_assert (pth->cth == NULL); |
449 | pth->cth_in_progress++; | 447 | pth->cth_in_progress++; |
450 | pth->cth = GNUNET_CORE_notify_transmit_ready (GSF_core, | 448 | pth->cth = |
451 | GNUNET_YES, | 449 | GNUNET_CORE_notify_transmit_ready (GSF_core, GNUNET_YES, pth->priority, |
452 | pth->priority, | 450 | GNUNET_TIME_absolute_get_remaining |
453 | GNUNET_TIME_absolute_get_remaining | 451 | (pth->timeout), &target, pth->size, |
454 | (pth->timeout), &target, | 452 | &peer_transmit_ready_cb, pth); |
455 | pth->size, | ||
456 | &peer_transmit_ready_cb, pth); | ||
457 | GNUNET_assert (0 < pth->cth_in_progress--); | 453 | GNUNET_assert (0 < pth->cth_in_progress--); |
458 | } | 454 | } |
459 | 455 | ||
@@ -495,8 +491,9 @@ peer_transmit_ready_cb (void *cls, size_t size, void *buf) | |||
495 | GNUNET_assert (0 < cp->ppd.pending_replies--); | 491 | GNUNET_assert (0 < cp->ppd.pending_replies--); |
496 | } | 492 | } |
497 | GNUNET_LOAD_update (cp->ppd.transmission_delay, | 493 | GNUNET_LOAD_update (cp->ppd.transmission_delay, |
498 | GNUNET_TIME_absolute_get_duration | 494 | GNUNET_TIME_absolute_get_duration (pth-> |
499 | (pth->transmission_request_start_time).rel_value); | 495 | transmission_request_start_time). |
496 | rel_value); | ||
500 | ret = pth->gmc (pth->gmc_cls, size, buf); | 497 | ret = pth->gmc (pth->gmc_cls, size, buf); |
501 | GNUNET_assert (NULL == pth->cth); | 498 | GNUNET_assert (NULL == pth->cth); |
502 | for (pos = cp->pth_head; pos != NULL; pos = pos->next) | 499 | for (pos = cp->pth_head; pos != NULL; pos = pos->next) |
@@ -528,12 +525,12 @@ retry_reservation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
528 | cp->irc_delay_task = GNUNET_SCHEDULER_NO_TASK; | 525 | cp->irc_delay_task = GNUNET_SCHEDULER_NO_TASK; |
529 | ip = cp->inc_preference; | 526 | ip = cp->inc_preference; |
530 | cp->inc_preference = 0; | 527 | cp->inc_preference = 0; |
531 | cp->irc = GNUNET_CORE_peer_change_preference (GSF_core, | 528 | cp->irc = |
532 | &target, | 529 | GNUNET_CORE_peer_change_preference (GSF_core, &target, |
533 | GNUNET_TIME_UNIT_FOREVER_REL, | 530 | GNUNET_TIME_UNIT_FOREVER_REL, |
534 | GNUNET_BANDWIDTH_VALUE_MAX, | 531 | GNUNET_BANDWIDTH_VALUE_MAX, |
535 | DBLOCK_SIZE, | 532 | DBLOCK_SIZE, ip, |
536 | ip, &core_reserve_callback, cp); | 533 | &core_reserve_callback, cp); |
537 | } | 534 | } |
538 | 535 | ||
539 | 536 | ||
@@ -550,11 +547,9 @@ retry_reservation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
550 | * @param preference current traffic preference for the given peer | 547 | * @param preference current traffic preference for the given peer |
551 | */ | 548 | */ |
552 | static void | 549 | static void |
553 | core_reserve_callback (void *cls, | 550 | core_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer, |
554 | const struct GNUNET_PeerIdentity *peer, | ||
555 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 551 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
556 | int32_t amount, | 552 | int32_t amount, struct GNUNET_TIME_Relative res_delay, |
557 | struct GNUNET_TIME_Relative res_delay, | ||
558 | uint64_t preference) | 553 | uint64_t preference) |
559 | { | 554 | { |
560 | struct GSF_ConnectedPeer *cp = cls; | 555 | struct GSF_ConnectedPeer *cp = cls; |
@@ -563,8 +558,8 @@ core_reserve_callback (void *cls, | |||
563 | cp->irc = NULL; | 558 | cp->irc = NULL; |
564 | if (0 == amount) | 559 | if (0 == amount) |
565 | { | 560 | { |
566 | cp->irc_delay_task = GNUNET_SCHEDULER_add_delayed (res_delay, | 561 | cp->irc_delay_task = |
567 | &retry_reservation, cp); | 562 | GNUNET_SCHEDULER_add_delayed (res_delay, &retry_reservation, cp); |
568 | return; | 563 | return; |
569 | } | 564 | } |
570 | cp->did_reserve = GNUNET_YES; | 565 | cp->did_reserve = GNUNET_YES; |
@@ -573,13 +568,11 @@ core_reserve_callback (void *cls, | |||
573 | { | 568 | { |
574 | /* reservation success, try transmission now! */ | 569 | /* reservation success, try transmission now! */ |
575 | pth->cth_in_progress++; | 570 | pth->cth_in_progress++; |
576 | pth->cth = GNUNET_CORE_notify_transmit_ready (GSF_core, | 571 | pth->cth = |
577 | GNUNET_YES, | 572 | GNUNET_CORE_notify_transmit_ready (GSF_core, GNUNET_YES, pth->priority, |
578 | pth->priority, | 573 | GNUNET_TIME_absolute_get_remaining |
579 | GNUNET_TIME_absolute_get_remaining | 574 | (pth->timeout), peer, pth->size, |
580 | (pth->timeout), peer, | 575 | &peer_transmit_ready_cb, pth); |
581 | pth->size, | ||
582 | &peer_transmit_ready_cb, pth); | ||
583 | GNUNET_assert (0 < pth->cth_in_progress--); | 576 | GNUNET_assert (0 < pth->cth_in_progress--); |
584 | } | 577 | } |
585 | } | 578 | } |
@@ -604,12 +597,12 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, | |||
604 | cp = GNUNET_malloc (sizeof (struct GSF_ConnectedPeer)); | 597 | cp = GNUNET_malloc (sizeof (struct GSF_ConnectedPeer)); |
605 | cp->ppd.pid = GNUNET_PEER_intern (peer); | 598 | cp->ppd.pid = GNUNET_PEER_intern (peer); |
606 | cp->ppd.transmission_delay = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_ZERO); | 599 | cp->ppd.transmission_delay = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_ZERO); |
607 | cp->irc = GNUNET_CORE_peer_change_preference (GSF_core, | 600 | cp->irc = |
608 | peer, | 601 | GNUNET_CORE_peer_change_preference (GSF_core, peer, |
609 | GNUNET_TIME_UNIT_FOREVER_REL, | 602 | GNUNET_TIME_UNIT_FOREVER_REL, |
610 | GNUNET_BANDWIDTH_VALUE_MAX, | 603 | GNUNET_BANDWIDTH_VALUE_MAX, |
611 | DBLOCK_SIZE, | 604 | DBLOCK_SIZE, 0, |
612 | 0, &core_reserve_callback, cp); | 605 | &core_reserve_callback, cp); |
613 | fn = get_trust_filename (peer); | 606 | fn = get_trust_filename (peer); |
614 | if ((GNUNET_DISK_file_test (fn) == GNUNET_YES) && | 607 | if ((GNUNET_DISK_file_test (fn) == GNUNET_YES) && |
615 | (sizeof (trust) == GNUNET_DISK_fn_read (fn, &trust, sizeof (trust)))) | 608 | (sizeof (trust) == GNUNET_DISK_fn_read (fn, &trust, sizeof (trust)))) |
@@ -617,8 +610,7 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, | |||
617 | GNUNET_free (fn); | 610 | GNUNET_free (fn); |
618 | cp->request_map = GNUNET_CONTAINER_multihashmap_create (128); | 611 | cp->request_map = GNUNET_CONTAINER_multihashmap_create (128); |
619 | GNUNET_break (GNUNET_OK == | 612 | GNUNET_break (GNUNET_OK == |
620 | GNUNET_CONTAINER_multihashmap_put (cp_map, | 613 | GNUNET_CONTAINER_multihashmap_put (cp_map, &peer->hashPubKey, |
621 | &peer->hashPubKey, | ||
622 | cp, | 614 | cp, |
623 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 615 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
624 | update_atsi (cp, atsi); | 616 | update_atsi (cp, atsi); |
@@ -645,8 +637,8 @@ revive_migration (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
645 | if (0 != bt.rel_value) | 637 | if (0 != bt.rel_value) |
646 | { | 638 | { |
647 | /* still time left... */ | 639 | /* still time left... */ |
648 | cp->mig_revive_task | 640 | cp->mig_revive_task = |
649 | = GNUNET_SCHEDULER_add_delayed (bt, &revive_migration, cp); | 641 | GNUNET_SCHEDULER_add_delayed (bt, &revive_migration, cp); |
650 | return; | 642 | return; |
651 | } | 643 | } |
652 | GSF_push_start_ (cp); | 644 | GSF_push_start_ (cp); |
@@ -705,8 +697,8 @@ GSF_handle_p2p_migration_stop_ (void *cls, | |||
705 | if (cp->mig_revive_task == GNUNET_SCHEDULER_NO_TASK) | 697 | if (cp->mig_revive_task == GNUNET_SCHEDULER_NO_TASK) |
706 | { | 698 | { |
707 | GSF_push_stop_ (cp); | 699 | GSF_push_stop_ (cp); |
708 | cp->mig_revive_task | 700 | cp->mig_revive_task = |
709 | = GNUNET_SCHEDULER_add_delayed (bt, &revive_migration, cp); | 701 | GNUNET_SCHEDULER_add_delayed (bt, &revive_migration, cp); |
710 | } | 702 | } |
711 | update_atsi (cp, atsi); | 703 | update_atsi (cp, atsi); |
712 | return GNUNET_OK; | 704 | return GNUNET_OK; |
@@ -740,8 +732,8 @@ copy_reply (void *cls, size_t buf_size, void *buf) | |||
740 | else | 732 | else |
741 | { | 733 | { |
742 | size = 0; | 734 | size = 0; |
743 | GNUNET_STATISTICS_update (GSF_stats, | 735 | GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# replies dropped"), 1, |
744 | gettext_noop ("# replies dropped"), 1, GNUNET_NO); | 736 | GNUNET_NO); |
745 | } | 737 | } |
746 | GNUNET_free (pm); | 738 | GNUNET_free (pm); |
747 | return size; | 739 | return size; |
@@ -769,8 +761,7 @@ cancel_pending_request (void *cls, const GNUNET_HashCode * query, void *value) | |||
769 | GNUNET_SCHEDULER_cancel (peerreq->kill_task); | 761 | GNUNET_SCHEDULER_cancel (peerreq->kill_task); |
770 | peerreq->kill_task = GNUNET_SCHEDULER_NO_TASK; | 762 | peerreq->kill_task = GNUNET_SCHEDULER_NO_TASK; |
771 | } | 763 | } |
772 | GNUNET_STATISTICS_update (GSF_stats, | 764 | GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# P2P searches active"), |
773 | gettext_noop ("# P2P searches active"), | ||
774 | -1, GNUNET_NO); | 765 | -1, GNUNET_NO); |
775 | prd = GSF_pending_request_get_data_ (pr); | 766 | prd = GSF_pending_request_get_data_ (pr); |
776 | GNUNET_break (GNUNET_YES == | 767 | GNUNET_break (GNUNET_YES == |
@@ -820,9 +811,8 @@ transmit_delayed_now (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
820 | GNUNET_free (dh); | 811 | GNUNET_free (dh); |
821 | return; | 812 | return; |
822 | } | 813 | } |
823 | (void) GSF_peer_transmit_ (cp, GNUNET_NO, | 814 | (void) GSF_peer_transmit_ (cp, GNUNET_NO, UINT32_MAX, REPLY_TIMEOUT, |
824 | UINT32_MAX, | 815 | dh->msize, ©_reply, dh->pm); |
825 | REPLY_TIMEOUT, dh->msize, ©_reply, dh->pm); | ||
826 | GNUNET_free (dh); | 816 | GNUNET_free (dh); |
827 | } | 817 | } |
828 | 818 | ||
@@ -838,9 +828,10 @@ get_randomized_delay () | |||
838 | struct GNUNET_TIME_Relative ret; | 828 | struct GNUNET_TIME_Relative ret; |
839 | 829 | ||
840 | /* FIXME: replace 5000 with something relating to current observed P2P message latency */ | 830 | /* FIXME: replace 5000 with something relating to current observed P2P message latency */ |
841 | ret = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, | 831 | ret = |
842 | GNUNET_CRYPTO_random_u32 | 832 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, |
843 | (GNUNET_CRYPTO_QUALITY_WEAK, 5000)); | 833 | GNUNET_CRYPTO_random_u32 |
834 | (GNUNET_CRYPTO_QUALITY_WEAK, 5000)); | ||
844 | GNUNET_STATISTICS_update (GSF_stats, | 835 | GNUNET_STATISTICS_update (GSF_stats, |
845 | gettext_noop | 836 | gettext_noop |
846 | ("# artificial delays introduced (ms)"), | 837 | ("# artificial delays introduced (ms)"), |
@@ -868,13 +859,11 @@ get_randomized_delay () | |||
868 | * @param data_len number of bytes in data | 859 | * @param data_len number of bytes in data |
869 | */ | 860 | */ |
870 | static void | 861 | static void |
871 | handle_p2p_reply (void *cls, | 862 | handle_p2p_reply (void *cls, enum GNUNET_BLOCK_EvaluationResult eval, |
872 | enum GNUNET_BLOCK_EvaluationResult eval, | 863 | struct GSF_PendingRequest *pr, uint32_t reply_anonymity_level, |
873 | struct GSF_PendingRequest *pr, | ||
874 | uint32_t reply_anonymity_level, | ||
875 | struct GNUNET_TIME_Absolute expiration, | 864 | struct GNUNET_TIME_Absolute expiration, |
876 | enum GNUNET_BLOCK_Type type, | 865 | enum GNUNET_BLOCK_Type type, const void *data, |
877 | const void *data, size_t data_len) | 866 | size_t data_len) |
878 | { | 867 | { |
879 | struct PeerRequest *peerreq = cls; | 868 | struct PeerRequest *peerreq = cls; |
880 | struct GSF_ConnectedPeer *cp = peerreq->cp; | 869 | struct GSF_ConnectedPeer *cp = peerreq->cp; |
@@ -888,8 +877,7 @@ handle_p2p_reply (void *cls, | |||
888 | prd = GSF_pending_request_get_data_ (pr); | 877 | prd = GSF_pending_request_get_data_ (pr); |
889 | if (NULL == data) | 878 | if (NULL == data) |
890 | { | 879 | { |
891 | GNUNET_STATISTICS_update (GSF_stats, | 880 | GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# P2P searches active"), |
892 | gettext_noop ("# P2P searches active"), | ||
893 | -1, GNUNET_NO); | 881 | -1, GNUNET_NO); |
894 | GNUNET_break (GNUNET_YES == | 882 | GNUNET_break (GNUNET_YES == |
895 | GNUNET_CONTAINER_multihashmap_remove (cp->request_map, | 883 | GNUNET_CONTAINER_multihashmap_remove (cp->request_map, |
@@ -936,8 +924,7 @@ handle_p2p_reply (void *cls, | |||
936 | pm->type = htonl (type); | 924 | pm->type = htonl (type); |
937 | pm->expiration = GNUNET_TIME_absolute_hton (expiration); | 925 | pm->expiration = GNUNET_TIME_absolute_hton (expiration); |
938 | memcpy (&pm[1], data, data_len); | 926 | memcpy (&pm[1], data, data_len); |
939 | if ((reply_anonymity_level != UINT32_MAX) && | 927 | if ((reply_anonymity_level != UINT32_MAX) && (reply_anonymity_level != 0) && |
940 | (reply_anonymity_level != 0) && | ||
941 | (GSF_enable_randomized_delays == GNUNET_YES)) | 928 | (GSF_enable_randomized_delays == GNUNET_YES)) |
942 | { | 929 | { |
943 | struct GSF_DelayedHandle *dh; | 930 | struct GSF_DelayedHandle *dh; |
@@ -947,14 +934,14 @@ handle_p2p_reply (void *cls, | |||
947 | dh->pm = pm; | 934 | dh->pm = pm; |
948 | dh->msize = msize; | 935 | dh->msize = msize; |
949 | GNUNET_CONTAINER_DLL_insert (cp->delayed_head, cp->delayed_tail, dh); | 936 | GNUNET_CONTAINER_DLL_insert (cp->delayed_head, cp->delayed_tail, dh); |
950 | dh->delay_task = GNUNET_SCHEDULER_add_delayed (get_randomized_delay (), | 937 | dh->delay_task = |
951 | &transmit_delayed_now, dh); | 938 | GNUNET_SCHEDULER_add_delayed (get_randomized_delay (), |
939 | &transmit_delayed_now, dh); | ||
952 | } | 940 | } |
953 | else | 941 | else |
954 | { | 942 | { |
955 | (void) GSF_peer_transmit_ (cp, GNUNET_NO, | 943 | (void) GSF_peer_transmit_ (cp, GNUNET_NO, UINT32_MAX, REPLY_TIMEOUT, msize, |
956 | UINT32_MAX, | 944 | ©_reply, pm); |
957 | REPLY_TIMEOUT, msize, ©_reply, pm); | ||
958 | } | 945 | } |
959 | if (eval != GNUNET_BLOCK_EVALUATION_OK_LAST) | 946 | if (eval != GNUNET_BLOCK_EVALUATION_OK_LAST) |
960 | return; | 947 | return; |
@@ -1220,8 +1207,8 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, | |||
1220 | #if DEBUG_FS | 1207 | #if DEBUG_FS |
1221 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1208 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1222 | "Received request for `%s' of type %u from peer `%4s' with flags %u\n", | 1209 | "Received request for `%s' of type %u from peer `%4s' with flags %u\n", |
1223 | GNUNET_h2s (&gm->query), | 1210 | GNUNET_h2s (&gm->query), (unsigned int) type, GNUNET_i2s (other), |
1224 | (unsigned int) type, GNUNET_i2s (other), (unsigned int) bm); | 1211 | (unsigned int) bm); |
1225 | #endif | 1212 | #endif |
1226 | namespace = (0 != (bm & GET_MESSAGE_BIT_SKS_NAMESPACE)) ? &opt[bits++] : NULL; | 1213 | namespace = (0 != (bm & GET_MESSAGE_BIT_SKS_NAMESPACE)) ? &opt[bits++] : NULL; |
1227 | if ((type == GNUNET_BLOCK_TYPE_FS_SBLOCK) && (namespace == NULL)) | 1214 | if ((type == GNUNET_BLOCK_TYPE_FS_SBLOCK) && (namespace == NULL)) |
@@ -1254,8 +1241,9 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, | |||
1254 | } | 1241 | } |
1255 | ttl = bound_ttl (ntohl (gm->ttl), priority); | 1242 | ttl = bound_ttl (ntohl (gm->ttl), priority); |
1256 | /* decrement ttl (always) */ | 1243 | /* decrement ttl (always) */ |
1257 | ttl_decrement = 2 * TTL_DECREMENT + | 1244 | ttl_decrement = |
1258 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, TTL_DECREMENT); | 1245 | 2 * TTL_DECREMENT + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
1246 | TTL_DECREMENT); | ||
1259 | if ((ttl < 0) && (((int32_t) (ttl - ttl_decrement)) > 0)) | 1247 | if ((ttl < 0) && (((int32_t) (ttl - ttl_decrement)) > 0)) |
1260 | { | 1248 | { |
1261 | #if DEBUG_FS | 1249 | #if DEBUG_FS |
@@ -1299,8 +1287,8 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, | |||
1299 | } | 1287 | } |
1300 | /* existing request has lower TTL, drop old one! */ | 1288 | /* existing request has lower TTL, drop old one! */ |
1301 | GNUNET_STATISTICS_update (GSF_stats, | 1289 | GNUNET_STATISTICS_update (GSF_stats, |
1302 | gettext_noop ("# P2P searches active"), | 1290 | gettext_noop ("# P2P searches active"), -1, |
1303 | -1, GNUNET_NO); | 1291 | GNUNET_NO); |
1304 | priority += prd->priority; | 1292 | priority += prd->priority; |
1305 | GSF_pending_request_cancel_ (pr, GNUNET_YES); | 1293 | GSF_pending_request_cancel_ (pr, GNUNET_YES); |
1306 | GNUNET_assert (GNUNET_YES == | 1294 | GNUNET_assert (GNUNET_YES == |
@@ -1318,10 +1306,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, | |||
1318 | 1306 | ||
1319 | peerreq = GNUNET_malloc (sizeof (struct PeerRequest)); | 1307 | peerreq = GNUNET_malloc (sizeof (struct PeerRequest)); |
1320 | peerreq->cp = cp; | 1308 | peerreq->cp = cp; |
1321 | pr = GSF_pending_request_create_ (options, | 1309 | pr = GSF_pending_request_create_ (options, type, &gm->query, namespace, |
1322 | type, | ||
1323 | &gm->query, | ||
1324 | namespace, | ||
1325 | target, | 1310 | target, |
1326 | (bfsize > | 1311 | (bfsize > |
1327 | 0) ? (const char *) &opt[bits] : NULL, | 1312 | 0) ? (const char *) &opt[bits] : NULL, |
@@ -1332,8 +1317,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, | |||
1332 | GNUNET_assert (NULL != pr); | 1317 | GNUNET_assert (NULL != pr); |
1333 | peerreq->pr = pr; | 1318 | peerreq->pr = pr; |
1334 | GNUNET_break (GNUNET_OK == | 1319 | GNUNET_break (GNUNET_OK == |
1335 | GNUNET_CONTAINER_multihashmap_put (cp->request_map, | 1320 | GNUNET_CONTAINER_multihashmap_put (cp->request_map, &gm->query, |
1336 | &gm->query, | ||
1337 | peerreq, | 1321 | peerreq, |
1338 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | 1322 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); |
1339 | GNUNET_STATISTICS_update (GSF_stats, | 1323 | GNUNET_STATISTICS_update (GSF_stats, |
@@ -1397,10 +1381,8 @@ peer_transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1397 | * @return handle to cancel request | 1381 | * @return handle to cancel request |
1398 | */ | 1382 | */ |
1399 | struct GSF_PeerTransmitHandle * | 1383 | struct GSF_PeerTransmitHandle * |
1400 | GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, | 1384 | GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, int is_query, |
1401 | int is_query, | 1385 | uint32_t priority, struct GNUNET_TIME_Relative timeout, |
1402 | uint32_t priority, | ||
1403 | struct GNUNET_TIME_Relative timeout, | ||
1404 | size_t size, GSF_GetMessageCallback gmc, void *gmc_cls) | 1386 | size_t size, GSF_GetMessageCallback gmc, void *gmc_cls) |
1405 | { | 1387 | { |
1406 | struct GSF_PeerTransmitHandle *pth; | 1388 | struct GSF_PeerTransmitHandle *pth; |
@@ -1432,9 +1414,8 @@ GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, | |||
1432 | cp->ppd.pending_queries++; | 1414 | cp->ppd.pending_queries++; |
1433 | else if (GNUNET_NO == is_query) | 1415 | else if (GNUNET_NO == is_query) |
1434 | cp->ppd.pending_replies++; | 1416 | cp->ppd.pending_replies++; |
1435 | pth->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, | 1417 | pth->timeout_task = |
1436 | &peer_transmit_timeout, | 1418 | GNUNET_SCHEDULER_add_delayed (timeout, &peer_transmit_timeout, pth); |
1437 | pth); | ||
1438 | schedule_transmission (pth); | 1419 | schedule_transmission (pth); |
1439 | return pth; | 1420 | return pth; |
1440 | } | 1421 | } |
@@ -1544,8 +1525,7 @@ GSF_peer_update_responder_peer_ (struct GSF_ConnectedPeer *cp, | |||
1544 | * @param atsi status information | 1525 | * @param atsi status information |
1545 | */ | 1526 | */ |
1546 | void | 1527 | void |
1547 | GSF_peer_status_handler_ (void *cls, | 1528 | GSF_peer_status_handler_ (void *cls, const struct GNUNET_PeerIdentity *peer, |
1548 | const struct GNUNET_PeerIdentity *peer, | ||
1549 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 1529 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
1550 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 1530 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
1551 | struct GNUNET_TIME_Absolute timeout, | 1531 | struct GNUNET_TIME_Absolute timeout, |
@@ -1752,27 +1732,24 @@ GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp, | |||
1752 | #if DEBUG_FS && 0 | 1732 | #if DEBUG_FS && 0 |
1753 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1733 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1754 | "Migration already blocked for another %llu ms\n", | 1734 | "Migration already blocked for another %llu ms\n", |
1755 | (unsigned long long) | 1735 | (unsigned long long) GNUNET_TIME_absolute_get_remaining (cp-> |
1756 | GNUNET_TIME_absolute_get_remaining | 1736 | last_migration_block). |
1757 | (cp->last_migration_block).rel_value); | 1737 | rel_value); |
1758 | #endif | 1738 | #endif |
1759 | return; /* already blocked */ | 1739 | return; /* already blocked */ |
1760 | } | 1740 | } |
1761 | #if DEBUG_FS && 0 | 1741 | #if DEBUG_FS && 0 |
1762 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1742 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking to stop migration for %llu ms\n", |
1763 | "Asking to stop migration for %llu ms\n", | ||
1764 | (unsigned long long) block_time.rel_value); | 1743 | (unsigned long long) block_time.rel_value); |
1765 | #endif | 1744 | #endif |
1766 | cp->last_migration_block = GNUNET_TIME_relative_to_absolute (block_time); | 1745 | cp->last_migration_block = GNUNET_TIME_relative_to_absolute (block_time); |
1767 | if (cp->migration_pth != NULL) | 1746 | if (cp->migration_pth != NULL) |
1768 | GSF_peer_transmit_cancel_ (cp->migration_pth); | 1747 | GSF_peer_transmit_cancel_ (cp->migration_pth); |
1769 | cp->migration_pth | 1748 | cp->migration_pth = |
1770 | = GSF_peer_transmit_ (cp, | 1749 | GSF_peer_transmit_ (cp, GNUNET_SYSERR, UINT32_MAX, |
1771 | GNUNET_SYSERR, | 1750 | GNUNET_TIME_UNIT_FOREVER_REL, |
1772 | UINT32_MAX, | 1751 | sizeof (struct MigrationStopMessage), |
1773 | GNUNET_TIME_UNIT_FOREVER_REL, | 1752 | &create_migration_stop_message, cp); |
1774 | sizeof (struct MigrationStopMessage), | ||
1775 | &create_migration_stop_message, cp); | ||
1776 | } | 1753 | } |
1777 | 1754 | ||
1778 | 1755 | ||
@@ -1806,12 +1783,12 @@ flush_trust (void *cls, const GNUNET_HashCode * key, void *value) | |||
1806 | else | 1783 | else |
1807 | { | 1784 | { |
1808 | trust = htonl (cp->ppd.trust); | 1785 | trust = htonl (cp->ppd.trust); |
1809 | if (sizeof (uint32_t) == GNUNET_DISK_fn_write (fn, &trust, | 1786 | if (sizeof (uint32_t) == |
1810 | sizeof (uint32_t), | 1787 | GNUNET_DISK_fn_write (fn, &trust, sizeof (uint32_t), |
1811 | GNUNET_DISK_PERM_USER_READ | | 1788 | GNUNET_DISK_PERM_USER_READ | |
1812 | GNUNET_DISK_PERM_USER_WRITE | | 1789 | GNUNET_DISK_PERM_USER_WRITE | |
1813 | GNUNET_DISK_PERM_GROUP_READ | | 1790 | GNUNET_DISK_PERM_GROUP_READ | |
1814 | GNUNET_DISK_PERM_OTHER_READ)) | 1791 | GNUNET_DISK_PERM_OTHER_READ)) |
1815 | cp->disk_trust = cp->ppd.trust; | 1792 | cp->disk_trust = cp->ppd.trust; |
1816 | } | 1793 | } |
1817 | GNUNET_free (fn); | 1794 | GNUNET_free (fn); |
@@ -1865,8 +1842,7 @@ GSF_connected_peer_init_ () | |||
1865 | { | 1842 | { |
1866 | cp_map = GNUNET_CONTAINER_multihashmap_create (128); | 1843 | cp_map = GNUNET_CONTAINER_multihashmap_create (128); |
1867 | GNUNET_assert (GNUNET_OK == | 1844 | GNUNET_assert (GNUNET_OK == |
1868 | GNUNET_CONFIGURATION_get_value_filename (GSF_cfg, | 1845 | GNUNET_CONFIGURATION_get_value_filename (GSF_cfg, "fs", |
1869 | "fs", | ||
1870 | "TRUST", | 1846 | "TRUST", |
1871 | &trustDirectory)); | 1847 | &trustDirectory)); |
1872 | GNUNET_DISK_directory_create (trustDirectory); | 1848 | GNUNET_DISK_directory_create (trustDirectory); |
@@ -1939,8 +1915,8 @@ GSF_handle_local_client_disconnect_ (const struct GSF_LocalClient *lc) | |||
1939 | { | 1915 | { |
1940 | if (NULL == cp_map) | 1916 | if (NULL == cp_map) |
1941 | return; /* already cleaned up */ | 1917 | return; /* already cleaned up */ |
1942 | GNUNET_CONTAINER_multihashmap_iterate (cp_map, | 1918 | GNUNET_CONTAINER_multihashmap_iterate (cp_map, &clean_local_client, |
1943 | &clean_local_client, (void *) lc); | 1919 | (void *) lc); |
1944 | } | 1920 | } |
1945 | 1921 | ||
1946 | 1922 | ||