From: Christian Grothoff Date: Tue, 20 Oct 2009 11:33:07 +0000 (+0000) Subject: bug fixes, api fixes, extended testcase X-Git-Tag: initial-import-from-subversion-38251~23302 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=66ec361f74889c6bcc73880af39dd8cd3a3179d5;p=oweals%2Fgnunet.git bug fixes, api fixes, extended testcase --- diff --git a/src/fs/fs.h b/src/fs/fs.h index 6c474369e..8270d38ba 100644 --- a/src/fs/fs.h +++ b/src/fs/fs.h @@ -478,11 +478,6 @@ struct GNUNET_FS_PublishContext */ struct GNUNET_FS_Handle *h; - /** - * Argument to pass to the client in callbacks. - */ - void *client_ctx; - /** * File-structure that is being shared. */ diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index 71d10edac..1938fb08f 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c @@ -745,6 +745,7 @@ try_reconnect (struct GNUNET_FS_DownloadContext *dc) * @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 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, 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 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, 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); diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index c143b6d17..6d3bbe7f6 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c @@ -930,8 +930,6 @@ fip_signal_start(void *cls, * 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 @@ fip_signal_start(void *cls, */ 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 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, 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) diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c index b4e787cfa..bf3daa68f 100644 --- a/src/fs/gnunet-download.c +++ b/src/fs/gnunet-download.c @@ -180,6 +180,7 @@ run (void *cls, GNUNET_FS_uri_chk_get_file_size (uri), anonymity, options, + NULL, NULL); GNUNET_FS_uri_destroy (uri); } diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c index bf6a46914..777370c90 100644 --- a/src/fs/gnunet-publish.c +++ b/src/fs/gnunet-publish.c @@ -416,7 +416,6 @@ run (void *cls, return; } pc = GNUNET_FS_publish_start (ctx, - NULL, fi, namespace, this_id, diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c index d7fb22bf6..f9a8109c5 100644 --- a/src/fs/test_fs_download.c +++ b/src/fs/test_fs_download.c @@ -85,8 +85,15 @@ static void 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 @@ progress_cb (void *cls, (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 @@ progress_cb (void *cls, FILESIZE, 1, GNUNET_FS_DOWNLOAD_OPTION_NONE, + "download", NULL); GNUNET_assert (download != NULL); break; @@ -132,6 +140,7 @@ progress_cb (void *cls, 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 @@ progress_cb (void *cls, 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 @@ run (void *cls, 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 @@ run (void *cls, 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); diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index 7c15358e8..0bed010d9 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h @@ -720,9 +720,8 @@ struct GNUNET_FS_ProgressInfo 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 @@ enum GNUNET_FS_PublishOptions * 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 @@ enum GNUNET_FS_PublishOptions */ 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 @@ enum GNUNET_FS_DownloadOptions * @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 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, uint64_t length, uint32_t anonymity, enum GNUNET_FS_DownloadOptions options, + void *cctx, struct GNUNET_FS_DownloadContext *parent);