struct ContentHashKey *chk;
char *emsg;
+
GNUNET_CRYPTO_hash (data, size, &query);
- sm = GNUNET_CONTAINER_multihashmap_get (dc->active,
+#if DEBUG_DOWNLOAD
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received result for query `%s' from `%s'-service\n",
+ GNUNET_h2s (&query),
+ "FS");
+#endif
+ sm = GNUNET_CONTAINER_multihashmap_get (dc->active,
&query);
if (NULL == sm)
{
sm->offset,
sm->depth))
{
+#if DEBUG_DOWNLOAD
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Internal error or bogus download URI\n");
+#endif
dc->emsg = GNUNET_strdup ("Internal error or bogus download URI");
/* signal error */
pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR;
sm->depth,
dc->treedepth);
emsg = NULL;
+#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 (dc->handle,
off,
GNUNET_assert (dc->completed <= dc->length);
if (dc->completed == dc->length)
{
+#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->handle != NULL)
{
// FIXME: make persistent
if (sm->depth == dc->treedepth)
return;
+#if DEBUG_DOWNLOAD
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Triggering downloads of children (this block was at level %u)\n",
+ dc->treedepth);
+#endif
GNUNET_assert (0 == (size % sizeof(struct ContentHashKey)));
chk = (struct ContentHashKey*) pt;
for (i=0;i<(size / sizeof(struct ContentHashKey));i++)
GNUNET_assert (size >= sizeof (struct SearchMessage));
msize = 0;
sm = buf;
- while ( (dc->pending == NULL) &&
+ while ( (dc->pending != NULL) &&
(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 (&dc->pending->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);
dc->h->cfg);
if (NULL == client)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Connecting to `%s'-service failed, will try again.\n",
+ "FS");
try_reconnect (dc);
return;
}
/**
- * Add entries that are not yet pending back to
- * the pending list.
+ * Add entries that are not yet pending back to the pending list.
*
* @param cls our download context
* @param key unused
if (NULL == buf)
{
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Failed to transmit result to local client, aborting datastore iteration.\n");
+#endif
/* error, abort! */
GNUNET_free (lgc->result);
lgc->result = NULL;
return 0;
}
msize = ntohs (lgc->result->header.size);
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitting %u bytes of result to local client.\n",
+ msize);
+#endif
GNUNET_assert (max >= msize);
memcpy (buf, lgc->result, msize);
GNUNET_free (lgc->result);
if (key == NULL)
{
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received last result for `%s' from local datastore, deciding what to do next.\n",
+ GNUNET_h2s (&lgc->query));
+#endif
/* no further results from datastore; continue
processing further requests from the client and
allow the next task to use the datastore; also,
(lgc->type == GNUNET_DATASTORE_BLOCKTYPE_SBLOCK) ||
(lgc->type == GNUNET_DATASTORE_BLOCKTYPE_SKBLOCK) )
{
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Forwarding query for `%s' to network.\n",
+ GNUNET_h2s (&lgc->query));
+#endif
cl = clients;
while ( (NULL != cl) &&
(cl->client != lgc->client) )
return;
}
/* got all possible results, clean up! */
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Found all possible results for query for `%s', done!\n",
+ GNUNET_h2s (&lgc->query));
+#endif
local_get_context_free (lgc);
return;
}
if (type == GNUNET_DATASTORE_BLOCKTYPE_ONDEMAND)
{
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received on-demand block for `%s' from local datastore, fetching data.\n",
+ GNUNET_h2s (&lgc->query));
+#endif
handle_on_demand_block (key, size, data, type, priority,
anonymity, expiration, uid,
&process_local_get_result,
query hash being identical to KBLOCK/SBLOCK query hash);
nevertheless, if it happens, the correct thing is to
simply skip the result. */
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received block of unexpected type for `%s' from local datastore, ignoring.\n",
+ GNUNET_h2s (&lgc->query));
+#endif
GNUNET_DATASTORE_get_next (dsh, GNUNET_YES);
return;
}
&lgc->results[i],
sizeof (GNUNET_HashCode)))
{
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received duplicate result for `%s' from local datastore, ignoring.\n",
+ GNUNET_h2s (&lgc->query));
+#endif
GNUNET_DATASTORE_get_next (dsh, GNUNET_YES);
return;
}
memcpy (&lgc->result[1],
data,
size);
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received new result for `%s' from local datastore, passing to client.\n",
+ GNUNET_h2s (&lgc->query));
+#endif
GNUNET_SERVER_notify_transmit_ready (lgc->client,
msize,
GNUNET_TIME_UNIT_FOREVER_REL,