gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r9221 - in gnunet/src: fs include


From: gnunet
Subject: [GNUnet-SVN] r9221 - in gnunet/src: fs include
Date: Tue, 20 Oct 2009 05:33:07 -0600

Author: grothoff
Date: 2009-10-20 05:33:07 -0600 (Tue, 20 Oct 2009)
New Revision: 9221

Modified:
   gnunet/src/fs/fs.h
   gnunet/src/fs/fs_download.c
   gnunet/src/fs/fs_publish.c
   gnunet/src/fs/gnunet-download.c
   gnunet/src/fs/gnunet-publish.c
   gnunet/src/fs/test_fs_download.c
   gnunet/src/include/gnunet_fs_service.h
Log:
bug fixes, api fixes, extended testcase

Modified: gnunet/src/fs/fs.h
===================================================================
--- gnunet/src/fs/fs.h  2009-10-20 08:38:04 UTC (rev 9220)
+++ gnunet/src/fs/fs.h  2009-10-20 11:33:07 UTC (rev 9221)
@@ -479,11 +479,6 @@
   struct GNUNET_FS_Handle *h;
 
   /**
-   * Argument to pass to the client in callbacks.
-   */
-  void *client_ctx;
-  
-  /**
    * File-structure that is being shared.
    */
   struct GNUNET_FS_FileInformation *fi;

Modified: gnunet/src/fs/fs_download.c
===================================================================
--- gnunet/src/fs/fs_download.c 2009-10-20 08:38:04 UTC (rev 9220)
+++ gnunet/src/fs/fs_download.c 2009-10-20 11:33:07 UTC (rev 9221)
@@ -745,6 +745,7 @@
  * @param length how many bytes should be downloaded starting at offset
  * @param anonymity anonymity level to use for the download
  * @param options various options
+ * @param cctx initial value for the client context for this download
  * @param parent parent download to associate this download with (use NULL
  *        for top-level downloads; useful for manually-triggered recursive 
downloads)
  * @return context that can be used to control this download
@@ -758,6 +759,7 @@
                          uint64_t length,
                          uint32_t anonymity,
                          enum GNUNET_FS_DownloadOptions options,
+                         void *cctx,
                          struct GNUNET_FS_DownloadContext *parent)
 {
   struct GNUNET_FS_ProgressInfo pi;
@@ -789,6 +791,7 @@
   dc->parent = parent;
   dc->uri = GNUNET_FS_uri_dup (uri);
   dc->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
+  dc->client_info = cctx;
   if (NULL != filename)
     {
       dc->filename = GNUNET_strdup (filename);

Modified: gnunet/src/fs/fs_publish.c
===================================================================
--- gnunet/src/fs/fs_publish.c  2009-10-20 08:38:04 UTC (rev 9220)
+++ gnunet/src/fs/fs_publish.c  2009-10-20 11:33:07 UTC (rev 9221)
@@ -930,8 +930,6 @@
  * Publish a file or directory.
  *
  * @param h handle to the file sharing subsystem
- * @param ctx initial value to use for the '*ctx'
- *        in the callback (for the GNUNET_FS_STATUS_PUBLISH_START event).
  * @param fi information about the file or directory structure to publish
  * @param namespace namespace to publish the file in, NULL for no namespace
  * @param nid identifier to use for the publishd content in the namespace
@@ -943,7 +941,6 @@
  */
 struct GNUNET_FS_PublishContext *
 GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h,
-                        void *ctx,
                         struct GNUNET_FS_FileInformation *fi,
                         struct GNUNET_FS_Namespace *namespace,
                         const char *nid,
@@ -967,7 +964,6 @@
   ret = GNUNET_malloc (sizeof (struct GNUNET_FS_PublishContext));
   ret->dsh = dsh;
   ret->h = h;
-  ret->client_ctx = ctx;
   ret->fi = fi;
   ret->namespace = namespace;
   if (namespace != NULL)

Modified: gnunet/src/fs/gnunet-download.c
===================================================================
--- gnunet/src/fs/gnunet-download.c     2009-10-20 08:38:04 UTC (rev 9220)
+++ gnunet/src/fs/gnunet-download.c     2009-10-20 11:33:07 UTC (rev 9221)
@@ -180,6 +180,7 @@
                                 GNUNET_FS_uri_chk_get_file_size (uri),
                                 anonymity,
                                 options,
+                                NULL,
                                 NULL);
   GNUNET_FS_uri_destroy (uri);
 }

Modified: gnunet/src/fs/gnunet-publish.c
===================================================================
--- gnunet/src/fs/gnunet-publish.c      2009-10-20 08:38:04 UTC (rev 9220)
+++ gnunet/src/fs/gnunet-publish.c      2009-10-20 11:33:07 UTC (rev 9221)
@@ -416,7 +416,6 @@
       return;
     }
   pc = GNUNET_FS_publish_start (ctx,
-                               NULL,
                                fi,
                                namespace,
                                this_id,

Modified: gnunet/src/fs/test_fs_download.c
===================================================================
--- gnunet/src/fs/test_fs_download.c    2009-10-20 08:38:04 UTC (rev 9220)
+++ gnunet/src/fs/test_fs_download.c    2009-10-20 11:33:07 UTC (rev 9221)
@@ -85,8 +85,15 @@
 abort_download_task (void *cls,
                     const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
+  uint64_t size;
+  
   GNUNET_FS_download_stop (download, GNUNET_YES);
   download = NULL;
+  GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_size (fn, &size, GNUNET_YES));
+  GNUNET_assert (size == FILESIZE); 
+  GNUNET_DISK_directory_remove (fn);
+  GNUNET_free (fn);
+  fn = NULL;
 }
 
 
@@ -104,7 +111,7 @@
               (unsigned long long) event->value.publish.size,
              event->value.publish.specifics.progress.depth,
              (unsigned long long) 
event->value.publish.specifics.progress.offset);
-#endif
+#endif      
       break;
     case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
       printf ("Publishing complete, %llu kbps.\n",
@@ -119,6 +126,7 @@
                                           FILESIZE,
                                           1,
                                           GNUNET_FS_DOWNLOAD_OPTION_NONE,
+                                          "download",
                                           NULL);
       GNUNET_assert (download != NULL);
       break;
@@ -132,6 +140,7 @@
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
       break;
     case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
+      GNUNET_assert (download == event->value.download.dc);
 #if VERBOSE
       printf ("Download is progressing (%llu/%llu at level %u off %llu)...\n",
               (unsigned long long) event->value.download.completed,
@@ -162,18 +171,32 @@
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
       break;
     case GNUNET_FS_STATUS_PUBLISH_START:
-      /* FIXME: add checks here... */
+      GNUNET_assert (0 == strcmp ("publish-context", 
event->value.publish.cctx));
+      GNUNET_assert (NULL == event->value.publish.pctx);
+      GNUNET_assert (FILESIZE == event->value.publish.size);
+      GNUNET_assert (0 == event->value.publish.completed);
+      GNUNET_assert (1 == event->value.publish.anonymity);
       break;
     case GNUNET_FS_STATUS_PUBLISH_STOPPED:
+      GNUNET_assert (publish == event->value.publish.sc);
+      GNUNET_assert (FILESIZE == event->value.publish.size);
+      GNUNET_assert (1 == event->value.publish.anonymity);
       /* FIXME: add checks here... */
       GNUNET_FS_stop (fs);
       fs = NULL;
       break;
     case GNUNET_FS_STATUS_DOWNLOAD_START:
-      /* FIXME: add checks here... */
+      GNUNET_assert (download == NULL);
+      GNUNET_assert (0 == strcmp ("download", event->value.download.cctx));
+      GNUNET_assert (NULL == event->value.download.pctx);
+      GNUNET_assert (NULL != event->value.download.uri);
+      GNUNET_assert (0 == strcmp (fn, event->value.download.filename));
+      GNUNET_assert (FILESIZE == event->value.download.size);
+      GNUNET_assert (0 == event->value.download.completed);
+      GNUNET_assert (1 == event->value.download.anonymity);
       break;
     case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
-      /* FIXME: add checks here... */
+      GNUNET_assert (download == event->value.download.dc);
       GNUNET_SCHEDULER_add_continuation (sched,
                                         GNUNET_NO,
                                         &abort_publish_task,
@@ -254,7 +277,7 @@
     buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
   meta = GNUNET_CONTAINER_meta_data_create ();
   kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
-  fi = GNUNET_FS_file_information_create_from_data ("file-to-publish",
+  fi = GNUNET_FS_file_information_create_from_data ("publish-context",
                                                    FILESIZE,
                                                    buf,
                                                    kuri,
@@ -268,7 +291,6 @@
   GNUNET_assert (NULL != fi);
   start = GNUNET_TIME_absolute_get ();
   publish = GNUNET_FS_publish_start (fs,
-                                   "publish-context",
                                    fi,
                                    NULL, NULL, NULL,
                                    GNUNET_FS_PUBLISH_OPTION_NONE);

Modified: gnunet/src/include/gnunet_fs_service.h
===================================================================
--- gnunet/src/include/gnunet_fs_service.h      2009-10-20 08:38:04 UTC (rev 
9220)
+++ gnunet/src/include/gnunet_fs_service.h      2009-10-20 11:33:07 UTC (rev 
9221)
@@ -720,9 +720,8 @@
       const struct GNUNET_FS_FileInformation *fi;
 
       /**
-       * Client context pointer (set the last time
-       * by the client for this operation; initially
-       * NULL on START/RESUME events).
+       * Client context pointer (set the last time by the client for
+       * this operation; initially NULL on START/RESUME events).
        */
       void *cctx;
 
@@ -1877,8 +1876,6 @@
  * Publish a file or directory.
  *
  * @param h handle to the file sharing subsystem
- * @param ctx initial value to use for the '*ctx'
- *        in the callback (for the GNUNET_FS_STATUS_PUBLISH_START event).
  * @param fi information about the file or directory structure to publish
  * @param namespace namespace to publish the file in, NULL for no namespace
  * @param nid identifier to use for the publishd content in the namespace
@@ -1890,7 +1887,6 @@
  */
 struct GNUNET_FS_PublishContext *
 GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h,
-                        void *ctx,
                         struct GNUNET_FS_FileInformation *fi,
                         struct GNUNET_FS_Namespace *namespace,
                         const char *nid,
@@ -2242,11 +2238,11 @@
  * @param length how many bytes should be downloaded starting at offset
  * @param anonymity anonymity level to use for the download
  * @param options various download options
+ * @param cctx initial value for the client context for this download
  * @param parent parent download to associate this download with (use NULL
  *        for top-level downloads; useful for manually-triggered recursive 
downloads)
  * @return context that can be used to control this download
  */
-// FIXME: add a "void *" context for the client to arguments!?
 struct GNUNET_FS_DownloadContext *
 GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
                          const struct GNUNET_FS_Uri *uri,
@@ -2256,6 +2252,7 @@
                          uint64_t length,
                          uint32_t anonymity,
                          enum GNUNET_FS_DownloadOptions options,
+                         void *cctx,
                          struct GNUNET_FS_DownloadContext *parent);
 
 





reply via email to

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