From 8da608f0e8391f0159c1e8faf43e8085a9309ce0 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 19 Oct 2009 13:31:03 +0000 Subject: [PATCH] fixes --- src/fs/fs_download.c | 18 ++++++++++++++++++ src/fs/fs_publish.c | 6 ++++++ src/fs/fs_tree.c | 20 ++++++++++---------- src/fs/test_fs_download.c | 11 +++++------ src/fs/test_fs_download_data.conf | 3 +++ 5 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index 346857c24..6d3886c70 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c @@ -176,6 +176,13 @@ schedule_block_download (struct GNUNET_FS_DownloadContext *dc, struct DownloadRequest *sm; uint64_t off; +#if DEBUG_DOWNLOAD + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Scheduling download at offset %llu and depth %u for `%s'\n", + (unsigned long long) offset, + depth, + GNUNET_h2s (&chk->query)); +#endif off = compute_disk_offset (GNUNET_ntohll (dc->uri->data.chk.file_length), offset, depth, @@ -676,6 +683,12 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, 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->client = client; @@ -717,6 +730,11 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, dc->options = options; dc->active = GNUNET_CONTAINER_multihashmap_create (1 + (length / DBLOCK_SIZE)); dc->treedepth = GNUNET_FS_compute_depth (GNUNET_ntohll(dc->uri->data.chk.file_length)); +#if DEBUG_DOWNLOAD + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Download tree has depth %u\n", + dc->treedepth); +#endif // FIXME: make persistent schedule_block_download (dc, &dc->uri->data.chk.chk, diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index f8c76c36b..72bbfdfa9 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c @@ -483,6 +483,12 @@ block_proc (void *cls, struct PutContCtx * dpc_cls; struct OnDemandBlock odb; +#if DEBUG_PUBLISH + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Publishing block `%s' for offset %llu\n", + GNUNET_h2s (query), + (unsigned long long) offset); +#endif p = sc->fi_pos; if (NULL == sc->dsh) { diff --git a/src/fs/fs_tree.c b/src/fs/fs_tree.c index 2108b4831..3dbf478df 100644 --- a/src/fs/fs_tree.c +++ b/src/fs/fs_tree.c @@ -301,16 +301,6 @@ void GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder * te) pt_block = &te->chk_tree[te->current_depth * CHK_PER_INODE]; } - off = compute_chk_offset (te->chk_tree_depth - te->current_depth, - te->publish_offset); - mychk = &te->chk_tree[(te->current_depth-1)*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); if (0 == te->current_depth) { te->uri = GNUNET_malloc (sizeof(struct GNUNET_FS_Uri)); @@ -324,6 +314,16 @@ void GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder * te) GNUNET_SCHEDULER_REASON_PREREQ_DONE); return; } + off = compute_chk_offset (te->chk_tree_depth - te->current_depth, + te->publish_offset); + mychk = &te->chk_tree[(te->current_depth-1)*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); if (NULL != te->proc) te->proc (te->cls, &mychk->query, diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c index 730720d40..f6fb2a1f2 100644 --- a/src/fs/test_fs_download.c +++ b/src/fs/test_fs_download.c @@ -29,8 +29,7 @@ #include "gnunet_arm_service.h" #include "gnunet_fs_service.h" -#define DEBUG_VERBOSE 42 -//GNUNET_NO +#define VERBOSE GNUNET_YES #define START_ARM GNUNET_YES @@ -95,7 +94,7 @@ progress_cb (void *cls, switch (event->status) { case GNUNET_FS_STATUS_PUBLISH_PROGRESS: -#if DEBUG_VERBOSE +#if VERBOSE printf ("Publish is progressing (%llu/%llu at level %u off %llu)...\n", (unsigned long long) event->value.publish.completed, (unsigned long long) event->value.publish.size, @@ -104,7 +103,7 @@ progress_cb (void *cls, #endif break; case GNUNET_FS_STATUS_PUBLISH_COMPLETED: -#if DEBUG_VERBOSE +#if VERBOSE printf ("Publish complete.\n"); #endif GNUNET_SCHEDULER_add_continuation (sched, @@ -125,7 +124,7 @@ progress_cb (void *cls, GNUNET_assert (download != NULL); break; case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: -#if DEBUG_VERBOSE +#if VERBOSE printf ("Download complete.\n"); #endif GNUNET_SCHEDULER_add_continuation (sched, @@ -135,7 +134,7 @@ progress_cb (void *cls, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: -#if DEBUG_VERBOSE +#if VERBOSE printf ("Download is progressing (%llu/%llu at level %u off %llu)...\n", (unsigned long long) event->value.download.completed, (unsigned long long) event->value.download.size, diff --git a/src/fs/test_fs_download_data.conf b/src/fs/test_fs_download_data.conf index ac90b3203..312c33d22 100644 --- a/src/fs/test_fs_download_data.conf +++ b/src/fs/test_fs_download_data.conf @@ -18,6 +18,9 @@ PORT = 42466 HOSTNAME = localhost DEFAULTSERVICES = resolver datastore transport core fs +[datastore] +DEBUG = YES + [statistics] PORT = 42467 HOSTNAME = localhost -- 2.25.1