2 This file is part of GNUnet.
3 (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file fs/gnunet-service-fs_pr.c
23 * @brief API to handle pending requests
24 * @author Christian Grothoff
27 #include "gnunet_load_lib.h"
28 #include "gnunet-service-fs.h"
29 #include "gnunet-service-fs_cp.h"
30 #include "gnunet-service-fs_indexing.h"
31 #include "gnunet-service-fs_pe.h"
32 #include "gnunet-service-fs_pr.h"
35 * Hard limit on the number of results we may get from the datastore per query.
37 #define MAX_RESULTS (100 * 1024)
42 struct GSF_PendingRequest
45 * Public data for the request.
47 struct GSF_PendingRequestData public_data;
50 * Function to call if we encounter a reply.
52 GSF_PendingRequestReplyHandler rh;
60 * Array of hash codes of replies we've already seen.
62 GNUNET_HashCode *replies_seen;
65 * Bloomfilter masking replies we've already seen.
67 struct GNUNET_CONTAINER_BloomFilter *bf;
70 * Entry for this pending request in the expiration heap, or NULL.
72 struct GNUNET_CONTAINER_HeapNode *hnode;
75 * Datastore queue entry for this request (or NULL for none).
77 struct GNUNET_DATASTORE_QueueEntry *qe;
80 * DHT request handle for this request (or NULL for none).
82 struct GNUNET_DHT_GetHandle *gh;
85 * Function to call upon completion of the local get
86 * request, or NULL for none.
88 GSF_LocalLookupContinuation llc_cont;
91 * Closure for llc_cont.
96 * Last result from the local datastore lookup evaluation.
98 enum GNUNET_BLOCK_EvaluationResult local_result;
101 * Identity of the peer that we should use for the 'sender'
102 * (recipient of the response) when forwarding (0 for none).
104 GNUNET_PEER_Id sender_pid;
107 * Identity of the peer that we should never forward this query
108 * to since it originated this query (0 for none).
110 GNUNET_PEER_Id origin_pid;
113 * Time we started the last datastore lookup.
115 struct GNUNET_TIME_Absolute qe_start;
118 * Task that warns us if the local datastore lookup takes too long.
120 GNUNET_SCHEDULER_TaskIdentifier warn_task;
123 * Current offset for querying our local datastore for results.
124 * Starts at a random value, incremented until we get the same
125 * UID again (detected using 'first_uid'), which is then used
126 * to termiante the iteration.
128 uint64_t local_result_offset;
131 * Unique ID of the first result from the local datastore;
132 * used to detect wrap-around of the offset.
137 * Number of valid entries in the 'replies_seen' array.
139 unsigned int replies_seen_count;
142 * Length of the 'replies_seen' array.
144 unsigned int replies_seen_size;
147 * Mingle value we currently use for the bf.
152 * Do we have a first UID yet?
154 unsigned int have_first_uid;
160 * All pending requests, ordered by the query. Entries
161 * are of type 'struct GSF_PendingRequest*'.
163 static struct GNUNET_CONTAINER_MultiHashMap *pr_map;
167 * Datastore 'PUT' load tracking.
169 static struct GNUNET_LOAD_Value *datastore_put_load;
173 * Are we allowed to migrate content to this peer.
175 static int active_to_migration;
179 * Size of the datastore queue we assume for common requests.
180 * Determined based on the network quota.
182 static unsigned int datastore_queue_size;
185 * Heap with the request that will expire next at the top. Contains
186 * pointers of type "struct PendingRequest*"; these will *also* be
187 * aliased from the "requests_by_peer" data structures and the
188 * "requests_by_query" table. Note that requests from our clients
189 * don't expire and are thus NOT in the "requests_by_expiration"
190 * (or the "requests_by_peer" tables).
192 static struct GNUNET_CONTAINER_Heap *requests_by_expiration_heap;
196 * Maximum number of requests (from other peers, overall) that we're
197 * willing to have pending at any given point in time. Can be changed
198 * via the configuration file (32k is just the default).
200 static unsigned long long max_pending_requests = (32 * 1024);
205 * Recalculate our bloom filter for filtering replies. This function
206 * will create a new bloom filter from scratch, so it should only be
207 * called if we have no bloomfilter at all (and hence can create a
208 * fresh one of minimal size without problems) OR if our peer is the
209 * initiator (in which case we may resize to larger than mimimum size).
211 * @param pr request for which the BF is to be recomputed
214 refresh_bloomfilter (struct GSF_PendingRequest *pr)
217 GNUNET_CONTAINER_bloomfilter_free (pr->bf);
219 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
221 GNUNET_BLOCK_construct_bloomfilter (pr->mingle, pr->replies_seen,
222 pr->replies_seen_count);
227 * Create a new pending request.
229 * @param options request options
230 * @param type type of the block that is being requested
231 * @param query key for the lookup
232 * @param namespace namespace to lookup, NULL for no namespace
233 * @param target preferred target for the request, NULL for none
234 * @param bf_data raw data for bloom filter for known replies, can be NULL
235 * @param bf_size number of bytes in bf_data
236 * @param mingle mingle value for bf
237 * @param anonymity_level desired anonymity level
238 * @param priority maximum outgoing cummulative request priority to use
239 * @param ttl current time-to-live for the request
240 * @param sender_pid peer ID to use for the sender when forwarding, 0 for none
241 * @param origin_pid peer ID of origin of query (do not loop back)
242 * @param replies_seen hash codes of known local replies
243 * @param replies_seen_count size of the 'replies_seen' array
244 * @param rh handle to call when we get a reply
245 * @param rh_cls closure for rh
246 * @return handle for the new pending request
248 struct GSF_PendingRequest *
249 GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
250 enum GNUNET_BLOCK_Type type,
251 const GNUNET_HashCode * query,
252 const GNUNET_HashCode * namespace,
253 const struct GNUNET_PeerIdentity *target,
254 const char *bf_data, size_t bf_size,
255 uint32_t mingle, uint32_t anonymity_level,
256 uint32_t priority, int32_t ttl,
257 GNUNET_PEER_Id sender_pid,
258 GNUNET_PEER_Id origin_pid,
259 const GNUNET_HashCode * replies_seen,
260 unsigned int replies_seen_count,
261 GSF_PendingRequestReplyHandler rh, void *rh_cls)
263 struct GSF_PendingRequest *pr;
264 struct GSF_PendingRequest *dpr;
267 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
268 "Creating request handle for `%s' of type %d\n",
269 GNUNET_h2s (query), type);
271 GNUNET_STATISTICS_update (GSF_stats,
272 gettext_noop ("# Pending requests created"), 1,
274 pr = GNUNET_malloc (sizeof (struct GSF_PendingRequest));
275 pr->local_result_offset =
276 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
277 pr->public_data.query = *query;
278 if (GNUNET_BLOCK_TYPE_FS_SBLOCK == type)
280 GNUNET_assert (NULL != namespace);
281 pr->public_data.namespace = *namespace;
285 pr->public_data.target = *target;
286 pr->public_data.has_target = GNUNET_YES;
288 pr->public_data.anonymity_level = anonymity_level;
289 pr->public_data.priority = priority;
290 pr->public_data.original_priority = priority;
291 pr->public_data.options = options;
292 pr->public_data.type = type;
293 pr->public_data.start_time = GNUNET_TIME_absolute_get ();
294 pr->sender_pid = sender_pid;
295 pr->origin_pid = origin_pid;
298 GNUNET_assert ((sender_pid != 0) || (0 == (options & GSF_PRO_FORWARD_ONLY)));
300 pr->public_data.ttl =
301 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply
302 (GNUNET_TIME_UNIT_SECONDS,
305 pr->public_data.ttl =
306 GNUNET_TIME_absolute_subtract (pr->public_data.start_time,
307 GNUNET_TIME_relative_multiply
308 (GNUNET_TIME_UNIT_SECONDS,
310 if (replies_seen_count > 0)
312 pr->replies_seen_size = replies_seen_count;
314 GNUNET_malloc (sizeof (GNUNET_HashCode) * pr->replies_seen_size);
315 memcpy (pr->replies_seen, replies_seen,
316 replies_seen_count * sizeof (GNUNET_HashCode));
317 pr->replies_seen_count = replies_seen_count;
322 GNUNET_CONTAINER_bloomfilter_init (bf_data, bf_size,
323 GNUNET_CONSTANTS_BLOOMFILTER_K);
326 else if ((replies_seen_count > 0) &&
327 (0 != (options & GSF_PRO_BLOOMFILTER_FULL_REFRESH)))
329 refresh_bloomfilter (pr);
331 GNUNET_CONTAINER_multihashmap_put (pr_map, query, pr,
332 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
333 if (0 != (options & GSF_PRO_REQUEST_EXPIRES))
336 GNUNET_CONTAINER_heap_insert (requests_by_expiration_heap, pr,
337 pr->public_data.ttl.abs_value);
338 /* make sure we don't track too many requests */
339 while (GNUNET_CONTAINER_heap_get_size (requests_by_expiration_heap) >
340 max_pending_requests)
342 dpr = GNUNET_CONTAINER_heap_peek (requests_by_expiration_heap);
343 GNUNET_assert (dpr != NULL);
345 break; /* let the request live briefly... */
346 dpr->rh (dpr->rh_cls, GNUNET_BLOCK_EVALUATION_REQUEST_VALID, dpr,
347 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_BLOCK_TYPE_ANY,
349 GSF_pending_request_cancel_ (dpr, GNUNET_YES);
352 GNUNET_STATISTICS_update (GSF_stats,
353 gettext_noop ("# Pending requests active"), 1,
360 * Obtain the public data associated with a pending request
362 * @param pr pending request
363 * @return associated public data
365 struct GSF_PendingRequestData *
366 GSF_pending_request_get_data_ (struct GSF_PendingRequest *pr)
368 return &pr->public_data;
373 * Test if two pending requests are compatible (would generate
374 * the same query modulo filters and should thus be processed
377 * @param pra a pending request
378 * @param prb another pending request
379 * @return GNUNET_OK if the requests are compatible
382 GSF_pending_request_is_compatible_ (struct GSF_PendingRequest *pra,
383 struct GSF_PendingRequest *prb)
385 if ((pra->public_data.type != prb->public_data.type) ||
387 memcmp (&pra->public_data.query, &prb->public_data.query,
388 sizeof (GNUNET_HashCode))) ||
389 ((pra->public_data.type == GNUNET_BLOCK_TYPE_FS_SBLOCK) &&
391 memcmp (&pra->public_data.namespace, &prb->public_data.namespace,
392 sizeof (GNUNET_HashCode)))))
400 * Update a given pending request with additional replies
401 * that have been seen.
403 * @param pr request to update
404 * @param replies_seen hash codes of replies that we've seen
405 * @param replies_seen_count size of the replies_seen array
408 GSF_pending_request_update_ (struct GSF_PendingRequest *pr,
409 const GNUNET_HashCode * replies_seen,
410 unsigned int replies_seen_count)
413 GNUNET_HashCode mhash;
415 if (replies_seen_count + pr->replies_seen_count < pr->replies_seen_count)
416 return; /* integer overflow */
417 if (0 != (pr->public_data.options & GSF_PRO_BLOOMFILTER_FULL_REFRESH))
419 /* we're responsible for the BF, full refresh */
420 if (replies_seen_count + pr->replies_seen_count > pr->replies_seen_size)
421 GNUNET_array_grow (pr->replies_seen, pr->replies_seen_size,
422 replies_seen_count + pr->replies_seen_count);
423 memcpy (&pr->replies_seen[pr->replies_seen_count], replies_seen,
424 sizeof (GNUNET_HashCode) * replies_seen_count);
425 pr->replies_seen_count += replies_seen_count;
426 refresh_bloomfilter (pr);
432 /* we're not the initiator, but the initiator did not give us
433 * any bloom-filter, so we need to create one on-the-fly */
435 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
437 GNUNET_BLOCK_construct_bloomfilter (pr->mingle, replies_seen,
442 for (i = 0; i < pr->replies_seen_count; i++)
444 GNUNET_BLOCK_mingle_hash (&replies_seen[i], pr->mingle, &mhash);
445 GNUNET_CONTAINER_bloomfilter_add (pr->bf, &mhash);
453 * Generate the message corresponding to the given pending request for
454 * transmission to other peers (or at least determine its size).
456 * @param pr request to generate the message for
457 * @param buf_size number of bytes available in buf
458 * @param buf where to copy the message (can be NULL)
459 * @return number of bytes needed (if > buf_size) or used
462 GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr,
463 size_t buf_size, void *buf)
465 char lbuf[GNUNET_SERVER_MAX_MESSAGE_SIZE];
466 struct GetMessage *gm;
467 GNUNET_HashCode *ext;
473 struct GNUNET_TIME_Absolute now;
479 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
480 "Building request message for `%s' of type %d\n",
481 GNUNET_h2s (&pr->public_data.query), pr->public_data.type);
485 do_route = (0 == (pr->public_data.options & GSF_PRO_FORWARD_ONLY));
486 if ((!do_route) && (pr->sender_pid == 0))
489 do_route = GNUNET_YES;
493 bm |= GET_MESSAGE_BIT_RETURN_TO;
496 if (GNUNET_BLOCK_TYPE_FS_SBLOCK == pr->public_data.type)
498 bm |= GET_MESSAGE_BIT_SKS_NAMESPACE;
501 if (GNUNET_YES == pr->public_data.has_target)
503 bm |= GET_MESSAGE_BIT_TRANSMIT_TO;
506 bf_size = GNUNET_CONTAINER_bloomfilter_get_size (pr->bf);
507 msize = sizeof (struct GetMessage) + bf_size + k * sizeof (GNUNET_HashCode);
508 GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE);
509 if (buf_size < msize)
511 gm = (struct GetMessage *) lbuf;
512 gm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_GET);
513 gm->header.size = htons (msize);
514 gm->type = htonl (pr->public_data.type);
517 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
518 pr->public_data.priority + 1);
521 pr->public_data.priority -= prio;
522 gm->priority = htonl (prio);
523 now = GNUNET_TIME_absolute_get ();
524 ttl = (int64_t) (pr->public_data.ttl.abs_value - now.abs_value);
525 gm->ttl = htonl (ttl / 1000);
526 gm->filter_mutator = htonl (pr->mingle);
527 gm->hash_bitmap = htonl (bm);
528 gm->query = pr->public_data.query;
529 ext = (GNUNET_HashCode *) & gm[1];
532 GNUNET_PEER_resolve (pr->sender_pid,
533 (struct GNUNET_PeerIdentity *) &ext[k++]);
534 if (GNUNET_BLOCK_TYPE_FS_SBLOCK == pr->public_data.type)
535 memcpy (&ext[k++], &pr->public_data.namespace, sizeof (GNUNET_HashCode));
536 if (GNUNET_YES == pr->public_data.has_target)
537 ext[k++] = pr->public_data.target.hashPubKey;
539 GNUNET_assert (GNUNET_SYSERR !=
540 GNUNET_CONTAINER_bloomfilter_get_raw_data (pr->bf,
543 memcpy (buf, gm, msize);
549 * Iterator to free pending requests.
551 * @param cls closure, unused
552 * @param key current key code
553 * @param value value in the hash map (pending request)
554 * @return GNUNET_YES (we should continue to iterate)
557 clean_request (void *cls, const GNUNET_HashCode * key, void *value)
559 struct GSF_PendingRequest *pr = value;
560 GSF_LocalLookupContinuation cont;
563 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
564 "Cleaning up pending request for `%s'.\n", GNUNET_h2s (key));
566 if (NULL != (cont = pr->llc_cont))
569 cont (pr->llc_cont_cls, pr, pr->local_result);
571 GSF_plan_notify_request_done_ (pr);
572 GNUNET_free_non_null (pr->replies_seen);
575 GNUNET_CONTAINER_bloomfilter_free (pr->bf);
578 GNUNET_PEER_change_rc (pr->sender_pid, -1);
580 GNUNET_PEER_change_rc (pr->origin_pid, -1);
582 if (NULL != pr->hnode)
584 GNUNET_CONTAINER_heap_remove_node (pr->hnode);
589 GNUNET_DATASTORE_cancel (pr->qe);
594 GNUNET_DHT_get_stop (pr->gh);
597 if (GNUNET_SCHEDULER_NO_TASK != pr->warn_task)
599 GNUNET_SCHEDULER_cancel (pr->warn_task);
600 pr->warn_task = GNUNET_SCHEDULER_NO_TASK;
602 GNUNET_assert (GNUNET_OK ==
603 GNUNET_CONTAINER_multihashmap_remove (pr_map,
604 &pr->public_data.query,
606 GNUNET_STATISTICS_update (GSF_stats,
607 gettext_noop ("# Pending requests active"), -1,
615 * Explicitly cancel a pending request.
617 * @param pr request to cancel
618 * @param full_cleanup fully purge the request
621 GSF_pending_request_cancel_ (struct GSF_PendingRequest *pr, int full_cleanup)
623 GSF_LocalLookupContinuation cont;
626 return; /* already cleaned up! */
627 if (GNUNET_YES != full_cleanup)
629 /* make request inactive (we're no longer interested in more results),
630 * but do NOT remove from our data-structures, we still need it there
631 * to prevent the request from looping */
633 if (NULL != (cont = pr->llc_cont))
636 cont (pr->llc_cont_cls, pr, pr->local_result);
638 GSF_plan_notify_request_done_ (pr);
641 GNUNET_DATASTORE_cancel (pr->qe);
646 GNUNET_DHT_get_stop (pr->gh);
649 if (GNUNET_SCHEDULER_NO_TASK != pr->warn_task)
651 GNUNET_SCHEDULER_cancel (pr->warn_task);
652 pr->warn_task = GNUNET_SCHEDULER_NO_TASK;
656 GNUNET_assert (GNUNET_YES ==
657 clean_request (NULL, &pr->public_data.query, pr));
662 * Iterate over all pending requests.
664 * @param it function to call for each request
665 * @param cls closure for it
668 GSF_iterate_pending_requests_ (GSF_PendingRequestIterator it, void *cls)
670 GNUNET_CONTAINER_multihashmap_iterate (pr_map,
671 (GNUNET_CONTAINER_HashMapIterator) it,
679 * Closure for "process_reply" function.
681 struct ProcessReplyClosure
684 * The data for the reply.
689 * Who gave us this reply? NULL for local host (or DHT)
691 struct GSF_ConnectedPeer *sender;
694 * When the reply expires.
696 struct GNUNET_TIME_Absolute expiration;
706 enum GNUNET_BLOCK_Type type;
709 * How much was this reply worth to us?
714 * Anonymity requirements for this reply.
716 uint32_t anonymity_level;
719 * Evaluation result (returned).
721 enum GNUNET_BLOCK_EvaluationResult eval;
724 * Did we find a matching request?
731 * Update the performance data for the sender (if any) since
732 * the sender successfully answered one of our queries.
734 * @param prq information about the sender
735 * @param pr request that was satisfied
738 update_request_performance_data (struct ProcessReplyClosure *prq,
739 struct GSF_PendingRequest *pr)
741 if (prq->sender == NULL)
743 GSF_peer_update_performance_ (prq->sender, pr->public_data.start_time,
749 * We have received a reply; handle it!
751 * @param cls response (struct ProcessReplyClosure)
752 * @param key our query
753 * @param value value in the hash map (info about the query)
754 * @return GNUNET_YES (we should continue to iterate)
757 process_reply (void *cls, const GNUNET_HashCode * key, void *value)
759 struct ProcessReplyClosure *prq = cls;
760 struct GSF_PendingRequest *pr = value;
761 GNUNET_HashCode chash;
766 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
767 "Matched result (type %u) for query `%s' with pending request\n",
768 (unsigned int) prq->type, GNUNET_h2s (key));
770 GNUNET_STATISTICS_update (GSF_stats,
771 gettext_noop ("# replies received and matched"), 1,
774 GNUNET_BLOCK_evaluate (GSF_block_ctx, prq->type, key, &pr->bf, pr->mingle,
775 &pr->public_data.namespace,
777 GNUNET_BLOCK_TYPE_FS_SBLOCK) ?
778 sizeof (GNUNET_HashCode) : 0, prq->data,
782 case GNUNET_BLOCK_EVALUATION_OK_MORE:
783 update_request_performance_data (prq, pr);
785 case GNUNET_BLOCK_EVALUATION_OK_LAST:
786 /* short cut: stop processing early, no BF-update, etc. */
787 update_request_performance_data (prq, pr);
788 GNUNET_LOAD_update (GSF_rt_entry_lifetime,
789 GNUNET_TIME_absolute_get_duration (pr->
790 public_data.start_time).rel_value);
791 /* pass on to other peers / local clients */
792 pr->rh (pr->rh_cls, prq->eval, pr, prq->anonymity_level, prq->expiration,
793 prq->type, prq->data, prq->size);
795 case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
796 GNUNET_STATISTICS_update (GSF_stats,
798 ("# duplicate replies discarded (bloomfilter)"),
801 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
802 "Duplicate response `%s', discarding.\n", GNUNET_h2s (&mhash));
804 return GNUNET_YES; /* duplicate */
805 case GNUNET_BLOCK_EVALUATION_RESULT_INVALID:
806 return GNUNET_YES; /* wrong namespace */
807 case GNUNET_BLOCK_EVALUATION_REQUEST_VALID:
810 case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID:
813 case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED:
814 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Unsupported block type %u\n"),
818 /* update bloomfilter */
819 GNUNET_CRYPTO_hash (prq->data, prq->size, &chash);
820 GSF_pending_request_update_ (pr, &chash, 1);
821 if (NULL == prq->sender)
824 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
825 "Found result for query `%s' in local datastore\n",
828 GNUNET_STATISTICS_update (GSF_stats,
829 gettext_noop ("# results found locally"), 1,
834 GSF_dht_lookup_ (pr);
836 prq->priority += pr->public_data.original_priority;
837 pr->public_data.priority = 0;
838 pr->public_data.original_priority = 0;
839 pr->public_data.results_found++;
840 prq->request_found = GNUNET_YES;
841 /* finally, pass on to other peer / local client */
842 pr->rh (pr->rh_cls, prq->eval, pr, prq->anonymity_level, prq->expiration,
843 prq->type, prq->data, prq->size);
849 * Context for the 'put_migration_continuation'.
851 struct PutMigrationContext
855 * Start time for the operation.
857 struct GNUNET_TIME_Absolute start;
862 struct GNUNET_PeerIdentity origin;
865 * GNUNET_YES if we had a matching request for this block,
873 * Continuation called to notify client about result of the
877 * @param success GNUNET_SYSERR on failure
878 * @param msg NULL on success, otherwise an error message
881 put_migration_continuation (void *cls, int success, const char *msg)
883 struct PutMigrationContext *pmc = cls;
884 struct GNUNET_TIME_Relative delay;
885 struct GNUNET_TIME_Relative block_time;
886 struct GSF_ConnectedPeer *cp;
887 struct GSF_PeerPerformanceData *ppd;
889 delay = GNUNET_TIME_absolute_get_duration (pmc->start);
890 cp = GSF_peer_get_ (&pmc->origin);
891 if ((GNUNET_OK != success) && (GNUNET_NO == pmc->requested))
893 /* block migration for a bit... */
896 ppd = GSF_get_peer_performance_data_ (cp);
897 ppd->migration_duplication++;
899 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
900 5 * ppd->migration_duplication +
901 GNUNET_CRYPTO_random_u32
902 (GNUNET_CRYPTO_QUALITY_WEAK, 5));
903 GSF_block_peer_migration_ (cp, block_time);
910 ppd = GSF_get_peer_performance_data_ (cp);
911 ppd->migration_duplication = 0; /* reset counter */
915 /* FIXME: should we really update the load value on failure? */
916 if (NULL != datastore_put_load)
917 GNUNET_LOAD_update (datastore_put_load, delay.rel_value);
918 if (GNUNET_OK == success)
920 GNUNET_STATISTICS_update (GSF_stats,
921 gettext_noop ("# Datastore `PUT' failures"), 1,
927 * Test if the DATABASE (PUT) load on this peer is too high
928 * to even consider processing the query at
931 * @return GNUNET_YES if the load is too high to do anything (load high)
932 * GNUNET_NO to process normally (load normal or low)
935 test_put_load_too_high (uint32_t priority)
939 if (NULL == datastore_put_load)
941 if (GNUNET_LOAD_get_average (datastore_put_load) < 50)
942 return GNUNET_NO; /* very fast */
943 ld = GNUNET_LOAD_get_load (datastore_put_load);
944 if (ld < 2.0 * (1 + priority))
946 GNUNET_STATISTICS_update (GSF_stats,
948 ("# storage requests dropped due to high load"), 1,
955 * Iterator called on each result obtained for a DHT
956 * operation that expects a reply
959 * @param exp when will this value expire
960 * @param key key of the result
961 * @param get_path peers on reply path (or NULL if not recorded)
962 * @param get_path_length number of entries in get_path
963 * @param put_path peers on the PUT path (or NULL if not recorded)
964 * @param put_path_length number of entries in get_path
965 * @param type type of the result
966 * @param size number of bytes in data
967 * @param data pointer to the result data
970 handle_dht_reply (void *cls, struct GNUNET_TIME_Absolute exp,
971 const GNUNET_HashCode * key,
972 const struct GNUNET_PeerIdentity *get_path,
973 unsigned int get_path_length,
974 const struct GNUNET_PeerIdentity *put_path,
975 unsigned int put_path_length, enum GNUNET_BLOCK_Type type,
976 size_t size, const void *data)
978 struct GSF_PendingRequest *pr = cls;
979 struct ProcessReplyClosure prq;
980 struct PutMigrationContext *pmc;
982 GNUNET_STATISTICS_update (GSF_stats,
983 gettext_noop ("# Replies received from DHT"), 1,
985 memset (&prq, 0, sizeof (prq));
987 prq.expiration = exp;
990 process_reply (&prq, key, pr);
991 if ((GNUNET_YES == active_to_migration) &&
992 (GNUNET_NO == test_put_load_too_high (prq.priority)))
995 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
996 "Replicating result for query `%s' with priority %u\n",
997 GNUNET_h2s (key), prq.priority);
999 pmc = GNUNET_malloc (sizeof (struct PutMigrationContext));
1000 pmc->start = GNUNET_TIME_absolute_get ();
1001 pmc->requested = GNUNET_YES;
1003 GNUNET_DATASTORE_put (GSF_dsh, 0, key, size, data, type, prq.priority,
1005 0 /* replication */ ,
1006 exp, 1 + prq.priority, MAX_DATASTORE_QUEUE,
1007 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1008 &put_migration_continuation, pmc))
1010 put_migration_continuation (pmc, GNUNET_NO, NULL);
1017 * Consider looking up the data in the DHT (anonymity-level permitting).
1019 * @param pr the pending request to process
1022 GSF_dht_lookup_ (struct GSF_PendingRequest *pr)
1026 struct GNUNET_PeerIdentity pi;
1027 char buf[sizeof (GNUNET_HashCode) * 2];
1029 if (0 != pr->public_data.anonymity_level)
1033 GNUNET_DHT_get_stop (pr->gh);
1038 if (GNUNET_BLOCK_TYPE_FS_SBLOCK == pr->public_data.type)
1041 memcpy (buf, &pr->public_data.namespace, sizeof (GNUNET_HashCode));
1042 xquery_size = sizeof (GNUNET_HashCode);
1044 if (0 != (pr->public_data.options & GSF_PRO_FORWARD_ONLY))
1046 GNUNET_assert (0 != pr->sender_pid);
1047 GNUNET_PEER_resolve (pr->sender_pid, &pi);
1048 memcpy (&buf[xquery_size], &pi, sizeof (struct GNUNET_PeerIdentity));
1049 xquery_size += sizeof (struct GNUNET_PeerIdentity);
1052 GNUNET_DHT_get_start (GSF_dht, GNUNET_TIME_UNIT_FOREVER_REL,
1053 pr->public_data.type, &pr->public_data.query,
1054 5 /* DEFAULT_GET_REPLICATION */ ,
1055 GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
1056 /* FIXME: can no longer pass pr->bf/pr->mingle... */
1057 xquery, xquery_size, &handle_dht_reply, pr);
1062 * Task that issues a warning if the datastore lookup takes too long.
1064 * @param cls the 'struct GSF_PendingRequest'
1065 * @param tc task context
1068 warn_delay_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1070 struct GSF_PendingRequest *pr = cls;
1072 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1073 _("Datastore lookup already took %llu ms!\n"),
1074 (unsigned long long)
1075 GNUNET_TIME_absolute_get_duration (pr->qe_start).rel_value);
1077 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &warn_delay_task,
1083 * Task that issues a warning if the datastore lookup takes too long.
1085 * @param cls the 'struct GSF_PendingRequest'
1086 * @param tc task context
1089 odc_warn_delay_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1091 struct GSF_PendingRequest *pr = cls;
1093 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1094 _("On-demand lookup already took %llu ms!\n"),
1095 (unsigned long long)
1096 GNUNET_TIME_absolute_get_duration (pr->qe_start).rel_value);
1098 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
1099 &odc_warn_delay_task, pr);
1104 * We're processing (local) results for a search request
1105 * from another peer. Pass applicable results to the
1106 * peer and if we are done either clean up (operation
1107 * complete) or forward to other peers (more results possible).
1109 * @param cls our closure (struct PendingRequest)
1110 * @param key key for the content
1111 * @param size number of bytes in data
1112 * @param data content stored
1113 * @param type type of the content
1114 * @param priority priority of the content
1115 * @param anonymity anonymity-level for the content
1116 * @param expiration expiration time for the content
1117 * @param uid unique identifier for the datum;
1118 * maybe 0 if no unique identifier is available
1121 process_local_reply (void *cls, const GNUNET_HashCode * key, size_t size,
1122 const void *data, enum GNUNET_BLOCK_Type type,
1123 uint32_t priority, uint32_t anonymity,
1124 struct GNUNET_TIME_Absolute expiration, uint64_t uid)
1126 struct GSF_PendingRequest *pr = cls;
1127 GSF_LocalLookupContinuation cont;
1128 struct ProcessReplyClosure prq;
1129 GNUNET_HashCode query;
1130 unsigned int old_rf;
1132 GNUNET_SCHEDULER_cancel (pr->warn_task);
1133 pr->warn_task = GNUNET_SCHEDULER_NO_TASK;
1139 GNUNET_STATISTICS_update (GSF_stats,
1141 ("# Datastore lookups concluded (no results)"),
1144 if (GNUNET_NO == pr->have_first_uid)
1146 pr->first_uid = uid;
1147 pr->have_first_uid = 1;
1151 if ((uid == pr->first_uid) && (key != NULL))
1153 GNUNET_STATISTICS_update (GSF_stats,
1155 ("# Datastore lookups concluded (seen all)"),
1157 key = NULL; /* all replies seen! */
1159 pr->have_first_uid++;
1160 if ((pr->have_first_uid > MAX_RESULTS) && (key != NULL))
1162 GNUNET_STATISTICS_update (GSF_stats,
1164 ("# Datastore lookups aborted (more than MAX_RESULTS)"),
1166 key = NULL; /* all replies seen! */
1173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1174 "No further local responses available.\n");
1176 if ((pr->public_data.type == GNUNET_BLOCK_TYPE_FS_DBLOCK) ||
1177 (pr->public_data.type == GNUNET_BLOCK_TYPE_FS_IBLOCK))
1178 GNUNET_STATISTICS_update (GSF_stats,
1180 ("# requested DBLOCK or IBLOCK not found"), 1,
1182 goto check_error_and_continue;
1185 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1186 "Received reply for `%s' of type %d with UID %llu from datastore.\n",
1187 GNUNET_h2s (key), type, (unsigned long long) uid);
1189 if (type == GNUNET_BLOCK_TYPE_FS_ONDEMAND)
1192 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1193 "Found ONDEMAND block, performing on-demand encoding\n");
1195 GNUNET_STATISTICS_update (GSF_stats,
1197 ("# on-demand blocks matched requests"), 1,
1199 pr->qe_start = GNUNET_TIME_absolute_get ();
1201 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
1202 &odc_warn_delay_task, pr);
1204 GNUNET_FS_handle_on_demand_block (key, size, data, type, priority,
1205 anonymity, expiration, uid,
1206 &process_local_reply, pr))
1208 GNUNET_STATISTICS_update (GSF_stats,
1210 ("# on-demand lookups performed successfully"),
1212 return; /* we're done */
1214 GNUNET_STATISTICS_update (GSF_stats,
1215 gettext_noop ("# on-demand lookups failed"), 1,
1217 GNUNET_SCHEDULER_cancel (pr->warn_task);
1219 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
1220 &warn_delay_task, pr);
1222 GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset - 1,
1223 &pr->public_data.query,
1224 pr->public_data.type ==
1225 GNUNET_BLOCK_TYPE_FS_DBLOCK ?
1226 GNUNET_BLOCK_TYPE_ANY : pr->public_data.type,
1228 (GSF_PRO_PRIORITY_UNLIMITED &
1229 pr->public_data.options)) ? UINT_MAX : 1
1230 /* queue priority */ ,
1232 (GSF_PRO_PRIORITY_UNLIMITED &
1233 pr->public_data.options)) ? UINT_MAX :
1234 datastore_queue_size
1235 /* max queue size */ ,
1236 GNUNET_TIME_UNIT_FOREVER_REL,
1237 &process_local_reply, pr);
1239 return; /* we're done */
1240 GNUNET_STATISTICS_update (GSF_stats,
1242 ("# Datastore lookups concluded (error queueing)"),
1244 goto check_error_and_continue;
1246 old_rf = pr->public_data.results_found;
1247 memset (&prq, 0, sizeof (prq));
1249 prq.expiration = expiration;
1252 GNUNET_BLOCK_get_key (GSF_block_ctx, type, data, size, &query))
1255 GNUNET_DATASTORE_remove (GSF_dsh, key, size, data, -1, -1,
1256 GNUNET_TIME_UNIT_FOREVER_REL, NULL, NULL);
1257 pr->qe_start = GNUNET_TIME_absolute_get ();
1259 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
1260 &warn_delay_task, pr);
1262 GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset - 1,
1263 &pr->public_data.query,
1264 pr->public_data.type ==
1265 GNUNET_BLOCK_TYPE_FS_DBLOCK ?
1266 GNUNET_BLOCK_TYPE_ANY : pr->public_data.type,
1268 (GSF_PRO_PRIORITY_UNLIMITED &
1269 pr->public_data.options)) ? UINT_MAX : 1
1270 /* queue priority */ ,
1272 (GSF_PRO_PRIORITY_UNLIMITED &
1273 pr->public_data.options)) ? UINT_MAX :
1274 datastore_queue_size
1275 /* max queue size */ ,
1276 GNUNET_TIME_UNIT_FOREVER_REL,
1277 &process_local_reply, pr);
1280 GNUNET_STATISTICS_update (GSF_stats,
1282 ("# Datastore lookups concluded (error queueing)"),
1284 goto check_error_and_continue;
1289 prq.priority = priority;
1290 prq.request_found = GNUNET_NO;
1291 prq.anonymity_level = anonymity;
1292 if ((old_rf == 0) && (pr->public_data.results_found == 0))
1293 GSF_update_datastore_delay_ (pr->public_data.start_time);
1294 process_reply (&prq, key, pr);
1295 pr->local_result = prq.eval;
1296 if (prq.eval == GNUNET_BLOCK_EVALUATION_OK_LAST)
1298 GNUNET_STATISTICS_update (GSF_stats,
1300 ("# Datastore lookups concluded (found last result)"),
1302 goto check_error_and_continue;
1304 if ((0 == (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data.options)) &&
1305 ((GNUNET_YES == GSF_test_get_load_too_high_ (0)) ||
1306 (pr->public_data.results_found > 5 + 2 * pr->public_data.priority)))
1309 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Load too high, done with request\n");
1311 GNUNET_STATISTICS_update (GSF_stats,
1313 ("# Datastore lookups concluded (load too high)"),
1315 goto check_error_and_continue;
1317 pr->qe_start = GNUNET_TIME_absolute_get ();
1319 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &warn_delay_task,
1322 GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset++,
1323 &pr->public_data.query,
1324 pr->public_data.type ==
1325 GNUNET_BLOCK_TYPE_FS_DBLOCK ?
1326 GNUNET_BLOCK_TYPE_ANY : pr->public_data.type,
1328 (GSF_PRO_PRIORITY_UNLIMITED & pr->
1329 public_data.options)) ? UINT_MAX : 1
1330 /* queue priority */ ,
1332 (GSF_PRO_PRIORITY_UNLIMITED & pr->
1333 public_data.options)) ? UINT_MAX :
1334 datastore_queue_size
1335 /* max queue size */ ,
1336 GNUNET_TIME_UNIT_FOREVER_REL,
1337 &process_local_reply, pr);
1338 /* check if we successfully queued another datastore request;
1339 * if so, return, otherwise call our continuation (if we have
1341 check_error_and_continue:
1344 if (GNUNET_SCHEDULER_NO_TASK != pr->warn_task)
1346 GNUNET_SCHEDULER_cancel (pr->warn_task);
1347 pr->warn_task = GNUNET_SCHEDULER_NO_TASK;
1349 if (NULL == (cont = pr->llc_cont))
1350 return; /* no continuation */
1351 pr->llc_cont = NULL;
1352 cont (pr->llc_cont_cls, pr, pr->local_result);
1357 * Is the given target a legitimate peer for forwarding the given request?
1361 * @return GNUNET_YES if this request could be forwarded to the given peer
1364 GSF_pending_request_test_target_ (struct GSF_PendingRequest *pr,
1365 const struct GNUNET_PeerIdentity *target)
1367 struct GNUNET_PeerIdentity pi;
1369 if (0 == pr->origin_pid)
1371 GNUNET_PEER_resolve (pr->origin_pid, &pi);
1373 memcmp (&pi, target,
1374 sizeof (struct GNUNET_PeerIdentity))) ? GNUNET_NO :
1380 * Look up the request in the local datastore.
1382 * @param pr the pending request to process
1383 * @param cont function to call at the end
1384 * @param cont_cls closure for cont
1387 GSF_local_lookup_ (struct GSF_PendingRequest *pr,
1388 GSF_LocalLookupContinuation cont, void *cont_cls)
1390 GNUNET_assert (NULL == pr->gh);
1391 GNUNET_assert (NULL == pr->llc_cont);
1392 pr->llc_cont = cont;
1393 pr->llc_cont_cls = cont_cls;
1394 pr->qe_start = GNUNET_TIME_absolute_get ();
1396 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &warn_delay_task,
1398 GNUNET_STATISTICS_update (GSF_stats,
1399 gettext_noop ("# Datastore lookups initiated"), 1,
1402 GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset++,
1403 &pr->public_data.query,
1404 pr->public_data.type ==
1405 GNUNET_BLOCK_TYPE_FS_DBLOCK ?
1406 GNUNET_BLOCK_TYPE_ANY : pr->public_data.type,
1408 (GSF_PRO_PRIORITY_UNLIMITED & pr->
1409 public_data.options)) ? UINT_MAX : 1
1410 /* queue priority */ ,
1412 (GSF_PRO_PRIORITY_UNLIMITED & pr->
1413 public_data.options)) ? UINT_MAX :
1414 datastore_queue_size
1415 /* max queue size */ ,
1416 GNUNET_TIME_UNIT_FOREVER_REL,
1417 &process_local_reply, pr);
1420 GNUNET_STATISTICS_update (GSF_stats,
1422 ("# Datastore lookups concluded (error queueing)"),
1424 GNUNET_SCHEDULER_cancel (pr->warn_task);
1425 pr->warn_task = GNUNET_SCHEDULER_NO_TASK;
1426 pr->llc_cont = NULL;
1428 cont (cont_cls, pr, pr->local_result);
1434 * Handle P2P "CONTENT" message. Checks that the message is
1435 * well-formed and then checks if there are any pending requests for
1436 * this content and possibly passes it on (to local clients or other
1437 * peers). Does NOT perform migration (content caching at this peer).
1439 * @param cp the other peer involved (sender or receiver, NULL
1440 * for loopback messages where we are both sender and receiver)
1441 * @param message the actual message
1442 * @return GNUNET_OK if the message was well-formed,
1443 * GNUNET_SYSERR if the message was malformed (close connection,
1444 * do not cache under any circumstances)
1447 GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp,
1448 const struct GNUNET_MessageHeader *message)
1450 const struct PutMessage *put;
1453 enum GNUNET_BLOCK_Type type;
1454 struct GNUNET_TIME_Absolute expiration;
1455 GNUNET_HashCode query;
1456 struct ProcessReplyClosure prq;
1457 struct GNUNET_TIME_Relative block_time;
1459 struct PutMigrationContext *pmc;
1461 msize = ntohs (message->size);
1462 if (msize < sizeof (struct PutMessage))
1464 GNUNET_break_op (0);
1465 return GNUNET_SYSERR;
1467 put = (const struct PutMessage *) message;
1468 dsize = msize - sizeof (struct PutMessage);
1469 type = ntohl (put->type);
1470 expiration = GNUNET_TIME_absolute_ntoh (put->expiration);
1471 if (type == GNUNET_BLOCK_TYPE_FS_ONDEMAND)
1472 return GNUNET_SYSERR;
1474 GNUNET_BLOCK_get_key (GSF_block_ctx, type, &put[1], dsize, &query))
1476 GNUNET_break_op (0);
1477 return GNUNET_SYSERR;
1479 GNUNET_STATISTICS_update (GSF_stats,
1480 gettext_noop ("# GAP PUT messages received"), 1,
1482 /* now, lookup 'query' */
1483 prq.data = (const void *) &put[1];
1490 prq.expiration = expiration;
1492 prq.anonymity_level = UINT32_MAX;
1493 prq.request_found = GNUNET_NO;
1494 GNUNET_CONTAINER_multihashmap_get_multiple (pr_map, &query, &process_reply,
1498 GSF_connected_peer_change_preference_ (cp,
1499 CONTENT_BANDWIDTH_VALUE +
1500 1000 * prq.priority);
1501 GSF_get_peer_performance_data_ (cp)->trust += prq.priority;
1503 if ((GNUNET_YES == active_to_migration) &&
1504 (GNUNET_NO == test_put_load_too_high (prq.priority)))
1507 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1508 "Replicating result for query `%s' with priority %u\n",
1509 GNUNET_h2s (&query), prq.priority);
1511 pmc = GNUNET_malloc (sizeof (struct PutMigrationContext));
1512 pmc->start = GNUNET_TIME_absolute_get ();
1513 pmc->requested = prq.request_found;
1514 GNUNET_assert (0 != GSF_get_peer_performance_data_ (cp)->pid);
1515 GNUNET_PEER_resolve (GSF_get_peer_performance_data_ (cp)->pid,
1518 GNUNET_DATASTORE_put (GSF_dsh, 0, &query, dsize, &put[1], type,
1519 prq.priority, 1 /* anonymity */ ,
1520 0 /* replication */ ,
1521 expiration, 1 + prq.priority, MAX_DATASTORE_QUEUE,
1522 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1523 &put_migration_continuation, pmc))
1525 put_migration_continuation (pmc, GNUNET_NO, NULL);
1531 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1532 "Choosing not to keep content `%s' (%d/%d)\n",
1533 GNUNET_h2s (&query), active_to_migration,
1534 test_put_load_too_high (prq.priority));
1537 putl = GNUNET_LOAD_get_load (datastore_put_load);
1538 if ((NULL != (cp = prq.sender)) && (GNUNET_NO == prq.request_found) &&
1539 ((GNUNET_YES != active_to_migration) ||
1540 (putl > 2.5 * (1 + prq.priority))))
1542 if (GNUNET_YES != active_to_migration)
1543 putl = 1.0 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 5);
1545 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
1547 GNUNET_CRYPTO_random_u32
1548 (GNUNET_CRYPTO_QUALITY_WEAK,
1549 (unsigned int) (60000 * putl * putl)));
1550 GSF_block_peer_migration_ (cp, block_time);
1557 * Setup the subsystem.
1560 GSF_pending_request_init_ ()
1562 unsigned long long bps;
1565 GNUNET_CONFIGURATION_get_value_number (GSF_cfg, "fs",
1566 "MAX_PENDING_REQUESTS",
1567 &max_pending_requests))
1569 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1571 ("Configuration fails to specify `%s', assuming default value."),
1572 "MAX_PENDING_REQUESTS");
1575 GNUNET_CONFIGURATION_get_value_number (GSF_cfg, "core", "TOTAL_QUOTA_OUT",
1578 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1580 ("Configuration fails to specify `%s', assuming default value."),
1584 /* queue size should be #queries we can have pending and satisfy within
1585 * a carry interval: */
1586 datastore_queue_size =
1587 bps * GNUNET_CONSTANTS_MAX_BANDWIDTH_CARRY_S / DBLOCK_SIZE;
1589 active_to_migration =
1590 GNUNET_CONFIGURATION_get_value_yesno (GSF_cfg, "FS", "CONTENT_CACHING");
1591 datastore_put_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE);
1592 pr_map = GNUNET_CONTAINER_multihashmap_create (32 * 1024);
1593 requests_by_expiration_heap =
1594 GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
1599 * Shutdown the subsystem.
1602 GSF_pending_request_done_ ()
1604 GNUNET_CONTAINER_multihashmap_iterate (pr_map, &clean_request, NULL);
1605 GNUNET_CONTAINER_multihashmap_destroy (pr_map);
1607 GNUNET_CONTAINER_heap_destroy (requests_by_expiration_heap);
1608 requests_by_expiration_heap = NULL;
1609 GNUNET_LOAD_value_free (datastore_put_load);
1610 datastore_put_load = NULL;
1614 /* end of gnunet-service-fs_pr.c */