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.c91
1 files changed, 48 insertions, 43 deletions
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c
index 63ae3a75f..ac183a980 100644
--- a/src/fs/gnunet-service-fs_pr.c
+++ b/src/fs/gnunet-service-fs_pr.c
@@ -216,10 +216,10 @@ refresh_bloomfilter (struct GSF_PendingRequest *pr)
216 if (pr->bf != NULL) 216 if (pr->bf != NULL)
217 GNUNET_CONTAINER_bloomfilter_free (pr->bf); 217 GNUNET_CONTAINER_bloomfilter_free (pr->bf);
218 pr->mingle = 218 pr->mingle =
219 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX); 219 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
220 pr->bf = GNUNET_BLOCK_construct_bloomfilter (pr->mingle, 220 pr->bf =
221 pr->replies_seen, 221 GNUNET_BLOCK_construct_bloomfilter (pr->mingle, pr->replies_seen,
222 pr->replies_seen_count); 222 pr->replies_seen_count);
223} 223}
224 224
225 225
@@ -319,7 +319,8 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
319 if (NULL != bf_data) 319 if (NULL != bf_data)
320 { 320 {
321 pr->bf = 321 pr->bf =
322 GNUNET_CONTAINER_bloomfilter_init (bf_data, bf_size, GNUNET_CONSTANTS_BLOOMFILTER_K); 322 GNUNET_CONTAINER_bloomfilter_init (bf_data, bf_size,
323 GNUNET_CONSTANTS_BLOOMFILTER_K);
323 pr->mingle = mingle; 324 pr->mingle = mingle;
324 } 325 }
325 else if ((replies_seen_count > 0) && 326 else if ((replies_seen_count > 0) &&
@@ -433,17 +434,16 @@ GSF_pending_request_update_ (struct GSF_PendingRequest *pr,
433 pr->mingle = 434 pr->mingle =
434 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX); 435 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
435 pr->bf = 436 pr->bf =
436 GNUNET_BLOCK_construct_bloomfilter (pr->mingle, 437 GNUNET_BLOCK_construct_bloomfilter (pr->mingle, replies_seen,
437 replies_seen, 438 replies_seen_count);
438 replies_seen_count); 439 }
439 }
440 else 440 else
441 { 441 {
442 for (i = 0; i < pr->replies_seen_count; i++) 442 for (i = 0; i < pr->replies_seen_count; i++)
443 { 443 {
444 GNUNET_BLOCK_mingle_hash (&replies_seen[i], pr->mingle, &mhash); 444 GNUNET_BLOCK_mingle_hash (&replies_seen[i], pr->mingle, &mhash);
445 GNUNET_CONTAINER_bloomfilter_add (pr->bf, &mhash); 445 GNUNET_CONTAINER_bloomfilter_add (pr->bf, &mhash);
446 } 446 }
447 } 447 }
448 } 448 }
449} 449}
@@ -970,10 +970,10 @@ static void
970handle_dht_reply (void *cls, struct GNUNET_TIME_Absolute exp, 970handle_dht_reply (void *cls, struct GNUNET_TIME_Absolute exp,
971 const GNUNET_HashCode * key, 971 const GNUNET_HashCode * key,
972 const struct GNUNET_PeerIdentity *get_path, 972 const struct GNUNET_PeerIdentity *get_path,
973 unsigned int get_path_length, 973 unsigned int get_path_length,
974 const struct GNUNET_PeerIdentity *put_path, 974 const struct GNUNET_PeerIdentity *put_path,
975 unsigned int put_path_length, 975 unsigned int put_path_length, enum GNUNET_BLOCK_Type type,
976 enum GNUNET_BLOCK_Type type, size_t size, const void *data) 976 size_t size, const void *data)
977{ 977{
978 struct GSF_PendingRequest *pr = cls; 978 struct GSF_PendingRequest *pr = cls;
979 struct ProcessReplyClosure prq; 979 struct ProcessReplyClosure prq;
@@ -1051,11 +1051,10 @@ GSF_dht_lookup_ (struct GSF_PendingRequest *pr)
1051 pr->gh = 1051 pr->gh =
1052 GNUNET_DHT_get_start (GSF_dht, GNUNET_TIME_UNIT_FOREVER_REL, 1052 GNUNET_DHT_get_start (GSF_dht, GNUNET_TIME_UNIT_FOREVER_REL,
1053 pr->public_data.type, &pr->public_data.query, 1053 pr->public_data.type, &pr->public_data.query,
1054 5 /* DEFAULT_GET_REPLICATION */, 1054 5 /* DEFAULT_GET_REPLICATION */ ,
1055 GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, 1055 GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
1056 /* FIXME: can no longer pass pr->bf/pr->mingle... */ 1056 /* FIXME: can no longer pass pr->bf/pr->mingle... */
1057 xquery, xquery_size, &handle_dht_reply, 1057 xquery, xquery_size, &handle_dht_reply, pr);
1058 pr);
1059} 1058}
1060 1059
1061 1060
@@ -1231,16 +1230,17 @@ process_local_reply (void *cls, const GNUNET_HashCode * key, size_t size,
1231 /* queue priority */ , 1230 /* queue priority */ ,
1232 (0 != 1231 (0 !=
1233 (GSF_PRO_PRIORITY_UNLIMITED & 1232 (GSF_PRO_PRIORITY_UNLIMITED &
1234 pr->public_data.options)) ? UINT_MAX : datastore_queue_size 1233 pr->public_data.options)) ? UINT_MAX :
1234 datastore_queue_size
1235 /* max queue size */ , 1235 /* max queue size */ ,
1236 GNUNET_TIME_UNIT_FOREVER_REL, 1236 GNUNET_TIME_UNIT_FOREVER_REL,
1237 &process_local_reply, pr); 1237 &process_local_reply, pr);
1238 if (NULL != pr->qe) 1238 if (NULL != pr->qe)
1239 return; /* we're done */ 1239 return; /* we're done */
1240 GNUNET_STATISTICS_update (GSF_stats, 1240 GNUNET_STATISTICS_update (GSF_stats,
1241 gettext_noop 1241 gettext_noop
1242 ("# Datastore lookups concluded (error queueing)"), 1242 ("# Datastore lookups concluded (error queueing)"),
1243 1, GNUNET_NO); 1243 1, GNUNET_NO);
1244 goto check_error_and_continue; 1244 goto check_error_and_continue;
1245 } 1245 }
1246 old_rf = pr->public_data.results_found; 1246 old_rf = pr->public_data.results_found;
@@ -1270,7 +1270,8 @@ process_local_reply (void *cls, const GNUNET_HashCode * key, size_t size,
1270 /* queue priority */ , 1270 /* queue priority */ ,
1271 (0 != 1271 (0 !=
1272 (GSF_PRO_PRIORITY_UNLIMITED & 1272 (GSF_PRO_PRIORITY_UNLIMITED &
1273 pr->public_data.options)) ? UINT_MAX : datastore_queue_size 1273 pr->public_data.options)) ? UINT_MAX :
1274 datastore_queue_size
1274 /* max queue size */ , 1275 /* max queue size */ ,
1275 GNUNET_TIME_UNIT_FOREVER_REL, 1276 GNUNET_TIME_UNIT_FOREVER_REL,
1276 &process_local_reply, pr); 1277 &process_local_reply, pr);
@@ -1329,7 +1330,8 @@ process_local_reply (void *cls, const GNUNET_HashCode * key, size_t size,
1329 /* queue priority */ , 1330 /* queue priority */ ,
1330 (0 != 1331 (0 !=
1331 (GSF_PRO_PRIORITY_UNLIMITED & pr-> 1332 (GSF_PRO_PRIORITY_UNLIMITED & pr->
1332 public_data.options)) ? UINT_MAX : datastore_queue_size 1333 public_data.options)) ? UINT_MAX :
1334 datastore_queue_size
1333 /* max queue size */ , 1335 /* max queue size */ ,
1334 GNUNET_TIME_UNIT_FOREVER_REL, 1336 GNUNET_TIME_UNIT_FOREVER_REL,
1335 &process_local_reply, pr); 1337 &process_local_reply, pr);
@@ -1353,21 +1355,24 @@ check_error_and_continue:
1353 1355
1354/** 1356/**
1355 * Is the given target a legitimate peer for forwarding the given request? 1357 * Is the given target a legitimate peer for forwarding the given request?
1356 * 1358 *
1357 * @param pr request 1359 * @param pr request
1358 * @param target 1360 * @param target
1359 * @return GNUNET_YES if this request could be forwarded to the given peer 1361 * @return GNUNET_YES if this request could be forwarded to the given peer
1360 */ 1362 */
1361int 1363int
1362GSF_pending_request_test_target_ (struct GSF_PendingRequest *pr, 1364GSF_pending_request_test_target_ (struct GSF_PendingRequest *pr,
1363 const struct GNUNET_PeerIdentity *target) 1365 const struct GNUNET_PeerIdentity *target)
1364{ 1366{
1365 struct GNUNET_PeerIdentity pi; 1367 struct GNUNET_PeerIdentity pi;
1366 1368
1367 if (0 == pr->origin_pid) 1369 if (0 == pr->origin_pid)
1368 return GNUNET_YES; 1370 return GNUNET_YES;
1369 GNUNET_PEER_resolve (pr->origin_pid, &pi); 1371 GNUNET_PEER_resolve (pr->origin_pid, &pi);
1370 return (0 == memcmp (&pi, target, sizeof (struct GNUNET_PeerIdentity))) ? GNUNET_NO :GNUNET_YES; 1372 return (0 ==
1373 memcmp (&pi, target,
1374 sizeof (struct GNUNET_PeerIdentity))) ? GNUNET_NO :
1375 GNUNET_YES;
1371} 1376}
1372 1377
1373 1378
@@ -1405,16 +1410,17 @@ GSF_local_lookup_ (struct GSF_PendingRequest *pr,
1405 /* queue priority */ , 1410 /* queue priority */ ,
1406 (0 != 1411 (0 !=
1407 (GSF_PRO_PRIORITY_UNLIMITED & pr-> 1412 (GSF_PRO_PRIORITY_UNLIMITED & pr->
1408 public_data.options)) ? UINT_MAX : datastore_queue_size 1413 public_data.options)) ? UINT_MAX :
1414 datastore_queue_size
1409 /* max queue size */ , 1415 /* max queue size */ ,
1410 GNUNET_TIME_UNIT_FOREVER_REL, 1416 GNUNET_TIME_UNIT_FOREVER_REL,
1411 &process_local_reply, pr); 1417 &process_local_reply, pr);
1412 if (NULL != pr->qe) 1418 if (NULL != pr->qe)
1413 return; 1419 return;
1414 GNUNET_STATISTICS_update (GSF_stats, 1420 GNUNET_STATISTICS_update (GSF_stats,
1415 gettext_noop 1421 gettext_noop
1416 ("# Datastore lookups concluded (error queueing)"), 1422 ("# Datastore lookups concluded (error queueing)"),
1417 1, GNUNET_NO); 1423 1, GNUNET_NO);
1418 GNUNET_SCHEDULER_cancel (pr->warn_task); 1424 GNUNET_SCHEDULER_cancel (pr->warn_task);
1419 pr->warn_task = GNUNET_SCHEDULER_NO_TASK; 1425 pr->warn_task = GNUNET_SCHEDULER_NO_TASK;
1420 pr->llc_cont = NULL; 1426 pr->llc_cont = NULL;
@@ -1566,10 +1572,8 @@ GSF_pending_request_init_ ()
1566 "MAX_PENDING_REQUESTS"); 1572 "MAX_PENDING_REQUESTS");
1567 } 1573 }
1568 if (GNUNET_OK != 1574 if (GNUNET_OK !=
1569 GNUNET_CONFIGURATION_get_value_number (GSF_cfg, 1575 GNUNET_CONFIGURATION_get_value_number (GSF_cfg, "core", "TOTAL_QUOTA_OUT",
1570 "core", 1576 &bps))
1571 "TOTAL_QUOTA_OUT",
1572 &bps))
1573 { 1577 {
1574 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1578 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1575 _ 1579 _
@@ -1578,9 +1582,10 @@ GSF_pending_request_init_ ()
1578 bps = 65536; 1582 bps = 65536;
1579 } 1583 }
1580 /* queue size should be #queries we can have pending and satisfy within 1584 /* queue size should be #queries we can have pending and satisfy within
1581 a carry interval: */ 1585 * a carry interval: */
1582 datastore_queue_size = bps * GNUNET_CONSTANTS_MAX_BANDWIDTH_CARRY_S / DBLOCK_SIZE; 1586 datastore_queue_size =
1583 1587 bps * GNUNET_CONSTANTS_MAX_BANDWIDTH_CARRY_S / DBLOCK_SIZE;
1588
1584 active_to_migration = 1589 active_to_migration =
1585 GNUNET_CONFIGURATION_get_value_yesno (GSF_cfg, "FS", "CONTENT_CACHING"); 1590 GNUNET_CONFIGURATION_get_value_yesno (GSF_cfg, "FS", "CONTENT_CACHING");
1586 datastore_put_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE); 1591 datastore_put_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE);