#include "fs_api.h"
#include "fs_tree.h"
-#define DEBUG_DOWNLOAD GNUNET_EXTRA_LOGGING
/**
* Determine if the given download (options and meta data) should cause
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Matching block for `%s' at offset %llu already present, no need for download!\n",
dc->filename, (unsigned long long) dr->offset);
-#endif
/* already got it! */
prc.dc = dc;
prc.data = enc;
if (type != EXTRACTOR_METATYPE_GNUNET_FULL_DATA)
return 0;
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found %u bytes of FD!\n",
(unsigned int) data_len);
-#endif
if (GNUNET_FS_uri_chk_get_file_size (dc->uri) != data_len)
{
GNUNET_break_op (0);
GNUNET_break (0);
return;
}
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Scheduling download at offset %llu and depth %u for `%s'\n",
(unsigned long long) dr->offset, dr->depth,
GNUNET_h2s (&dr->chk.query));
-#endif
if (GNUNET_NO !=
GNUNET_CONTAINER_multihashmap_contains_value (dc->active, &dr->chk.query,
dr))
}
temp_name = NULL;
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Triggering recursive download of size %llu with %u bytes MD\n",
(unsigned long long) GNUNET_FS_uri_chk_get_file_size (uri),
(unsigned int)
GNUNET_CONTAINER_meta_data_get_serialized_size (meta));
-#endif
GNUNET_FS_download_start (dc->h, uri, meta, full_name, temp_name, 0,
GNUNET_FS_uri_chk_get_file_size (uri),
dc->anonymity, dc->options, NULL, dc);
int i;
struct ContentHashKey *chkarr;
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received block `%s' matching pending request at depth %u and offset %llu/%llu\n",
GNUNET_h2s (key), dr->depth, (unsigned long long) dr->offset,
(unsigned long long) GNUNET_ntohll (dc->uri->data.
chk.file_length));
-
-#endif
bs = GNUNET_FS_tree_calculate_block_size (GNUNET_ntohll
(dc->uri->data.chk.file_length),
dr->offset, dr->depth);
dc->filename, STRERROR (errno));
goto signal_error;
}
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Saving decrypted block to disk at offset %llu\n",
(unsigned long long) off);
-#endif
if ((off != GNUNET_DISK_file_seek (fh, off, GNUNET_DISK_SEEK_SET)))
{
GNUNET_asprintf (&dc->emsg,
if (dc->completed == dc->length)
{
/* download completed, signal */
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Download completed, truncating file to desired length %llu\n",
(unsigned long long) GNUNET_ntohll (dc->uri->data.
chk.file_length));
-#endif
/* truncate file to size (since we store IBlocks at the end) */
if (dc->filename != NULL)
{
return GNUNET_YES;
}
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Triggering downloads of children (this block was at depth %u and offset %llu)\n",
dr->depth, (unsigned long long) dr->offset);
-#endif
GNUNET_assert (0 == (prc->size % sizeof (struct ContentHashKey)));
chkarr = (struct ContentHashKey *) pt;
for (i = (prc->size / sizeof (struct ContentHashKey)) - 1; i >= 0; i--)
prc.do_store = GNUNET_YES;
prc.last_transmission = last_transmission;
GNUNET_CRYPTO_hash (data, size, &prc.query);
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received result for query `%s' from `%s'-service\n",
GNUNET_h2s (&prc.query), "FS");
-#endif
GNUNET_CONTAINER_multihashmap_get_multiple (dc->active, &prc.query,
&process_result_with_request,
&prc);
dc->th = NULL;
if (NULL == buf)
{
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transmitting download request failed, trying to reconnect\n");
-#endif
try_reconnect (dc);
return 0;
}
while ((NULL != (dr = dc->pending_head)) &&
(size >= msize + sizeof (struct SearchMessage)))
{
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transmitting download request for `%s' to `%s'-service\n",
GNUNET_h2s (&dr->chk.query), "FS");
-#endif
memset (sm, 0, sizeof (struct SearchMessage));
sm->header.size = htons (sizeof (struct SearchMessage));
sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
if (NULL != dc->client)
{
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Moving all requests back to pending list\n");
-#endif
if (NULL != dc->th)
{
GNUNET_CLIENT_notify_transmit_ready_cancel (dc->th);
dc->in_receive = GNUNET_NO;
dc->client = NULL;
}
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Will try to reconnect in 1s\n");
-#endif
dc->task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_reconnect,
dc);
struct GNUNET_FS_DownloadContext *dc = cls;
struct GNUNET_FS_ProgressInfo pi;
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download activated\n");
-#endif
GNUNET_assert (NULL != client);
GNUNET_assert (dc->client == NULL);
GNUNET_assert (dc->th == NULL);
dc->pending_head = NULL;
dc->pending_tail = NULL;
GNUNET_CONTAINER_multihashmap_iterate (dc->active, &retry_entry, dc);
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asking for transmission to FS service\n");
-#endif
if (dc->pending_head != NULL)
{
dc->th =
struct GNUNET_FS_DownloadContext *dc = cls;
struct GNUNET_FS_ProgressInfo pi;
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download deactivated\n");
-#endif
if (NULL != dc->th)
{
GNUNET_CLIENT_notify_transmit_ready_cancel (dc->th);
if (dc->completed == dc->length)
{
/* download completed, signal */
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Download completed, truncating file to desired length %llu\n",
(unsigned long long) GNUNET_ntohll (dc->uri->data.
chk.file_length));
-#endif
/* truncate file to size (since we store IBlocks at the end) */
if (dc->filename != NULL)
{
struct GNUNET_FS_ProgressInfo pi;
struct GNUNET_DISK_FileHandle *fh;
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start task running...\n");
-#endif
dc->task = GNUNET_SCHEDULER_NO_TASK;
if (dc->length == 0)
{
if (dc->rfh != NULL)
{
/* first, try top-down */
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Trying top-down reconstruction for `%s'\n", dc->filename);
-#endif
try_top_down_reconstruction (dc, dc->top_request);
switch (dc->top_request->state)
{
if ((GNUNET_FS_uri_chk_get_file_size (dc->uri) <= MAX_INLINE_SIZE) &&
(NULL != dc->meta))
{
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Trying to find embedded meta data for download of size %llu with %u bytes MD\n",
(unsigned long long) GNUNET_FS_uri_chk_get_file_size (dc->uri),
(unsigned int)
GNUNET_CONTAINER_meta_data_get_serialized_size (dc->meta));
-#endif
GNUNET_CONTAINER_meta_data_iterate (dc->meta, &match_full_data, dc);
if (dc->top_request->state == BRS_DOWNLOAD_UP)
{
if (dc->rfh != NULL)
{
/* finally, try bottom-up */
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Trying bottom-up reconstruction of file `%s'\n", dc->filename);
-#endif
dc->te =
GNUNET_FS_tree_encoder_create (dc->h, dc->old_file_size, dc, &fh_reader,
&reconstruct_cb, NULL,
GNUNET_break (0);
return NULL;
}
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting download `%s' of %llu bytes\n",
filename, (unsigned long long) length);
-#endif
dc = GNUNET_malloc (sizeof (struct GNUNET_FS_DownloadContext));
dc->h = h;
dc->parent = parent;
dc->temp_filename = GNUNET_DISK_mktemp ("gnunet-directory-download-tmp");
}
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download tree has depth %u\n",
dc->treedepth);
-#endif
if (parent == NULL)
{
dc->top =
GNUNET_break (0);
return NULL;
}
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting download `%s' of %llu bytes\n",
filename, (unsigned long long) length);
-#endif
dc = GNUNET_malloc (sizeof (struct GNUNET_FS_DownloadContext));
dc->h = h;
dc->search = sr;
dc->temp_filename = GNUNET_DISK_mktemp ("gnunet-directory-download-tmp");
}
-#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download tree has depth %u\n",
dc->treedepth);
-#endif
dc->task = GNUNET_SCHEDULER_add_now (&GNUNET_FS_download_start_task_, dc);
return dc;
}
#include "platform.h"
#include "fs_tree.h"
-#define DEBUG_TREE GNUNET_EXTRA_LOGGING
/**
* Context for an ECRS-based file encoder that computes
if (te->chk_tree_depth == te->current_depth)
{
off = CHK_PER_INODE * (te->chk_tree_depth - 1);
-#if DEBUG_TREE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TE done, reading CHK `%s' from %u\n",
GNUNET_h2s (&te->chk_tree[off].query), off);
-#endif
te->uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri));
te->uri->type = chk;
te->uri->data.chk.chk = te->chk_tree[off];
pt_block = &te->chk_tree[(te->current_depth - 1) * CHK_PER_INODE];
}
off = compute_chk_offset (te->current_depth, te->publish_offset);
-#if DEBUG_TREE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"TE is at offset %llu and depth %u with block size %u and target-CHK-offset %u\n",
(unsigned long long) te->publish_offset, te->current_depth,
(unsigned int) pt_size, (unsigned int) off);
-#endif
mychk = &te->chk_tree[te->current_depth * CHK_PER_INODE + off];
GNUNET_CRYPTO_hash (pt_block, pt_size, &mychk->key);
GNUNET_CRYPTO_hash_to_aes_key (&mychk->key, &sk, &iv);
GNUNET_CRYPTO_aes_encrypt (pt_block, pt_size, &sk, &iv, enc);
GNUNET_CRYPTO_hash (enc, pt_size, &mychk->query);
-#if DEBUG_TREE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"TE calculates query to be `%s', stored at %u\n",
GNUNET_h2s (&mychk->query),
te->current_depth * CHK_PER_INODE + off);
-#endif
if (NULL != te->proc)
te->proc (te->cls, mychk, te->publish_offset, te->current_depth,
(0 ==
#include "fs_api.h"
#include "fs_tree.h"
-#define DEBUG_UNINDEX GNUNET_EXTRA_LOGGING
/**
* Function called by the tree encoder to obtain
signal_unindex_error (uc);
return;
}
-#if DEBUG_UNINDEX
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Datastore REMOVE operation succeeded\n");
-#endif
GNUNET_FS_tree_encoder_next (uc->tc);
}
odb.file_id = uc->file_id;
data = &odb;
}
-#if DEBUG_UNINDEX
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending REMOVE request to DATASTORE service\n");
-#endif
GNUNET_DATASTORE_remove (uc->dsh, &chk->query, size, data, -2, 1,
GNUNET_CONSTANTS_SERVICE_TIMEOUT, &process_cont, uc);
}
signal_unindex_error (uc);
return;
}
-#if DEBUG_UNINDEX
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending UNINDEX message to FS service\n");
-#endif
req.header.size = htons (sizeof (struct UnindexMessage));
req.header.type = htons (GNUNET_MESSAGE_TYPE_FS_UNINDEX);
req.reserved = 0;
struct GSF_PendingRequestData *prd;
prd = GSF_pending_request_get_data_ (pr);
-#if DEBUG_FS_CLIENT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Finished database lookup for local request `%s' with result %d\n",
GNUNET_h2s (&prd->query), result);
-#endif
GNUNET_SERVER_receive_done (client, GNUNET_OK);
if (GNUNET_BLOCK_EVALUATION_OK_LAST == result)
return; /* we're done, 'pr' was already destroyed... */
#include "gnunet_block_lib.h"
#include "fs.h"
-#define DEBUG_FS GNUNET_YES
-
-#define DEBUG_FS_CLIENT GNUNET_EXTRA_LOGGING
/**
* By which amount do we decrement the TTL for simple forwarding /
1, GNUNET_NO);
return;
}
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transmitting result for query `%s' to peer\n",
GNUNET_h2s (&prd->query));
-#endif
GNUNET_STATISTICS_update (GSF_stats,
gettext_noop ("# replies received for other peers"),
1, GNUNET_NO);
cp = cps;
if (cp == NULL)
{
-#if DEBUG_FS
if (0 != (bm & GET_MESSAGE_BIT_RETURN_TO))
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Failed to find RETURN-TO peer `%4s' in connection set. Dropping query.\n",
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Failed to find peer `%4s' in connection set. Dropping query.\n",
GNUNET_i2s (other));
-#endif
GNUNET_STATISTICS_update (GSF_stats,
gettext_noop
("# requests dropped due to missing reverse route"),
priority = bound_priority (ntohl (gm->priority), cps);
if (priority < 0)
{
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Dropping query from `%s', this peer is too busy.\n",
GNUNET_i2s (other));
-#endif
return NULL;
}
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received request for `%s' of type %u from peer `%4s' with flags %u\n",
GNUNET_h2s (&gm->query), (unsigned int) type, GNUNET_i2s (other),
(unsigned int) bm);
-#endif
namespace = (0 != (bm & GET_MESSAGE_BIT_SKS_NAMESPACE)) ? &opt[bits++] : NULL;
if ((type == GNUNET_BLOCK_TYPE_FS_SBLOCK) && (namespace == NULL))
{
TTL_DECREMENT);
if ((ttl < 0) && (((int32_t) (ttl - ttl_decrement)) > 0))
{
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Dropping query from `%s' due to TTL underflow (%d - %u).\n",
GNUNET_i2s (other), ttl, ttl_decrement);
-#endif
GNUNET_STATISTICS_update (GSF_stats,
gettext_noop
("# requests dropped due TTL underflow"), 1,
{
/* existing request has higher TTL, drop new one! */
prd->priority += priority;
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Have existing request with higher TTL, dropping new request.\n",
GNUNET_i2s (other));
-#endif
GNUNET_STATISTICS_update (GSF_stats,
gettext_noop
("# requests dropped due to higher-TTL request"),
struct GSF_PeerTransmitHandle *pth = cls;
struct GSF_ConnectedPeer *cp;
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Timeout trying to transmit to other peer\n");
-#endif
pth->timeout_task = GNUNET_SCHEDULER_NO_TASK;
cp = pth->cp;
GNUNET_CONTAINER_DLL_remove (cp->pth_head, cp->pth_tail, pth);
{
if (cp->last_migration_block.abs_value > block_time.abs_value)
{
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Migration already blocked for another %llu ms\n",
(unsigned long long)
GNUNET_TIME_absolute_get_remaining
(cp->last_migration_block).rel_value);
-#endif
return; /* already blocked */
}
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking to stop migration for %llu ms\n",
(unsigned long long) GNUNET_TIME_absolute_get_remaining (block_time).rel_value);
-#endif
cp->last_migration_block = block_time;
if (cp->migration_pth != NULL)
GSF_peer_transmit_cancel_ (cp->migration_pth);
_
("Hash mismatch trying to index file `%s' which has hash `%s'\n"),
ii->filename, GNUNET_h2s (res));
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Wanted `%s'\n",
GNUNET_h2s (&ii->file_id));
-#endif
GNUNET_SERVER_transmit_context_append_data (ii->tc, NULL, 0,
GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED);
GNUNET_SERVER_transmit_context_run (ii->tc, GNUNET_TIME_UNIT_MINUTES);
ii->filename = (const char *) &ii[1];
memcpy (&ii[1], fn, slen);
ii->file_id = ism->file_id;
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message for file `%s'\n",
"START_INDEX", ii->filename);
-#endif
-
ii->tc = GNUNET_SERVER_transmit_context_create (client);
mydev = 0;
myino = 0;
GNUNET_free (fn);
return;
}
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Mismatch in file identifiers (%llu != %llu or %u != %u), need to hash.\n",
(unsigned long long) ino, (unsigned long long) myino,
(unsigned int) dev, (unsigned int) mydev);
-#endif
/* slow validation, need to hash full file (again) */
ii->fhc =
GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, fn,
}
pos = next;
}
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Client requested unindexing of file `%s': %s\n",
GNUNET_h2s (&um->file_id), found ? "found" : "not found");
-#endif
if (GNUNET_YES == found)
write_index_list ();
tc = GNUNET_SERVER_transmit_context_create (client);
GNUNET_TIME_UNIT_FOREVER_REL, &remove_cont, NULL);
return GNUNET_SYSERR;
}
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"On-demand encoded block for query `%s'\n", GNUNET_h2s (key));
-#endif
cont (cont_cls, key, nsize, edata, GNUNET_BLOCK_TYPE_FS_DBLOCK, priority,
anonymity, expiration, uid);
return GNUNET_OK;
memcpy (&pm[1], data, data_len);
GSF_local_client_transmit_ (lc, &pm->header);
}
-#if DEBUG_FS_CLIENT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Queued reply to query `%s' for local client\n",
GNUNET_h2s (&prd->query), (unsigned int) prd->type);
-#endif
if (eval != GNUNET_BLOCK_EVALUATION_OK_LAST)
return;
if (GNUNET_SCHEDULER_NO_TASK != cr->kill_task)
sc = (msize - sizeof (struct SearchMessage)) / sizeof (GNUNET_HashCode);
sm = (const struct SearchMessage *) message;
type = ntohl (sm->type);
-#if DEBUG_FS_CLIENT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received request for `%s' of type %u from local client\n",
GNUNET_h2s (&sm->query), (unsigned int) type);
-#endif
lc = GSF_local_client_lookup_ (client);
cr = NULL;
/* detect duplicate KBLOCK requests */
}
if (cr != NULL)
{
-#if DEBUG_FS_CLIENT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Have existing request, merging content-seen lists.\n");
-#endif
GSF_pending_request_update_ (cr->pr, (const GNUNET_HashCode *) &sm[1], sc);
GNUNET_STATISTICS_update (GSF_stats,
gettext_noop
(unsigned int) rp->transmission_counter,
(unsigned long long) delay.rel_value);
rp->earliest_transmission = GNUNET_TIME_relative_to_absolute (delay);
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Earliest (re)transmission for `%s' in %us\n",
GNUNET_h2s (&prd->query), rp->transmission_counter);
-#endif
-
GNUNET_assert (rp->hn == NULL);
if (GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission).rel_value
== 0)
rp->last_transmission = GNUNET_TIME_absolute_get ();
rp->transmission_counter++;
total_delay++;
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Executing plan %p executed %u times, planning retransmission\n",
rp, rp->transmission_counter);
-#endif
plan (pp, rp);
GNUNET_STATISTICS_update (GSF_stats,
gettext_noop
rp = GNUNET_CONTAINER_heap_peek (pp->delay_heap);
if (NULL == rp)
{
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No active requests for plan %p.\n",
pp);
-#endif
return; /* both queues empty */
}
delay = GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission);
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sleeping for %llu ms before retrying requests on plan %p.\n",
(unsigned long long) delay.rel_value, pp);
-#endif
GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# delay heap timeout"),
delay.rel_value, GNUNET_NO);
1, GNUNET_NO);
/* process from priority heap */
rp = GNUNET_CONTAINER_heap_peek (pp->priority_heap);
-#if DEBUG_FS > 1
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing query plan %p\n", rp);
-#endif
GNUNET_assert (NULL != rp);
msize = GSF_pending_request_get_message_ (get_latest (rp), 0, NULL);
pp->pth =
GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# query plan entries"), 1,
GNUNET_NO);
prd = GSF_pending_request_get_data_ (pr);
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Planning transmission of query `%s' to peer `%s'\n",
GNUNET_h2s (&prd->query), GNUNET_i2s (&id));
-#endif
rp = GNUNET_malloc (sizeof (struct GSF_RequestPlan));
rpr = GNUNET_malloc (sizeof (struct GSF_RequestPlanReference));
prl = GNUNET_malloc (sizeof (struct PendingRequestList));
struct GSF_PendingRequest *pr;
struct GSF_PendingRequest *dpr;
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Creating request handle for `%s' of type %d\n",
GNUNET_h2s (query), type);
-#endif
GNUNET_STATISTICS_update (GSF_stats,
gettext_noop ("# Pending requests created"), 1,
GNUNET_NO);
int64_t ttl;
int do_route;
-#if DEBUG_FS
if (buf_size > 0)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Building request message for `%s' of type %d\n",
GNUNET_h2s (&pr->public_data.query), pr->public_data.type);
-#endif
k = 0;
bm = 0;
do_route = (0 == (pr->public_data.options & GSF_PRO_FORWARD_ONLY));
struct GSF_PendingRequest *pr = value;
GSF_LocalLookupContinuation cont;
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Cleaning up pending request for `%s'.\n", GNUNET_h2s (key));
-#endif
if (NULL != (cont = pr->llc_cont))
{
pr->llc_cont = NULL;
if (NULL == pr->rh)
return GNUNET_YES;
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Matched result (type %u) for query `%s' with pending request\n",
(unsigned int) prq->type, GNUNET_h2s (key));
-#endif
GNUNET_STATISTICS_update (GSF_stats,
gettext_noop ("# replies received and matched"), 1,
GNUNET_NO);
gettext_noop
("# duplicate replies discarded (bloomfilter)"),
1, GNUNET_NO);
-#if DEBUG_FS && 0
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Duplicate response `%s', discarding.\n", GNUNET_h2s (&mhash));
-#endif
+ "Duplicate response, discarding.\n");
return GNUNET_YES; /* duplicate */
case GNUNET_BLOCK_EVALUATION_RESULT_INVALID:
return GNUNET_YES; /* wrong namespace */
GSF_pending_request_update_ (pr, &chash, 1);
if (NULL == prq->sender)
{
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Found result for query `%s' in local datastore\n",
GNUNET_h2s (key));
-#endif
GNUNET_STATISTICS_update (GSF_stats,
gettext_noop ("# results found locally"), 1,
GNUNET_NO);
ppd = GSF_get_peer_performance_data_ (cp);
if (min_expiration.abs_value > 0)
{
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asking to stop migration for %llu ms because datastore is full\n",
(unsigned long long) GNUNET_TIME_absolute_get_remaining (min_expiration).rel_value);
-#endif
GSF_block_peer_migration_ (cp, min_expiration);
}
else
mig_pause.rel_value = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
ppd->migration_delay.rel_value);
ppd->migration_delay = GNUNET_TIME_relative_multiply (ppd->migration_delay, 2);
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Replicated content already exists locally, asking to stop migration for %llu ms\n",
(unsigned long long) mig_pause.rel_value);
-#endif
GSF_block_peer_migration_ (cp, GNUNET_TIME_relative_to_absolute (mig_pause));
}
}
if ((GNUNET_YES == active_to_migration) &&
(GNUNET_NO == test_put_load_too_high (prq.priority)))
{
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Replicating result for query `%s' with priority %u\n",
GNUNET_h2s (key), prq.priority);
-#endif
pmc = GNUNET_malloc (sizeof (struct PutMigrationContext));
pmc->start = GNUNET_TIME_absolute_get ();
pmc->requested = GNUNET_YES;
}
if (NULL == key)
{
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
"No further local responses available.\n");
-#endif
if ((pr->public_data.type == GNUNET_BLOCK_TYPE_FS_DBLOCK) ||
(pr->public_data.type == GNUNET_BLOCK_TYPE_FS_IBLOCK))
GNUNET_STATISTICS_update (GSF_stats,
GNUNET_NO);
goto check_error_and_continue;
}
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received reply for `%s' of type %d with UID %llu from datastore.\n",
GNUNET_h2s (key), type, (unsigned long long) uid);
-#endif
if (type == GNUNET_BLOCK_TYPE_FS_ONDEMAND)
{
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Found ONDEMAND block, performing on-demand encoding\n");
-#endif
GNUNET_STATISTICS_update (GSF_stats,
gettext_noop
("# on-demand blocks matched requests"), 1,
((GNUNET_YES == GSF_test_get_load_too_high_ (0)) ||
(pr->public_data.results_found > 5 + 2 * pr->public_data.priority)))
{
-#if DEBUG_FS > 2
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Load too high, done with request\n");
-#endif
GNUNET_STATISTICS_update (GSF_stats,
gettext_noop
("# Datastore lookups concluded (load too high)"),
if ((GNUNET_YES == active_to_migration) &&
(GNUNET_NO == test_put_load_too_high (prq.priority)))
{
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Replicating result for query `%s' with priority %u\n",
GNUNET_h2s (&query), prq.priority);
-#endif
pmc = GNUNET_malloc (sizeof (struct PutMigrationContext));
pmc->start = GNUNET_TIME_absolute_get ();
pmc->requested = prq.request_found;
}
else
{
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Choosing not to keep content `%s' (%d/%d)\n",
GNUNET_h2s (&query), active_to_migration,
test_put_load_too_high (prq.priority));
-#endif
}
putl = GNUNET_LOAD_get_load (datastore_put_load);
if ((NULL != (cp = prq.sender)) && (GNUNET_NO == prq.request_found) &&
GNUNET_CRYPTO_random_u32
(GNUNET_CRYPTO_QUALITY_WEAK,
(unsigned int) (60000 * putl * putl)));
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asking to stop migration for %llu ms because of load %f and events %d/%d\n",
(unsigned long long) block_time.rel_value,
putl,
active_to_migration,
(GNUNET_NO == prq.request_found));
-#endif
GSF_block_peer_migration_ (cp, GNUNET_TIME_relative_to_absolute (block_time));
}
return GNUNET_OK;
#include "gnunet-service-fs_push.h"
-#define DEBUG_FS_MIGRATION GNUNET_EXTRA_LOGGING
-
/**
* Maximum number of blocks we keep in memory for migration.
*/
peer->msg = NULL;
if (buf == NULL)
{
-#if DEBUG_FS_MIGRATION
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Failed to migrate content to another peer (disconnect)\n");
-#endif
GNUNET_free (msg);
return 0;
}
GNUNET_assert (msize <= buf_size);
memcpy (buf, msg, msize);
GNUNET_free (msg);
-#if DEBUG_FS_MIGRATION
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Pushing %u bytes to another peer\n",
msize);
-#endif
find_content (peer);
return msize;
}
{
ret = GNUNET_NO;
}
-#if DEBUG_FS_MIGRATION
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asking for transmission of %u bytes for migration\n", msize);
-#endif
peer->th = GSF_peer_transmit_ (peer->peer, GNUNET_NO, 0 /* priority */ ,
GNUNET_TIME_UNIT_FOREVER_REL, msize,
&transmit_message, peer);
{
if (mig_size < MAX_MIGRATION_QUEUE)
{
-#if DEBUG_FS_MIGRATION
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"No content found for pushing, waiting for queue to fill\n");
-#endif
return; /* will fill up eventually... */
}
-#if DEBUG_FS_MIGRATION
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"No suitable content found, purging content from full queue\n");
-#endif
/* failed to find migration target AND
* queue is full, purge most-forwarded
* block from queue to make room for more */
consider_gathering ();
return;
}
-#if DEBUG_FS_MIGRATION
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Preparing to push best content to peer\n");
-#endif
transmit_content (mrp, best);
}
delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, mig_size);
delay = GNUNET_TIME_relative_divide (delay, MAX_MIGRATION_QUEUE);
delay = GNUNET_TIME_relative_max (delay, min_migration_delay);
-#if DEBUG_FS_MIGRATION
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Scheduling gathering task (queue size: %u)\n", mig_size);
-#endif
mig_task =
GNUNET_SCHEDULER_add_delayed (delay, &gather_migration_blocks, NULL);
}
mig_qe = NULL;
if (key == NULL)
{
-#if DEBUG_FS_MIGRATION
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No content found for migration...\n");
-#endif
consider_gathering ();
return;
}
consider_gathering ();
return;
}
-#if DEBUG_FS_MIGRATION
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Retrieved block `%s' of type %u for migration (queue size: %u/%u)\n",
GNUNET_h2s (key), type, mig_size + 1, MAX_MIGRATION_QUEUE);
-#endif
mb = GNUNET_malloc (sizeof (struct MigrationReadyBlock) + size);
mb->query = *key;
mb->expiration = expiration;
{
if (NULL == pos->th)
{
-#if DEBUG_FS_MIGRATION
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Preparing to push best content to peer\n");
-#endif
if (GNUNET_YES == transmit_content (pos, mb))
break; /* 'mb' was freed! */
}
return;
if (GSF_dsh != NULL)
{
-#if DEBUG_FS_MIGRATION
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asking datastore for content for replication (queue size: %u)\n",
mig_size);
-#endif
mig_qe =
GNUNET_DATASTORE_get_for_replication (GSF_dsh, 0, UINT_MAX,
GNUNET_TIME_UNIT_FOREVER_REL,
}
po->zero_anonymity_count_estimate =
GNUNET_MAX (po->current_offset, po->zero_anonymity_count_estimate);
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Retrieved block `%s' of type %u for DHT PUT\n", GNUNET_h2s (key),
type);
-#endif
GNUNET_DHT_put (GSF_dht, key, 5 /* DEFAULT_PUT_REPLICATION */ ,
GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, type, size, data,
expiration, GNUNET_TIME_UNIT_FOREVER_REL,