GNUnet  0.11.x
Data Structures | Macros | Functions | Variables
gnunet-service-fs_pr.c File Reference

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"
Include dependency graph for gnunet-service-fs_pr.c:

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 valueable 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 instane 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_PendingRequestGSF_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 mingle, 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_PendingRequestDataGSF_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_EnvelopeGSF_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 int 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 *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *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_MultiHashMappr_map
 All pending requests, ordered by the query. More...
 
static struct GNUNET_LOAD_Valuedatastore_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_Heaprequests_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...
 

Detailed Description

API to handle pending requests.

Author
Christian Grothoff

Definition in file gnunet-service-fs_pr.c.

Macro Definition Documentation

◆ DHT_GET_REPLICATION

#define DHT_GET_REPLICATION   5

Desired replication level for GETs.

Definition at line 40 of file gnunet-service-fs_pr.c.

Referenced by GSF_dht_lookup_().

◆ MAX_DATASTORE_QUEUE

#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.

Referenced by handle_dht_reply(), and handle_p2p_put().

◆ CONTENT_BANDWIDTH_VALUE

#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 valueable since it can take many queries to get one piece of content).

Definition at line 55 of file gnunet-service-fs_pr.c.

Referenced by handle_p2p_put().

◆ MAX_RESULTS

#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.

Referenced by process_local_reply().

◆ INSANE_STATISTICS

#define INSANE_STATISTICS   GNUNET_NO

Collect an instane number of statistics? May cause excessive IPC.

Definition at line 65 of file gnunet-service-fs_pr.c.

◆ CADET_RETRY_MAX

#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.

Referenced by cadet_reply_proc(), clean_request(), and GSF_pending_request_cancel_().

Function Documentation

◆ refresh_bloomfilter()

static void refresh_bloomfilter ( enum GNUNET_BLOCK_Type  type,
struct GSF_PendingRequest pr 
)
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 mimimum size).

Parameters
typetype of the request
prrequest 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_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_OK, GSF_block_ctx, GSF_PendingRequest::replies_seen, and GSF_PendingRequest::replies_seen_count.

Referenced by GSF_pending_request_create_(), and GSF_pending_request_update_().

251 {
252  if (NULL != pr->bg)
253  {
255  pr->bg = NULL;
256  }
258  return; /* no need */
259  pr->bg =
261  type,
264  UINT32_MAX),
265  NULL,
266  0,
267  "seen-set-size",
268  pr->replies_seen_count,
269  NULL);
270  if (NULL == pr->bg)
271  return;
274  pr->replies_seen,
275  pr->replies_seen_count));
276 }
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
unsigned int replies_seen_count
Number of valid entries in the 'replies_seen' array.
struct GNUNET_BLOCK_Context * GSF_block_ctx
Our block context.
Type of a block representing any type of search result (universal).
struct GNUNET_BLOCK_Group * GNUNET_BLOCK_group_create(struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, uint32_t nonce, const void *raw_data, size_t raw_data_size,...)
Create a new block group.
Definition: block.c:289
struct GNUNET_BLOCK_Group * bg
Block group for filtering replies we've already seen.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
struct GNUNET_HashCode * replies_seen
Array of hash codes of replies we've already seen.
void GNUNET_BLOCK_group_destroy(struct GNUNET_BLOCK_Group *bg)
Destroy resources used by a block group.
Definition: block.c:205
int GNUNET_BLOCK_group_set_seen(struct GNUNET_BLOCK_Group *bg, const struct GNUNET_HashCode *seen_results, unsigned int seen_results_count)
Update block group to filter out the given results.
Definition: block.c:409
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_pending_request_create_()

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  mingle,
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.

Parameters
optionsrequest options
typetype of the block that is being requested
querykey for the lookup
targetpreferred target for the request, NULL for none
bf_dataraw data for bloom filter for known replies, can be NULL
bf_sizenumber of bytes in bf_data
minglemingle value for bf
anonymity_leveldesired anonymity level
prioritymaximum outgoing cummulative request priority to use
ttlcurrent time-to-live for the request
sender_pidpeer ID to use for the sender when forwarding, 0 for none
origin_pidpeer ID of origin of query (do not loop back)
replies_seenhash codes of known local replies
replies_seen_countsize of the replies_seen array
rhhandle to call when we get a reply
rh_clsclosure for rh
Returns
handle for the new pending request

Definition at line 301 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_EVALUATION_REQUEST_VALID, GNUNET_BLOCK_group_create(), 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, 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, GSF_PendingRequest::rh, GSF_PendingRequest::rh_cls, GSF_PendingRequest::sender_pid, GSF_PendingRequestData::start_time, GSF_PendingRequestData::target, GSF_PendingRequestData::ttl, type, and GSF_PendingRequestData::type.

Referenced by handle_client_start_search(), and handle_p2p_get().

317 {
318  struct GSF_PendingRequest *pr;
319  struct GSF_PendingRequest *dpr;
320  size_t extra;
321  struct GNUNET_HashCode *eptr;
322 
324  "Creating request handle for `%s' of type %d\n",
325  GNUNET_h2s (query),
326  type);
327 #if INSANE_STATISTICS
329  gettext_noop ("# Pending requests created"),
330  1,
331  GNUNET_NO);
332 #endif
333  extra = 0;
334  if (NULL != target)
335  extra += sizeof(struct GNUNET_PeerIdentity);
336  pr = GNUNET_malloc (sizeof(struct GSF_PendingRequest) + extra);
337  pr->public_data.query = *query;
338  eptr = (struct GNUNET_HashCode *) &pr[1];
339  if (NULL != target)
340  {
341  pr->public_data.target = (struct GNUNET_PeerIdentity *) eptr;
342  GNUNET_memcpy (eptr, target, sizeof(struct GNUNET_PeerIdentity));
343  }
345  pr->public_data.priority = priority;
346  pr->public_data.original_priority = priority;
348  pr->public_data.type = type;
350  pr->sender_pid = sender_pid;
351  pr->origin_pid = origin_pid;
352  pr->rh = rh;
353  pr->rh_cls = rh_cls;
354  GNUNET_assert ((sender_pid != 0) || (0 == (options & GSF_PRO_FORWARD_ONLY)));
355  if (ttl >= 0)
358  else
362  (uint32_t) (-ttl)));
363  if (replies_seen_count > 0)
364  {
365  pr->replies_seen_size = replies_seen_count;
366  pr->replies_seen =
369  replies_seen,
370  replies_seen_count * sizeof(struct GNUNET_HashCode));
371  pr->replies_seen_count = replies_seen_count;
372  }
373  if ((NULL != bf_data) &&
375  {
377  pr->public_data.type,
378  mingle,
379  bf_data,
380  bf_size,
381  "seen-set-size",
382  0,
383  NULL);
384  }
385  else if ((replies_seen_count > 0) &&
387  {
389  }
391  &pr->public_data.query,
392  pr,
395  {
397  pr,
399  /* make sure we don't track too many requests */
402  {
404  GNUNET_assert (NULL != dpr);
405  if (pr == dpr)
406  break; /* let the request live briefly... */
407  if (NULL != dpr->rh)
408  dpr->rh (dpr->rh_cls,
410  dpr,
411  UINT32_MAX,
415  NULL,
416  0);
418  }
419  }
421  gettext_noop ("# Pending requests active"),
422  1,
423  GNUNET_NO);
424  return pr;
425 }
const struct GNUNET_PeerIdentity * target
Identity of a peer hosting the content, otherwise NULl.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_subtract(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Subtract a given relative duration from the given start time.
Definition: time.c:422
Request is allowed to refresh bloomfilter and change mingle value.
Any type of block, used as a wildcard when searching.
struct GNUNET_CONTAINER_HeapNode * GNUNET_CONTAINER_heap_insert(struct GNUNET_CONTAINER_Heap *heap, void *element, GNUNET_CONTAINER_HeapCostType cost)
Inserts a new element into the heap.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_TIME_Absolute ttl
Current TTL for the request.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:246
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_TIME_UNIT_SECONDS
One second.
uint32_t anonymity_level
Desired anonymity level.
static struct GNUNET_CONTAINER_Heap * requests_by_expiration_heap
Heap with the request that will expire next at the top.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static struct GNUNET_CONTAINER_MultiHashMap * pr_map
All pending requests, ordered by the query.
struct GSF_PendingRequestData public_data
Public data for the request.
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
#define GNUNET_NO
Definition: gnunet_common.h:78
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
struct GNUNET_TIME_Absolute start_time
When did we start with the request.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static void refresh_bloomfilter(enum GNUNET_BLOCK_Type type, struct GSF_PendingRequest *pr)
Recalculate our bloom filter for filtering replies.
uint64_t abs_value_us
The actual value.
static unsigned int anonymity_level
Anonymity level option to use for publishing.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
struct GNUNET_HashCode query
Primary query hash for this request.
unsigned int replies_seen_count
Number of valid entries in the 'replies_seen' array.
Request persists indefinitely (no expiration).
GNUNET_PEER_Id origin_pid
Identity of the peer that we should never forward this query to since it originated this query (0 for...
static unsigned long long max_pending_requests
Maximum number of requests (from other peers, overall) that we're willing to have pending at any give...
struct GNUNET_BLOCK_Context * GSF_block_ctx
Our block context.
void * GNUNET_CONTAINER_heap_peek(const struct GNUNET_CONTAINER_Heap *heap)
Get element stored at the root of heap.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
void * rh_cls
Closure for rh.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:442
enum GNUNET_BLOCK_Type type
Type of the requested block.
Type of a block representing any type of search result (universal).
A 512-bit hashcode.
GSF_PendingRequestReplyHandler rh
Function to call if we encounter a reply.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
unsigned int GNUNET_CONTAINER_heap_get_size(const struct GNUNET_CONTAINER_Heap *heap)
Get the current size of the heap.
uint32_t original_priority
Priority that this request (originally) had for us.
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_BLOCK_Group * GNUNET_BLOCK_group_create(struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, uint32_t nonce, const void *raw_data, size_t raw_data_size,...)
Create a new block group.
Definition: block.c:289
Allow multiple values with the same key.
unsigned int replies_seen_size
Length of the 'replies_seen' array.
The identity of the host (wraps the signing key of the peer).
enum GSF_PendingRequestOptions options
Options for the request.
Request must only be forwarded (no routing)
struct GNUNET_BLOCK_Group * bg
Block group for filtering replies we've already seen.
#define GNUNET_log(kind,...)
struct GNUNET_CONTAINER_HeapNode * hnode
Entry for this pending request in the expiration heap, or NULL.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
#define GNUNET_YES
Definition: gnunet_common.h:77
uint32_t priority
Priority that this request (still) has for us.
An active request.
void GSF_pending_request_cancel_(struct GSF_PendingRequest *pr, int full_cleanup)
Explicitly cancel a pending request.
Query is valid, no reply given.
GNUNET_PEER_Id sender_pid
Identity of the peer that we should use for the 'sender' (recipient of the response) when forwarding ...
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_HashCode * replies_seen
Array of hash codes of replies we've already seen.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_pending_request_get_data_()

struct GSF_PendingRequestData* GSF_pending_request_get_data_ ( struct GSF_PendingRequest pr)

Obtain the public data associated with a pending request.

Parameters
prpending request
Returns
associated public data

Definition at line 435 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().

436 {
437  return &pr->public_data;
438 }
struct GSF_PendingRequestData public_data
Public data for the request.
Here is the caller graph for this function:

◆ GSF_pending_request_is_compatible_()

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).

Parameters
praa pending request
prbanother pending request
Returns
GNUNET_OK if the requests are compatible

Definition at line 451 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().

453 {
454  if ((pra->public_data.type != prb->public_data.type) ||
455  (0 != memcmp (&pra->public_data.query,
456  &prb->public_data.query,
457  sizeof(struct GNUNET_HashCode))))
458  return GNUNET_NO;
459  return GNUNET_OK;
460 }
struct GSF_PendingRequestData public_data
Public data for the request.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct GNUNET_HashCode query
Primary query hash for this request.
enum GNUNET_BLOCK_Type type
Type of the requested block.
A 512-bit hashcode.
Here is the caller graph for this function:

◆ GSF_pending_request_update_()

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.

Parameters
prrequest to update
replies_seenhash codes of replies that we've seen
replies_seen_countsize of the replies_seen array

Definition at line 472 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().

475 {
476  if (replies_seen_count + pr->replies_seen_count < pr->replies_seen_count)
477  return; /* integer overflow */
479  {
480  /* we're responsible for the BF, full refresh */
481  if (replies_seen_count + pr->replies_seen_count > pr->replies_seen_size)
483  pr->replies_seen_size,
484  replies_seen_count + pr->replies_seen_count);
486  replies_seen,
487  sizeof(struct GNUNET_HashCode) * replies_seen_count);
488  pr->replies_seen_count += replies_seen_count;
490  }
491  else
492  {
493  if (NULL == pr->bg)
494  {
495  /* we're not the initiator, but the initiator did not give us
496  * any bloom-filter, so we need to create one on-the-fly */
498  }
499  else
500  {
503  replies_seen,
504  pr->replies_seen_count));
505  }
506  }
507  if (NULL != pr->gh)
509  replies_seen_count,
510  replies_seen);
511 }
Request is allowed to refresh bloomfilter and change mingle value.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GSF_PendingRequestData public_data
Public data for the request.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static void refresh_bloomfilter(enum GNUNET_BLOCK_Type type, struct GSF_PendingRequest *pr)
Recalculate our bloom filter for filtering replies.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
unsigned int replies_seen_count
Number of valid entries in the &#39;replies_seen&#39; array.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
enum GNUNET_BLOCK_Type type
Type of the requested block.
A 512-bit hashcode.
struct GNUNET_DHT_GetHandle * gh
DHT request handle for this request (or NULL for none).
void GNUNET_DHT_get_filter_known_results(struct GNUNET_DHT_GetHandle *get_handle, unsigned int num_results, const struct GNUNET_HashCode *results)
Tell the DHT not to return any of the following known results to this client.
Definition: dht_api.c:1126
unsigned int replies_seen_size
Length of the &#39;replies_seen&#39; array.
enum GSF_PendingRequestOptions options
Options for the request.
struct GNUNET_BLOCK_Group * bg
Block group for filtering replies we&#39;ve already seen.
struct GNUNET_HashCode * replies_seen
Array of hash codes of replies we&#39;ve already seen.
int GNUNET_BLOCK_group_set_seen(struct GNUNET_BLOCK_Group *bg, const struct GNUNET_HashCode *seen_results, unsigned int seen_results_count)
Update block group to filter out the given results.
Definition: block.c:409
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_pending_request_get_message_()

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.

Parameters
prrequest to generate the message for
Returns
envelope with the request message

Definition at line 522 of file gnunet-service-fs_pr.c.

References GNUNET_TIME_Absolute::abs_value_us, GSF_PendingRequest::bg, env, GetMessage::filter_mutator, 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_non_null, 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, GSF_PendingRequestData::respect_offered, GSF_PendingRequest::sender_pid, GSF_PendingRequestData::target, GSF_PendingRequestData::ttl, GetMessage::ttl, GSF_PendingRequestData::type, and GetMessage::type.

Referenced by schedule_peer_transmission().

523 {
524  struct GNUNET_MQ_Envelope *env;
525  struct GetMessage *gm;
526  struct GNUNET_PeerIdentity *ext;
527  unsigned int k;
528  uint32_t bm;
529  uint32_t prio;
530  size_t bf_size;
531  struct GNUNET_TIME_Absolute now;
532  int64_t ttl;
533  int do_route;
534  void *bf_data;
535  uint32_t bf_nonce;
536 
538  "Building request message for `%s' of type %d\n",
540  pr->public_data.type);
541  k = 0;
542  bm = 0;
543  do_route = (0 == (pr->public_data.options & GSF_PRO_FORWARD_ONLY));
544  if ((! do_route) && (pr->sender_pid == 0))
545  {
546  GNUNET_break (0);
547  do_route = GNUNET_YES;
548  }
549  if (! do_route)
550  {
552  k++;
553  }
554  if (NULL != pr->public_data.target)
555  {
557  k++;
558  }
559  if (GNUNET_OK !=
560  GNUNET_BLOCK_group_serialize (pr->bg, &bf_nonce, &bf_data, &bf_size))
561  {
562  bf_size = 0;
563  bf_data = NULL;
564  }
565  env = GNUNET_MQ_msg_extra (gm,
566  bf_size + k * sizeof(struct GNUNET_PeerIdentity),
568  gm->type = htonl (pr->public_data.type);
569  if (do_route)
571  pr->public_data.priority + 1);
572  else
573  prio = 0;
574  pr->public_data.priority -= prio;
576  pr->public_data.respect_offered += prio;
577  gm->priority = htonl (prio);
578  now = GNUNET_TIME_absolute_get ();
579  ttl = (int64_t) (pr->public_data.ttl.abs_value_us - now.abs_value_us);
580  gm->ttl = htonl (ttl / 1000LL / 1000LL);
581  gm->filter_mutator = htonl (bf_nonce);
582  gm->hash_bitmap = htonl (bm);
583  gm->query = pr->public_data.query;
584  ext = (struct GNUNET_PeerIdentity *) &gm[1];
585  k = 0;
586  if (! do_route)
587  GNUNET_PEER_resolve (pr->sender_pid, &ext[k++]);
588  if (NULL != pr->public_data.target)
589  ext[k++] = *pr->public_data.target;
590  GNUNET_memcpy (&ext[k], bf_data, bf_size);
591  GNUNET_free_non_null (bf_data);
592  return env;
593 }
const struct GNUNET_PeerIdentity * target
Identity of a peer hosting the content, otherwise NULl.
uint32_t num_transmissions
Counter for how often this request has been transmitted (estimate, because we might have the same req...
#define GET_MESSAGE_BIT_TRANSMIT_TO
The peer identity of a peer that had claimed to have the content previously is included (can be used ...
int32_t ttl
Relative time to live in MILLISECONDS (network byte order)
uint32_t priority
How important is this request (network byte order)
struct GNUNET_TIME_Absolute ttl
Current TTL for the request.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GSF_PendingRequestData public_data
Public data for the request.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
void GNUNET_PEER_resolve(GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid)
Convert an interned PID to a normal peer identity.
Definition: peer.c:225
uint64_t abs_value_us
The actual value.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
uint32_t filter_mutator
The content hash should be mutated using this value before checking against the bloomfilter (used to ...
struct GNUNET_HashCode query
Primary query hash for this request.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
Message to the datastore service asking about specific content.
Definition: datastore.h:140
uint32_t hash_bitmap
Which of the optional hash codes are present at the end of the message? See GET_MESSAGE_BIT_xx consta...
struct GNUNET_HashCode query
Hashcodes of the file(s) we&#39;re looking for.
#define GET_MESSAGE_BIT_RETURN_TO
The peer identity of a peer waiting for the reply is included (used if the response should be transmi...
uint32_t respect_offered
How much respect did we (in total) offer for this request so far (estimate, because we might have the...
enum GNUNET_BLOCK_Type type
Type of the requested block.
int GNUNET_BLOCK_group_serialize(struct GNUNET_BLOCK_Group *bg, uint32_t *nonce, void **raw_data, size_t *raw_data_size)
Serialize state of a block group.
Definition: block.c:180
uint32_t type
Desired content type.
Definition: datastore.h:150
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
The identity of the host (wraps the signing key of the peer).
enum GSF_PendingRequestOptions options
Options for the request.
Request must only be forwarded (no routing)
struct GNUNET_BLOCK_Group * bg
Block group for filtering replies we&#39;ve already seen.
#define GNUNET_log(kind,...)
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:77
uint32_t priority
Priority that this request (still) has for us.
#define GNUNET_MESSAGE_TYPE_FS_GET
P2P request for content (one FS to another).
GNUNET_PEER_Id sender_pid
Identity of the peer that we should use for the &#39;sender&#39; (recipient of the response) when forwarding ...
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clean_request()

static int clean_request ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Iterator to free pending requests.

Parameters
clsclosure, unused
keycurrent key code
valuevalue in the hash map (pending request)
Returns
GNUNET_YES (we should continue to iterate)

Definition at line 605 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_free_non_null, 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, GSF_PendingRequest::llc_cont, GSF_PendingRequest::llc_cont_cls, GSF_PendingRequest::local_result, GSF_PendingRequest::origin_pid, 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_().

606 {
607  struct GSF_PendingRequest *pr = value;
609 
611  "Cleaning up pending request for `%s'.\n",
612  GNUNET_h2s (key));
613  if (NULL != pr->cadet_request)
614  {
617  pr->cadet_request = NULL;
618  }
619  if (NULL != (cont = pr->llc_cont))
620  {
621  pr->llc_cont = NULL;
622  cont (pr->llc_cont_cls, pr, pr->local_result);
623  }
627  pr->bg = NULL;
629  pr->sender_pid = 0;
631  pr->origin_pid = 0;
632  if (NULL != pr->hnode)
633  {
635  pr->hnode = NULL;
636  }
637  if (NULL != pr->qe)
638  {
640  pr->qe = NULL;
641  }
642  if (NULL != pr->gh)
643  {
644  GNUNET_DHT_get_stop (pr->gh);
645  pr->gh = NULL;
646  }
647  if (NULL != pr->warn_task)
648  {
650  pr->warn_task = NULL;
651  }
652  GNUNET_assert (
653  GNUNET_OK ==
656  gettext_noop ("# Pending requests active"),
657  -1,
658  GNUNET_NO);
659  GNUNET_free (pr);
660  return GNUNET_YES;
661 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_SCHEDULER_Task * warn_task
Task that warns us if the local datastore lookup takes too long.
static struct GNUNET_CONTAINER_MultiHashMap * pr_map
All pending requests, ordered by the query.
struct GSF_PendingRequestData public_data
Public data for the request.
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
GSF_LocalLookupContinuation llc_cont
Function to call upon completion of the local get request, or NULL for none.
struct GNUNET_HashCode query
Primary query hash for this request.
void(* GSF_LocalLookupContinuation)(void *cls, struct GSF_PendingRequest *pr, enum GNUNET_BLOCK_EvaluationResult result)
Function to be called after we&#39;re done processing replies from the local lookup.
GNUNET_PEER_Id origin_pid
Identity of the peer that we should never forward this query to since it originated this query (0 for...
enum GNUNET_BLOCK_EvaluationResult local_result
Last result from the local datastore lookup evaluation.
static char * value
Value of the record to add/remove.
void * llc_cont_cls
Closure for llc_cont.
int GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
void GNUNET_DHT_get_stop(struct GNUNET_DHT_GetHandle *get_handle)
Stop async DHT-get.
Definition: dht_api.c:1155
struct GNUNET_DHT_GetHandle * gh
DHT request handle for this request (or NULL for none).
void GSF_plan_notify_request_done_(struct GSF_PendingRequest *pr)
Notify the plan about a request being done; destroy all entries associated with this request...
#define CADET_RETRY_MAX
If obtaining a block via cadet fails, how often do we retry it before giving up for good (and stickin...
unsigned int cadet_retry_count
How often have we retried this request via &#39;cadet&#39;? (used to bound overall retries).
void GNUNET_DATASTORE_cancel(struct GNUNET_DATASTORE_QueueEntry *qe)
Cancel a datastore operation.
struct GNUNET_DATASTORE_QueueEntry * qe
Datastore queue entry for this request (or NULL for none).
void GSF_cadet_query_cancel(struct GSF_CadetRequest *sr)
Cancel an active request; must not be called after &#39;proc&#39; was calld.
struct GNUNET_BLOCK_Group * bg
Block group for filtering replies we&#39;ve already seen.
void GNUNET_PEER_change_rc(GNUNET_PEER_Id id, int delta)
Change the reference counter of an interned PID.
Definition: peer.c:197
#define GNUNET_log(kind,...)
struct GNUNET_CONTAINER_HeapNode * hnode
Entry for this pending request in the expiration heap, or NULL.
#define GNUNET_YES
Definition: gnunet_common.h:77
An active request.
struct GSF_CadetRequest * cadet_request
Cadet request handle for this request (or NULL for none).
void * GNUNET_CONTAINER_heap_remove_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
GNUNET_PEER_Id sender_pid
Identity of the peer that we should use for the &#39;sender&#39; (recipient of the response) when forwarding ...
struct GNUNET_HashCode * replies_seen
Array of hash codes of replies we&#39;ve already seen.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_BLOCK_group_destroy(struct GNUNET_BLOCK_Group *bg)
Destroy resources used by a block group.
Definition: block.c:205
#define gettext_noop(String)
Definition: gettext.h:69
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_pending_request_cancel_()

void GSF_pending_request_cancel_ ( struct GSF_PendingRequest pr,
int  full_cleanup 
)

Explicitly cancel a pending request.

Parameters
prrequest to cancel
full_cleanupfully purge the request

Definition at line 671 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, 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().

672 {
674 
675  if (NULL == pr_map)
676  return; /* already cleaned up! */
677  if (GNUNET_NO == full_cleanup)
678  {
679  /* make request inactive (we're no longer interested in more results),
680  * but do NOT remove from our data-structures, we still need it there
681  * to prevent the request from looping */
682  pr->rh = NULL;
683  if (NULL != pr->cadet_request)
684  {
687  pr->cadet_request = NULL;
688  }
689  if (NULL != (cont = pr->llc_cont))
690  {
691  pr->llc_cont = NULL;
692  cont (pr->llc_cont_cls, pr, pr->local_result);
693  }
695  if (NULL != pr->qe)
696  {
698  pr->qe = NULL;
699  }
700  if (NULL != pr->gh)
701  {
702  GNUNET_DHT_get_stop (pr->gh);
703  pr->gh = NULL;
704  }
705  if (NULL != pr->warn_task)
706  {
708  pr->warn_task = NULL;
709  }
710  return;
711  }
713  clean_request (NULL, &pr->public_data.query, pr));
714 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_SCHEDULER_Task * warn_task
Task that warns us if the local datastore lookup takes too long.
static struct GNUNET_CONTAINER_MultiHashMap * pr_map
All pending requests, ordered by the query.
struct GSF_PendingRequestData public_data
Public data for the request.
#define GNUNET_NO
Definition: gnunet_common.h:78
GSF_LocalLookupContinuation llc_cont
Function to call upon completion of the local get request, or NULL for none.
struct GNUNET_HashCode query
Primary query hash for this request.
void(* GSF_LocalLookupContinuation)(void *cls, struct GSF_PendingRequest *pr, enum GNUNET_BLOCK_EvaluationResult result)
Function to be called after we&#39;re done processing replies from the local lookup.
enum GNUNET_BLOCK_EvaluationResult local_result
Last result from the local datastore lookup evaluation.
void * llc_cont_cls
Closure for llc_cont.
GSF_PendingRequestReplyHandler rh
Function to call if we encounter a reply.
void GNUNET_DHT_get_stop(struct GNUNET_DHT_GetHandle *get_handle)
Stop async DHT-get.
Definition: dht_api.c:1155
struct GNUNET_DHT_GetHandle * gh
DHT request handle for this request (or NULL for none).
void GSF_plan_notify_request_done_(struct GSF_PendingRequest *pr)
Notify the plan about a request being done; destroy all entries associated with this request...
#define CADET_RETRY_MAX
If obtaining a block via cadet fails, how often do we retry it before giving up for good (and stickin...
unsigned int cadet_retry_count
How often have we retried this request via &#39;cadet&#39;? (used to bound overall retries).
static int clean_request(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator to free pending requests.
void GNUNET_DATASTORE_cancel(struct GNUNET_DATASTORE_QueueEntry *qe)
Cancel a datastore operation.
struct GNUNET_DATASTORE_QueueEntry * qe
Datastore queue entry for this request (or NULL for none).
void GSF_cadet_query_cancel(struct GSF_CadetRequest *sr)
Cancel an active request; must not be called after &#39;proc&#39; was calld.
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GSF_CadetRequest * cadet_request
Cadet request handle for this request (or NULL for none).
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_iterate_pending_requests_()

void GSF_iterate_pending_requests_ ( GSF_PendingRequestIterator  it,
void *  cls 
)

Iterate over all pending requests.

Parameters
itfunction to call for each request
clsclosure for it

Definition at line 724 of file gnunet-service-fs_pr.c.

References GNUNET_CONTAINER_multihashmap_iterate().

Referenced by GSF_peer_connect_handler().

725 {
727  pr_map,
729  cls);
730 }
int(* GNUNET_CONTAINER_MulitHashMapIteratorCallback)(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over hash map entries.
static struct GNUNET_CONTAINER_MultiHashMap * pr_map
All pending requests, ordered by the query.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_request_performance_data()

static void update_request_performance_data ( struct ProcessReplyClosure prq,
struct GSF_PendingRequest pr 
)
static

Update the performance data for the sender (if any) since the sender successfully answered one of our queries.

Parameters
prqinformation about the sender
prrequest that was satisfied

Definition at line 798 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().

800 {
801  if (prq->sender == NULL)
802  return;
805  prq->priority);
806 }
struct GSF_ConnectedPeer * sender
Who gave us this reply? NULL for local host (or DHT)
uint32_t priority
How much was this reply worth to us?
struct GSF_PendingRequestData public_data
Public data for the request.
struct GNUNET_TIME_Absolute start_time
When did we start with the request.
void GSF_peer_update_performance_(struct GSF_ConnectedPeer *cp, struct GNUNET_TIME_Absolute request_time, uint32_t request_priority)
Report on receiving a reply; update the performance record of the given peer.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_reply()

static int process_reply ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

We have received a reply; handle it!

Parameters
clsresponse (a struct ProcessReplyClosure)
keyour query
valuevalue in the hash map (info about the query)
Returns
GNUNET_YES (we should continue to iterate)

Definition at line 818 of file gnunet-service-fs_pr.c.

References _, GNUNET_TIME_Absolute::abs_value_us, ProcessReplyClosure::anonymity_level, GSF_PendingRequest::bg, ProcessReplyClosure::data, ProcessReplyClosure::eo, ProcessReplyClosure::eval, ProcessReplyClosure::expiration, gettext_noop, GNUNET_BLOCK_evaluate(), GNUNET_BLOCK_EVALUATION_OK_DUPLICATE, GNUNET_BLOCK_EVALUATION_OK_LAST, GNUNET_BLOCK_EVALUATION_OK_MORE, GNUNET_BLOCK_EVALUATION_REQUEST_INVALID, GNUNET_BLOCK_EVALUATION_REQUEST_VALID, GNUNET_BLOCK_EVALUATION_RESULT_INVALID, GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT, GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED, GNUNET_break, GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, 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, GSF_PendingRequestData::original_priority, GSF_PendingRequestData::pr_head, GSF_PendingRequestData::priority, ProcessReplyClosure::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().

819 {
820  struct ProcessReplyClosure *prq = cls;
821  struct GSF_PendingRequest *pr = value;
822  struct GNUNET_HashCode chash;
824 
825  if (NULL == pr->rh)
826  return GNUNET_YES;
828  "Matched result (type %u) for query `%s' with pending request\n",
829  (unsigned int) prq->type,
830  GNUNET_h2s (key));
832  gettext_noop ("# replies received and matched"),
833  1,
834  GNUNET_NO);
836  prq->type,
837  pr->bg,
838  prq->eo,
839  key,
840  NULL,
841  0,
842  prq->data,
843  prq->size);
844  switch (prq->eval)
845  {
848  break;
849 
851  /* short cut: stop processing early, no BF-update, etc. */
856  .rel_value_us);
857  if (GNUNET_YES !=
859  .pr_head,
860  prq->sender,
862  last_transmission.abs_value_us =
863  GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
864  /* pass on to other peers / local clients */
865  pr->rh (pr->rh_cls,
866  prq->eval,
867  pr,
868  prq->anonymity_level,
869  prq->expiration,
871  prq->type,
872  prq->data,
873  prq->size);
874  return GNUNET_YES;
875 
877 #if INSANE_STATISTICS
879  gettext_noop (
880  "# duplicate replies discarded (bloomfilter)"),
881  1,
882  GNUNET_NO);
883 #endif
884  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Duplicate response, discarding.\n");
885  return GNUNET_YES; /* duplicate */
886 
889  gettext_noop ("# irrelevant replies discarded"),
890  1,
891  GNUNET_NO);
892  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Irrelevant response, ignoring.\n");
893  return GNUNET_YES;
894 
896  return GNUNET_YES; /* wrong namespace */
897 
899  GNUNET_break (0);
900  return GNUNET_YES;
901 
903  GNUNET_break (0);
904  return GNUNET_YES;
905 
908  _ ("Unsupported block type %u\n"),
909  prq->type);
910  return GNUNET_NO;
911  }
912  /* update bloomfilter */
913  GNUNET_CRYPTO_hash (prq->data, prq->size, &chash);
914  GSF_pending_request_update_ (pr, &chash, 1);
915  if (NULL == prq->sender)
916  {
918  "Found result for query `%s' in local datastore\n",
919  GNUNET_h2s (key));
921  gettext_noop ("# results found locally"),
922  1,
923  GNUNET_NO);
924  }
925  else
926  {
927  GSF_dht_lookup_ (pr);
928  }
930  pr->public_data.priority = 0;
933  prq->request_found = GNUNET_YES;
934  /* finally, pass on to other peer / local client */
936  .pr_head,
937  prq->sender,
939  last_transmission.abs_value_us = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
940  pr->rh (pr->rh_cls,
941  prq->eval,
942  pr,
943  prq->anonymity_level,
944  prq->expiration,
946  prq->type,
947  prq->data,
948  prq->size);
949  return GNUNET_YES;
950 }
Block does not match query (invalid result)
struct GSF_ConnectedPeer * sender
Who gave us this reply? NULL for local host (or DHT)
const void * data
The data for the reply.
uint32_t priority
How much was this reply worth to us?
uint64_t rel_value_us
The actual value.
int GSF_request_plan_reference_get_last_transmission_(struct GSF_PendingRequestPlanBijection *pr_head, struct GSF_ConnectedPeer *sender, struct GNUNET_TIME_Absolute *result)
Get the last transmission attempt time for the request plan list referenced by pr_head, that was sent to sender.
static GNUNET_CronTime last_transmission
struct GNUNET_TIME_Absolute expiration
When the reply expires.
enum GNUNET_BLOCK_EvaluationOptions eo
Control flags for evaluation.
Closure for process_reply() function.
unsigned int results_found
Number of results we have found for this request so far.
struct GSF_PendingRequestPlanBijection * pr_head
Fields for the plan module to track a DLL with the request.
struct GSF_PendingRequestData public_data
Public data for the request.
Block does not match xquery (valid result, not relevant for the request)
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
#define GNUNET_NO
Definition: gnunet_common.h:78
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
struct GNUNET_TIME_Absolute start_time
When did we start with the request.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
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...
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.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
size_t size
Size of data.
void GNUNET_LOAD_update(struct GNUNET_LOAD_Value *load, uint64_t data)
Update the current load.
Definition: load.c:236
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static char * value
Value of the record to add/remove.
Valid result, but suppressed because it is a duplicate.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
enum GNUNET_BLOCK_EvaluationResult GNUNET_BLOCK_evaluate(struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, struct GNUNET_BLOCK_Group *group, enum GNUNET_BLOCK_EvaluationOptions eo, const struct GNUNET_HashCode *query, const void *xquery, size_t xquery_size, const void *reply_block, size_t reply_block_size)
Function called to validate a reply or a request.
Definition: block.c:338
struct GNUNET_BLOCK_Context * GSF_block_ctx
Our block context.
Last possible valid result.
void * rh_cls
Closure for rh.
A 512-bit hashcode.
GSF_PendingRequestReplyHandler rh
Function to call if we encounter a reply.
Valid result, and there may be more.
uint32_t original_priority
Priority that this request (originally) had for us.
Specified block type not supported by this plugin.
enum GNUNET_BLOCK_Type type
Type of the block.
uint32_t anonymity_level
Anonymity requirements for this reply.
struct GNUNET_LOAD_Value * GSF_rt_entry_lifetime
How long do requests typically stay in the routing table?
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:375
struct GNUNET_BLOCK_Group * bg
Block group for filtering replies we&#39;ve already seen.
enum GNUNET_BLOCK_EvaluationResult eval
Evaluation result (returned).
Query format does not match block type (invalid query).
void GSF_dht_lookup_(struct GSF_PendingRequest *pr)
Consider looking up the data in the DHT (anonymity-level permitting).
#define GNUNET_log(kind,...)
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:77
uint32_t priority
Priority that this request (still) has for us.
An active request.
int request_found
Did we find a matching request?
Query is valid, no reply given.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ put_migration_continuation()

static void put_migration_continuation ( void *  cls,
int  success,
struct GNUNET_TIME_Absolute  min_expiration,
const char *  msg 
)
static

Continuation called to notify client about result of the operation.

Parameters
clsclosure
successGNUNET_SYSERR on failure
min_expirationminimum expiration time required for content to be stored
msgNULL on success, otherwise an error message

Definition at line 986 of file gnunet-service-fs_pr.c.

References GNUNET_TIME_Absolute::abs_value_us, 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, PutMigrationContext::origin, GNUNET_TIME_Relative::rel_value_us, PutMigrationContext::requested, and PutMigrationContext::start.

Referenced by handle_dht_reply(), and handle_p2p_put().

990 {
991  struct PutMigrationContext *pmc = cls;
992  struct GSF_ConnectedPeer *cp;
993  struct GNUNET_TIME_Relative mig_pause;
994  struct GSF_PeerPerformanceData *ppd;
995 
996  if (NULL != datastore_put_load)
997  {
998  if (GNUNET_SYSERR != success)
999  {
1002  .rel_value_us);
1003  }
1004  else
1005  {
1006  /* on queue failure / timeout, increase the put load dramatically */
1008  GNUNET_TIME_UNIT_MINUTES.rel_value_us);
1009  }
1010  }
1011  cp = GSF_peer_get_ (&pmc->origin);
1012  if (GNUNET_OK == success)
1013  {
1014  if (NULL != cp)
1015  {
1016  ppd = GSF_get_peer_performance_data_ (cp);
1017  ppd->migration_delay.rel_value_us /= 2;
1018  }
1019  GNUNET_free (pmc);
1020  return;
1021  }
1022  if ((GNUNET_NO == success) && (GNUNET_NO == pmc->requested) && (NULL != cp))
1023  {
1024  ppd = GSF_get_peer_performance_data_ (cp);
1025  if (min_expiration.abs_value_us > 0)
1026  {
1028  "Asking to stop migration for %s because datastore is full\n",
1030  GNUNET_TIME_absolute_get_remaining (min_expiration),
1031  GNUNET_YES));
1032  GSF_block_peer_migration_ (cp, min_expiration);
1033  }
1034  else
1035  {
1037  ppd->migration_delay);
1038  ppd->migration_delay =
1040  mig_pause.rel_value_us =
1043  ppd->migration_delay =
1045  GNUNET_log (
1047  "Replicated content already exists locally, asking to stop migration for %s\n",
1050  GNUNET_TIME_relative_to_absolute (mig_pause));
1051  }
1052  }
1053  GNUNET_free (pmc);
1055  gettext_noop ("# Datastore `PUT' failures"),
1056  1,
1057  GNUNET_NO);
1058 }
#define GNUNET_TIME_UNIT_HOURS
One hour.
uint64_t rel_value_us
The actual value.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
#define GNUNET_TIME_UNIT_MINUTES
One minute.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_max(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the maximum of two relative time values.
Definition: time.c:287
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:246
#define GNUNET_TIME_UNIT_SECONDS
One second.
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
uint64_t abs_value_us
The actual value.
void GNUNET_LOAD_update(struct GNUNET_LOAD_Value *load, uint64_t data)
Update the current load.
Definition: load.c:236
struct GNUNET_TIME_Absolute start
Start time for the operation.
struct GSF_PeerPerformanceData * GSF_get_peer_performance_data_(struct GSF_ConnectedPeer *cp)
Return the performance data record for the given peer.
struct GSF_ConnectedPeer * GSF_peer_get_(const struct GNUNET_PeerIdentity *peer)
Get a handle for a connected peer.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:687
int requested
GNUNET_YES if we had a matching request for this block, GNUNET_NO if not.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_min(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the minimum of two relative time values.
Definition: time.c:272
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static struct GNUNET_LOAD_Value * datastore_put_load
Datastore &#39;PUT&#39; load tracking.
Performance data kept for a peer.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:375
struct GNUNET_PeerIdentity origin
Request origin.
#define GNUNET_log(kind,...)
Context for put_migration_continuation().
A connected peer.
struct GNUNET_TIME_Relative migration_delay
If we get content we already have from this peer, for how long do we block it? Adjusted based on the ...
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition: time.c:331
#define GNUNET_YES
Definition: gnunet_common.h:77
void GSF_block_peer_migration_(struct GSF_ConnectedPeer *cp, struct GNUNET_TIME_Absolute block_time)
Ask a peer to stop migrating data to us until the given point in time.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_saturating_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Saturating multiply relative time by a given factor.
Definition: time.c:501
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_put_load_too_high()

static int test_put_load_too_high ( uint32_t  priority)
static

Test if the DATABASE (PUT) load on this peer is too high to even consider processing the query at all.

Parameters
prioritythe priority of the item
Returns
GNUNET_YES if the load is too high to do anything (load high) GNUNET_NO to process normally (load normal or low)

Definition at line 1071 of file gnunet-service-fs_pr.c.

References 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().

1072 {
1073  double ld;
1074 
1075  if (NULL == datastore_put_load)
1076  return GNUNET_NO;
1078  return GNUNET_NO; /* very fast */
1080  if (ld < 2.0 * (1 + priority))
1081  return GNUNET_NO;
1083  gettext_noop (
1084  "# storage requests dropped due to high load"),
1085  1,
1086  GNUNET_NO);
1087  return GNUNET_YES;
1088 }
double GNUNET_LOAD_get_load(struct GNUNET_LOAD_Value *load)
Get the current load.
Definition: load.c:200
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
#define GNUNET_NO
Definition: gnunet_common.h:78
double GNUNET_LOAD_get_average(struct GNUNET_LOAD_Value *load)
Get the average value given to update so far.
Definition: load.c:215
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static struct GNUNET_LOAD_Value * datastore_put_load
Datastore &#39;PUT&#39; load tracking.
#define GNUNET_YES
Definition: gnunet_common.h:77
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_dht_reply()

static void handle_dht_reply ( void *  cls,
struct GNUNET_TIME_Absolute  exp,
const struct GNUNET_HashCode key,
const struct GNUNET_PeerIdentity get_path,
unsigned int  get_path_length,
const struct GNUNET_PeerIdentity put_path,
unsigned int  put_path_length,
enum GNUNET_BLOCK_Type  type,
size_t  size,
const void *  data 
)
static

Iterator called on each result obtained for a DHT operation that expects a reply.

Parameters
clsclosure
expwhen will this value expire
keykey of the result
get_pathpeers on reply path (or NULL if not recorded)
get_path_lengthnumber of entries in get_path
put_pathpeers on the PUT path (or NULL if not recorded)
put_path_lengthnumber of entries in get_path
typetype of the result
sizenumber of bytes in data
datapointer to the result data

Definition at line 1107 of file gnunet-service-fs_pr.c.

References active_to_migration, data, ProcessReplyClosure::data, ProcessReplyClosure::eo, ProcessReplyClosure::expiration, gettext_noop, GNUNET_BLOCK_EO_NONE, 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, 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_().

1117 {
1118  struct GSF_PendingRequest *pr = cls;
1119  struct ProcessReplyClosure prq;
1120  struct PutMigrationContext *pmc;
1121 
1123  gettext_noop ("# Replies received from DHT"),
1124  1,
1125  GNUNET_NO);
1126  memset (&prq, 0, sizeof(prq));
1127  prq.data = data;
1128  prq.expiration = exp;
1129  /* do not allow migrated content to live longer than 1 year */
1132  prq.expiration);
1133  prq.size = size;
1134  prq.type = type;
1135  prq.eo = GNUNET_BLOCK_EO_NONE;
1136  process_reply (&prq, key, pr);
1137  if ((GNUNET_YES == active_to_migration) &&
1138  (GNUNET_NO == test_put_load_too_high (prq.priority)))
1139  {
1141  "Replicating result for query `%s' with priority %u\n",
1142  GNUNET_h2s (key),
1143  prq.priority);
1144  pmc = GNUNET_new (struct PutMigrationContext);
1145  pmc->start = GNUNET_TIME_absolute_get ();
1146  pmc->requested = GNUNET_YES;
1147  if (NULL == GNUNET_DATASTORE_put (GSF_dsh,
1148  0,
1149  key,
1150  size,
1151  data,
1152  type,
1153  prq.priority,
1154  1 /* anonymity */,
1155  0 /* replication */,
1156  exp,
1157  1 + prq.priority,
1160  pmc))
1161  {
1163  GNUNET_SYSERR,
1165  NULL);
1166  }
1167  }
1168 }
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_put(struct GNUNET_DATASTORE_Handle *h, uint32_t rid, 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, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the datastore.
Closure for process_reply() function.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:246
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.
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
#define GNUNET_NO
Definition: gnunet_common.h:78
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Default behavior.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
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...
static int process_reply(void *cls, const struct GNUNET_HashCode *key, void *value)
We have received a reply; handle it!
struct GNUNET_TIME_Absolute start
Start time for the operation.
struct GNUNET_DATASTORE_Handle * GSF_dsh
Our connection to the datastore.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
int requested
GNUNET_YES if we had a matching request for this block, GNUNET_NO if not.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67
#define MAX_DATASTORE_QUEUE
Maximum size of the datastore queue for P2P operations.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_min(struct GNUNET_TIME_Absolute t1, struct GNUNET_TIME_Absolute t2)
Return the minimum of two absolute time values.
Definition: time.c:302
#define GNUNET_TIME_UNIT_YEARS
One year (365 days).
#define GNUNET_log(kind,...)
Context for put_migration_continuation().
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
#define GNUNET_YES
Definition: gnunet_common.h:77
An active request.
uint32_t data
The data value.
static int active_to_migration
Are we allowed to migrate content to this peer.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_dht_lookup_()

void GSF_dht_lookup_ ( struct GSF_PendingRequest pr)

Consider looking up the data in the DHT (anonymity-level permitting).

Parameters
prthe pending request to process

Definition at line 1177 of file gnunet-service-fs_pr.c.

References GSF_PendingRequestData::anonymity_level, buf, 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().

1178 {
1179  const void *xquery;
1180  size_t xquery_size;
1181  struct GNUNET_PeerIdentity pi;
1182  char buf[sizeof(struct GNUNET_HashCode) * 2] GNUNET_ALIGN;
1183 
1184  if (0 != pr->public_data.anonymity_level)
1185  return;
1186  if (NULL != pr->gh)
1187  {
1188  GNUNET_DHT_get_stop (pr->gh);
1189  pr->gh = NULL;
1190  }
1191  xquery = NULL;
1192  xquery_size = 0;
1193  if (0 != (pr->public_data.options & GSF_PRO_FORWARD_ONLY))
1194  {
1195  GNUNET_assert (0 != pr->sender_pid);
1197  GNUNET_memcpy (&buf[xquery_size], &pi, sizeof(struct GNUNET_PeerIdentity));
1198  xquery_size += sizeof(struct GNUNET_PeerIdentity);
1199  }
1201  pr->public_data.type,
1202  &pr->public_data.query,
1205  xquery,
1206  xquery_size,
1208  pr);
1209  if ((NULL != pr->gh) && (0 != pr->replies_seen_count))
1211  pr->replies_seen_count,
1212  pr->replies_seen);
1213 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint32_t anonymity_level
Desired anonymity level.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GSF_PendingRequestData public_data
Public data for the request.
struct GNUNET_DHT_Handle * GSF_dht
Handle for DHT operations.
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
void GNUNET_PEER_resolve(GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid)
Convert an interned PID to a normal peer identity.
Definition: peer.c:225
struct GNUNET_HashCode query
Primary query hash for this request.
unsigned int replies_seen_count
Number of valid entries in the &#39;replies_seen&#39; array.
static char buf[2048]
enum GNUNET_BLOCK_Type type
Type of the requested block.
A 512-bit hashcode.
void GNUNET_DHT_get_stop(struct GNUNET_DHT_GetHandle *get_handle)
Stop async DHT-get.
Definition: dht_api.c:1155
struct GNUNET_DHT_GetHandle * gh
DHT request handle for this request (or NULL for none).
void GNUNET_DHT_get_filter_known_results(struct GNUNET_DHT_GetHandle *get_handle, unsigned int num_results, const struct GNUNET_HashCode *results)
Tell the DHT not to return any of the following known results to this client.
Definition: dht_api.c:1126
#define DHT_GET_REPLICATION
Desired replication level for GETs.
The identity of the host (wraps the signing key of the peer).
enum GSF_PendingRequestOptions options
Options for the request.
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to &#39;struct&#39;s...
Request must only be forwarded (no routing)
struct GNUNET_DHT_GetHandle * GNUNET_DHT_get_start(struct GNUNET_DHT_Handle *handle, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *key, uint32_t desired_replication_level, enum GNUNET_DHT_RouteOption options, const void *xquery, size_t xquery_size, GNUNET_DHT_GetIterator iter, void *iter_cls)
Perform an asynchronous GET operation on the DHT identified.
Definition: dht_api.c:1067
static void handle_dht_reply(void *cls, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *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. ...
GNUNET_PEER_Id sender_pid
Identity of the peer that we should use for the &#39;sender&#39; (recipient of the response) when forwarding ...
Each peer along the way should look at &#39;enc&#39; (otherwise only the k-peers closest to the key should lo...
struct GNUNET_HashCode * replies_seen
Array of hash codes of replies we&#39;ve already seen.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cadet_reply_proc()

static void cadet_reply_proc ( void *  cls,
enum GNUNET_BLOCK_Type  type,
struct GNUNET_TIME_Absolute  expiration,
size_t  data_size,
const void *  data 
)
static

Function called with a reply from the cadet.

Parameters
clsthe pending request struct
typetype of the block, ANY on error
expirationexpiration time for the block
data_sizenumber of bytes in data, 0 on error
datareply block data, NULL on error

Definition at line 1226 of file gnunet-service-fs_pr.c.

References GSF_PendingRequest::cadet_request, GSF_PendingRequest::cadet_retry_count, CADET_RETRY_MAX, data, ProcessReplyClosure::data, data_size, ProcessReplyClosure::eo, expiration, ProcessReplyClosure::expiration, gettext_noop, GNUNET_BLOCK_EO_NONE, GNUNET_BLOCK_get_key(), GNUNET_BLOCK_TYPE_ANY, GNUNET_break, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, 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, GSF_PendingRequestData::type, and ProcessReplyClosure::type.

Referenced by GSF_cadet_lookup_().

1231 {
1232  struct GSF_PendingRequest *pr = cls;
1233  struct ProcessReplyClosure prq;
1234  struct GNUNET_HashCode query;
1235 
1236  pr->cadet_request = NULL;
1237  if (GNUNET_BLOCK_TYPE_ANY == type)
1238  {
1239  GNUNET_break (NULL == data);
1240  GNUNET_break (0 == data_size);
1241  pr->cadet_retry_count++;
1243  return; /* give up on cadet */
1244  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error retrieiving block via cadet\n");
1245  /* retry -- without delay, as this is non-anonymous
1246  and cadet/cadet connect will take some time anyway */
1248  &pr->public_data.query,
1249  pr->public_data.type,
1251  pr);
1252  return;
1253  }
1254  if (GNUNET_YES !=
1256  {
1258  "Failed to derive key for block of type %d\n",
1259  (int) type);
1260  GNUNET_break_op (0);
1261  return;
1262  }
1264  gettext_noop ("# Replies received from CADET"),
1265  1,
1266  GNUNET_NO);
1267  memset (&prq, 0, sizeof(prq));
1268  prq.data = data;
1269  prq.expiration = expiration;
1270  /* do not allow migrated content to live longer than 1 year */
1273  prq.expiration);
1274  prq.size = data_size;
1275  prq.type = type;
1276  prq.eo = GNUNET_BLOCK_EO_NONE;
1277  process_reply (&prq, &query, pr);
1278 }
const struct GNUNET_PeerIdentity * target
Identity of a peer hosting the content, otherwise NULl.
struct GSF_CadetRequest * GSF_cadet_query(const struct GNUNET_PeerIdentity *target, const struct GNUNET_HashCode *query, enum GNUNET_BLOCK_Type type, GSF_CadetReplyProcessor proc, void *proc_cls)
Look for a block by directly contacting a particular peer.
Any type of block, used as a wildcard when searching.
Closure for process_reply() function.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:246
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
struct GSF_PendingRequestData public_data
Public data for the request.
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
#define GNUNET_NO
Definition: gnunet_common.h:78
Default behavior.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static int process_reply(void *cls, const struct GNUNET_HashCode *key, void *value)
We have received a reply; handle it!
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
int GNUNET_BLOCK_get_key(struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, const void *block, size_t block_size, struct GNUNET_HashCode *key)
Function called to obtain the key for a block.
Definition: block.c:378
struct GNUNET_HashCode query
Primary query hash for this request.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_BLOCK_Context * GSF_block_ctx
Our block context.
enum GNUNET_BLOCK_Type type
Type of the requested block.
A 512-bit hashcode.
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:96
#define CADET_RETRY_MAX
If obtaining a block via cadet fails, how often do we retry it before giving up for good (and stickin...
unsigned int cadet_retry_count
How often have we retried this request via &#39;cadet&#39;? (used to bound overall retries).
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.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_min(struct GNUNET_TIME_Absolute t1, struct GNUNET_TIME_Absolute t2)
Return the minimum of two absolute time values.
Definition: time.c:302
#define GNUNET_TIME_UNIT_YEARS
One year (365 days).
#define GNUNET_log(kind,...)
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
#define GNUNET_YES
Definition: gnunet_common.h:77
An active request.
struct GSF_CadetRequest * cadet_request
Cadet request handle for this request (or NULL for none).
uint32_t data
The data value.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_cadet_lookup_()

void GSF_cadet_lookup_ ( struct GSF_PendingRequest pr)

Consider downloading via cadet (if possible)

Parameters
prthe pending request to process

Definition at line 1287 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().

1288 {
1289  if (0 != pr->public_data.anonymity_level)
1290  return;
1291  if (0 == pr->public_data.target)
1292  {
1294  "Cannot do cadet-based download, target peer not known\n");
1295  return;
1296  }
1297  if (NULL != pr->cadet_request)
1298  return;
1300  &pr->public_data.query,
1301  pr->public_data.type,
1303  pr);
1304 }
const struct GNUNET_PeerIdentity * target
Identity of a peer hosting the content, otherwise NULl.
struct GSF_CadetRequest * GSF_cadet_query(const struct GNUNET_PeerIdentity *target, const struct GNUNET_HashCode *query, enum GNUNET_BLOCK_Type type, GSF_CadetReplyProcessor proc, void *proc_cls)
Look for a block by directly contacting a particular peer.
uint32_t anonymity_level
Desired anonymity level.
struct GSF_PendingRequestData public_data
Public data for the request.
struct GNUNET_HashCode query
Primary query hash for this request.
enum GNUNET_BLOCK_Type type
Type of the requested block.
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.
#define GNUNET_log(kind,...)
struct GSF_CadetRequest * cadet_request
Cadet request handle for this request (or NULL for none).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ warn_delay_task()

static void warn_delay_task ( void *  cls)
static

Task that issues a warning if the datastore lookup takes too long.

Parameters
clsthe struct GSF_PendingRequest

Definition at line 1313 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, and GSF_PendingRequest::warn_task.

Referenced by start_local_query().

1314 {
1315  struct GSF_PendingRequest *pr = cls;
1316 
1318  _ ("Datastore lookup already took %s!\n"),
1321  GNUNET_YES));
1323  &warn_delay_task,
1324  pr);
1325 }
static void warn_delay_task(void *cls)
Task that issues a warning if the datastore lookup takes too long.
#define GNUNET_TIME_UNIT_MINUTES
One minute.
struct GNUNET_SCHEDULER_Task * warn_task
Task that warns us if the local datastore lookup takes too long.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1253
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:687
struct GNUNET_TIME_Absolute qe_start
Time we started the last datastore lookup.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:375
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
An active request.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ odc_warn_delay_task()

static void odc_warn_delay_task ( void *  cls)
static

Task that issues a warning if the datastore lookup takes too long.

Parameters
clsthe struct GSF_PendingRequest

Definition at line 1334 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, GSF_PendingRequest::qe_start, and GSF_PendingRequest::warn_task.

Referenced by process_local_reply().

1335 {
1336  struct GSF_PendingRequest *pr = cls;
1337 
1339  _ ("On-demand lookup already took %s!\n"),
1342  GNUNET_YES));
1345  pr);
1346 }
#define GNUNET_TIME_UNIT_MINUTES
One minute.
struct GNUNET_SCHEDULER_Task * warn_task
Task that warns us if the local datastore lookup takes too long.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1253
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:687
struct GNUNET_TIME_Absolute qe_start
Time we started the last datastore lookup.
static void odc_warn_delay_task(void *cls)
Task that issues a warning if the datastore lookup takes too long.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:375
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
An active request.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ call_continuation()

static void call_continuation ( struct GSF_PendingRequest pr)
static

Definition at line 1351 of file gnunet-service-fs_pr.c.

References GNUNET_assert, GNUNET_BLOCK_EVALUATION_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().

1352 {
1354 
1355  GNUNET_assert (NULL == pr->qe);
1356  if (NULL != pr->warn_task)
1357  {
1359  pr->warn_task = NULL;
1360  }
1361  if (NULL == cont)
1362  return; /* no continuation */
1363  pr->llc_cont = NULL;
1364  if (0 != (GSF_PRO_LOCAL_ONLY & pr->public_data.options))
1365  {
1367  {
1368  /* Signal that we are done and that there won't be any
1369  additional results to allow client to clean up state. */
1370  pr->rh (pr->rh_cls,
1372  pr,
1373  UINT32_MAX,
1377  NULL,
1378  0);
1379  }
1380  /* Finally, call our continuation to signal that we are
1381  done with local processing of this request; i.e. to
1382  start reading again from the client. */
1384  return;
1385  }
1386 
1387  cont (pr->llc_cont_cls, pr, pr->local_result);
1388 }
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
Any type of block, used as a wildcard when searching.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_SCHEDULER_Task * warn_task
Task that warns us if the local datastore lookup takes too long.
struct GSF_PendingRequestData public_data
Public data for the request.
GSF_LocalLookupContinuation llc_cont
Function to call upon completion of the local get request, or NULL for none.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
void(* GSF_LocalLookupContinuation)(void *cls, struct GSF_PendingRequest *pr, enum GNUNET_BLOCK_EvaluationResult result)
Function to be called after we&#39;re done processing replies from the local lookup.
enum GNUNET_BLOCK_EvaluationResult local_result
Last result from the local datastore lookup evaluation.
void * llc_cont_cls
Closure for llc_cont.
Last possible valid result.
void * rh_cls
Closure for rh.
Request must only be processed locally.
GSF_PendingRequestReplyHandler rh
Function to call if we encounter a reply.
struct GNUNET_DATASTORE_QueueEntry * qe
Datastore queue entry for this request (or NULL for none).
enum GSF_PendingRequestOptions options
Options for the request.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ no_more_local_results()

static void no_more_local_results ( struct GSF_PendingRequest pr)
static

Definition at line 1393 of file gnunet-service-fs_pr.c.

References anonymity, call_continuation(), data, expiration, 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, key, process_local_reply(), GSF_PendingRequest::public_data, replication, size, type, and GSF_PendingRequestData::type.

Referenced by process_local_reply().

1394 {
1396  "No further local responses available.\n");
1397 #if INSANE_STATISTICS
1401  gettext_noop (
1402  "# requested DBLOCK or IBLOCK not found"),
1403  1,
1404  GNUNET_NO);
1405 #endif
1406  call_continuation (pr);
1407 }
struct GSF_PendingRequestData public_data
Public data for the request.
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
#define GNUNET_NO
Definition: gnunet_common.h:78
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
Inner block in the CHK tree.
enum GNUNET_BLOCK_Type type
Type of the requested block.
#define GNUNET_log(kind,...)
Data block (leaf) in the CHK tree.
static void call_continuation(struct GSF_PendingRequest *pr)
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_local_reply()

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 
)
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).

Parameters
clsour closure (struct GSF_PendingRequest *)
keykey for the content
sizenumber of bytes in data
datacontent stored
typetype of the content
prioritypriority of the content
anonymityanonymity-level for the content
replicationreplication-level for the content
expirationexpiration time for the content
uidunique identifier for the datum; maybe 0 if no unique identifier is available

Definition at line 1490 of file gnunet-service-fs_pr.c.

References anonymity, ProcessReplyClosure::anonymity_level, call_continuation(), data, ProcessReplyClosure::data, ProcessReplyClosure::eo, ProcessReplyClosure::eval, expiration, ProcessReplyClosure::expiration, GSF_PendingRequest::first_uid, gettext_noop, GNUNET_assert, GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO, GNUNET_BLOCK_EVALUATION_OK_LAST, GNUNET_BLOCK_get_key(), 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, GSF_PendingRequest::local_result, MAX_RESULTS, no_more_local_results(), odc_warn_delay_task(), GSF_PendingRequestData::options, GSF_PendingRequestData::priority, ProcessReplyClosure::priority, process_reply(), GSF_PendingRequest::public_data, GSF_PendingRequest::qe, GSF_PendingRequest::qe_start, 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 no_more_local_results(), and start_local_query().

1500 {
1501  struct GSF_PendingRequest *pr = cls;
1502  struct ProcessReplyClosure prq;
1503  struct GNUNET_HashCode query;
1504  unsigned int old_rf;
1505 
1507  pr->warn_task = NULL;
1508  if (NULL == pr->qe)
1509  goto called_from_on_demand;
1510  pr->qe = NULL;
1511  if (
1512  (NULL == key) && pr->seen_null &&
1513  ! pr->have_first_uid) /* We have hit the end for the 2nd time with no results */
1514  {
1515  /* No results */
1516 #if INSANE_STATISTICS
1518  gettext_noop (
1519  "# Datastore lookups concluded (no results)"),
1520  1,
1521  GNUNET_NO);
1522 #endif
1523  no_more_local_results (pr);
1524  return;
1525  }
1526  if (((NULL == key) &&
1527  pr->seen_null) || /* We have hit the end for the 2nd time OR */
1528  (pr->seen_null && pr->have_first_uid &&
1529  (uid >= pr->first_uid))) /* We have hit the end and past first UID */
1530  {
1531  /* Seen all results */
1533  gettext_noop (
1534  "# Datastore lookups concluded (seen all)"),
1535  1,
1536  GNUNET_NO);
1537  no_more_local_results (pr);
1538  return;
1539  }
1540  if (NULL == key)
1541  {
1542  GNUNET_assert (! pr->seen_null);
1543  pr->seen_null = true;
1544  start_local_query (pr, 0 /* next_uid */, false /* random */);
1545  return;
1546  }
1547  if (! pr->have_first_uid)
1548  {
1549  pr->first_uid = uid;
1550  pr->have_first_uid = true;
1551  }
1552  pr->result_count++;
1553  if (pr->result_count > MAX_RESULTS)
1554  {
1556  GSF_stats,
1557  gettext_noop ("# Datastore lookups aborted (more than MAX_RESULTS)"),
1558  1,
1559  GNUNET_NO);
1560  no_more_local_results (pr);
1561  return;
1562  }
1564  "Received reply for `%s' of type %d with UID %llu from datastore.\n",
1565  GNUNET_h2s (key),
1566  type,
1567  (unsigned long long) uid);
1569  {
1571  "Found ONDEMAND block, performing on-demand encoding\n");
1573  gettext_noop (
1574  "# on-demand blocks matched requests"),
1575  1,
1576  GNUNET_NO);
1580  pr);
1582  size,
1583  data,
1584  type,
1585  priority,
1586  anonymity,
1587  replication,
1588  expiration,
1589  uid,
1591  pr))
1592  {
1594  gettext_noop (
1595  "# on-demand lookups performed successfully"),
1596  1,
1597  GNUNET_NO);
1598  return; /* we're done */
1599  }
1601  gettext_noop ("# on-demand lookups failed"),
1602  1,
1603  GNUNET_NO);
1605  start_local_query (pr, uid + 1 /* next_uid */, false /* random */);
1606  return;
1607  }
1608 called_from_on_demand:
1609  old_rf = pr->public_data.results_found;
1610  memset (&prq, 0, sizeof(prq));
1611  prq.data = data;
1612  prq.expiration = expiration;
1613  prq.size = size;
1614  if (GNUNET_OK !=
1616  {
1617  GNUNET_break (0);
1619  key,
1620  size,
1621  data,
1622  UINT_MAX,
1623  UINT_MAX,
1624  NULL,
1625  NULL);
1626  start_local_query (pr, uid + 1 /* next_uid */, false /* random */);
1627  return;
1628  }
1629  prq.type = type;
1630  prq.priority = priority;
1631  prq.request_found = GNUNET_NO;
1632  prq.anonymity_level = anonymity;
1633  if ((0 == old_rf) && (0 == pr->public_data.results_found))
1636  process_reply (&prq, key, pr);
1637  pr->local_result = prq.eval;
1638  if (GNUNET_BLOCK_EVALUATION_OK_LAST == prq.eval)
1639  {
1641  GSF_stats,
1642  gettext_noop ("# Datastore lookups concluded (found last result)"),
1643  1,
1644  GNUNET_NO);
1645  call_continuation (pr);
1646  return;
1647  }
1648  if ((0 == (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data.options)) &&
1650  (pr->public_data.results_found > 5 + 2 * pr->public_data.priority)))
1651  {
1652  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Load too high, done with request\n");
1654  gettext_noop (
1655  "# Datastore lookups concluded (load too high)"),
1656  1,
1657  GNUNET_NO);
1658  call_continuation (pr);
1659  return;
1660  }
1661  start_local_query (pr, uid + 1 /* next_uid */, false /* random */);
1662 }
void GSF_update_datastore_delay_(struct GNUNET_TIME_Absolute start)
We&#39;ve just now completed a datastore request.
bool seen_null
Have we seen a NULL result yet?
#define GNUNET_TIME_UNIT_MINUTES
One minute.
static void no_more_local_results(struct GSF_PendingRequest *pr)
Closure for process_reply() function.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
unsigned int results_found
Number of results we have found for this request so far.
struct GNUNET_SCHEDULER_Task * warn_task
Task that warns us if the local datastore lookup takes too long.
static unsigned int replication
struct GSF_PendingRequestData public_data
Public data for the request.
bool have_first_uid
Do we have a first UID yet?
Request priority is allowed to be exceeded.
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
struct GNUNET_TIME_Absolute start_time
When did we start with the request.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static int process_reply(void *cls, const struct GNUNET_HashCode *key, void *value)
We have received a reply; handle it!
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Type of a block representing a block to be encoded on demand from disk.
int GNUNET_BLOCK_get_key(struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, const void *block, size_t block_size, struct GNUNET_HashCode *key)
Function called to obtain the key for a block.
Definition: block.c:378
size_t result_count
Result count.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1253
enum GNUNET_BLOCK_EvaluationResult local_result
Last result from the local datastore lookup evaluation.
static void start_local_query(struct GSF_PendingRequest *pr, uint64_t next_uid, bool random)
struct GNUNET_BLOCK_Context * GSF_block_ctx
Our block context.
Last possible valid result.
struct GNUNET_TIME_Absolute qe_start
Time we started the last datastore lookup.
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_remove(struct GNUNET_DATASTORE_Handle *h, const struct GNUNET_HashCode *key, size_t size, const void *data, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls)
Explicitly remove some content from the database.
A 512-bit hashcode.
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:96
static void odc_warn_delay_task(void *cls)
Task that issues a warning if the datastore lookup takes too long.
struct GNUNET_DATASTORE_Handle * GSF_dsh
Our connection to the datastore.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
The block is obtained from the local database, skip cryptographic checks.
static unsigned int size
Size of the "table".
Definition: peer.c:67
#define MAX_RESULTS
Hard limit on the number of results we may get from the datastore per query.
int GSF_test_get_load_too_high_(uint32_t priority)
Test if the DATABASE (GET) load on this peer is too high to even consider processing the query at all...
struct GNUNET_DATASTORE_QueueEntry * qe
Datastore queue entry for this request (or NULL for none).
enum GSF_PendingRequestOptions options
Options for the request.
uint64_t first_uid
Unique ID of the first result from the local datastore; used to terminate the loop.
#define GNUNET_log(kind,...)
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&#39;re processing (local) results for a search request from another peer.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
#define GNUNET_YES
Definition: gnunet_common.h:77
static unsigned int anonymity
uint32_t priority
Priority that this request (still) has for us.
An active request.
int GNUNET_FS_handle_on_demand_block(const struct GNUNET_HashCode *key, uint32_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, GNUNET_DATASTORE_DatumProcessor cont, void *cont_cls)
We&#39;ve received an on-demand encoded block from the datastore.
uint32_t data
The data value.
static void call_continuation(struct GSF_PendingRequest *pr)
#define gettext_noop(String)
Definition: gettext.h:69
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_local_query()

static void start_local_query ( struct GSF_PendingRequest pr,
uint64_t  next_uid,
bool  random 
)
static

Definition at line 1426 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().

1429 {
1432  &warn_delay_task,
1433  pr);
1435  next_uid,
1436  random,
1437  &pr->public_data.query,
1438  pr->public_data.type ==
1441  : pr->public_data.type,
1443  & pr->public_data.options))
1444  ? UINT_MAX
1445  : 1
1446  /* queue priority */,
1448  & pr->public_data.options))
1449  ? UINT_MAX
1451  /* max queue size */,
1453  pr);
1454  if (NULL != pr->qe)
1455  return;
1456  GNUNET_log (
1458  "ERROR Requesting `%s' of type %d with next_uid %llu from datastore.\n",
1459  GNUNET_h2s (&pr->public_data.query),
1460  pr->public_data.type,
1461  (unsigned long long) next_uid);
1463  gettext_noop (
1464  "# Datastore lookups concluded (error queueing)"),
1465  1,
1466  GNUNET_NO);
1467  call_continuation (pr);
1468 }
static void warn_delay_task(void *cls)
Task that issues a warning if the datastore lookup takes too long.
Any type of block, used as a wildcard when searching.
#define GNUNET_TIME_UNIT_MINUTES
One minute.
struct GNUNET_SCHEDULER_Task * warn_task
Task that warns us if the local datastore lookup takes too long.
struct GSF_PendingRequestData public_data
Public data for the request.
Request priority is allowed to be exceeded.
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
#define GNUNET_NO
Definition: gnunet_common.h:78
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_HashCode query
Primary query hash for this request.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1253
unsigned int GSF_datastore_queue_size
Size of the datastore queue we assume for common requests.
struct GNUNET_TIME_Absolute qe_start
Time we started the last datastore lookup.
enum GNUNET_BLOCK_Type type
Type of the requested block.
struct GNUNET_DATASTORE_Handle * GSF_dsh
Our connection to the datastore.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct GNUNET_DATASTORE_QueueEntry * qe
Datastore queue entry for this request (or NULL for none).
enum GSF_PendingRequestOptions options
Options for the request.
#define GNUNET_log(kind,...)
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&#39;re processing (local) results for a search request from another peer.
Data block (leaf) in the CHK tree.
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_get_key(struct GNUNET_DATASTORE_Handle *h, uint64_t next_uid, bool random, const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_DatumProcessor proc, void *proc_cls)
Get a result for a particular key from the datastore.
static void call_continuation(struct GSF_PendingRequest *pr)
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_pending_request_test_target_()

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?

Parameters
prrequest
target
Returns
GNUNET_YES if this request could be forwarded to the given peer

Definition at line 1673 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().

1675 {
1676  struct GNUNET_PeerIdentity pi;
1677 
1678  if (0 == pr->origin_pid)
1679  return GNUNET_YES;
1681  return (0 == memcmp (&pi, target, sizeof(struct GNUNET_PeerIdentity)))
1682  ? GNUNET_NO
1683  : GNUNET_YES;
1684 }
#define GNUNET_NO
Definition: gnunet_common.h:78
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
void GNUNET_PEER_resolve(GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid)
Convert an interned PID to a normal peer identity.
Definition: peer.c:225
GNUNET_PEER_Id origin_pid
Identity of the peer that we should never forward this query to since it originated this query (0 for...
The identity of the host (wraps the signing key of the peer).
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_local_lookup_()

void GSF_local_lookup_ ( struct GSF_PendingRequest pr,
GSF_LocalLookupContinuation  cont,
void *  cont_cls 
)

Look up the request in the local datastore.

Parameters
prthe pending request to process
contfunction to call at the end
cont_clsclosure for cont

Definition at line 1695 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().

1698 {
1699  GNUNET_assert (NULL == pr->gh);
1700  GNUNET_assert (NULL == pr->cadet_request);
1701  GNUNET_assert (NULL == pr->llc_cont);
1702  pr->llc_cont = cont;
1703  pr->llc_cont_cls = cont_cls;
1704 #if INSANE_STATISTICS
1706  gettext_noop ("# Datastore lookups initiated"),
1707  1,
1708  GNUNET_NO);
1709 #endif
1710  start_local_query (pr, 0 /* next_uid */, true /* random */);
1711 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
#define GNUNET_NO
Definition: gnunet_common.h:78
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
GSF_LocalLookupContinuation llc_cont
Function to call upon completion of the local get request, or NULL for none.
static void start_local_query(struct GSF_PendingRequest *pr, uint64_t next_uid, bool random)
void * llc_cont_cls
Closure for llc_cont.
struct GNUNET_DHT_GetHandle * gh
DHT request handle for this request (or NULL for none).
struct GSF_CadetRequest * cadet_request
Cadet request handle for this request (or NULL for none).
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_p2p_put()

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).

Parameters
clsthe other peer involved
putthe actual message

Definition at line 1724 of file gnunet-service-fs_pr.c.

References active_to_migration, ProcessReplyClosure::anonymity_level, CONTENT_BANDWIDTH_VALUE, ProcessReplyClosure::data, ProcessReplyClosure::eo, expiration, PutMessage::expiration, ProcessReplyClosure::expiration, gettext_noop, GNUNET_assert, GNUNET_BLOCK_EO_NONE, 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, peer, pid, 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.

1725 {
1726  struct GSF_ConnectedPeer *cp = cls;
1727  uint16_t msize;
1728  size_t dsize;
1729  enum GNUNET_BLOCK_Type type;
1731  struct GNUNET_HashCode query;
1732  struct ProcessReplyClosure prq;
1733  struct GNUNET_TIME_Relative block_time;
1734  double putl;
1735  struct PutMigrationContext *pmc;
1736 
1738  "Received P2P PUT from %s\n",
1741  msize = ntohs (put->header.size);
1742  dsize = msize - sizeof(struct PutMessage);
1743  type = ntohl (put->type);
1745  /* do not allow migrated content to live longer than 1 year */
1748  expiration);
1749  if (GNUNET_OK !=
1750  GNUNET_BLOCK_get_key (GSF_block_ctx, type, &put[1], dsize, &query))
1751  {
1752  GNUNET_break_op (0);
1753  return;
1754  }
1756  gettext_noop ("# GAP PUT messages received"),
1757  1,
1758  GNUNET_NO);
1759  /* now, lookup 'query' */
1760  prq.data = (const void *) &put[1];
1761  prq.sender = cp;
1762  prq.size = dsize;
1763  prq.type = type;
1764  prq.expiration = expiration;
1765  prq.priority = 0;
1766  prq.anonymity_level = UINT32_MAX;
1767  prq.request_found = GNUNET_NO;
1768  prq.eo = GNUNET_BLOCK_EO_NONE;
1770  &query,
1771  &process_reply,
1772  &prq);
1773  if (NULL != cp)
1774  {
1777  + 1000 * prq.priority);
1778  GSF_get_peer_performance_data_ (cp)->respect += prq.priority;
1779  }
1780  if ((GNUNET_YES == active_to_migration) && (NULL != cp) &&
1781  (GNUNET_NO == test_put_load_too_high (prq.priority)))
1782  {
1784  "Replicating result for query `%s' with priority %u\n",
1785  GNUNET_h2s (&query),
1786  prq.priority);
1787  pmc = GNUNET_new (struct PutMigrationContext);
1788  pmc->start = GNUNET_TIME_absolute_get ();
1789  pmc->requested = prq.request_found;
1792  &pmc->origin);
1793  if (NULL == GNUNET_DATASTORE_put (GSF_dsh,
1794  0,
1795  &query,
1796  dsize,
1797  &put[1],
1798  type,
1799  prq.priority,
1800  1 /* anonymity */,
1801  0 /* replication */,
1802  expiration,
1803  1 + prq.priority,
1806  pmc))
1807  {
1809  GNUNET_SYSERR,
1811  NULL);
1812  }
1813  }
1814  else if (NULL != cp)
1815  {
1817  "Choosing not to keep content `%s' (%d/%d)\n",
1818  GNUNET_h2s (&query),
1820  test_put_load_too_high (prq.priority));
1821  }
1823  if ((NULL != cp) && (GNUNET_NO == prq.request_found) &&
1825  (putl > 2.5 * (1 + prq.priority))))
1826  {
1829  block_time = GNUNET_TIME_relative_multiply (
1832  (unsigned int) (60000 * putl * putl)));
1833  GNUNET_log (
1835  "Asking to stop migration for %s because of load %f and events %d/%d\n",
1837  putl,
1839  (GNUNET_NO == prq.request_found));
1841  GNUNET_TIME_relative_to_absolute (block_time));
1842  }
1843 }
void GSF_connected_peer_change_preference_(struct GSF_ConnectedPeer *cp, uint64_t pref)
Notify core about a preference we have for the given peer (to allocate more resources towards it)...
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:673
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
Response from FS service with a result for a previous FS search.
Definition: fs.h:328
struct GNUNET_TIME_AbsoluteNBO expiration
When does this result expire?
Definition: fs.h:343
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_put(struct GNUNET_DATASTORE_Handle *h, uint32_t rid, 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, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the datastore.
Closure for process_reply() function.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:246
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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.
double GNUNET_LOAD_get_load(struct GNUNET_LOAD_Value *load)
Get the current load.
Definition: load.c:200
static struct GNUNET_CONTAINER_MultiHashMap * pr_map
All pending requests, ordered by the query.
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
#define GNUNET_NO
Definition: gnunet_common.h:78
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Default behavior.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
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...
static int process_reply(void *cls, const struct GNUNET_HashCode *key, void *value)
We have received a reply; handle it!
void GNUNET_PEER_resolve(GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid)
Convert an interned PID to a normal peer identity.
Definition: peer.c:225
int GNUNET_BLOCK_get_key(struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, const void *block, size_t block_size, struct GNUNET_HashCode *key)
Function called to obtain the key for a block.
Definition: block.c:378
struct GNUNET_TIME_Absolute start
Start time for the operation.
uint32_t respect
Respect rating for this peer.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GSF_PeerPerformanceData * GSF_get_peer_performance_data_(struct GSF_ConnectedPeer *cp)
Return the performance data record for the given peer.
struct GNUNET_BLOCK_Context * GSF_block_ctx
Our block context.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:687
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:442
#define CONTENT_BANDWIDTH_VALUE
Bandwidth value of a 0-priority content (must be fairly high compared to query since content is typic...
struct GNUNET_MessageHeader header
Message type will be GNUNET_MESSAGE_TYPE_FS_PUT.
Definition: fs.h:333
A 512-bit hashcode.
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:96
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
struct GNUNET_DATASTORE_Handle * GSF_dsh
Our connection to the datastore.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
int requested
GNUNET_YES if we had a matching request for this block, GNUNET_NO if not.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
uint32_t type
Type of the block (in big endian).
Definition: fs.h:338
static struct GNUNET_LOAD_Value * datastore_put_load
Datastore &#39;PUT&#39; load tracking.
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
#define MAX_DATASTORE_QUEUE
Maximum size of the datastore queue for P2P operations.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_min(struct GNUNET_TIME_Absolute t1, struct GNUNET_TIME_Absolute t2)
Return the minimum of two absolute time values.
Definition: time.c:302
struct GNUNET_PeerIdentity origin
Request origin.
#define GNUNET_TIME_UNIT_YEARS
One year (365 days).
#define GNUNET_log(kind,...)
Context for put_migration_continuation().
A connected peer.
unsigned int GSF_cover_content_count
How many content messages have we received &#39;recently&#39; that have not yet been claimed as cover traffic...
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:77
void GSF_block_peer_migration_(struct GSF_ConnectedPeer *cp, struct GNUNET_TIME_Absolute block_time)
Ask a peer to stop migrating data to us until the given point in time.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
static int active_to_migration
Are we allowed to migrate content to this peer.
Time for relative time used by GNUnet, in microseconds.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

◆ GSF_pending_request_test_active_()

int GSF_pending_request_test_active_ ( struct GSF_PendingRequest pr)

Check if the given request is still active.

Parameters
prpending request
Returns
GNUNET_YES if the request is still active

Definition at line 1853 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().

1854 {
1855  return (NULL != pr->rh) ? GNUNET_YES : GNUNET_NO;
1856 }
#define GNUNET_NO
Definition: gnunet_common.h:78
GSF_PendingRequestReplyHandler rh
Function to call if we encounter a reply.
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the caller graph for this function:

◆ GSF_pending_request_init_()

void GSF_pending_request_init_ ( void  )

Setup the subsystem.

Definition at line 1863 of file gnunet-service-fs_pr.c.

References active_to_migration, DATASTORE_LOAD_AUTODECLINE, 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, and max_pending_requests.

Referenced by run().

1864 {
1865  if (GNUNET_OK !=
1867  "fs",
1868  "MAX_PENDING_REQUESTS",
1870  {
1872  "fs",
1873  "MAX_PENDING_REQUESTS");
1874  }
1876  GNUNET_CONFIGURATION_get_value_yesno (GSF_cfg, "FS", "CONTENT_CACHING");
1881 }
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
struct GNUNET_LOAD_Value * GNUNET_LOAD_value_init(struct GNUNET_TIME_Relative autodecline)
Create a new load value.
Definition: load.c:124
static struct GNUNET_CONTAINER_Heap * requests_by_expiration_heap
Heap with the request that will expire next at the top.
static struct GNUNET_CONTAINER_MultiHashMap * pr_map
All pending requests, ordered by the query.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
const struct GNUNET_CONFIGURATION_Handle * GSF_cfg
Our configuration.
static unsigned long long max_pending_requests
Maximum number of requests (from other peers, overall) that we&#39;re willing to have pending at any give...
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
Heap with the minimum cost at the root.
struct GNUNET_CONTAINER_Heap * GNUNET_CONTAINER_heap_create(enum GNUNET_CONTAINER_HeapOrder order)
Create a new heap.
static struct GNUNET_LOAD_Value * datastore_put_load
Datastore &#39;PUT&#39; load tracking.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
#define GNUNET_YES
Definition: gnunet_common.h:77
int GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
#define DATASTORE_LOAD_AUTODECLINE
At what frequency should our datastore load decrease automatically (since if we don&#39;t use it...
static int active_to_migration
Are we allowed to migrate content to this peer.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_pending_request_done_()

void GSF_pending_request_done_ ( void  )

Shutdown the subsystem.

Definition at line 1888 of file gnunet-service-fs_pr.c.

References clean_request(), GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), and GNUNET_LOAD_value_free.

Referenced by shutdown_task().

1889 {
1892  pr_map = NULL;
1896  datastore_put_load = NULL;
1897 }
static struct GNUNET_CONTAINER_Heap * requests_by_expiration_heap
Heap with the request that will expire next at the top.
static struct GNUNET_CONTAINER_MultiHashMap * pr_map
All pending requests, ordered by the query.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
static int clean_request(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator to free pending requests.
static struct GNUNET_LOAD_Value * datastore_put_load
Datastore &#39;PUT&#39; load tracking.
#define GNUNET_LOAD_value_free(lv)
Free a load value.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ pr_map

struct GNUNET_CONTAINER_MultiHashMap* pr_map
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.

◆ datastore_put_load

struct GNUNET_LOAD_Value* datastore_put_load
static

Datastore 'PUT' load tracking.

Definition at line 211 of file gnunet-service-fs_pr.c.

◆ active_to_migration

int active_to_migration
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().

◆ requests_by_expiration_heap

struct GNUNET_CONTAINER_Heap* requests_by_expiration_heap
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.

◆ max_pending_requests

unsigned long long max_pending_requests = (32 * 1024)
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_().