From a8698c1dc9200d021e0aa38ae1dcad6a44e57a6d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 25 Mar 2011 15:13:45 +0000 Subject: [PATCH] polishing --- src/fs/gnunet-service-fs_pr.c | 2 +- src/fs/test_fs_download.c | 4 ++-- src/fs/test_fs_namespace.c | 25 +++++++++++++++++++++---- src/fs/test_fs_namespace_data.conf | 2 +- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index ea8f3b80c..b022cc23f 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c @@ -958,7 +958,7 @@ process_local_reply (void *cls, { #if DEBUG_FS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "No further local repsonses available.\n"); + "No further local responses available.\n"); #endif pr->qe = NULL; if (NULL != (cont = pr->llc_cont)) diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c index 45df96043..5091c5a61 100644 --- a/src/fs/test_fs_download.c +++ b/src/fs/test_fs_download.c @@ -150,7 +150,7 @@ progress_cb (void *cls, #endif break; case GNUNET_FS_STATUS_PUBLISH_COMPLETED: - printf ("Publishing complete, %llu kbps.\n", + printf ("Publishing complete, %llu kb/s.\n", (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024LL)); GAUGER ("FS", "Publishing speed (insertion)", @@ -171,7 +171,7 @@ progress_cb (void *cls, GNUNET_assert (download != NULL); break; case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: - printf ("Download complete, %llu kbps.\n", + printf ("Download complete, %llu kb/s.\n", (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024LL)); GAUGER ("FS", "Local download speed (inserted)", diff --git a/src/fs/test_fs_namespace.c b/src/fs/test_fs_namespace.c index 0d37affa2..b5e210f4c 100644 --- a/src/fs/test_fs_namespace.c +++ b/src/fs/test_fs_namespace.c @@ -22,16 +22,13 @@ * @file fs/test_fs_namespace.c * @brief Test for fs_namespace.c * @author Christian Grothoff - * - * TODO: - * - add timeout task */ #include "platform.h" #include "gnunet_util_lib.h" #include "gnunet_arm_service.h" #include "gnunet_fs_service.h" -#define VERBOSE GNUNET_NO +#define VERBOSE GNUNET_YES #define START_ARM GNUNET_YES @@ -49,6 +46,8 @@ static struct GNUNET_FS_SearchContext *sks_search; static struct GNUNET_FS_SearchContext *ksk_search; +static GNUNET_SCHEDULER_TaskIdentifier kill_task; + static int update_started; static int err; @@ -91,6 +90,8 @@ stop_arm (struct PeerContext *p) GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; #endif + if (GNUNET_SCHEDULER_NO_TASK != kill_task) + GNUNET_SCHEDULER_cancel (kill_task); GNUNET_CONFIGURATION_destroy (p->cfg); } @@ -132,6 +133,19 @@ abort_sks_search_task (void *cls, } +static void +do_timeout (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + fprintf (stderr, + "Operation timed out\n"); + kill_task = GNUNET_SCHEDULER_NO_TASK; + abort_sks_search_task (NULL, tc); + abort_ksk_search_task (NULL, tc); +} + + + static void * progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) @@ -370,6 +384,9 @@ testNamespace () expiration, "root", &adv_cont, NULL); + kill_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, + &do_timeout, + NULL); GNUNET_FS_uri_destroy (ksk_uri); GNUNET_FS_namespace_delete (ns, GNUNET_NO); GNUNET_CONTAINER_meta_data_destroy (meta); diff --git a/src/fs/test_fs_namespace_data.conf b/src/fs/test_fs_namespace_data.conf index d1ed94a8b..42c1f430b 100644 --- a/src/fs/test_fs_namespace_data.conf +++ b/src/fs/test_fs_namespace_data.conf @@ -37,7 +37,7 @@ HOSTNAME = localhost PORT = 42471 HOSTNAME = localhost IDENTITY_DIR = $SERVICEHOME/pseudos/ -# DEBUG = YES +DEBUG = YES [testing] WEAKRANDOM = YES -- 2.25.1