From 7f5570186d7d89dc6b3742bff7070fb94343279b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 20 Oct 2009 08:38:04 +0000 Subject: [PATCH] fix --- src/fs/fs_download.c | 3 +-- src/fs/test_fs_download.c | 44 +++++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index e0c4471ac..71d10edac 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c @@ -822,8 +822,7 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, dc->length = length; dc->anonymity = anonymity; dc->options = options; - // dc->active = GNUNET_CONTAINER_multihashmap_create (1); // + (length / DBLOCK_SIZE)); - dc->active = GNUNET_CONTAINER_multihashmap_create (1 + (length / DBLOCK_SIZE)); + dc->active = GNUNET_CONTAINER_multihashmap_create (2 * (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, diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c index 879f054b8..d7fb22bf6 100644 --- a/src/fs/test_fs_download.c +++ b/src/fs/test_fs_download.c @@ -20,7 +20,7 @@ /** * @file fs/test_fs_download.c - * @brief simple testcase for download + * @brief simple testcase for simple publish + download operation * @author Christian Grothoff */ @@ -33,6 +33,9 @@ #define START_ARM GNUNET_YES +/** + * File-size we use for testing. + */ #define FILESIZE (1024 * 1024 * 2) /** @@ -56,6 +59,7 @@ struct PeerContext static struct PeerContext p1; +static struct GNUNET_TIME_Absolute start; static struct GNUNET_SCHEDULER_Handle *sched; @@ -69,20 +73,20 @@ static char *fn; static void -abort_download_task (void *cls, +abort_publish_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - GNUNET_FS_download_stop (download, GNUNET_YES); - download = NULL; + GNUNET_FS_publish_stop (publish); + publish = NULL; } static void -abort_publish_task (void *cls, +abort_download_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - GNUNET_FS_publish_stop (publish); - publish = NULL; + GNUNET_FS_download_stop (download, GNUNET_YES); + download = NULL; } @@ -103,15 +107,10 @@ progress_cb (void *cls, #endif break; case GNUNET_FS_STATUS_PUBLISH_COMPLETED: -#if VERBOSE - printf ("Publish complete.\n"); -#endif - GNUNET_SCHEDULER_add_continuation (sched, - GNUNET_NO, - &abort_publish_task, - NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + printf ("Publishing complete, %llu kbps.\n", + (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024)); fn = GNUNET_DISK_mktemp ("gnunet-download-test-dstXXXXXX"); + start = GNUNET_TIME_absolute_get (); download = GNUNET_FS_download_start (fs, event->value.publish.specifics.completed.chk_uri, NULL, @@ -124,9 +123,8 @@ progress_cb (void *cls, GNUNET_assert (download != NULL); break; case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: -#if VERBOSE - printf ("Download complete.\n"); -#endif + printf ("Download complete, %llu kbps.\n", + (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024)); GNUNET_SCHEDULER_add_continuation (sched, GNUNET_NO, &abort_download_task, @@ -168,14 +166,19 @@ progress_cb (void *cls, break; case GNUNET_FS_STATUS_PUBLISH_STOPPED: /* FIXME: add checks here... */ + GNUNET_FS_stop (fs); + fs = NULL; break; case GNUNET_FS_STATUS_DOWNLOAD_START: /* FIXME: add checks here... */ break; case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: /* FIXME: add checks here... */ - GNUNET_FS_stop (fs); - fs = NULL; + GNUNET_SCHEDULER_add_continuation (sched, + GNUNET_NO, + &abort_publish_task, + NULL, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; default: printf ("Unexpected event: %d\n", @@ -263,6 +266,7 @@ run (void *cls, GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fi); + start = GNUNET_TIME_absolute_get (); publish = GNUNET_FS_publish_start (fs, "publish-context", fi, -- 2.25.1