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 * Heap with the request that will expire next at the top. Contains
180 * pointers of type "struct PendingRequest*"; these will *also* be
181 * aliased from the "requests_by_peer" data structures and the
182 * "requests_by_query" table. Note that requests from our clients
183 * don't expire and are thus NOT in the "requests_by_expiration"
184 * (or the "requests_by_peer" tables).
186 static struct GNUNET_CONTAINER_Heap *requests_by_expiration_heap;
190 * Maximum number of requests (from other peers, overall) that we're
191 * willing to have pending at any given point in time. Can be changed
192 * via the configuration file (32k is just the default).
194 static unsigned long long max_pending_requests = (32 * 1024);
199 * Recalculate our bloom filter for filtering replies. This function
200 * will create a new bloom filter from scratch, so it should only be
201 * called if we have no bloomfilter at all (and hence can create a
202 * fresh one of minimal size without problems) OR if our peer is the
203 * initiator (in which case we may resize to larger than mimimum size).
205 * @param pr request for which the BF is to be recomputed
208 refresh_bloomfilter (struct GSF_PendingRequest *pr)
211 GNUNET_CONTAINER_bloomfilter_free (pr->bf);
213 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
214 pr->bf = GNUNET_BLOCK_construct_bloomfilter (pr->mingle,
216 pr->replies_seen_count);
221 * Create a new pending request.
223 * @param options request options
224 * @param type type of the block that is being requested
225 * @param query key for the lookup
226 * @param namespace namespace to lookup, NULL for no namespace
227 * @param target preferred target for the request, NULL for none
228 * @param bf_data raw data for bloom filter for known replies, can be NULL
229 * @param bf_size number of bytes in bf_data
230 * @param mingle mingle value for bf
231 * @param anonymity_level desired anonymity level
232 * @param priority maximum outgoing cummulative request priority to use
233 * @param ttl current time-to-live for the request
234 * @param sender_pid peer ID to use for the sender when forwarding, 0 for none
235 * @param origin_pid peer ID of origin of query (do not loop back)
236 * @param replies_seen hash codes of known local replies
237 * @param replies_seen_count size of the 'replies_seen' array
238 * @param rh handle to call when we get a reply
239 * @param rh_cls closure for rh
240 * @return handle for the new pending request
242 struct GSF_PendingRequest *
243 GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
244 enum GNUNET_BLOCK_Type type,
245 const GNUNET_HashCode * query,
246 const GNUNET_HashCode * namespace,
247 const struct GNUNET_PeerIdentity *target,
248 const char *bf_data, size_t bf_size,
249 uint32_t mingle, uint32_t anonymity_level,
250 uint32_t priority, int32_t ttl,
251 GNUNET_PEER_Id sender_pid,
252 GNUNET_PEER_Id origin_pid,
253 const GNUNET_HashCode * replies_seen,
254 unsigned int replies_seen_count,
255 GSF_PendingRequestReplyHandler rh, void *rh_cls)
257 struct GSF_PendingRequest *pr;
258 struct GSF_PendingRequest *dpr;
261 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
262 "Creating request handle for `%s' of type %d\n",
263 GNUNET_h2s (query), type);
265 GNUNET_STATISTICS_update (GSF_stats,
266 gettext_noop ("# Pending requests created"), 1,
268 pr = GNUNET_malloc (sizeof (struct GSF_PendingRequest));
269 pr->local_result_offset =
270 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
271 pr->public_data.query = *query;
272 if (GNUNET_BLOCK_TYPE_FS_SBLOCK == type)
274 GNUNET_assert (NULL != namespace);
275 pr->public_data.namespace = *namespace;
279 pr->public_data.target = *target;
280 pr->public_data.has_target = GNUNET_YES;
282 pr->public_data.anonymity_level = anonymity_level;
283 pr->public_data.priority = priority;
284 pr->public_data.original_priority = priority;
285 pr->public_data.options = options;
286 pr->public_data.type = type;
287 pr->public_data.start_time = GNUNET_TIME_absolute_get ();
288 pr->sender_pid = sender_pid;
289 pr->origin_pid = origin_pid;
292 GNUNET_assert ((sender_pid != 0) || (0 == (options & GSF_PRO_FORWARD_ONLY)));
294 pr->public_data.ttl =
295 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply
296 (GNUNET_TIME_UNIT_SECONDS,
299 pr->public_data.ttl =
300 GNUNET_TIME_absolute_subtract (pr->public_data.start_time,
301 GNUNET_TIME_relative_multiply
302 (GNUNET_TIME_UNIT_SECONDS,
304 if (replies_seen_count > 0)
306 pr->replies_seen_size = replies_seen_count;
308 GNUNET_malloc (sizeof (GNUNET_HashCode) * pr->replies_seen_size);
309 memcpy (pr->replies_seen, replies_seen,
310 replies_seen_count * sizeof (GNUNET_HashCode));
311 pr->replies_seen_count = replies_seen_count;
316 GNUNET_CONTAINER_bloomfilter_init (bf_data, bf_size, GNUNET_CONSTANTS_BLOOMFILTER_K);
319 else if ((replies_seen_count > 0) &&
320 (0 != (options & GSF_PRO_BLOOMFILTER_FULL_REFRESH)))
322 refresh_bloomfilter (pr);
324 GNUNET_CONTAINER_multihashmap_put (pr_map, query, pr,
325 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
326 if (0 != (options & GSF_PRO_REQUEST_EXPIRES))
329 GNUNET_CONTAINER_heap_insert (requests_by_expiration_heap, pr,
330 pr->public_data.ttl.abs_value);
331 /* make sure we don't track too many requests */
332 while (GNUNET_CONTAINER_heap_get_size (requests_by_expiration_heap) >
333 max_pending_requests)
335 dpr = GNUNET_CONTAINER_heap_peek (requests_by_expiration_heap);
336 GNUNET_assert (dpr != NULL);
338 break; /* let the request live briefly... */
339 dpr->rh (dpr->rh_cls, GNUNET_BLOCK_EVALUATION_REQUEST_VALID, dpr,
340 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_BLOCK_TYPE_ANY,
342 GSF_pending_request_cancel_ (dpr, GNUNET_YES);
345 GNUNET_STATISTICS_update (GSF_stats,
346 gettext_noop ("# Pending requests active"), 1,
353 * Obtain the public data associated with a pending request
355 * @param pr pending request
356 * @return associated public data
358 struct GSF_PendingRequestData *
359 GSF_pending_request_get_data_ (struct GSF_PendingRequest *pr)
361 return &pr->public_data;
366 * Test if two pending requests are compatible (would generate
367 * the same query modulo filters and should thus be processed
370 * @param pra a pending request
371 * @param prb another pending request
372 * @return GNUNET_OK if the requests are compatible
375 GSF_pending_request_is_compatible_ (struct GSF_PendingRequest *pra,
376 struct GSF_PendingRequest *prb)
378 if ((pra->public_data.type != prb->public_data.type) ||
380 memcmp (&pra->public_data.query, &prb->public_data.query,
381 sizeof (GNUNET_HashCode))) ||
382 ((pra->public_data.type == GNUNET_BLOCK_TYPE_FS_SBLOCK) &&
384 memcmp (&pra->public_data.namespace, &prb->public_data.namespace,
385 sizeof (GNUNET_HashCode)))))
393 * Update a given pending request with additional replies
394 * that have been seen.
396 * @param pr request to update
397 * @param replies_seen hash codes of replies that we've seen
398 * @param replies_seen_count size of the replies_seen array
401 GSF_pending_request_update_ (struct GSF_PendingRequest *pr,
402 const GNUNET_HashCode * replies_seen,
403 unsigned int replies_seen_count)
406 GNUNET_HashCode mhash;
408 if (replies_seen_count + pr->replies_seen_count < pr->replies_seen_count)
409 return; /* integer overflow */
410 if (0 != (pr->public_data.options & GSF_PRO_BLOOMFILTER_FULL_REFRESH))
412 /* we're responsible for the BF, full refresh */
413 if (replies_seen_count + pr->replies_seen_count > pr->replies_seen_size)
414 GNUNET_array_grow (pr->replies_seen, pr->replies_seen_size,
415 replies_seen_count + pr->replies_seen_count);
416 memcpy (&pr->replies_seen[pr->replies_seen_count], replies_seen,
417 sizeof (GNUNET_HashCode) * replies_seen_count);
418 pr->replies_seen_count += replies_seen_count;
419 refresh_bloomfilter (pr);
425 /* we're not the initiator, but the initiator did not give us
426 * any bloom-filter, so we need to create one on-the-fly */
428 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
430 GNUNET_BLOCK_construct_bloomfilter (pr->mingle,
436 for (i = 0; i < pr->replies_seen_count; i++)
438 GNUNET_BLOCK_mingle_hash (&replies_seen[i], pr->mingle, &mhash);
439 GNUNET_CONTAINER_bloomfilter_add (pr->bf, &mhash);
447 * Generate the message corresponding to the given pending request for
448 * transmission to other peers (or at least determine its size).
450 * @param pr request to generate the message for
451 * @param buf_size number of bytes available in buf
452 * @param buf where to copy the message (can be NULL)
453 * @return number of bytes needed (if > buf_size) or used
456 GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr,
457 size_t buf_size, void *buf)
459 char lbuf[GNUNET_SERVER_MAX_MESSAGE_SIZE];
460 struct GetMessage *gm;
461 GNUNET_HashCode *ext;
467 struct GNUNET_TIME_Absolute now;
473 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
474 "Building request message for `%s' of type %d\n",
475 GNUNET_h2s (&pr->public_data.query), pr->public_data.type);
479 do_route = (0 == (pr->public_data.options & GSF_PRO_FORWARD_ONLY));
480 if ((!do_route) && (pr->sender_pid == 0))
483 do_route = GNUNET_YES;
487 bm |= GET_MESSAGE_BIT_RETURN_TO;
490 if (GNUNET_BLOCK_TYPE_FS_SBLOCK == pr->public_data.type)
492 bm |= GET_MESSAGE_BIT_SKS_NAMESPACE;
495 if (GNUNET_YES == pr->public_data.has_target)
497 bm |= GET_MESSAGE_BIT_TRANSMIT_TO;
500 bf_size = GNUNET_CONTAINER_bloomfilter_get_size (pr->bf);
501 msize = sizeof (struct GetMessage) + bf_size + k * sizeof (GNUNET_HashCode);
502 GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE);
503 if (buf_size < msize)
505 gm = (struct GetMessage *) lbuf;
506 gm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_GET);
507 gm->header.size = htons (msize);
508 gm->type = htonl (pr->public_data.type);
511 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
512 pr->public_data.priority + 1);
515 pr->public_data.priority -= prio;
516 gm->priority = htonl (prio);
517 now = GNUNET_TIME_absolute_get ();
518 ttl = (int64_t) (pr->public_data.ttl.abs_value - now.abs_value);
519 gm->ttl = htonl (ttl / 1000);
520 gm->filter_mutator = htonl (pr->mingle);
521 gm->hash_bitmap = htonl (bm);
522 gm->query = pr->public_data.query;
523 ext = (GNUNET_HashCode *) & gm[1];
526 GNUNET_PEER_resolve (pr->sender_pid,
527 (struct GNUNET_PeerIdentity *) &ext[k++]);
528 if (GNUNET_BLOCK_TYPE_FS_SBLOCK == pr->public_data.type)
529 memcpy (&ext[k++], &pr->public_data.namespace, sizeof (GNUNET_HashCode));
530 if (GNUNET_YES == pr->public_data.has_target)
531 ext[k++] = pr->public_data.target.hashPubKey;
533 GNUNET_assert (GNUNET_SYSERR !=
534 GNUNET_CONTAINER_bloomfilter_get_raw_data (pr->bf,
537 memcpy (buf, gm, msize);
543 * Iterator to free pending requests.
545 * @param cls closure, unused
546 * @param key current key code
547 * @param value value in the hash map (pending request)
548 * @return GNUNET_YES (we should continue to iterate)
551 clean_request (void *cls, const GNUNET_HashCode * key, void *value)
553 struct GSF_PendingRequest *pr = value;
554 GSF_LocalLookupContinuation cont;
557 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
558 "Cleaning up pending request for `%s'.\n", GNUNET_h2s (key));
560 if (NULL != (cont = pr->llc_cont))
563 cont (pr->llc_cont_cls, pr, pr->local_result);
565 GSF_plan_notify_request_done_ (pr);
566 GNUNET_free_non_null (pr->replies_seen);
569 GNUNET_CONTAINER_bloomfilter_free (pr->bf);
572 GNUNET_PEER_change_rc (pr->sender_pid, -1);
574 GNUNET_PEER_change_rc (pr->origin_pid, -1);
576 if (NULL != pr->hnode)
578 GNUNET_CONTAINER_heap_remove_node (pr->hnode);
583 GNUNET_DATASTORE_cancel (pr->qe);
588 GNUNET_DHT_get_stop (pr->gh);
591 if (GNUNET_SCHEDULER_NO_TASK != pr->warn_task)
593 GNUNET_SCHEDULER_cancel (pr->warn_task);
594 pr->warn_task = GNUNET_SCHEDULER_NO_TASK;
596 GNUNET_assert (GNUNET_OK ==
597 GNUNET_CONTAINER_multihashmap_remove (pr_map,
598 &pr->public_data.query,
600 GNUNET_STATISTICS_update (GSF_stats,
601 gettext_noop ("# Pending requests active"), -1,
609 * Explicitly cancel a pending request.
611 * @param pr request to cancel
612 * @param full_cleanup fully purge the request
615 GSF_pending_request_cancel_ (struct GSF_PendingRequest *pr, int full_cleanup)
617 GSF_LocalLookupContinuation cont;
620 return; /* already cleaned up! */
621 if (GNUNET_YES != full_cleanup)
623 /* make request inactive (we're no longer interested in more results),
624 * but do NOT remove from our data-structures, we still need it there
625 * to prevent the request from looping */
627 if (NULL != (cont = pr->llc_cont))
630 cont (pr->llc_cont_cls, pr, pr->local_result);
632 GSF_plan_notify_request_done_ (pr);
635 GNUNET_DATASTORE_cancel (pr->qe);
640 GNUNET_DHT_get_stop (pr->gh);
643 if (GNUNET_SCHEDULER_NO_TASK != pr->warn_task)
645 GNUNET_SCHEDULER_cancel (pr->warn_task);
646 pr->warn_task = GNUNET_SCHEDULER_NO_TASK;
650 GNUNET_assert (GNUNET_YES ==
651 clean_request (NULL, &pr->public_data.query, pr));
656 * Iterate over all pending requests.
658 * @param it function to call for each request
659 * @param cls closure for it
662 GSF_iterate_pending_requests_ (GSF_PendingRequestIterator it, void *cls)
664 GNUNET_CONTAINER_multihashmap_iterate (pr_map,
665 (GNUNET_CONTAINER_HashMapIterator) it,
673 * Closure for "process_reply" function.
675 struct ProcessReplyClosure
678 * The data for the reply.
683 * Who gave us this reply? NULL for local host (or DHT)
685 struct GSF_ConnectedPeer *sender;
688 * When the reply expires.
690 struct GNUNET_TIME_Absolute expiration;
700 enum GNUNET_BLOCK_Type type;
703 * How much was this reply worth to us?
708 * Anonymity requirements for this reply.
710 uint32_t anonymity_level;
713 * Evaluation result (returned).
715 enum GNUNET_BLOCK_EvaluationResult eval;
718 * Did we find a matching request?
725 * Update the performance data for the sender (if any) since
726 * the sender successfully answered one of our queries.
728 * @param prq information about the sender
729 * @param pr request that was satisfied
732 update_request_performance_data (struct ProcessReplyClosure *prq,
733 struct GSF_PendingRequest *pr)
735 if (prq->sender == NULL)
737 GSF_peer_update_performance_ (prq->sender, pr->public_data.start_time,
743 * We have received a reply; handle it!
745 * @param cls response (struct ProcessReplyClosure)
746 * @param key our query
747 * @param value value in the hash map (info about the query)
748 * @return GNUNET_YES (we should continue to iterate)
751 process_reply (void *cls, const GNUNET_HashCode * key, void *value)
753 struct ProcessReplyClosure *prq = cls;
754 struct GSF_PendingRequest *pr = value;
755 GNUNET_HashCode chash;
760 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
761 "Matched result (type %u) for query `%s' with pending request\n",
762 (unsigned int) prq->type, GNUNET_h2s (key));
764 GNUNET_STATISTICS_update (GSF_stats,
765 gettext_noop ("# replies received and matched"), 1,
768 GNUNET_BLOCK_evaluate (GSF_block_ctx, prq->type, key, &pr->bf, pr->mingle,
769 &pr->public_data.namespace,
771 GNUNET_BLOCK_TYPE_FS_SBLOCK) ?
772 sizeof (GNUNET_HashCode) : 0, prq->data,
776 case GNUNET_BLOCK_EVALUATION_OK_MORE:
777 update_request_performance_data (prq, pr);
779 case GNUNET_BLOCK_EVALUATION_OK_LAST:
780 /* short cut: stop processing early, no BF-update, etc. */
781 update_request_performance_data (prq, pr);
782 GNUNET_LOAD_update (GSF_rt_entry_lifetime,
783 GNUNET_TIME_absolute_get_duration (pr->
784 public_data.start_time).rel_value);
785 /* pass on to other peers / local clients */
786 pr->rh (pr->rh_cls, prq->eval, pr, prq->anonymity_level, prq->expiration,
787 prq->type, prq->data, prq->size);
789 case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
790 GNUNET_STATISTICS_update (GSF_stats,
792 ("# duplicate replies discarded (bloomfilter)"),
795 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
796 "Duplicate response `%s', discarding.\n", GNUNET_h2s (&mhash));
798 return GNUNET_YES; /* duplicate */
799 case GNUNET_BLOCK_EVALUATION_RESULT_INVALID:
800 return GNUNET_YES; /* wrong namespace */
801 case GNUNET_BLOCK_EVALUATION_REQUEST_VALID:
804 case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID:
807 case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED:
808 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Unsupported block type %u\n"),
812 /* update bloomfilter */
813 GNUNET_CRYPTO_hash (prq->data, prq->size, &chash);
814 GSF_pending_request_update_ (pr, &chash, 1);
815 if (NULL == prq->sender)
818 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
819 "Found result for query `%s' in local datastore\n",
822 GNUNET_STATISTICS_update (GSF_stats,
823 gettext_noop ("# results found locally"), 1,
828 GSF_dht_lookup_ (pr);
830 prq->priority += pr->public_data.original_priority;
831 pr->public_data.priority = 0;
832 pr->public_data.original_priority = 0;
833 pr->public_data.results_found++;
834 prq->request_found = GNUNET_YES;
835 /* finally, pass on to other peer / local client */
836 pr->rh (pr->rh_cls, prq->eval, pr, prq->anonymity_level, prq->expiration,
837 prq->type, prq->data, prq->size);
843 * Context for the 'put_migration_continuation'.
845 struct PutMigrationContext
849 * Start time for the operation.
851 struct GNUNET_TIME_Absolute start;
856 struct GNUNET_PeerIdentity origin;
859 * GNUNET_YES if we had a matching request for this block,
867 * Continuation called to notify client about result of the
871 * @param success GNUNET_SYSERR on failure
872 * @param msg NULL on success, otherwise an error message
875 put_migration_continuation (void *cls, int success, const char *msg)
877 struct PutMigrationContext *pmc = cls;
878 struct GNUNET_TIME_Relative delay;
879 struct GNUNET_TIME_Relative block_time;
880 struct GSF_ConnectedPeer *cp;
881 struct GSF_PeerPerformanceData *ppd;
883 delay = GNUNET_TIME_absolute_get_duration (pmc->start);
884 cp = GSF_peer_get_ (&pmc->origin);
885 if ((GNUNET_OK != success) && (GNUNET_NO == pmc->requested))
887 /* block migration for a bit... */
890 ppd = GSF_get_peer_performance_data_ (cp);
891 ppd->migration_duplication++;
893 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
894 5 * ppd->migration_duplication +
895 GNUNET_CRYPTO_random_u32
896 (GNUNET_CRYPTO_QUALITY_WEAK, 5));
897 GSF_block_peer_migration_ (cp, block_time);
904 ppd = GSF_get_peer_performance_data_ (cp);
905 ppd->migration_duplication = 0; /* reset counter */
909 /* FIXME: should we really update the load value on failure? */
910 if (NULL != datastore_put_load)
911 GNUNET_LOAD_update (datastore_put_load, delay.rel_value);
912 if (GNUNET_OK == success)
914 GNUNET_STATISTICS_update (GSF_stats,
915 gettext_noop ("# Datastore `PUT' failures"), 1,
921 * Test if the DATABASE (PUT) load on this peer is too high
922 * to even consider processing the query at
925 * @return GNUNET_YES if the load is too high to do anything (load high)
926 * GNUNET_NO to process normally (load normal or low)
929 test_put_load_too_high (uint32_t priority)
933 if (NULL == datastore_put_load)
935 if (GNUNET_LOAD_get_average (datastore_put_load) < 50)
936 return GNUNET_NO; /* very fast */
937 ld = GNUNET_LOAD_get_load (datastore_put_load);
938 if (ld < 2.0 * (1 + priority))
940 GNUNET_STATISTICS_update (GSF_stats,
942 ("# storage requests dropped due to high load"), 1,
949 * Iterator called on each result obtained for a DHT
950 * operation that expects a reply
953 * @param exp when will this value expire
954 * @param key key of the result
955 * @param get_path peers on reply path (or NULL if not recorded)
956 * @param get_path_length number of entries in get_path
957 * @param put_path peers on the PUT path (or NULL if not recorded)
958 * @param put_path_length number of entries in get_path
959 * @param type type of the result
960 * @param size number of bytes in data
961 * @param data pointer to the result data
964 handle_dht_reply (void *cls, struct GNUNET_TIME_Absolute exp,
965 const GNUNET_HashCode * key,
966 const struct GNUNET_PeerIdentity *get_path,
967 unsigned int get_path_length,
968 const struct GNUNET_PeerIdentity *put_path,
969 unsigned int put_path_length,
970 enum GNUNET_BLOCK_Type type, size_t size, const void *data)
972 struct GSF_PendingRequest *pr = cls;
973 struct ProcessReplyClosure prq;
974 struct PutMigrationContext *pmc;
976 GNUNET_STATISTICS_update (GSF_stats,
977 gettext_noop ("# Replies received from DHT"), 1,
979 memset (&prq, 0, sizeof (prq));
981 prq.expiration = exp;
984 process_reply (&prq, key, pr);
985 if ((GNUNET_YES == active_to_migration) &&
986 (GNUNET_NO == test_put_load_too_high (prq.priority)))
989 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
990 "Replicating result for query `%s' with priority %u\n",
991 GNUNET_h2s (key), prq.priority);
993 pmc = GNUNET_malloc (sizeof (struct PutMigrationContext));
994 pmc->start = GNUNET_TIME_absolute_get ();
995 pmc->requested = GNUNET_YES;
997 GNUNET_DATASTORE_put (GSF_dsh, 0, key, size, data, type, prq.priority,
999 0 /* replication */ ,
1000 exp, 1 + prq.priority, MAX_DATASTORE_QUEUE,
1001 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1002 &put_migration_continuation, pmc))
1004 put_migration_continuation (pmc, GNUNET_NO, NULL);
1011 * Consider looking up the data in the DHT (anonymity-level permitting).
1013 * @param pr the pending request to process
1016 GSF_dht_lookup_ (struct GSF_PendingRequest *pr)
1020 struct GNUNET_PeerIdentity pi;
1021 char buf[sizeof (GNUNET_HashCode) * 2];
1023 if (0 != pr->public_data.anonymity_level)
1027 GNUNET_DHT_get_stop (pr->gh);
1032 if (GNUNET_BLOCK_TYPE_FS_SBLOCK == pr->public_data.type)
1035 memcpy (buf, &pr->public_data.namespace, sizeof (GNUNET_HashCode));
1036 xquery_size = sizeof (GNUNET_HashCode);
1038 if (0 != (pr->public_data.options & GSF_PRO_FORWARD_ONLY))
1040 GNUNET_assert (0 != pr->sender_pid);
1041 GNUNET_PEER_resolve (pr->sender_pid, &pi);
1042 memcpy (&buf[xquery_size], &pi, sizeof (struct GNUNET_PeerIdentity));
1043 xquery_size += sizeof (struct GNUNET_PeerIdentity);
1046 GNUNET_DHT_get_start (GSF_dht, GNUNET_TIME_UNIT_FOREVER_REL,
1047 pr->public_data.type, &pr->public_data.query,
1048 5 /* DEFAULT_GET_REPLICATION */,
1049 GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
1050 /* FIXME: can no longer pass pr->bf/pr->mingle... */
1051 xquery, xquery_size, &handle_dht_reply,
1057 * Task that issues a warning if the datastore lookup takes too long.
1059 * @param cls the 'struct GSF_PendingRequest'
1060 * @param tc task context
1063 warn_delay_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1065 struct GSF_PendingRequest *pr = cls;
1067 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1068 _("Datastore lookup already took %llu ms!\n"),
1069 (unsigned long long)
1070 GNUNET_TIME_absolute_get_duration (pr->qe_start).rel_value);
1072 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &warn_delay_task,
1078 * Task that issues a warning if the datastore lookup takes too long.
1080 * @param cls the 'struct GSF_PendingRequest'
1081 * @param tc task context
1084 odc_warn_delay_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1086 struct GSF_PendingRequest *pr = cls;
1088 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1089 _("On-demand lookup already took %llu ms!\n"),
1090 (unsigned long long)
1091 GNUNET_TIME_absolute_get_duration (pr->qe_start).rel_value);
1093 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
1094 &odc_warn_delay_task, pr);
1099 * We're processing (local) results for a search request
1100 * from another peer. Pass applicable results to the
1101 * peer and if we are done either clean up (operation
1102 * complete) or forward to other peers (more results possible).
1104 * @param cls our closure (struct PendingRequest)
1105 * @param key key for the content
1106 * @param size number of bytes in data
1107 * @param data content stored
1108 * @param type type of the content
1109 * @param priority priority of the content
1110 * @param anonymity anonymity-level for the content
1111 * @param expiration expiration time for the content
1112 * @param uid unique identifier for the datum;
1113 * maybe 0 if no unique identifier is available
1116 process_local_reply (void *cls, const GNUNET_HashCode * key, size_t size,
1117 const void *data, enum GNUNET_BLOCK_Type type,
1118 uint32_t priority, uint32_t anonymity,
1119 struct GNUNET_TIME_Absolute expiration, uint64_t uid)
1121 struct GSF_PendingRequest *pr = cls;
1122 GSF_LocalLookupContinuation cont;
1123 struct ProcessReplyClosure prq;
1124 GNUNET_HashCode query;
1125 unsigned int old_rf;
1127 GNUNET_SCHEDULER_cancel (pr->warn_task);
1128 pr->warn_task = GNUNET_SCHEDULER_NO_TASK;
1134 GNUNET_STATISTICS_update (GSF_stats,
1136 ("# Datastore lookups concluded (no results)"),
1139 if (GNUNET_NO == pr->have_first_uid)
1141 pr->first_uid = uid;
1142 pr->have_first_uid = 1;
1146 if ((uid == pr->first_uid) && (key != NULL))
1148 GNUNET_STATISTICS_update (GSF_stats,
1150 ("# Datastore lookups concluded (seen all)"),
1152 key = NULL; /* all replies seen! */
1154 pr->have_first_uid++;
1155 if ((pr->have_first_uid > MAX_RESULTS) && (key != NULL))
1157 GNUNET_STATISTICS_update (GSF_stats,
1159 ("# Datastore lookups aborted (more than MAX_RESULTS)"),
1161 key = NULL; /* all replies seen! */
1168 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1169 "No further local responses available.\n");
1171 if ((pr->public_data.type == GNUNET_BLOCK_TYPE_FS_DBLOCK) ||
1172 (pr->public_data.type == GNUNET_BLOCK_TYPE_FS_IBLOCK))
1173 GNUNET_STATISTICS_update (GSF_stats,
1175 ("# requested DBLOCK or IBLOCK not found"), 1,
1177 goto check_error_and_continue;
1180 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1181 "Received reply for `%s' of type %d with UID %llu from datastore.\n",
1182 GNUNET_h2s (key), type, (unsigned long long) uid);
1184 if (type == GNUNET_BLOCK_TYPE_FS_ONDEMAND)
1187 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1188 "Found ONDEMAND block, performing on-demand encoding\n");
1190 GNUNET_STATISTICS_update (GSF_stats,
1192 ("# on-demand blocks matched requests"), 1,
1194 pr->qe_start = GNUNET_TIME_absolute_get ();
1196 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
1197 &odc_warn_delay_task, pr);
1199 GNUNET_FS_handle_on_demand_block (key, size, data, type, priority,
1200 anonymity, expiration, uid,
1201 &process_local_reply, pr))
1203 GNUNET_STATISTICS_update (GSF_stats,
1205 ("# on-demand lookups performed successfully"),
1207 return; /* we're done */
1209 GNUNET_STATISTICS_update (GSF_stats,
1210 gettext_noop ("# on-demand lookups failed"), 1,
1212 GNUNET_SCHEDULER_cancel (pr->warn_task);
1214 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
1215 &warn_delay_task, pr);
1217 GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset - 1,
1218 &pr->public_data.query,
1219 pr->public_data.type ==
1220 GNUNET_BLOCK_TYPE_FS_DBLOCK ?
1221 GNUNET_BLOCK_TYPE_ANY : pr->public_data.type,
1223 (GSF_PRO_PRIORITY_UNLIMITED &
1224 pr->public_data.options)) ? UINT_MAX : 1
1225 /* queue priority */ ,
1227 (GSF_PRO_PRIORITY_UNLIMITED &
1228 pr->public_data.options)) ? UINT_MAX : 16
1229 /* max queue size */ ,
1230 GNUNET_TIME_UNIT_FOREVER_REL,
1231 &process_local_reply, pr);
1233 return; /* we're done */
1234 GNUNET_STATISTICS_update (GSF_stats,
1236 ("# Datastore lookups concluded (error queueing)"),
1238 goto check_error_and_continue;
1240 old_rf = pr->public_data.results_found;
1241 memset (&prq, 0, sizeof (prq));
1243 prq.expiration = expiration;
1246 GNUNET_BLOCK_get_key (GSF_block_ctx, type, data, size, &query))
1249 GNUNET_DATASTORE_remove (GSF_dsh, key, size, data, -1, -1,
1250 GNUNET_TIME_UNIT_FOREVER_REL, NULL, NULL);
1251 pr->qe_start = GNUNET_TIME_absolute_get ();
1253 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
1254 &warn_delay_task, pr);
1256 GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset - 1,
1257 &pr->public_data.query,
1258 pr->public_data.type ==
1259 GNUNET_BLOCK_TYPE_FS_DBLOCK ?
1260 GNUNET_BLOCK_TYPE_ANY : pr->public_data.type,
1262 (GSF_PRO_PRIORITY_UNLIMITED &
1263 pr->public_data.options)) ? UINT_MAX : 1
1264 /* queue priority */ ,
1266 (GSF_PRO_PRIORITY_UNLIMITED &
1267 pr->public_data.options)) ? UINT_MAX : 16
1268 /* max queue size */ ,
1269 GNUNET_TIME_UNIT_FOREVER_REL,
1270 &process_local_reply, pr);
1273 GNUNET_STATISTICS_update (GSF_stats,
1275 ("# Datastore lookups concluded (error queueing)"),
1277 goto check_error_and_continue;
1282 prq.priority = priority;
1283 prq.request_found = GNUNET_NO;
1284 prq.anonymity_level = anonymity;
1285 if ((old_rf == 0) && (pr->public_data.results_found == 0))
1286 GSF_update_datastore_delay_ (pr->public_data.start_time);
1287 process_reply (&prq, key, pr);
1288 pr->local_result = prq.eval;
1289 if (prq.eval == GNUNET_BLOCK_EVALUATION_OK_LAST)
1291 GNUNET_STATISTICS_update (GSF_stats,
1293 ("# Datastore lookups concluded (found last result)"),
1295 goto check_error_and_continue;
1297 if ((0 == (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data.options)) &&
1298 ((GNUNET_YES == GSF_test_get_load_too_high_ (0)) ||
1299 (pr->public_data.results_found > 5 + 2 * pr->public_data.priority)))
1302 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Load too high, done with request\n");
1304 GNUNET_STATISTICS_update (GSF_stats,
1306 ("# Datastore lookups concluded (load too high)"),
1308 goto check_error_and_continue;
1310 pr->qe_start = GNUNET_TIME_absolute_get ();
1312 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &warn_delay_task,
1315 GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset++,
1316 &pr->public_data.query,
1317 pr->public_data.type ==
1318 GNUNET_BLOCK_TYPE_FS_DBLOCK ?
1319 GNUNET_BLOCK_TYPE_ANY : pr->public_data.type,
1321 (GSF_PRO_PRIORITY_UNLIMITED & pr->
1322 public_data.options)) ? UINT_MAX : 1
1323 /* queue priority */ ,
1325 (GSF_PRO_PRIORITY_UNLIMITED & pr->
1326 public_data.options)) ? UINT_MAX : 16
1327 /* max queue size */ ,
1328 GNUNET_TIME_UNIT_FOREVER_REL,
1329 &process_local_reply, pr);
1330 /* check if we successfully queued another datastore request;
1331 * if so, return, otherwise call our continuation (if we have
1333 check_error_and_continue:
1336 if (GNUNET_SCHEDULER_NO_TASK != pr->warn_task)
1338 GNUNET_SCHEDULER_cancel (pr->warn_task);
1339 pr->warn_task = GNUNET_SCHEDULER_NO_TASK;
1341 if (NULL == (cont = pr->llc_cont))
1342 return; /* no continuation */
1343 pr->llc_cont = NULL;
1344 cont (pr->llc_cont_cls, pr, pr->local_result);
1349 * Is the given target a legitimate peer for forwarding the given request?
1353 * @return GNUNET_YES if this request could be forwarded to the given peer
1356 GSF_pending_request_test_target_ (struct GSF_PendingRequest *pr,
1357 const struct GNUNET_PeerIdentity *target)
1359 struct GNUNET_PeerIdentity pi;
1361 if (0 == pr->origin_pid)
1363 GNUNET_PEER_resolve (pr->origin_pid, &pi);
1364 return (0 == memcmp (&pi, target, sizeof (struct GNUNET_PeerIdentity))) ? GNUNET_NO :GNUNET_YES;
1369 * Look up the request in the local datastore.
1371 * @param pr the pending request to process
1372 * @param cont function to call at the end
1373 * @param cont_cls closure for cont
1376 GSF_local_lookup_ (struct GSF_PendingRequest *pr,
1377 GSF_LocalLookupContinuation cont, void *cont_cls)
1379 GNUNET_assert (NULL == pr->gh);
1380 GNUNET_assert (NULL == pr->llc_cont);
1381 pr->llc_cont = cont;
1382 pr->llc_cont_cls = cont_cls;
1383 pr->qe_start = GNUNET_TIME_absolute_get ();
1385 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &warn_delay_task,
1387 GNUNET_STATISTICS_update (GSF_stats,
1388 gettext_noop ("# Datastore lookups initiated"), 1,
1391 GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset++,
1392 &pr->public_data.query,
1393 pr->public_data.type ==
1394 GNUNET_BLOCK_TYPE_FS_DBLOCK ?
1395 GNUNET_BLOCK_TYPE_ANY : pr->public_data.type,
1397 (GSF_PRO_PRIORITY_UNLIMITED & pr->
1398 public_data.options)) ? UINT_MAX : 1
1399 /* queue priority */ ,
1401 (GSF_PRO_PRIORITY_UNLIMITED & pr->
1402 public_data.options)) ? UINT_MAX : 16
1403 /* max queue size */ ,
1404 GNUNET_TIME_UNIT_FOREVER_REL,
1405 &process_local_reply, pr);
1408 GNUNET_STATISTICS_update (GSF_stats,
1410 ("# Datastore lookups concluded (error queueing)"),
1412 GNUNET_SCHEDULER_cancel (pr->warn_task);
1413 pr->warn_task = GNUNET_SCHEDULER_NO_TASK;
1414 pr->llc_cont = NULL;
1416 cont (cont_cls, pr, pr->local_result);
1422 * Handle P2P "CONTENT" message. Checks that the message is
1423 * well-formed and then checks if there are any pending requests for
1424 * this content and possibly passes it on (to local clients or other
1425 * peers). Does NOT perform migration (content caching at this peer).
1427 * @param cp the other peer involved (sender or receiver, NULL
1428 * for loopback messages where we are both sender and receiver)
1429 * @param message the actual message
1430 * @return GNUNET_OK if the message was well-formed,
1431 * GNUNET_SYSERR if the message was malformed (close connection,
1432 * do not cache under any circumstances)
1435 GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp,
1436 const struct GNUNET_MessageHeader *message)
1438 const struct PutMessage *put;
1441 enum GNUNET_BLOCK_Type type;
1442 struct GNUNET_TIME_Absolute expiration;
1443 GNUNET_HashCode query;
1444 struct ProcessReplyClosure prq;
1445 struct GNUNET_TIME_Relative block_time;
1447 struct PutMigrationContext *pmc;
1449 msize = ntohs (message->size);
1450 if (msize < sizeof (struct PutMessage))
1452 GNUNET_break_op (0);
1453 return GNUNET_SYSERR;
1455 put = (const struct PutMessage *) message;
1456 dsize = msize - sizeof (struct PutMessage);
1457 type = ntohl (put->type);
1458 expiration = GNUNET_TIME_absolute_ntoh (put->expiration);
1459 if (type == GNUNET_BLOCK_TYPE_FS_ONDEMAND)
1460 return GNUNET_SYSERR;
1462 GNUNET_BLOCK_get_key (GSF_block_ctx, type, &put[1], dsize, &query))
1464 GNUNET_break_op (0);
1465 return GNUNET_SYSERR;
1467 GNUNET_STATISTICS_update (GSF_stats,
1468 gettext_noop ("# GAP PUT messages received"), 1,
1470 /* now, lookup 'query' */
1471 prq.data = (const void *) &put[1];
1478 prq.expiration = expiration;
1480 prq.anonymity_level = UINT32_MAX;
1481 prq.request_found = GNUNET_NO;
1482 GNUNET_CONTAINER_multihashmap_get_multiple (pr_map, &query, &process_reply,
1486 GSF_connected_peer_change_preference_ (cp,
1487 CONTENT_BANDWIDTH_VALUE +
1488 1000 * prq.priority);
1489 GSF_get_peer_performance_data_ (cp)->trust += prq.priority;
1491 if ((GNUNET_YES == active_to_migration) &&
1492 (GNUNET_NO == test_put_load_too_high (prq.priority)))
1495 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1496 "Replicating result for query `%s' with priority %u\n",
1497 GNUNET_h2s (&query), prq.priority);
1499 pmc = GNUNET_malloc (sizeof (struct PutMigrationContext));
1500 pmc->start = GNUNET_TIME_absolute_get ();
1501 pmc->requested = prq.request_found;
1502 GNUNET_assert (0 != GSF_get_peer_performance_data_ (cp)->pid);
1503 GNUNET_PEER_resolve (GSF_get_peer_performance_data_ (cp)->pid,
1506 GNUNET_DATASTORE_put (GSF_dsh, 0, &query, dsize, &put[1], type,
1507 prq.priority, 1 /* anonymity */ ,
1508 0 /* replication */ ,
1509 expiration, 1 + prq.priority, MAX_DATASTORE_QUEUE,
1510 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1511 &put_migration_continuation, pmc))
1513 put_migration_continuation (pmc, GNUNET_NO, NULL);
1519 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1520 "Choosing not to keep content `%s' (%d/%d)\n",
1521 GNUNET_h2s (&query), active_to_migration,
1522 test_put_load_too_high (prq.priority));
1525 putl = GNUNET_LOAD_get_load (datastore_put_load);
1526 if ((NULL != (cp = prq.sender)) && (GNUNET_NO == prq.request_found) &&
1527 ((GNUNET_YES != active_to_migration) ||
1528 (putl > 2.5 * (1 + prq.priority))))
1530 if (GNUNET_YES != active_to_migration)
1531 putl = 1.0 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 5);
1533 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
1535 GNUNET_CRYPTO_random_u32
1536 (GNUNET_CRYPTO_QUALITY_WEAK,
1537 (unsigned int) (60000 * putl * putl)));
1538 GSF_block_peer_migration_ (cp, block_time);
1545 * Setup the subsystem.
1548 GSF_pending_request_init_ ()
1551 GNUNET_CONFIGURATION_get_value_number (GSF_cfg, "fs",
1552 "MAX_PENDING_REQUESTS",
1553 &max_pending_requests))
1555 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1557 ("Configuration fails to specify `%s', assuming default value."),
1558 "MAX_PENDING_REQUESTS");
1560 active_to_migration =
1561 GNUNET_CONFIGURATION_get_value_yesno (GSF_cfg, "FS", "CONTENT_CACHING");
1562 datastore_put_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE);
1563 pr_map = GNUNET_CONTAINER_multihashmap_create (32 * 1024);
1564 requests_by_expiration_heap =
1565 GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
1570 * Shutdown the subsystem.
1573 GSF_pending_request_done_ ()
1575 GNUNET_CONTAINER_multihashmap_iterate (pr_map, &clean_request, NULL);
1576 GNUNET_CONTAINER_multihashmap_destroy (pr_map);
1578 GNUNET_CONTAINER_heap_destroy (requests_by_expiration_heap);
1579 requests_by_expiration_heap = NULL;
1580 GNUNET_LOAD_value_free (datastore_put_load);
1581 datastore_put_load = NULL;
1585 /* end of gnunet-service-fs_pr.c */