API to handle pending requests. More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_load_lib.h"
#include "gnunet-service-fs.h"
#include "gnunet-service-fs_cp.h"
#include "gnunet-service-fs_indexing.h"
#include "gnunet-service-fs_pe.h"
#include "gnunet-service-fs_pr.h"
#include "gnunet-service-fs_cadet.h"
Go to the source code of this file.
Data Structures | |
struct | GSF_PendingRequest |
An active request. More... | |
struct | ProcessReplyClosure |
Closure for process_reply() function. More... | |
struct | PutMigrationContext |
Context for put_migration_continuation(). More... | |
Macros | |
#define | DHT_GET_REPLICATION 5 |
Desired replication level for GETs. More... | |
#define | MAX_DATASTORE_QUEUE (16 * MAX_QUEUE_PER_PEER) |
Maximum size of the datastore queue for P2P operations. More... | |
#define | CONTENT_BANDWIDTH_VALUE 800 |
Bandwidth value of a 0-priority content (must be fairly high compared to query since content is typically significantly larger – and more valuable since it can take many queries to get one piece of content). More... | |
#define | MAX_RESULTS (100 * 1024) |
Hard limit on the number of results we may get from the datastore per query. More... | |
#define | INSANE_STATISTICS GNUNET_NO |
Collect an instance number of statistics? May cause excessive IPC. More... | |
#define | CADET_RETRY_MAX 3 |
If obtaining a block via cadet fails, how often do we retry it before giving up for good (and sticking to non-anonymous transfer)? More... | |
Functions | |
static void | refresh_bloomfilter (enum GNUNET_BLOCK_Type type, struct GSF_PendingRequest *pr) |
Recalculate our bloom filter for filtering replies. More... | |
struct GSF_PendingRequest * | GSF_pending_request_create_ (enum GSF_PendingRequestOptions options, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *query, const struct GNUNET_PeerIdentity *target, const char *bf_data, size_t bf_size, uint32_t anonymity_level, uint32_t priority, int32_t ttl, GNUNET_PEER_Id sender_pid, GNUNET_PEER_Id origin_pid, const struct GNUNET_HashCode *replies_seen, unsigned int replies_seen_count, GSF_PendingRequestReplyHandler rh, void *rh_cls) |
Create a new pending request. More... | |
struct GSF_PendingRequestData * | GSF_pending_request_get_data_ (struct GSF_PendingRequest *pr) |
Obtain the public data associated with a pending request. More... | |
int | GSF_pending_request_is_compatible_ (struct GSF_PendingRequest *pra, struct GSF_PendingRequest *prb) |
Test if two pending requests are compatible (would generate the same query modulo filters and should thus be processed jointly). More... | |
void | GSF_pending_request_update_ (struct GSF_PendingRequest *pr, const struct GNUNET_HashCode *replies_seen, unsigned int replies_seen_count) |
Update a given pending request with additional replies that have been seen. More... | |
struct GNUNET_MQ_Envelope * | GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr) |
Generate the message corresponding to the given pending request for transmission to other peers. More... | |
static int | clean_request (void *cls, const struct GNUNET_HashCode *key, void *value) |
Iterator to free pending requests. More... | |
void | GSF_pending_request_cancel_ (struct GSF_PendingRequest *pr, int full_cleanup) |
Explicitly cancel a pending request. More... | |
void | GSF_iterate_pending_requests_ (GSF_PendingRequestIterator it, void *cls) |
Iterate over all pending requests. More... | |
static void | update_request_performance_data (struct ProcessReplyClosure *prq, struct GSF_PendingRequest *pr) |
Update the performance data for the sender (if any) since the sender successfully answered one of our queries. More... | |
static enum GNUNET_GenericReturnValue | process_reply (void *cls, const struct GNUNET_HashCode *key, void *value) |
We have received a reply; handle it! More... | |
static void | put_migration_continuation (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) |
Continuation called to notify client about result of the operation. More... | |
static int | test_put_load_too_high (uint32_t priority) |
Test if the DATABASE (PUT) load on this peer is too high to even consider processing the query at all. More... | |
static void | handle_dht_reply (void *cls, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const struct GNUNET_PeerIdentity *trunc_peer, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *put_path, unsigned int put_path_length, enum GNUNET_BLOCK_Type type, size_t size, const void *data) |
Iterator called on each result obtained for a DHT operation that expects a reply. More... | |
void | GSF_dht_lookup_ (struct GSF_PendingRequest *pr) |
Consider looking up the data in the DHT (anonymity-level permitting). More... | |
static void | cadet_reply_proc (void *cls, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute expiration, size_t data_size, const void *data) |
Function called with a reply from the cadet. More... | |
void | GSF_cadet_lookup_ (struct GSF_PendingRequest *pr) |
Consider downloading via cadet (if possible) More... | |
static void | warn_delay_task (void *cls) |
Task that issues a warning if the datastore lookup takes too long. More... | |
static void | odc_warn_delay_task (void *cls) |
Task that issues a warning if the datastore lookup takes too long. More... | |
static void | call_continuation (struct GSF_PendingRequest *pr) |
static void | no_more_local_results (struct GSF_PendingRequest *pr) |
static void | process_local_reply (void *cls, const struct GNUNET_HashCode *key, size_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, uint64_t uid) |
We're processing (local) results for a search request from another peer. More... | |
static void | start_local_query (struct GSF_PendingRequest *pr, uint64_t next_uid, bool random) |
int | GSF_pending_request_test_target_ (struct GSF_PendingRequest *pr, const struct GNUNET_PeerIdentity *target) |
Is the given target a legitimate peer for forwarding the given request? More... | |
void | GSF_local_lookup_ (struct GSF_PendingRequest *pr, GSF_LocalLookupContinuation cont, void *cont_cls) |
Look up the request in the local datastore. More... | |
void | handle_p2p_put (void *cls, const struct PutMessage *put) |
Handle P2P "CONTENT" message. More... | |
int | GSF_pending_request_test_active_ (struct GSF_PendingRequest *pr) |
Check if the given request is still active. More... | |
void | GSF_pending_request_init_ () |
Setup the subsystem. More... | |
void | GSF_pending_request_done_ () |
Shutdown the subsystem. More... | |
Variables | |
static struct GNUNET_CONTAINER_MultiHashMap * | pr_map |
All pending requests, ordered by the query. More... | |
static struct GNUNET_LOAD_Value * | datastore_put_load |
Datastore 'PUT' load tracking. More... | |
static int | active_to_migration |
Are we allowed to migrate content to this peer. More... | |
static struct GNUNET_CONTAINER_Heap * | requests_by_expiration_heap |
Heap with the request that will expire next at the top. More... | |
static unsigned long long | max_pending_requests = (32 * 1024) |
Maximum number of requests (from other peers, overall) that we're willing to have pending at any given point in time. More... | |
API to handle pending requests.
Definition in file gnunet-service-fs_pr.c.
#define DHT_GET_REPLICATION 5 |
Desired replication level for GETs.
Definition at line 40 of file gnunet-service-fs_pr.c.
#define MAX_DATASTORE_QUEUE (16 * MAX_QUEUE_PER_PEER) |
Maximum size of the datastore queue for P2P operations.
Needs to be large enough to queue MAX_QUEUE_PER_PEER operations for roughly the number of active (connected) peers.
Definition at line 47 of file gnunet-service-fs_pr.c.
#define CONTENT_BANDWIDTH_VALUE 800 |
Bandwidth value of a 0-priority content (must be fairly high compared to query since content is typically significantly larger – and more valuable since it can take many queries to get one piece of content).
Definition at line 55 of file gnunet-service-fs_pr.c.
#define MAX_RESULTS (100 * 1024) |
Hard limit on the number of results we may get from the datastore per query.
Definition at line 60 of file gnunet-service-fs_pr.c.
#define INSANE_STATISTICS GNUNET_NO |
Collect an instance number of statistics? May cause excessive IPC.
Definition at line 65 of file gnunet-service-fs_pr.c.
#define CADET_RETRY_MAX 3 |
If obtaining a block via cadet fails, how often do we retry it before giving up for good (and sticking to non-anonymous transfer)?
Definition at line 71 of file gnunet-service-fs_pr.c.
|
static |
Recalculate our bloom filter for filtering replies.
This function will create a new bloom filter from scratch, so it should only be called if we have no bloomfilter at all (and hence can create a fresh one of minimal size without problems) OR if our peer is the initiator (in which case we may resize to larger than minimum size).
type | type of the request |
pr | request for which the BF is to be recomputed |
Definition at line 250 of file gnunet-service-fs_pr.c.
References GSF_PendingRequest::bg, GNUNET_BLOCK_group_create(), GNUNET_BLOCK_group_destroy(), GNUNET_BLOCK_group_set_seen(), GNUNET_BLOCK_TYPE_FS_UBLOCK, GNUNET_break, GNUNET_OK, GSF_block_ctx, GSF_PendingRequest::replies_seen, GSF_PendingRequest::replies_seen_count, and type.
Referenced by GSF_pending_request_create_(), and GSF_pending_request_update_().
struct GSF_PendingRequest * GSF_pending_request_create_ | ( | enum GSF_PendingRequestOptions | options, |
enum GNUNET_BLOCK_Type | type, | ||
const struct GNUNET_HashCode * | query, | ||
const struct GNUNET_PeerIdentity * | target, | ||
const char * | bf_data, | ||
size_t | bf_size, | ||
uint32_t | anonymity_level, | ||
uint32_t | priority, | ||
int32_t | ttl, | ||
GNUNET_PEER_Id | sender_pid, | ||
GNUNET_PEER_Id | origin_pid, | ||
const struct GNUNET_HashCode * | replies_seen, | ||
unsigned int | replies_seen_count, | ||
GSF_PendingRequestReplyHandler | rh, | ||
void * | rh_cls | ||
) |
Create a new pending request.
options | request options |
type | type of the block that is being requested |
query | key for the lookup |
target | preferred target for the request, NULL for none |
bf_data | raw data for bloom filter for known replies, can be NULL |
bf_size | number of bytes in bf_data |
anonymity_level | desired anonymity level |
priority | maximum outgoing cumulative request priority to use |
ttl | current time-to-live for the request |
sender_pid | peer ID to use for the sender when forwarding, 0 for none; reference counter is taken over by this function |
origin_pid | peer ID of origin of query (do not loop back) |
replies_seen | hash codes of known local replies |
replies_seen_count | size of the 'replies_seen' array |
rh | handle to call when we get a reply |
rh_cls | closure for rh |
Definition at line 278 of file gnunet-service-fs_pr.c.
References GNUNET_TIME_Absolute::abs_value_us, anonymity_level, GSF_PendingRequestData::anonymity_level, GSF_PendingRequest::bg, gettext_noop, GNUNET_assert, GNUNET_BLOCK_group_create(), GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED, GNUNET_BLOCK_TYPE_ANY, GNUNET_BLOCK_TYPE_FS_UBLOCK, GNUNET_CONTAINER_heap_get_size(), GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_heap_peek(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_new_array, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_subtract(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_SECONDS, GNUNET_YES, GSF_block_ctx, GSF_pending_request_cancel_(), GSF_PRO_BLOOMFILTER_FULL_REFRESH, GSF_PRO_FORWARD_ONLY, GSF_PRO_REQUEST_NEVER_EXPIRES, GSF_stats, GSF_PendingRequest::hnode, max_pending_requests, options, GSF_PendingRequestData::options, GSF_PendingRequest::origin_pid, GSF_PendingRequestData::original_priority, pr_map, GSF_PendingRequestData::priority, GSF_PendingRequest::public_data, GSF_PendingRequestData::query, refresh_bloomfilter(), GSF_PendingRequest::replies_seen, GSF_PendingRequest::replies_seen_count, GSF_PendingRequest::replies_seen_size, requests_by_expiration_heap, GSF_PendingRequest::rh, GSF_PendingRequest::rh_cls, GSF_PendingRequest::sender_pid, GSF_PendingRequestData::start_time, GSF_PendingRequestData::target, ttl, GSF_PendingRequestData::ttl, type, and GSF_PendingRequestData::type.
Referenced by handle_client_start_search(), and handle_p2p_get().
struct GSF_PendingRequestData * GSF_pending_request_get_data_ | ( | struct GSF_PendingRequest * | pr | ) |
Obtain the public data associated with a pending request.
pr | pending request |
Definition at line 410 of file gnunet-service-fs_pr.c.
References GSF_PendingRequest::public_data.
Referenced by client_response_handler(), free_pending_request(), get_latest(), get_rp_key(), GSF_plan_add_(), GSF_plan_notify_peer_disconnect_(), GSF_plan_notify_request_done_(), handle_client_start_search(), handle_p2p_get(), handle_p2p_reply(), merge_pr(), peer_request_destroy(), plan(), start_p2p_processing(), and test_exist_cb().
int GSF_pending_request_is_compatible_ | ( | struct GSF_PendingRequest * | pra, |
struct GSF_PendingRequest * | prb | ||
) |
Test if two pending requests are compatible (would generate the same query modulo filters and should thus be processed jointly).
pra | a pending request |
prb | another pending request |
Definition at line 426 of file gnunet-service-fs_pr.c.
References GNUNET_NO, GNUNET_OK, GSF_PendingRequest::public_data, GSF_PendingRequestData::query, and GSF_PendingRequestData::type.
Referenced by merge_pr().
void GSF_pending_request_update_ | ( | struct GSF_PendingRequest * | pr, |
const struct GNUNET_HashCode * | replies_seen, | ||
unsigned int | replies_seen_count | ||
) |
Update a given pending request with additional replies that have been seen.
pr | request to update |
replies_seen | hash codes of replies that we've seen |
replies_seen_count | size of the replies_seen array |
Definition at line 439 of file gnunet-service-fs_pr.c.
References GSF_PendingRequest::bg, GSF_PendingRequest::gh, GNUNET_array_grow, GNUNET_BLOCK_group_set_seen(), GNUNET_break, GNUNET_DHT_get_filter_known_results(), GNUNET_memcpy, GNUNET_OK, GSF_PRO_BLOOMFILTER_FULL_REFRESH, GSF_PendingRequestData::options, GSF_PendingRequest::public_data, refresh_bloomfilter(), GSF_PendingRequest::replies_seen, GSF_PendingRequest::replies_seen_count, GSF_PendingRequest::replies_seen_size, and GSF_PendingRequestData::type.
Referenced by handle_client_start_search(), and process_reply().
struct GNUNET_MQ_Envelope * GSF_pending_request_get_message_ | ( | struct GSF_PendingRequest * | pr | ) |
Generate the message corresponding to the given pending request for transmission to other peers.
pr | request to generate the message for |
Definition at line 489 of file gnunet-service-fs_pr.c.
References GNUNET_TIME_Absolute::abs_value_us, GSF_PendingRequest::bg, env, GET_MESSAGE_BIT_RETURN_TO, GET_MESSAGE_BIT_TRANSMIT_TO, GNUNET_BLOCK_group_serialize(), GNUNET_break, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_FS_GET, GNUNET_MQ_msg_extra, GNUNET_OK, GNUNET_PEER_resolve(), GNUNET_TIME_absolute_get(), GNUNET_YES, GSF_PRO_FORWARD_ONLY, GetMessage::hash_bitmap, GSF_PendingRequestData::num_transmissions, GSF_PendingRequestData::options, GetMessage::priority, GSF_PendingRequestData::priority, GSF_PendingRequest::public_data, GetMessage::query, GSF_PendingRequestData::query, GetMessage::reserved, GSF_PendingRequestData::respect_offered, GSF_PendingRequest::sender_pid, GSF_PendingRequestData::target, ttl, GetMessage::ttl, GSF_PendingRequestData::ttl, GetMessage::type, and GSF_PendingRequestData::type.
Referenced by schedule_peer_transmission().
|
static |
Iterator to free pending requests.
cls | closure, unused |
key | current key code |
value | value in the hash map (pending request) |
Definition at line 573 of file gnunet-service-fs_pr.c.
References GSF_PendingRequest::bg, GSF_PendingRequest::cadet_request, GSF_PendingRequest::cadet_retry_count, CADET_RETRY_MAX, gettext_noop, GSF_PendingRequest::gh, GNUNET_assert, GNUNET_BLOCK_group_destroy(), GNUNET_CONTAINER_heap_remove_node(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_DATASTORE_cancel(), GNUNET_DHT_get_stop(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_PEER_change_rc(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_update(), GNUNET_YES, GSF_cadet_query_cancel(), GSF_plan_notify_request_done_(), GSF_stats, GSF_PendingRequest::hnode, key, GSF_PendingRequest::llc_cont, GSF_PendingRequest::llc_cont_cls, GSF_PendingRequest::local_result, GSF_PendingRequest::origin_pid, pr_map, GSF_PendingRequest::public_data, GSF_PendingRequest::qe, GSF_PendingRequestData::query, GSF_PendingRequest::replies_seen, GSF_PendingRequest::sender_pid, value, and GSF_PendingRequest::warn_task.
Referenced by GSF_pending_request_cancel_(), and GSF_pending_request_done_().
void GSF_pending_request_cancel_ | ( | struct GSF_PendingRequest * | pr, |
int | full_cleanup | ||
) |
Explicitly cancel a pending request.
pr | request to cancel |
full_cleanup | fully purge the request |
Definition at line 641 of file gnunet-service-fs_pr.c.
References GSF_PendingRequest::cadet_request, GSF_PendingRequest::cadet_retry_count, CADET_RETRY_MAX, clean_request(), GSF_PendingRequest::gh, GNUNET_assert, GNUNET_DATASTORE_cancel(), GNUNET_DHT_get_stop(), GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_YES, GSF_cadet_query_cancel(), GSF_plan_notify_request_done_(), GSF_PendingRequest::llc_cont, GSF_PendingRequest::llc_cont_cls, GSF_PendingRequest::local_result, pr_map, GSF_PendingRequest::public_data, GSF_PendingRequest::qe, GSF_PendingRequestData::query, GSF_PendingRequest::rh, and GSF_PendingRequest::warn_task.
Referenced by cancel_pending_request(), client_request_destroy(), GSF_pending_request_create_(), and test_exist_cb().
void GSF_iterate_pending_requests_ | ( | GSF_PendingRequestIterator | it, |
void * | cls | ||
) |
Iterate over all pending requests.
it | function to call for each request |
cls | closure for it |
Definition at line 690 of file gnunet-service-fs_pr.c.
References GNUNET_CONTAINER_multihashmap_iterate(), and pr_map.
Referenced by GSF_peer_connect_handler().
|
static |
Update the performance data for the sender (if any) since the sender successfully answered one of our queries.
prq | information about the sender |
pr | request that was satisfied |
Definition at line 759 of file gnunet-service-fs_pr.c.
References GSF_peer_update_performance_(), ProcessReplyClosure::priority, GSF_PendingRequest::public_data, ProcessReplyClosure::sender, and GSF_PendingRequestData::start_time.
Referenced by process_reply().
|
static |
We have received a reply; handle it!
cls | response (a struct ProcessReplyClosure ) |
key | our query |
value | value in the hash map (info about the query) |
Definition at line 779 of file gnunet-service-fs_pr.c.
References ProcessReplyClosure::anonymity_level, GSF_PendingRequest::bg, ProcessReplyClosure::data, ProcessReplyClosure::eval, ProcessReplyClosure::expiration, gettext_noop, GNUNET_BLOCK_check_reply(), GNUNET_BLOCK_REPLY_IRRELEVANT, GNUNET_BLOCK_REPLY_OK_DUPLICATE, GNUNET_BLOCK_REPLY_OK_LAST, GNUNET_BLOCK_REPLY_OK_MORE, GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED, GNUNET_break, GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_LOAD_update(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_YES, GSF_block_ctx, GSF_dht_lookup_(), GSF_pending_request_update_(), GSF_request_plan_reference_get_last_transmission_(), GSF_rt_entry_lifetime, GSF_stats, key, GSF_PendingRequestData::original_priority, GSF_PendingRequestData::pr_head, ProcessReplyClosure::priority, GSF_PendingRequestData::priority, GSF_PendingRequest::public_data, GNUNET_TIME_Relative::rel_value_us, ProcessReplyClosure::request_found, GSF_PendingRequestData::results_found, GSF_PendingRequest::rh, GSF_PendingRequest::rh_cls, ProcessReplyClosure::sender, ProcessReplyClosure::size, GSF_PendingRequestData::start_time, ProcessReplyClosure::type, update_request_performance_data(), and value.
Referenced by cadet_reply_proc(), handle_dht_reply(), handle_p2p_put(), and process_local_reply().
|
static |
Continuation called to notify client about result of the operation.
cls | closure |
success | GNUNET_SYSERR on failure |
min_expiration | minimum expiration time required for content to be stored |
msg | NULL on success, otherwise an error message |
Definition at line 934 of file gnunet-service-fs_pr.c.
References GNUNET_TIME_Absolute::abs_value_us, datastore_put_load, gettext_noop, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u64(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_LOAD_update(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_max(), GNUNET_TIME_relative_min(), GNUNET_TIME_relative_saturating_multiply(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_HOURS, GNUNET_TIME_UNIT_MINUTES, GNUNET_TIME_UNIT_SECONDS, GNUNET_YES, GSF_block_peer_migration_(), GSF_get_peer_performance_data_(), GSF_peer_get_(), GSF_stats, GSF_PeerPerformanceData::migration_delay, min_expiration, PutMigrationContext::origin, GNUNET_TIME_Relative::rel_value_us, PutMigrationContext::requested, and PutMigrationContext::start.
Referenced by handle_dht_reply(), and handle_p2p_put().
|
static |
Test if the DATABASE (PUT) load on this peer is too high to even consider processing the query at all.
priority | the priority of the item |
Definition at line 1019 of file gnunet-service-fs_pr.c.
References datastore_put_load, gettext_noop, GNUNET_LOAD_get_average(), GNUNET_LOAD_get_load(), GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, and GSF_stats.
Referenced by handle_dht_reply(), and handle_p2p_put().
|
static |
Iterator called on each result obtained for a DHT operation that expects a reply.
cls | closure |
exp | when will this value expire |
key | key of the result |
trunc_peer | truncated peer, NULL for none |
get_path | peers on reply path (or NULL if not recorded) |
get_path_length | number of entries in get_path |
put_path | peers on the PUT path (or NULL if not recorded) |
put_path_length | number of entries in get_path |
type | type of the result |
size | number of bytes in data |
data | pointer to the result data |
Definition at line 1056 of file gnunet-service-fs_pr.c.
References active_to_migration, data, ProcessReplyClosure::data, ProcessReplyClosure::expiration, gettext_noop, GNUNET_DATASTORE_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_min(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_YEARS, GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_YES, GSF_dsh, GSF_stats, key, MAX_DATASTORE_QUEUE, ProcessReplyClosure::priority, process_reply(), put_migration_continuation(), PutMigrationContext::requested, size, ProcessReplyClosure::size, PutMigrationContext::start, test_put_load_too_high(), type, and ProcessReplyClosure::type.
Referenced by GSF_dht_lookup_().
void GSF_dht_lookup_ | ( | struct GSF_PendingRequest * | pr | ) |
Consider looking up the data in the DHT (anonymity-level permitting).
pr | the pending request to process |
Definition at line 1128 of file gnunet-service-fs_pr.c.
References GSF_PendingRequestData::anonymity_level, DHT_GET_REPLICATION, GSF_PendingRequest::gh, GNUNET_ALIGN, GNUNET_assert, GNUNET_DHT_get_filter_known_results(), GNUNET_DHT_get_start(), GNUNET_DHT_get_stop(), GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, GNUNET_memcpy, GNUNET_PEER_resolve(), GSF_dht, GSF_PRO_FORWARD_ONLY, handle_dht_reply(), GSF_PendingRequestData::options, GSF_PendingRequest::public_data, GSF_PendingRequestData::query, GSF_PendingRequest::replies_seen, GSF_PendingRequest::replies_seen_count, GSF_PendingRequest::sender_pid, and GSF_PendingRequestData::type.
Referenced by process_reply(), and start_p2p_processing().
|
static |
Function called with a reply from the cadet.
cls | the pending request struct |
type | type of the block, ANY on error |
expiration | expiration time for the block |
data_size | number of bytes in data, 0 on error |
data | reply block data, NULL on error |
Definition at line 1177 of file gnunet-service-fs_pr.c.
References cadet_reply_proc(), GSF_PendingRequest::cadet_request, GSF_PendingRequest::cadet_retry_count, CADET_RETRY_MAX, data, ProcessReplyClosure::data, data_size, expiration, ProcessReplyClosure::expiration, gettext_noop, GNUNET_BLOCK_check_block(), GNUNET_BLOCK_get_key(), GNUNET_BLOCK_TYPE_ANY, GNUNET_break, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_min(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_YEARS, GNUNET_YES, GSF_block_ctx, GSF_cadet_query(), GSF_stats, process_reply(), GSF_PendingRequest::public_data, GSF_PendingRequestData::query, ProcessReplyClosure::size, GSF_PendingRequestData::target, type, ProcessReplyClosure::type, and GSF_PendingRequestData::type.
Referenced by cadet_reply_proc(), and GSF_cadet_lookup_().
void GSF_cadet_lookup_ | ( | struct GSF_PendingRequest * | pr | ) |
Consider downloading via cadet (if possible)
pr | the pending request to process |
Definition at line 1252 of file gnunet-service-fs_pr.c.
References GSF_PendingRequestData::anonymity_level, cadet_reply_proc(), GSF_PendingRequest::cadet_request, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GSF_cadet_query(), GSF_PendingRequest::public_data, GSF_PendingRequestData::query, GSF_PendingRequestData::target, and GSF_PendingRequestData::type.
Referenced by start_p2p_processing().
|
static |
Task that issues a warning if the datastore lookup takes too long.
cls | the struct GSF_PendingRequest |
Definition at line 1278 of file gnunet-service-fs_pr.c.
References _, GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_UNIT_MINUTES, GNUNET_YES, GSF_PendingRequest::qe_start, warn_delay_task(), and GSF_PendingRequest::warn_task.
Referenced by start_local_query(), and warn_delay_task().
|
static |
Task that issues a warning if the datastore lookup takes too long.
cls | the struct GSF_PendingRequest |
Definition at line 1299 of file gnunet-service-fs_pr.c.
References _, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_UNIT_MINUTES, GNUNET_YES, odc_warn_delay_task(), GSF_PendingRequest::qe_start, and GSF_PendingRequest::warn_task.
Referenced by odc_warn_delay_task(), and process_local_reply().
|
static |
Definition at line 1316 of file gnunet-service-fs_pr.c.
References GNUNET_assert, GNUNET_BLOCK_REPLY_OK_LAST, GNUNET_BLOCK_TYPE_ANY, GNUNET_SCHEDULER_cancel(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_ZERO_ABS, GSF_PRO_LOCAL_ONLY, GSF_PendingRequest::llc_cont, GSF_PendingRequest::llc_cont_cls, GSF_PendingRequest::local_result, GSF_PendingRequestData::options, GSF_PendingRequest::public_data, GSF_PendingRequest::qe, GSF_PendingRequest::rh, GSF_PendingRequest::rh_cls, and GSF_PendingRequest::warn_task.
Referenced by no_more_local_results(), process_local_reply(), and start_local_query().
|
static |
Definition at line 1362 of file gnunet-service-fs_pr.c.
References call_continuation(), gettext_noop, GNUNET_BLOCK_TYPE_FS_DBLOCK, GNUNET_BLOCK_TYPE_FS_IBLOCK, GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GSF_stats, GSF_PendingRequest::public_data, and GSF_PendingRequestData::type.
Referenced by process_local_reply().
|
static |
We're processing (local) results for a search request from another peer.
Pass applicable results to the peer and if we are done either clean up (operation complete) or forward to other peers (more results possible).
cls | our closure (struct GSF_PendingRequest * ) |
key | key for the content |
size | number of bytes in data |
data | content stored |
type | type of the content |
priority | priority of the content |
anonymity | anonymity-level for the content |
replication | replication-level for the content |
expiration | expiration time for the content |
uid | unique identifier for the datum; maybe 0 if no unique identifier is available |
Definition at line 1459 of file gnunet-service-fs_pr.c.
References anonymity, ProcessReplyClosure::anonymity_level, call_continuation(), data, ProcessReplyClosure::data, ProcessReplyClosure::eval, expiration, ProcessReplyClosure::expiration, GSF_PendingRequest::first_uid, gettext_noop, GNUNET_assert, GNUNET_BLOCK_get_key(), GNUNET_BLOCK_REPLY_OK_LAST, GNUNET_BLOCK_TYPE_FS_ONDEMAND, GNUNET_break, GNUNET_DATASTORE_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_handle_on_demand_block(), GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_MINUTES, GNUNET_YES, GSF_block_ctx, GSF_dsh, GSF_PRO_PRIORITY_UNLIMITED, GSF_stats, GSF_test_get_load_too_high_(), GSF_update_datastore_delay_(), GSF_PendingRequest::have_first_uid, key, GSF_PendingRequest::local_result, MAX_RESULTS, no_more_local_results(), odc_warn_delay_task(), GSF_PendingRequestData::options, ProcessReplyClosure::priority, GSF_PendingRequestData::priority, process_local_reply(), process_reply(), GSF_PendingRequest::public_data, GSF_PendingRequest::qe, GSF_PendingRequest::qe_start, replication, ProcessReplyClosure::request_found, GSF_PendingRequest::result_count, GSF_PendingRequestData::results_found, GSF_PendingRequest::seen_null, size, ProcessReplyClosure::size, start_local_query(), GSF_PendingRequestData::start_time, type, ProcessReplyClosure::type, and GSF_PendingRequest::warn_task.
Referenced by process_local_reply(), and start_local_query().
|
static |
Definition at line 1395 of file gnunet-service-fs_pr.c.
References call_continuation(), gettext_noop, GNUNET_BLOCK_TYPE_ANY, GNUNET_BLOCK_TYPE_FS_DBLOCK, GNUNET_DATASTORE_get_key(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_MINUTES, GSF_datastore_queue_size, GSF_dsh, GSF_PRO_PRIORITY_UNLIMITED, GSF_stats, GSF_PendingRequestData::options, process_local_reply(), GSF_PendingRequest::public_data, GSF_PendingRequest::qe, GSF_PendingRequest::qe_start, GSF_PendingRequestData::query, GSF_PendingRequestData::type, warn_delay_task(), and GSF_PendingRequest::warn_task.
Referenced by GSF_local_lookup_(), and process_local_reply().
int GSF_pending_request_test_target_ | ( | struct GSF_PendingRequest * | pr, |
const struct GNUNET_PeerIdentity * | target | ||
) |
Is the given target a legitimate peer for forwarding the given request?
pr | request |
target |
Definition at line 1647 of file gnunet-service-fs_pr.c.
References GNUNET_NO, GNUNET_PEER_resolve(), GNUNET_YES, and GSF_PendingRequest::origin_pid.
Referenced by consider_peer_for_forwarding(), and consider_request_for_forwarding().
void GSF_local_lookup_ | ( | struct GSF_PendingRequest * | pr, |
GSF_LocalLookupContinuation | cont, | ||
void * | cont_cls | ||
) |
Look up the request in the local datastore.
pr | the pending request to process |
cont | function to call at the end |
cont_cls | closure for cont |
Definition at line 1669 of file gnunet-service-fs_pr.c.
References GSF_PendingRequest::cadet_request, gettext_noop, GSF_PendingRequest::gh, GNUNET_assert, GNUNET_NO, GNUNET_STATISTICS_update(), GSF_stats, GSF_PendingRequest::llc_cont, GSF_PendingRequest::llc_cont_cls, and start_local_query().
Referenced by handle_client_start_search(), and handle_p2p_get().
void handle_p2p_put | ( | void * | cls, |
const struct PutMessage * | put | ||
) |
Handle P2P "CONTENT" message.
Checks that the message is well-formed and then checks if there are any pending requests for this content and possibly passes it on (to local clients or other peers). Does NOT perform migration (content caching at this peer).
cls | the other peer involved |
put | the actual message |
Definition at line 1698 of file gnunet-service-fs_pr.c.
References active_to_migration, ProcessReplyClosure::anonymity_level, CONTENT_BANDWIDTH_VALUE, ProcessReplyClosure::data, datastore_put_load, expiration, PutMessage::expiration, ProcessReplyClosure::expiration, gettext_noop, GNUNET_assert, GNUNET_BLOCK_check_block(), GNUNET_BLOCK_get_key(), GNUNET_break_op, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_DATASTORE_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_i2s(), GNUNET_LOAD_get_load(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_PEER_resolve(), GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_min(), GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_TIME_UNIT_YEARS, GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_YES, GSF_block_ctx, GSF_block_peer_migration_(), GSF_connected_peer_change_preference_(), GSF_cover_content_count, GSF_dsh, GSF_get_peer_performance_data_(), GSF_stats, PutMessage::header, MAX_DATASTORE_QUEUE, PutMigrationContext::origin, pid, pr_map, ProcessReplyClosure::priority, process_reply(), put_migration_continuation(), ProcessReplyClosure::request_found, PutMigrationContext::requested, GSF_PeerPerformanceData::respect, ProcessReplyClosure::sender, GNUNET_MessageHeader::size, ProcessReplyClosure::size, PutMigrationContext::start, test_put_load_too_high(), type, PutMessage::type, and ProcessReplyClosure::type.
int GSF_pending_request_test_active_ | ( | struct GSF_PendingRequest * | pr | ) |
Check if the given request is still active.
pr | pending request |
Definition at line 1840 of file gnunet-service-fs_pr.c.
References GNUNET_NO, GNUNET_YES, and GSF_PendingRequest::rh.
Referenced by consider_peer_for_forwarding(), get_latest(), GSF_consider_forwarding(), GSF_plan_add_(), and merge_pr().
void GSF_pending_request_init_ | ( | void | ) |
Setup the subsystem.
Definition at line 1850 of file gnunet-service-fs_pr.c.
References active_to_migration, DATASTORE_LOAD_AUTODECLINE, datastore_put_load, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONTAINER_heap_create(), GNUNET_CONTAINER_HEAP_ORDER_MIN, GNUNET_CONTAINER_multihashmap_create(), GNUNET_ERROR_TYPE_INFO, GNUNET_LOAD_value_init(), GNUNET_log_config_missing(), GNUNET_OK, GNUNET_YES, GSF_cfg, max_pending_requests, pr_map, and requests_by_expiration_heap.
Referenced by run().
void GSF_pending_request_done_ | ( | void | ) |
Shutdown the subsystem.
Definition at line 1875 of file gnunet-service-fs_pr.c.
References clean_request(), datastore_put_load, GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_LOAD_value_free, pr_map, and requests_by_expiration_heap.
Referenced by shutdown_task().
|
static |
All pending requests, ordered by the query.
Entries are of type 'struct GSF_PendingRequest*'.
Definition at line 205 of file gnunet-service-fs_pr.c.
Referenced by clean_request(), GSF_iterate_pending_requests_(), GSF_pending_request_cancel_(), GSF_pending_request_create_(), GSF_pending_request_done_(), GSF_pending_request_init_(), and handle_p2p_put().
|
static |
Datastore 'PUT' load tracking.
Definition at line 211 of file gnunet-service-fs_pr.c.
Referenced by GSF_pending_request_done_(), GSF_pending_request_init_(), handle_p2p_put(), put_migration_continuation(), and test_put_load_too_high().
|
static |
Are we allowed to migrate content to this peer.
Definition at line 217 of file gnunet-service-fs_pr.c.
Referenced by GSF_pending_request_init_(), handle_dht_reply(), and handle_p2p_put().
|
static |
Heap with the request that will expire next at the top.
Contains pointers of type "struct PendingRequest*"; these will also be aliased from the "requests_by_peer" data structures and the "requests_by_query" table. Note that requests from our clients don't expire and are thus NOT in the "requests_by_expiration" (or the "requests_by_peer" tables).
Definition at line 228 of file gnunet-service-fs_pr.c.
Referenced by GSF_pending_request_create_(), GSF_pending_request_done_(), and GSF_pending_request_init_().
|
static |
Maximum number of requests (from other peers, overall) that we're willing to have pending at any given point in time.
Can be changed via the configuration file (32k is just the default).
Definition at line 236 of file gnunet-service-fs_pr.c.
Referenced by GSF_pending_request_create_(), and GSF_pending_request_init_().