aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-service-fs_pr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-service-fs_pr.c')
-rw-r--r--src/fs/gnunet-service-fs_pr.c74
1 files changed, 51 insertions, 23 deletions
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c
index beb29a506..154c454ca 100644
--- a/src/fs/gnunet-service-fs_pr.c
+++ b/src/fs/gnunet-service-fs_pr.c
@@ -247,7 +247,8 @@ static unsigned long long max_pending_requests = (32 * 1024);
247 * @param pr request for which the BF is to be recomputed 247 * @param pr request for which the BF is to be recomputed
248 */ 248 */
249static void 249static void
250refresh_bloomfilter (enum GNUNET_BLOCK_Type type, struct GSF_PendingRequest *pr) 250refresh_bloomfilter (enum GNUNET_BLOCK_Type type,
251 struct GSF_PendingRequest *pr)
251{ 252{
252 if (NULL != pr->bg) 253 if (NULL != pr->bg)
253 { 254 {
@@ -406,7 +407,7 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
406 break; /* let the request live briefly... */ 407 break; /* let the request live briefly... */
407 if (NULL != dpr->rh) 408 if (NULL != dpr->rh)
408 dpr->rh (dpr->rh_cls, 409 dpr->rh (dpr->rh_cls,
409 GNUNET_BLOCK_EVALUATION_REQUEST_VALID, 410 GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED,
410 dpr, 411 dpr,
411 UINT32_MAX, 412 UINT32_MAX,
412 GNUNET_TIME_UNIT_FOREVER_ABS, 413 GNUNET_TIME_UNIT_FOREVER_ABS,
@@ -557,7 +558,10 @@ GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr)
557 k++; 558 k++;
558 } 559 }
559 if (GNUNET_OK != 560 if (GNUNET_OK !=
560 GNUNET_BLOCK_group_serialize (pr->bg, &bf_nonce, &bf_data, &bf_size)) 561 GNUNET_BLOCK_group_serialize (pr->bg,
562 &bf_nonce,
563 &bf_data,
564 &bf_size))
561 { 565 {
562 bf_size = 0; 566 bf_size = 0;
563 bf_data = NULL; 567 bf_data = NULL;
@@ -765,11 +769,6 @@ struct ProcessReplyClosure
765 enum GNUNET_BLOCK_Type type; 769 enum GNUNET_BLOCK_Type type;
766 770
767 /** 771 /**
768 * Control flags for evaluation.
769 */
770 enum GNUNET_BLOCK_EvaluationOptions eo;
771
772 /**
773 * How much was this reply worth to us? 772 * How much was this reply worth to us?
774 */ 773 */
775 uint32_t priority; 774 uint32_t priority;
@@ -850,7 +849,6 @@ process_reply (void *cls,
850 case GNUNET_BLOCK_REPLY_OK_MORE: 849 case GNUNET_BLOCK_REPLY_OK_MORE:
851 update_request_performance_data (prq, pr); 850 update_request_performance_data (prq, pr);
852 break; 851 break;
853
854 case GNUNET_BLOCK_REPLY_OK_LAST: 852 case GNUNET_BLOCK_REPLY_OK_LAST:
855 /* short cut: stop processing early, no BF-update, etc. */ 853 /* short cut: stop processing early, no BF-update, etc. */
856 update_request_performance_data (prq, pr); 854 update_request_performance_data (prq, pr);
@@ -885,7 +883,6 @@ process_reply (void *cls,
885 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 883 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
886 "Duplicate response, discarding.\n"); 884 "Duplicate response, discarding.\n");
887 return GNUNET_YES; /* duplicate */ 885 return GNUNET_YES; /* duplicate */
888
889 case GNUNET_BLOCK_REPLY_IRRELEVANT: 886 case GNUNET_BLOCK_REPLY_IRRELEVANT:
890 GNUNET_STATISTICS_update (GSF_stats, 887 GNUNET_STATISTICS_update (GSF_stats,
891 "# irrelevant replies discarded", 888 "# irrelevant replies discarded",
@@ -894,8 +891,6 @@ process_reply (void *cls,
894 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 891 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
895 "Irrelevant response, ignoring.\n"); 892 "Irrelevant response, ignoring.\n");
896 return GNUNET_YES; 893 return GNUNET_YES;
897 case GNUNET_BLOCK_REPLY_INVALID:
898 return GNUNET_YES;
899 case GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED: 894 case GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED:
900 GNUNET_break (0); /* bad installation? */ 895 GNUNET_break (0); /* bad installation? */
901 return GNUNET_NO; 896 return GNUNET_NO;
@@ -1127,8 +1122,9 @@ handle_dht_reply (void *cls,
1127 prq.expiration); 1122 prq.expiration);
1128 prq.size = size; 1123 prq.size = size;
1129 prq.type = type; 1124 prq.type = type;
1130 prq.eo = GNUNET_BLOCK_EO_NONE; 1125 process_reply (&prq,
1131 process_reply (&prq, key, pr); 1126 key,
1127 pr);
1132 if ((GNUNET_YES == active_to_migration) && 1128 if ((GNUNET_YES == active_to_migration) &&
1133 (GNUNET_NO == test_put_load_too_high (prq.priority))) 1129 (GNUNET_NO == test_put_load_too_high (prq.priority)))
1134 { 1130 {
@@ -1229,6 +1225,15 @@ cadet_reply_proc (void *cls,
1229 struct GNUNET_HashCode query; 1225 struct GNUNET_HashCode query;
1230 1226
1231 pr->cadet_request = NULL; 1227 pr->cadet_request = NULL;
1228 if (GNUNET_OK !=
1229 GNUNET_BLOCK_check_block (GSF_block_ctx,
1230 type,
1231 data,
1232 data_size))
1233 {
1234 GNUNET_break_op (0);
1235 return;
1236 }
1232 if (GNUNET_BLOCK_TYPE_ANY == type) 1237 if (GNUNET_BLOCK_TYPE_ANY == type)
1233 { 1238 {
1234 GNUNET_break (NULL == data); 1239 GNUNET_break (NULL == data);
@@ -1247,7 +1252,11 @@ cadet_reply_proc (void *cls,
1247 return; 1252 return;
1248 } 1253 }
1249 if (GNUNET_YES != 1254 if (GNUNET_YES !=
1250 GNUNET_BLOCK_get_key (GSF_block_ctx, type, data, data_size, &query)) 1255 GNUNET_BLOCK_get_key (GSF_block_ctx,
1256 type,
1257 data,
1258 data_size,
1259 &query))
1251 { 1260 {
1252 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1261 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1253 "Failed to derive key for block of type %d\n", 1262 "Failed to derive key for block of type %d\n",
@@ -1268,8 +1277,9 @@ cadet_reply_proc (void *cls,
1268 prq.expiration); 1277 prq.expiration);
1269 prq.size = data_size; 1278 prq.size = data_size;
1270 prq.type = type; 1279 prq.type = type;
1271 prq.eo = GNUNET_BLOCK_EO_NONE; 1280 process_reply (&prq,
1272 process_reply (&prq, &query, pr); 1281 &query,
1282 pr);
1273} 1283}
1274 1284
1275 1285
@@ -1611,7 +1621,11 @@ called_from_on_demand:
1611 prq.expiration = expiration; 1621 prq.expiration = expiration;
1612 prq.size = size; 1622 prq.size = size;
1613 if (GNUNET_OK != 1623 if (GNUNET_OK !=
1614 GNUNET_BLOCK_get_key (GSF_block_ctx, type, data, size, &query)) 1624 GNUNET_BLOCK_get_key (GSF_block_ctx,
1625 type,
1626 data,
1627 size,
1628 &query))
1615 { 1629 {
1616 GNUNET_break (0); 1630 GNUNET_break (0);
1617 GNUNET_DATASTORE_remove (GSF_dsh, 1631 GNUNET_DATASTORE_remove (GSF_dsh,
@@ -1631,8 +1645,9 @@ called_from_on_demand:
1631 prq.anonymity_level = anonymity; 1645 prq.anonymity_level = anonymity;
1632 if ((0 == old_rf) && (0 == pr->public_data.results_found)) 1646 if ((0 == old_rf) && (0 == pr->public_data.results_found))
1633 GSF_update_datastore_delay_ (pr->public_data.start_time); 1647 GSF_update_datastore_delay_ (pr->public_data.start_time);
1634 prq.eo = GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO; 1648 process_reply (&prq,
1635 process_reply (&prq, key, pr); 1649 key,
1650 pr);
1636 pr->local_result = prq.eval; 1651 pr->local_result = prq.eval;
1637 if (GNUNET_BLOCK_REPLY_OK_LAST == prq.eval) 1652 if (GNUNET_BLOCK_REPLY_OK_LAST == prq.eval)
1638 { 1653 {
@@ -1720,7 +1735,8 @@ GSF_local_lookup_ (struct GSF_PendingRequest *pr,
1720 * @param put the actual message 1735 * @param put the actual message
1721 */ 1736 */
1722void 1737void
1723handle_p2p_put (void *cls, const struct PutMessage *put) 1738handle_p2p_put (void *cls,
1739 const struct PutMessage *put)
1724{ 1740{
1725 struct GSF_ConnectedPeer *cp = cls; 1741 struct GSF_ConnectedPeer *cp = cls;
1726 uint16_t msize; 1742 uint16_t msize;
@@ -1746,7 +1762,20 @@ handle_p2p_put (void *cls, const struct PutMessage *put)
1746 GNUNET_TIME_UNIT_YEARS), 1762 GNUNET_TIME_UNIT_YEARS),
1747 expiration); 1763 expiration);
1748 if (GNUNET_OK != 1764 if (GNUNET_OK !=
1749 GNUNET_BLOCK_get_key (GSF_block_ctx, type, &put[1], dsize, &query)) 1765 GNUNET_BLOCK_check_block (GSF_block_ctx,
1766 type,
1767 &put[1],
1768 dsize))
1769 {
1770 GNUNET_break_op (0);
1771 return;
1772 }
1773 if (GNUNET_OK !=
1774 GNUNET_BLOCK_get_key (GSF_block_ctx,
1775 type,
1776 &put[1],
1777 dsize,
1778 &query))
1750 { 1779 {
1751 GNUNET_break_op (0); 1780 GNUNET_break_op (0);
1752 return; 1781 return;
@@ -1764,7 +1793,6 @@ handle_p2p_put (void *cls, const struct PutMessage *put)
1764 prq.priority = 0; 1793 prq.priority = 0;
1765 prq.anonymity_level = UINT32_MAX; 1794 prq.anonymity_level = UINT32_MAX;
1766 prq.request_found = GNUNET_NO; 1795 prq.request_found = GNUNET_NO;
1767 prq.eo = GNUNET_BLOCK_EO_NONE;
1768 GNUNET_CONTAINER_multihashmap_get_multiple (pr_map, 1796 GNUNET_CONTAINER_multihashmap_get_multiple (pr_map,
1769 &query, 1797 &query,
1770 &process_reply, 1798 &process_reply,