+ if (NULL == data)
+ {
+ /* Some apps might have an 'empty' reply as a valid reply; however,
+ 'process' will call GNUNET_BLOCK_evaluate' which treats a 'NULL'
+ reply as request-validation (but we need response-validation).
+ So we set 'data' to a 0-byte non-NULL value just to be sure */
+ GNUNET_break (0 == data_size);
+ pc.data_size = 0;
+ pc.data = ""; /* something not null */
+ }
+ GNUNET_CONTAINER_multihashmap_get_multiple (recent_map, key, &process, &pc);
+}
+
+
+/**
+ * Remove the oldest entry from the DHT routing table. Must only
+ * be called if it is known that there is at least one entry
+ * in the heap and hashmap.
+ */
+static void
+expire_oldest_entry ()
+{
+ struct RecentRequest *recent_req;
+
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop
+ ("# Entries removed from routing table"), 1,
+ GNUNET_NO);
+ recent_req = GNUNET_CONTAINER_heap_peek (recent_heap);
+ GNUNET_assert (recent_req != NULL);
+ GNUNET_CONTAINER_heap_remove_node (recent_req->heap_node);
+ GNUNET_CONTAINER_bloomfilter_free (recent_req->reply_bf);
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_remove (recent_map,
+ &recent_req->key,
+ recent_req));
+ GNUNET_free (recent_req);
+}
+
+
+/**
+ * Try to combine multiple recent requests for the same value
+ * (if they come from the same peer).
+ *
+ * @param cls the new 'struct RecentRequest' (to discard upon successful combination)
+ * @param key the query
+ * @param value the existing 'struct RecentRequest' (to update upon successful combination)
+ * @return GNUNET_OK (continue to iterate),
+ * GNUNET_SYSERR if the request was successfully combined
+ */
+static int
+try_combine_recent (void *cls, const struct GNUNET_HashCode * key, void *value)
+{
+ struct RecentRequest *in = cls;
+ struct RecentRequest *rr = value;
+
+ if ( (0 != memcmp (&in->peer,
+ &rr->peer,
+ sizeof (struct GNUNET_PeerIdentity))) ||
+ (in->type != rr->type) ||
+ (in->xquery_size != rr->xquery_size) ||
+ (0 != memcmp (in->xquery,
+ rr->xquery,
+ in->xquery_size)) )
+ return GNUNET_OK;
+ if (in->reply_bf_mutator != rr->reply_bf_mutator)
+ {
+ rr->reply_bf_mutator = in->reply_bf_mutator;
+ GNUNET_CONTAINER_bloomfilter_free (rr->reply_bf);
+ rr->reply_bf = in->reply_bf;
+ }
+ else
+ {
+ GNUNET_CONTAINER_bloomfilter_or2 (rr->reply_bf,
+ in->reply_bf);
+ GNUNET_CONTAINER_bloomfilter_free (in->reply_bf);
+ }
+ GNUNET_free (in);
+ return GNUNET_SYSERR;