gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r9220 - gnunet/src/fs


From: gnunet
Subject: [GNUnet-SVN] r9220 - gnunet/src/fs
Date: Tue, 20 Oct 2009 02:38:05 -0600

Author: grothoff
Date: 2009-10-20 02:38:04 -0600 (Tue, 20 Oct 2009)
New Revision: 9220

Modified:
   gnunet/src/fs/fs_download.c
   gnunet/src/fs/test_fs_download.c
Log:
fix

Modified: gnunet/src/fs/fs_download.c
===================================================================
--- gnunet/src/fs/fs_download.c 2009-10-20 08:18:33 UTC (rev 9219)
+++ gnunet/src/fs/fs_download.c 2009-10-20 08:38:04 UTC (rev 9220)
@@ -822,8 +822,7 @@
   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,

Modified: gnunet/src/fs/test_fs_download.c
===================================================================
--- gnunet/src/fs/test_fs_download.c    2009-10-20 08:18:33 UTC (rev 9219)
+++ gnunet/src/fs/test_fs_download.c    2009-10-20 08:38:04 UTC (rev 9220)
@@ -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 @@
 
 static struct PeerContext p1;
 
+static struct GNUNET_TIME_Absolute start;
 
 static struct GNUNET_SCHEDULER_Handle *sched;
 
@@ -69,20 +73,20 @@
 
 
 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 @@
 #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 @@
       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 @@
       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 @@
   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,





reply via email to

[Prev in Thread] Current Thread [Next in Thread]