diff options
Diffstat (limited to 'src/fs/gnunet-service-fs_pr.c')
-rw-r--r-- | src/fs/gnunet-service-fs_pr.c | 99 |
1 files changed, 49 insertions, 50 deletions
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index a5db4b6b7..c3fe5ff58 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c | |||
@@ -135,7 +135,7 @@ struct GSF_PendingRequest | |||
135 | /** | 135 | /** |
136 | * Last result from the local datastore lookup evaluation. | 136 | * Last result from the local datastore lookup evaluation. |
137 | */ | 137 | */ |
138 | enum GNUNET_BLOCK_EvaluationResult local_result; | 138 | enum GNUNET_BLOCK_ReplyEvaluationResult local_result; |
139 | 139 | ||
140 | /** | 140 | /** |
141 | * Identity of the peer that we should use for the 'sender' | 141 | * Identity of the peer that we should use for the 'sender' |
@@ -619,7 +619,9 @@ clean_request (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
619 | if (NULL != (cont = pr->llc_cont)) | 619 | if (NULL != (cont = pr->llc_cont)) |
620 | { | 620 | { |
621 | pr->llc_cont = NULL; | 621 | pr->llc_cont = NULL; |
622 | cont (pr->llc_cont_cls, pr, pr->local_result); | 622 | cont (pr->llc_cont_cls, |
623 | pr, | ||
624 | pr->local_result); | ||
623 | } | 625 | } |
624 | GSF_plan_notify_request_done_ (pr); | 626 | GSF_plan_notify_request_done_ (pr); |
625 | GNUNET_free (pr->replies_seen); | 627 | GNUNET_free (pr->replies_seen); |
@@ -689,7 +691,9 @@ GSF_pending_request_cancel_ (struct GSF_PendingRequest *pr, int full_cleanup) | |||
689 | if (NULL != (cont = pr->llc_cont)) | 691 | if (NULL != (cont = pr->llc_cont)) |
690 | { | 692 | { |
691 | pr->llc_cont = NULL; | 693 | pr->llc_cont = NULL; |
692 | cont (pr->llc_cont_cls, pr, pr->local_result); | 694 | cont (pr->llc_cont_cls, |
695 | pr, | ||
696 | pr->local_result); | ||
693 | } | 697 | } |
694 | GSF_plan_notify_request_done_ (pr); | 698 | GSF_plan_notify_request_done_ (pr); |
695 | if (NULL != pr->qe) | 699 | if (NULL != pr->qe) |
@@ -778,7 +782,7 @@ struct ProcessReplyClosure | |||
778 | /** | 782 | /** |
779 | * Evaluation result (returned). | 783 | * Evaluation result (returned). |
780 | */ | 784 | */ |
781 | enum GNUNET_BLOCK_EvaluationResult eval; | 785 | enum GNUNET_BLOCK_ReplyEvaluationResult eval; |
782 | 786 | ||
783 | /** | 787 | /** |
784 | * Did we find a matching request? | 788 | * Did we find a matching request? |
@@ -814,8 +818,10 @@ update_request_performance_data (struct ProcessReplyClosure *prq, | |||
814 | * @param value value in the hash map (info about the query) | 818 | * @param value value in the hash map (info about the query) |
815 | * @return #GNUNET_YES (we should continue to iterate) | 819 | * @return #GNUNET_YES (we should continue to iterate) |
816 | */ | 820 | */ |
817 | static int | 821 | static enum GNUNET_GenericReturnValue |
818 | process_reply (void *cls, const struct GNUNET_HashCode *key, void *value) | 822 | process_reply (void *cls, |
823 | const struct GNUNET_HashCode *key, | ||
824 | void *value) | ||
819 | { | 825 | { |
820 | struct ProcessReplyClosure *prq = cls; | 826 | struct ProcessReplyClosure *prq = cls; |
821 | struct GSF_PendingRequest *pr = value; | 827 | struct GSF_PendingRequest *pr = value; |
@@ -832,22 +838,20 @@ process_reply (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
832 | gettext_noop ("# replies received and matched"), | 838 | gettext_noop ("# replies received and matched"), |
833 | 1, | 839 | 1, |
834 | GNUNET_NO); | 840 | GNUNET_NO); |
835 | prq->eval = GNUNET_BLOCK_evaluate (GSF_block_ctx, | 841 | prq->eval = GNUNET_BLOCK_check_reply (GSF_block_ctx, |
836 | prq->type, | 842 | prq->type, |
837 | pr->bg, | 843 | pr->bg, |
838 | prq->eo, | 844 | key, |
839 | key, | 845 | NULL, 0, |
840 | NULL, | 846 | prq->data, |
841 | 0, | 847 | prq->size); |
842 | prq->data, | ||
843 | prq->size); | ||
844 | switch (prq->eval) | 848 | switch (prq->eval) |
845 | { | 849 | { |
846 | case GNUNET_BLOCK_EVALUATION_OK_MORE: | 850 | case GNUNET_BLOCK_REPLY_OK_MORE: |
847 | update_request_performance_data (prq, pr); | 851 | update_request_performance_data (prq, pr); |
848 | break; | 852 | break; |
849 | 853 | ||
850 | case GNUNET_BLOCK_EVALUATION_OK_LAST: | 854 | case GNUNET_BLOCK_REPLY_OK_LAST: |
851 | /* short cut: stop processing early, no BF-update, etc. */ | 855 | /* short cut: stop processing early, no BF-update, etc. */ |
852 | update_request_performance_data (prq, pr); | 856 | update_request_performance_data (prq, pr); |
853 | GNUNET_LOAD_update (GSF_rt_entry_lifetime, | 857 | GNUNET_LOAD_update (GSF_rt_entry_lifetime, |
@@ -859,8 +863,7 @@ process_reply (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
859 | .pr_head, | 863 | .pr_head, |
860 | prq->sender, | 864 | prq->sender, |
861 | &last_transmission)) | 865 | &last_transmission)) |
862 | last_transmission.abs_value_us = | 866 | last_transmission = GNUNET_TIME_UNIT_FOREVER_ABS; |
863 | GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; | ||
864 | /* pass on to other peers / local clients */ | 867 | /* pass on to other peers / local clients */ |
865 | pr->rh (pr->rh_cls, | 868 | pr->rh (pr->rh_cls, |
866 | prq->eval, | 869 | prq->eval, |
@@ -872,46 +875,38 @@ process_reply (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
872 | prq->data, | 875 | prq->data, |
873 | prq->size); | 876 | prq->size); |
874 | return GNUNET_YES; | 877 | return GNUNET_YES; |
875 | 878 | case GNUNET_BLOCK_REPLY_OK_DUPLICATE: | |
876 | case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: | ||
877 | #if INSANE_STATISTICS | 879 | #if INSANE_STATISTICS |
878 | GNUNET_STATISTICS_update (GSF_stats, | 880 | GNUNET_STATISTICS_update (GSF_stats, |
879 | gettext_noop ( | 881 | "# duplicate replies discarded (bloomfilter)", |
880 | "# duplicate replies discarded (bloomfilter)"), | ||
881 | 1, | 882 | 1, |
882 | GNUNET_NO); | 883 | GNUNET_NO); |
883 | #endif | 884 | #endif |
884 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Duplicate response, discarding.\n"); | 885 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
886 | "Duplicate response, discarding.\n"); | ||
885 | return GNUNET_YES; /* duplicate */ | 887 | return GNUNET_YES; /* duplicate */ |
886 | 888 | ||
887 | case GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT: | 889 | case GNUNET_BLOCK_REPLY_IRRELEVANT: |
888 | GNUNET_STATISTICS_update (GSF_stats, | 890 | GNUNET_STATISTICS_update (GSF_stats, |
889 | gettext_noop ("# irrelevant replies discarded"), | 891 | "# irrelevant replies discarded", |
890 | 1, | 892 | 1, |
891 | GNUNET_NO); | 893 | GNUNET_NO); |
892 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Irrelevant response, ignoring.\n"); | 894 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
893 | return GNUNET_YES; | 895 | "Irrelevant response, ignoring.\n"); |
894 | |||
895 | case GNUNET_BLOCK_EVALUATION_RESULT_INVALID: | ||
896 | return GNUNET_YES; /* wrong namespace */ | ||
897 | |||
898 | case GNUNET_BLOCK_EVALUATION_REQUEST_VALID: | ||
899 | GNUNET_break (0); | ||
900 | return GNUNET_YES; | 896 | return GNUNET_YES; |
901 | 897 | case GNUNET_BLOCK_REPLY_INVALID: | |
902 | case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID: | ||
903 | GNUNET_break (0); | ||
904 | return GNUNET_YES; | 898 | return GNUNET_YES; |
905 | 899 | case GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED: | |
906 | case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED: | 900 | GNUNET_break (0); /* bad installation? */ |
907 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
908 | _ ("Unsupported block type %u\n"), | ||
909 | prq->type); | ||
910 | return GNUNET_NO; | 901 | return GNUNET_NO; |
911 | } | 902 | } |
912 | /* update bloomfilter */ | 903 | /* update bloomfilter */ |
913 | GNUNET_CRYPTO_hash (prq->data, prq->size, &chash); | 904 | GNUNET_CRYPTO_hash (prq->data, |
914 | GSF_pending_request_update_ (pr, &chash, 1); | 905 | prq->size, |
906 | &chash); | ||
907 | GSF_pending_request_update_ (pr, | ||
908 | &chash, | ||
909 | 1); | ||
915 | if (NULL == prq->sender) | 910 | if (NULL == prq->sender) |
916 | { | 911 | { |
917 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 912 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -936,7 +931,7 @@ process_reply (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
936 | .pr_head, | 931 | .pr_head, |
937 | prq->sender, | 932 | prq->sender, |
938 | &last_transmission)) | 933 | &last_transmission)) |
939 | last_transmission.abs_value_us = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; | 934 | last_transmission = GNUNET_TIME_UNIT_FOREVER_ABS; |
940 | pr->rh (pr->rh_cls, | 935 | pr->rh (pr->rh_cls, |
941 | prq->eval, | 936 | prq->eval, |
942 | pr, | 937 | pr, |
@@ -1363,12 +1358,12 @@ call_continuation (struct GSF_PendingRequest *pr) | |||
1363 | pr->llc_cont = NULL; | 1358 | pr->llc_cont = NULL; |
1364 | if (0 != (GSF_PRO_LOCAL_ONLY & pr->public_data.options)) | 1359 | if (0 != (GSF_PRO_LOCAL_ONLY & pr->public_data.options)) |
1365 | { | 1360 | { |
1366 | if (GNUNET_BLOCK_EVALUATION_OK_LAST != pr->local_result) | 1361 | if (GNUNET_BLOCK_REPLY_OK_LAST != pr->local_result) |
1367 | { | 1362 | { |
1368 | /* Signal that we are done and that there won't be any | 1363 | /* Signal that we are done and that there won't be any |
1369 | additional results to allow client to clean up state. */ | 1364 | additional results to allow client to clean up state. */ |
1370 | pr->rh (pr->rh_cls, | 1365 | pr->rh (pr->rh_cls, |
1371 | GNUNET_BLOCK_EVALUATION_OK_LAST, | 1366 | GNUNET_BLOCK_REPLY_OK_LAST, |
1372 | pr, | 1367 | pr, |
1373 | UINT32_MAX, | 1368 | UINT32_MAX, |
1374 | GNUNET_TIME_UNIT_ZERO_ABS, | 1369 | GNUNET_TIME_UNIT_ZERO_ABS, |
@@ -1380,11 +1375,15 @@ call_continuation (struct GSF_PendingRequest *pr) | |||
1380 | /* Finally, call our continuation to signal that we are | 1375 | /* Finally, call our continuation to signal that we are |
1381 | done with local processing of this request; i.e. to | 1376 | done with local processing of this request; i.e. to |
1382 | start reading again from the client. */ | 1377 | start reading again from the client. */ |
1383 | cont (pr->llc_cont_cls, NULL, GNUNET_BLOCK_EVALUATION_OK_LAST); | 1378 | cont (pr->llc_cont_cls, |
1379 | NULL, | ||
1380 | GNUNET_BLOCK_REPLY_OK_LAST); | ||
1384 | return; | 1381 | return; |
1385 | } | 1382 | } |
1386 | 1383 | ||
1387 | cont (pr->llc_cont_cls, pr, pr->local_result); | 1384 | cont (pr->llc_cont_cls, |
1385 | pr, | ||
1386 | pr->local_result); | ||
1388 | } | 1387 | } |
1389 | 1388 | ||
1390 | 1389 | ||
@@ -1635,7 +1634,7 @@ called_from_on_demand: | |||
1635 | prq.eo = GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO; | 1634 | prq.eo = GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO; |
1636 | process_reply (&prq, key, pr); | 1635 | process_reply (&prq, key, pr); |
1637 | pr->local_result = prq.eval; | 1636 | pr->local_result = prq.eval; |
1638 | if (GNUNET_BLOCK_EVALUATION_OK_LAST == prq.eval) | 1637 | if (GNUNET_BLOCK_REPLY_OK_LAST == prq.eval) |
1639 | { | 1638 | { |
1640 | GNUNET_STATISTICS_update ( | 1639 | GNUNET_STATISTICS_update ( |
1641 | GSF_stats, | 1640 | GSF_stats, |