aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-service-fs_pr.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-28 21:12:03 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-28 21:12:03 +0000
commit3a2737d76679c68331fad0be0b89d8efdcde5079 (patch)
tree5bd4ef163438954cdcb75558e6368a297629b56d /src/fs/gnunet-service-fs_pr.c
parent9c46ed792caae948fd99cca44deaf5a265af7614 (diff)
downloadgnunet-3a2737d76679c68331fad0be0b89d8efdcde5079.tar.gz
gnunet-3a2737d76679c68331fad0be0b89d8efdcde5079.zip
-extend block API to allow specifying flags, use this to allow reducing checks for replies from local DB
Diffstat (limited to 'src/fs/gnunet-service-fs_pr.c')
-rw-r--r--src/fs/gnunet-service-fs_pr.c89
1 files changed, 64 insertions, 25 deletions
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c
index 545c7c657..709874f75 100644
--- a/src/fs/gnunet-service-fs_pr.c
+++ b/src/fs/gnunet-service-fs_pr.c
@@ -748,6 +748,11 @@ struct ProcessReplyClosure
748 enum GNUNET_BLOCK_Type type; 748 enum GNUNET_BLOCK_Type type;
749 749
750 /** 750 /**
751 * Control flags for evaluation.
752 */
753 enum GNUNET_BLOCK_EvaluationOptions eo;
754
755 /**
751 * How much was this reply worth to us? 756 * How much was this reply worth to us?
752 */ 757 */
753 uint32_t priority; 758 uint32_t priority;
@@ -790,7 +795,7 @@ update_request_performance_data (struct ProcessReplyClosure *prq,
790/** 795/**
791 * We have received a reply; handle it! 796 * We have received a reply; handle it!
792 * 797 *
793 * @param cls response (struct ProcessReplyClosure) 798 * @param cls response (a `struct ProcessReplyClosure`)
794 * @param key our query 799 * @param key our query
795 * @param value value in the hash map (info about the query) 800 * @param value value in the hash map (info about the query)
796 * @return #GNUNET_YES (we should continue to iterate) 801 * @return #GNUNET_YES (we should continue to iterate)
@@ -809,13 +814,21 @@ process_reply (void *cls,
809 return GNUNET_YES; 814 return GNUNET_YES;
810 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 815 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
811 "Matched result (type %u) for query `%s' with pending request\n", 816 "Matched result (type %u) for query `%s' with pending request\n",
812 (unsigned int) prq->type, GNUNET_h2s (key)); 817 (unsigned int) prq->type,
818 GNUNET_h2s (key));
813 GNUNET_STATISTICS_update (GSF_stats, 819 GNUNET_STATISTICS_update (GSF_stats,
814 gettext_noop ("# replies received and matched"), 1, 820 gettext_noop ("# replies received and matched"), 1,
815 GNUNET_NO); 821 GNUNET_NO);
816 prq->eval = 822 prq->eval =
817 GNUNET_BLOCK_evaluate (GSF_block_ctx, prq->type, key, &pr->bf, pr->mingle, 823 GNUNET_BLOCK_evaluate (GSF_block_ctx,
818 NULL, 0, prq->data, 824 prq->type,
825 prq->eo,
826 key,
827 &pr->bf,
828 pr->mingle,
829 NULL,
830 0,
831 prq->data,
819 prq->size); 832 prq->size);
820 switch (prq->eval) 833 switch (prq->eval)
821 { 834 {
@@ -864,20 +877,26 @@ process_reply (void *cls,
864 GNUNET_break (0); 877 GNUNET_break (0);
865 return GNUNET_YES; 878 return GNUNET_YES;
866 case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED: 879 case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED:
867 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Unsupported block type %u\n"), 880 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
881 _("Unsupported block type %u\n"),
868 prq->type); 882 prq->type);
869 return GNUNET_NO; 883 return GNUNET_NO;
870 } 884 }
871 /* update bloomfilter */ 885 /* update bloomfilter */
872 GNUNET_CRYPTO_hash (prq->data, prq->size, &chash); 886 GNUNET_CRYPTO_hash (prq->data,
873 GSF_pending_request_update_ (pr, &chash, 1); 887 prq->size,
888 &chash);
889 GSF_pending_request_update_ (pr,
890 &chash,
891 1);
874 if (NULL == prq->sender) 892 if (NULL == prq->sender)
875 { 893 {
876 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 894 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
877 "Found result for query `%s' in local datastore\n", 895 "Found result for query `%s' in local datastore\n",
878 GNUNET_h2s (key)); 896 GNUNET_h2s (key));
879 GNUNET_STATISTICS_update (GSF_stats, 897 GNUNET_STATISTICS_update (GSF_stats,
880 gettext_noop ("# results found locally"), 1, 898 gettext_noop ("# results found locally"),
899 1,
881 GNUNET_NO); 900 GNUNET_NO);
882 } 901 }
883 else 902 else
@@ -894,9 +913,15 @@ process_reply (void *cls,
894 prq->sender, 913 prq->sender,
895 &last_transmission)) 914 &last_transmission))
896 last_transmission.abs_value_us = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; 915 last_transmission.abs_value_us = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
897 pr->rh (pr->rh_cls, prq->eval, pr, 916 pr->rh (pr->rh_cls,
898 prq->anonymity_level, prq->expiration, 917 prq->eval,
899 last_transmission, prq->type, prq->data, prq->size); 918 pr,
919 prq->anonymity_level,
920 prq->expiration,
921 last_transmission,
922 prq->type,
923 prq->data,
924 prq->size);
900 return GNUNET_YES; 925 return GNUNET_YES;
901} 926}
902 927
@@ -1076,6 +1101,7 @@ handle_dht_reply (void *cls,
1076 prq.expiration); 1101 prq.expiration);
1077 prq.size = size; 1102 prq.size = size;
1078 prq.type = type; 1103 prq.type = type;
1104 prq.eo = GNUNET_BLOCK_EO_NONE;
1079 process_reply (&prq, key, pr); 1105 process_reply (&prq, key, pr);
1080 if ((GNUNET_YES == active_to_migration) && 1106 if ((GNUNET_YES == active_to_migration) &&
1081 (GNUNET_NO == test_put_load_too_high (prq.priority))) 1107 (GNUNET_NO == test_put_load_too_high (prq.priority)))
@@ -1207,6 +1233,7 @@ cadet_reply_proc (void *cls,
1207 prq.expiration); 1233 prq.expiration);
1208 prq.size = data_size; 1234 prq.size = data_size;
1209 prq.type = type; 1235 prq.type = type;
1236 prq.eo = GNUNET_BLOCK_EO_NONE;
1210 process_reply (&prq, &query, pr); 1237 process_reply (&prq, &query, pr);
1211} 1238}
1212 1239
@@ -1283,9 +1310,9 @@ odc_warn_delay_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1283 * peer and if we are done either clean up (operation 1310 * peer and if we are done either clean up (operation
1284 * complete) or forward to other peers (more results possible). 1311 * complete) or forward to other peers (more results possible).
1285 * 1312 *
1286 * @param cls our closure (struct PendingRequest) 1313 * @param cls our closure (`struct GSF_PendingRequest *`)
1287 * @param key key for the content 1314 * @param key key for the content
1288 * @param size number of bytes in data 1315 * @param size number of bytes in @a data
1289 * @param data content stored 1316 * @param data content stored
1290 * @param type type of the content 1317 * @param type type of the content
1291 * @param priority priority of the content 1318 * @param priority priority of the content
@@ -1295,10 +1322,15 @@ odc_warn_delay_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1295 * maybe 0 if no unique identifier is available 1322 * maybe 0 if no unique identifier is available
1296 */ 1323 */
1297static void 1324static void
1298process_local_reply (void *cls, const struct GNUNET_HashCode * key, size_t size, 1325process_local_reply (void *cls,
1299 const void *data, enum GNUNET_BLOCK_Type type, 1326 const struct GNUNET_HashCode *key,
1300 uint32_t priority, uint32_t anonymity, 1327 size_t size,
1301 struct GNUNET_TIME_Absolute expiration, uint64_t uid) 1328 const void *data,
1329 enum GNUNET_BLOCK_Type type,
1330 uint32_t priority,
1331 uint32_t anonymity,
1332 struct GNUNET_TIME_Absolute expiration,
1333 uint64_t uid)
1302{ 1334{
1303 struct GSF_PendingRequest *pr = cls; 1335 struct GSF_PendingRequest *pr = cls;
1304 GSF_LocalLookupContinuation cont; 1336 GSF_LocalLookupContinuation cont;
@@ -1464,8 +1496,9 @@ process_local_reply (void *cls, const struct GNUNET_HashCode * key, size_t size,
1464 prq.priority = priority; 1496 prq.priority = priority;
1465 prq.request_found = GNUNET_NO; 1497 prq.request_found = GNUNET_NO;
1466 prq.anonymity_level = anonymity; 1498 prq.anonymity_level = anonymity;
1467 if ((old_rf == 0) && (pr->public_data.results_found == 0)) 1499 if ((0 == old_rf) && (0 == pr->public_data.results_found))
1468 GSF_update_datastore_delay_ (pr->public_data.start_time); 1500 GSF_update_datastore_delay_ (pr->public_data.start_time);
1501 prq.eo = GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO;
1469 process_reply (&prq, key, pr); 1502 process_reply (&prq, key, pr);
1470 pr->local_result = prq.eval; 1503 pr->local_result = prq.eval;
1471 if (prq.eval == GNUNET_BLOCK_EVALUATION_OK_LAST) 1504 if (prq.eval == GNUNET_BLOCK_EVALUATION_OK_LAST)
@@ -1473,7 +1506,8 @@ process_local_reply (void *cls, const struct GNUNET_HashCode * key, size_t size,
1473 GNUNET_STATISTICS_update (GSF_stats, 1506 GNUNET_STATISTICS_update (GSF_stats,
1474 gettext_noop 1507 gettext_noop
1475 ("# Datastore lookups concluded (found last result)"), 1508 ("# Datastore lookups concluded (found last result)"),
1476 1, GNUNET_NO); 1509 1,
1510 GNUNET_NO);
1477 goto check_error_and_continue; 1511 goto check_error_and_continue;
1478 } 1512 }
1479 if ((0 == (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data.options)) && 1513 if ((0 == (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data.options)) &&
@@ -1484,12 +1518,14 @@ process_local_reply (void *cls, const struct GNUNET_HashCode * key, size_t size,
1484 GNUNET_STATISTICS_update (GSF_stats, 1518 GNUNET_STATISTICS_update (GSF_stats,
1485 gettext_noop 1519 gettext_noop
1486 ("# Datastore lookups concluded (load too high)"), 1520 ("# Datastore lookups concluded (load too high)"),
1487 1, GNUNET_NO); 1521 1,
1522 GNUNET_NO);
1488 goto check_error_and_continue; 1523 goto check_error_and_continue;
1489 } 1524 }
1490 pr->qe_start = GNUNET_TIME_absolute_get (); 1525 pr->qe_start = GNUNET_TIME_absolute_get ();
1491 pr->warn_task = 1526 pr->warn_task =
1492 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &warn_delay_task, 1527 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
1528 &warn_delay_task,
1493 pr); 1529 pr);
1494 pr->qe = 1530 pr->qe =
1495 GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset++, 1531 GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset++,
@@ -1553,7 +1589,7 @@ check_error_and_continue:
1553 * 1589 *
1554 * @param pr request 1590 * @param pr request
1555 * @param target 1591 * @param target
1556 * @return GNUNET_YES if this request could be forwarded to the given peer 1592 * @return #GNUNET_YES if this request could be forwarded to the given peer
1557 */ 1593 */
1558int 1594int
1559GSF_pending_request_test_target_ (struct GSF_PendingRequest *pr, 1595GSF_pending_request_test_target_ (struct GSF_PendingRequest *pr,
@@ -1576,11 +1612,12 @@ GSF_pending_request_test_target_ (struct GSF_PendingRequest *pr,
1576 * 1612 *
1577 * @param pr the pending request to process 1613 * @param pr the pending request to process
1578 * @param cont function to call at the end 1614 * @param cont function to call at the end
1579 * @param cont_cls closure for cont 1615 * @param cont_cls closure for @a cont
1580 */ 1616 */
1581void 1617void
1582GSF_local_lookup_ (struct GSF_PendingRequest *pr, 1618GSF_local_lookup_ (struct GSF_PendingRequest *pr,
1583 GSF_LocalLookupContinuation cont, void *cont_cls) 1619 GSF_LocalLookupContinuation cont,
1620 void *cont_cls)
1584{ 1621{
1585 GNUNET_assert (NULL == pr->gh); 1622 GNUNET_assert (NULL == pr->gh);
1586 GNUNET_assert (NULL == pr->cadet_request); 1623 GNUNET_assert (NULL == pr->cadet_request);
@@ -1682,7 +1719,8 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp,
1682 return GNUNET_SYSERR; 1719 return GNUNET_SYSERR;
1683 } 1720 }
1684 GNUNET_STATISTICS_update (GSF_stats, 1721 GNUNET_STATISTICS_update (GSF_stats,
1685 gettext_noop ("# GAP PUT messages received"), 1, 1722 gettext_noop ("# GAP PUT messages received"),
1723 1,
1686 GNUNET_NO); 1724 GNUNET_NO);
1687 /* now, lookup 'query' */ 1725 /* now, lookup 'query' */
1688 prq.data = (const void *) &put[1]; 1726 prq.data = (const void *) &put[1];
@@ -1693,6 +1731,7 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp,
1693 prq.priority = 0; 1731 prq.priority = 0;
1694 prq.anonymity_level = UINT32_MAX; 1732 prq.anonymity_level = UINT32_MAX;
1695 prq.request_found = GNUNET_NO; 1733 prq.request_found = GNUNET_NO;
1734 prq.eo = GNUNET_BLOCK_EO_NONE;
1696 GNUNET_CONTAINER_multihashmap_get_multiple (pr_map, 1735 GNUNET_CONTAINER_multihashmap_get_multiple (pr_map,
1697 &query, 1736 &query,
1698 &process_reply, 1737 &process_reply,