diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-08-03 09:35:48 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-08-03 09:35:48 +0000 |
commit | d3e7a5e40dd2d5409009a30e1e41148c4d852673 (patch) | |
tree | 21ff19580a99137e9b8aec4393feb67f0f1c7b5a /src/fs | |
parent | ec69ceabc67a72373a2579d871c5fe85676a73bd (diff) |
-use simpler, modern scheduler API
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/fs_test_lib.c | 29 | ||||
-rw-r--r-- | src/fs/fs_test_lib.h | 35 | ||||
-rw-r--r-- | src/fs/gnunet-download.c | 3 | ||||
-rw-r--r-- | src/fs/gnunet-search.c | 3 | ||||
-rw-r--r-- | src/fs/gnunet-unindex.c | 3 | ||||
-rw-r--r-- | src/fs/perf_gnunet_service_fs_p2p.c | 29 | ||||
-rw-r--r-- | src/fs/perf_gnunet_service_fs_p2p_respect.c | 6 | ||||
-rw-r--r-- | src/fs/test_fs_download.c | 6 | ||||
-rw-r--r-- | src/fs/test_fs_download_persistence.c | 6 | ||||
-rw-r--r-- | src/fs/test_fs_list_indexed.c | 13 | ||||
-rw-r--r-- | src/fs/test_fs_namespace.c | 9 | ||||
-rw-r--r-- | src/fs/test_fs_publish.c | 6 | ||||
-rw-r--r-- | src/fs/test_fs_search.c | 12 | ||||
-rw-r--r-- | src/fs/test_fs_search_persistence.c | 12 | ||||
-rw-r--r-- | src/fs/test_fs_search_probes.c | 13 | ||||
-rw-r--r-- | src/fs/test_fs_search_with_and.c | 20 | ||||
-rw-r--r-- | src/fs/test_fs_test_lib.c | 25 | ||||
-rw-r--r-- | src/fs/test_fs_unindex.c | 12 | ||||
-rw-r--r-- | src/fs/test_fs_unindex_persistence.c | 12 | ||||
-rw-r--r-- | src/fs/test_gnunet_service_fs_migration.c | 60 | ||||
-rw-r--r-- | src/fs/test_gnunet_service_fs_p2p.c | 25 |
21 files changed, 183 insertions, 156 deletions
diff --git a/src/fs/fs_test_lib.c b/src/fs/fs_test_lib.c index a848a8bc9d..a807939123 100644 --- a/src/fs/fs_test_lib.c +++ b/src/fs/fs_test_lib.c @@ -245,8 +245,8 @@ publish_progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) po->publish_timeout_task = NULL; po->publish_uri = GNUNET_FS_uri_dup (info->value.publish.specifics.completed.chk_uri); - GNUNET_SCHEDULER_add_continuation (&report_uri, po, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&report_uri, + po); break; case GNUNET_FS_STATUS_PUBLISH_PROGRESS: if (po->verbose) @@ -490,10 +490,10 @@ download_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Timeout while trying to download file\n"); dop->download_timeout_task = NULL; - GNUNET_FS_download_stop (dop->download_context, GNUNET_YES); - GNUNET_SCHEDULER_add_continuation (dop->download_cont, - dop->download_cont_cls, - GNUNET_SCHEDULER_REASON_TIMEOUT); + GNUNET_FS_download_stop (dop->download_context, + GNUNET_YES); + GNUNET_SCHEDULER_add_now (dop->download_cont, + dop->download_cont_cls); GNUNET_TESTBED_operation_done (dop->fs_op); GNUNET_FS_uri_destroy (dop->uri); GNUNET_free (dop); @@ -512,10 +512,10 @@ report_success (void *cls, { struct TestDownloadOperation *dop = cls; - GNUNET_FS_download_stop (dop->download_context, GNUNET_YES); - GNUNET_SCHEDULER_add_continuation (dop->download_cont, - dop->download_cont_cls, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_FS_download_stop (dop->download_context, + GNUNET_YES); + GNUNET_SCHEDULER_add_now (dop->download_cont, + dop->download_cont_cls); GNUNET_TESTBED_operation_done (dop->fs_op); GNUNET_FS_uri_destroy (dop->uri); GNUNET_free (dop); @@ -529,7 +529,8 @@ report_success (void *cls, * @param info information about the event */ static void * -download_progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) +download_progress_cb (void *cls, + const struct GNUNET_FS_ProgressInfo *info) { struct TestDownloadOperation *dop = cls; @@ -537,15 +538,15 @@ download_progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) { case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: if (dop->verbose) - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Download at %llu/%llu bytes\n", + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Download at %llu/%llu bytes\n", (unsigned long long) info->value.download.completed, (unsigned long long) info->value.download.size); break; case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: GNUNET_SCHEDULER_cancel (dop->download_timeout_task); dop->download_timeout_task = NULL; - GNUNET_SCHEDULER_add_continuation (&report_success, dop, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&report_success, dop); break; case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE: diff --git a/src/fs/fs_test_lib.h b/src/fs/fs_test_lib.h index 2a8237aacf..72348e018c 100644 --- a/src/fs/fs_test_lib.h +++ b/src/fs/fs_test_lib.h @@ -42,10 +42,10 @@ * @param fn name of the file on disk to be removed upon * completion, or NULL for inserted files (also NULL on error) */ -typedef void (*GNUNET_FS_TEST_UriContinuation) (void *cls, - const struct GNUNET_FS_Uri * - uri, - const char *fn); +typedef void +(*GNUNET_FS_TEST_UriContinuation) (void *cls, + const struct GNUNET_FS_Uri *uri, + const char *fn); /** @@ -55,20 +55,24 @@ typedef void (*GNUNET_FS_TEST_UriContinuation) (void *cls, * @param timeout if this operation cannot be completed within the * given period, call the continuation with an error code * @param anonymity option for publication - * @param do_index GNUNET_YES for index, GNUNET_NO for insertion, - * GNUNET_SYSERR for simulation + * @param do_index #GNUNET_YES for index, #GNUNET_NO for insertion, + * #GNUNET_SYSERR for simulation * @param size size of the file to publish * @param seed seed to use for file generation * @param verbose how verbose to be in reporting * @param cont function to call when done - * @param cont_cls closure for cont + * @param cont_cls closure for @a cont */ void GNUNET_FS_TEST_publish (struct GNUNET_TESTBED_Peer *peer, - struct GNUNET_TIME_Relative timeout, uint32_t anonymity, - int do_index, uint64_t size, uint32_t seed, + struct GNUNET_TIME_Relative timeout, + uint32_t anonymity, + int do_index, + uint64_t size, + uint32_t seed, unsigned int verbose, - GNUNET_FS_TEST_UriContinuation cont, void *cont_cls); + GNUNET_FS_TEST_UriContinuation cont, + void *cont_cls); /** @@ -82,14 +86,17 @@ GNUNET_FS_TEST_publish (struct GNUNET_TESTBED_Peer *peer, * @param uri URI of file to download (CHK/LOC only) * @param verbose how verbose to be in reporting * @param cont function to call when done - * @param cont_cls closure for cont + * @param cont_cls closure for @a cont */ void GNUNET_FS_TEST_download (struct GNUNET_TESTBED_Peer *peer, struct GNUNET_TIME_Relative timeout, - uint32_t anonymity, uint32_t seed, - const struct GNUNET_FS_Uri *uri, unsigned int verbose, - GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls); + uint32_t anonymity, + uint32_t seed, + const struct GNUNET_FS_Uri *uri, + unsigned int verbose, + GNUNET_SCHEDULER_TaskCallback cont, + void *cont_cls); diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c index 10f890c0f4..0f1dfaa7c8 100644 --- a/src/fs/gnunet-download.c +++ b/src/fs/gnunet-download.c @@ -199,8 +199,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) break; case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: if (info->value.download.dc == dc) - GNUNET_SCHEDULER_add_continuation (&cleanup_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&cleanup_task, NULL); break; case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE: diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c index 0c25388fda..5d76335916 100644 --- a/src/fs/gnunet-search.c +++ b/src/fs/gnunet-search.c @@ -199,8 +199,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) GNUNET_SCHEDULER_shutdown (); break; case GNUNET_FS_STATUS_SEARCH_STOPPED: - GNUNET_SCHEDULER_add_continuation (&clean_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&clean_task, NULL); break; default: FPRINTF (stderr, _("Unexpected status: %d\n"), info->status); diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c index 5383930e90..52a7952406 100644 --- a/src/fs/gnunet-unindex.c +++ b/src/fs/gnunet-unindex.c @@ -101,8 +101,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) GNUNET_SCHEDULER_shutdown (); break; case GNUNET_FS_STATUS_UNINDEX_STOPPED: - GNUNET_SCHEDULER_add_continuation (&cleanup_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&cleanup_task, NULL); break; default: FPRINTF (stderr, _("Unexpected status: %d\n"), info->status); diff --git a/src/fs/perf_gnunet_service_fs_p2p.c b/src/fs/perf_gnunet_service_fs_p2p.c index 5f9c807054..e2f58d13da 100644 --- a/src/fs/perf_gnunet_service_fs_p2p.c +++ b/src/fs/perf_gnunet_service_fs_p2p.c @@ -51,6 +51,8 @@ static struct GNUNET_TIME_Absolute start_time; static const char *progname; +static struct GNUNET_TIME_Absolute start_time; + /** * Master context for 'stat_run'. @@ -105,8 +107,8 @@ static struct StatValues stats[] = { * @param subsystem name of subsystem that created the statistic * @param name the name of the datum * @param value the current value - * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not - * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration + * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not + * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration */ static int print_stat (void *cls, const char *subsystem, const char *name, uint64_t value, @@ -114,8 +116,12 @@ print_stat (void *cls, const char *subsystem, const char *name, uint64_t value, { struct StatMaster *sm = cls; - FPRINTF (stderr, "Peer %2u: %12s/%50s = %12llu\n", sm->daemon, subsystem, - name, (unsigned long long) value); + FPRINTF (stderr, + "Peer %2u: %12s/%50s = %12llu\n", + sm->daemon, + subsystem, + name, + (unsigned long long) value); return GNUNET_OK; } @@ -232,7 +238,8 @@ stat_run (void *cls, static void -do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +do_report (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) { char *fn = cls; struct GNUNET_TIME_Relative del; @@ -244,7 +251,9 @@ do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_DISK_directory_remove (fn); GNUNET_free (fn); } - if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) + if (0 == + GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_add (start_time, + TIMEOUT)).rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Timeout during download, shutting down with error\n"); @@ -297,7 +306,13 @@ do_download (void *cls, anonymity = 0; else anonymity = 1; - GNUNET_FS_TEST_download (daemons[0], TIMEOUT, anonymity, SEED, uri, VERBOSE, + start_time = GNUNET_TIME_absolute_get (); + GNUNET_FS_TEST_download (daemons[0], + TIMEOUT, + anonymity, + SEED, + uri, + VERBOSE, &do_report, (NULL == fn) ? NULL : GNUNET_strdup (fn)); } diff --git a/src/fs/perf_gnunet_service_fs_p2p_respect.c b/src/fs/perf_gnunet_service_fs_p2p_respect.c index 6b70afbf5b..01f8dbe263 100644 --- a/src/fs/perf_gnunet_service_fs_p2p_respect.c +++ b/src/fs/perf_gnunet_service_fs_p2p_respect.c @@ -287,7 +287,9 @@ do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) char *fancy; struct StatMaster *sm; - if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) + if (0 == + GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_add (start_time, + TIMEOUT)).rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Timeout during download for type `%s', shutting down with error\n", @@ -362,7 +364,7 @@ do_downloads (void *cls, const struct GNUNET_FS_Uri *u2, static void -do_publish2 (void *cls, +do_publish2 (void *cls, const struct GNUNET_FS_Uri *u1, const char *fn) { diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c index d0cc4d6f06..32d5f5a343 100644 --- a/src/fs/test_fs_download.c +++ b/src/fs/test_fs_download.c @@ -198,8 +198,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) FPRINTF (stderr, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); GNUNET_SCHEDULER_shutdown (); break; case GNUNET_FS_STATUS_DOWNLOAD_ERROR: @@ -235,8 +234,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) break; case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: GNUNET_assert (download == event->value.download.dc); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); break; default: printf ("Unexpected event: %d\n", event->status); diff --git a/src/fs/test_fs_download_persistence.c b/src/fs/test_fs_download_persistence.c index 3de1fa9cb3..fd1dbf242d 100644 --- a/src/fs/test_fs_download_persistence.c +++ b/src/fs/test_fs_download_persistence.c @@ -202,8 +202,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) FPRINTF (stderr, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); break; case GNUNET_FS_STATUS_DOWNLOAD_ERROR: FPRINTF (stderr, "Error downloading file: %s\n", @@ -265,8 +264,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) break; case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: GNUNET_assert (download == event->value.download.dc); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); download = NULL; break; default: diff --git a/src/fs/test_fs_list_indexed.c b/src/fs/test_fs_list_indexed.c index 7059d30b56..97f465f790 100644 --- a/src/fs/test_fs_list_indexed.c +++ b/src/fs/test_fs_list_indexed.c @@ -76,11 +76,10 @@ abort_publish_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -list_indexed_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +list_indexed_task (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) { - - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); } @@ -100,8 +99,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) GNUNET_TIME_absolute_get_duration (start).rel_value_us) / 1024)); if (0 == strcmp ("list_indexed-context-dir", event->value.publish.cctx)) - GNUNET_SCHEDULER_add_continuation (&list_indexed_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&list_indexed_task, NULL); break; case GNUNET_FS_STATUS_PUBLISH_PROGRESS: @@ -124,8 +122,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) event->value.publish.specifics.error.message); err = 1; if (0 == strcmp ("list_indexed-context-dir", event->value.publish.cctx)) - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); break; case GNUNET_FS_STATUS_PUBLISH_START: ret = event->value.publish.cctx; diff --git a/src/fs/test_fs_namespace.c b/src/fs/test_fs_namespace.c index 628cc0f1d8..99af39d5c7 100644 --- a/src/fs/test_fs_namespace.c +++ b/src/fs/test_fs_namespace.c @@ -118,8 +118,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) FPRINTF (stderr, "%s", "Wrong result for ksk search!\n"); err = 1; } - GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_ksk_search_task, NULL); } else { @@ -131,11 +130,9 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) FPRINTF (stderr, "Error searching file: %s\n", event->value.search.specifics.error.message); if (sks_search == event->value.search.sc) - GNUNET_SCHEDULER_add_continuation (&abort_sks_search_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_sks_search_task, NULL); else if (ksk_search == event->value.search.sc) - GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_ksk_search_task, NULL); else GNUNET_break (0); break; diff --git a/src/fs/test_fs_publish.c b/src/fs/test_fs_publish.c index 0d621e4894..481108d50b 100644 --- a/src/fs/test_fs_publish.c +++ b/src/fs/test_fs_publish.c @@ -87,8 +87,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) GNUNET_TIME_absolute_get_duration (start).rel_value_us) / 1024)); if (0 == strcmp ("publish-context-dir", event->value.publish.cctx)) - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); break; case GNUNET_FS_STATUS_PUBLISH_PROGRESS: ret = event->value.publish.cctx; @@ -113,8 +112,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) { FPRINTF (stderr, "Scheduling abort task for error on `%s'\n", (const char *) event->value.publish.cctx); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); } break; case GNUNET_FS_STATUS_PUBLISH_START: diff --git a/src/fs/test_fs_search.c b/src/fs/test_fs_search.c index a3f498f776..c24d062dd8 100644 --- a/src/fs/test_fs_search.c +++ b/src/fs/test_fs_search.c @@ -137,21 +137,18 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) case GNUNET_FS_STATUS_SEARCH_RESULT: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Search complete.\n"); - GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_search_task, NULL); break; case GNUNET_FS_STATUS_PUBLISH_ERROR: FPRINTF (stderr, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); break; case GNUNET_FS_STATUS_SEARCH_ERROR: FPRINTF (stderr, "Error searching file: %s\n", event->value.search.specifics.error.message); - GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_search_task, NULL); break; case GNUNET_FS_STATUS_PUBLISH_START: GNUNET_assert (0 == strcmp ("publish-context", event->value.publish.cctx)); @@ -176,8 +173,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) break; case GNUNET_FS_STATUS_SEARCH_STOPPED: GNUNET_assert (search == event->value.search.sc); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); break; default: FPRINTF (stderr, "Unexpected event: %d\n", event->status); diff --git a/src/fs/test_fs_search_persistence.c b/src/fs/test_fs_search_persistence.c index 43275fb8d5..7c84c24c92 100644 --- a/src/fs/test_fs_search_persistence.c +++ b/src/fs/test_fs_search_persistence.c @@ -183,21 +183,18 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) * search result since we exit here after the first one... */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Search complete.\n"); - GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_search_task, NULL); break; case GNUNET_FS_STATUS_PUBLISH_ERROR: FPRINTF (stderr, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); break; case GNUNET_FS_STATUS_SEARCH_ERROR: FPRINTF (stderr, "Error searching file: %s\n", event->value.search.specifics.error.message); - GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_search_task, NULL); break; case GNUNET_FS_STATUS_SEARCH_SUSPEND: if (event->value.search.sc == search) @@ -235,8 +232,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) break; case GNUNET_FS_STATUS_SEARCH_STOPPED: GNUNET_assert (search == event->value.search.sc); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); search = NULL; break; default: diff --git a/src/fs/test_fs_search_probes.c b/src/fs/test_fs_search_probes.c index 203d3fa360..218951509b 100644 --- a/src/fs/test_fs_search_probes.c +++ b/src/fs/test_fs_search_probes.c @@ -140,14 +140,12 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) FPRINTF (stderr, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); break; case GNUNET_FS_STATUS_SEARCH_ERROR: FPRINTF (stderr, "Error searching file: %s\n", event->value.search.specifics.error.message); - GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_search_task, NULL); break; case GNUNET_FS_STATUS_PUBLISH_START: GNUNET_assert (0 == strcmp ("publish-context", event->value.publish.cctx)); @@ -177,11 +175,12 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) break; case GNUNET_FS_STATUS_SEARCH_STOPPED: GNUNET_assert (search == event->value.search.sc); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); break; default: - FPRINTF (stderr, "Unexpected event: %d\n", event->status); + FPRINTF (stderr, + "Unexpected event: %d\n", + event->status); break; } return NULL; diff --git a/src/fs/test_fs_search_with_and.c b/src/fs/test_fs_search_with_and.c index 55498ddca5..7798f88c04 100644 --- a/src/fs/test_fs_search_with_and.c +++ b/src/fs/test_fs_search_with_and.c @@ -138,7 +138,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) char *emsg = NULL; kuri = GNUNET_FS_uri_ksk_create ("+down_foo +down_bar", &emsg); GNUNET_assert (kuri != NULL); - + start = GNUNET_TIME_absolute_get (); search = GNUNET_FS_search_start (fs, kuri, 1, GNUNET_FS_SEARCH_OPTION_NONE, @@ -150,21 +150,18 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) case GNUNET_FS_STATUS_SEARCH_RESULT: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Search complete.\n"); - GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_search_task, NULL); break; case GNUNET_FS_STATUS_PUBLISH_ERROR: FPRINTF (stderr, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); break; case GNUNET_FS_STATUS_SEARCH_ERROR: FPRINTF (stderr, "Error searching file: %s\n", event->value.search.specifics.error.message); - GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_search_task, NULL); break; case GNUNET_FS_STATUS_PUBLISH_START: GNUNET_assert (0 == strcmp ("publish-context", event->value.publish.cctx)); @@ -189,8 +186,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) break; case GNUNET_FS_STATUS_SEARCH_STOPPED: GNUNET_assert (search == event->value.search.sc); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); break; default: FPRINTF (stderr, "Unexpected event: %d\n", event->status); @@ -220,7 +216,7 @@ run (void *cls, fs = GNUNET_FS_start (cfg, "test-fs-search", &progress_cb, NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); GNUNET_assert (NULL != fs); - + processed_files = 0; for(j = 0; j < NUM_FILES; j++){ buf = GNUNET_malloc (FILESIZE); @@ -244,8 +240,8 @@ run (void *cls, GNUNET_FS_PUBLISH_OPTION_NONE); GNUNET_assert (publish != NULL); } - - + + timeout_task = GNUNET_SCHEDULER_add_delayed (LIFETIME, &abort_error, NULL); } diff --git a/src/fs/test_fs_test_lib.c b/src/fs/test_fs_test_lib.c index bc950ed755..3f802bfcf0 100644 --- a/src/fs/test_fs_test_lib.c +++ b/src/fs/test_fs_test_lib.c @@ -44,22 +44,28 @@ static struct GNUNET_TESTBED_Peer *the_peers[NUM_DAEMONS]; +static struct GNUNET_TIME_Absolute start_time; + static int ret; static void -do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +do_stop (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) { char *fn = cls; - if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) + if (0 == + GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_add (start_time, + TIMEOUT)).rel_value_us) { GNUNET_break (0); ret = 1; } else { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Finished download, shutting down\n", (unsigned long long) FILESIZE); } if (NULL != fn) @@ -72,7 +78,8 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -do_download (void *cls, const struct GNUNET_FS_Uri *uri, +do_download (void *cls, + const struct GNUNET_FS_Uri *uri, const char *fn) { if (NULL == uri) @@ -82,9 +89,15 @@ do_download (void *cls, const struct GNUNET_FS_Uri *uri, ret = 1; return; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Downloading %llu bytes\n", (unsigned long long) FILESIZE); - GNUNET_FS_TEST_download (the_peers[0], TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop, + start_time = GNUNET_TIME_absolute_get (); + GNUNET_FS_TEST_download (the_peers[0], + TIMEOUT, 1, SEED, + uri, + VERBOSE, + &do_stop, (NULL == fn) ? NULL : GNUNET_strdup (fn)); } diff --git a/src/fs/test_fs_unindex.c b/src/fs/test_fs_unindex.c index dcde15bc05..c7a0c7cd5f 100644 --- a/src/fs/test_fs_unindex.c +++ b/src/fs/test_fs_unindex.c @@ -108,8 +108,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (1 + GNUNET_TIME_absolute_get_duration (start).rel_value_us) / 1024)); - GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_unindex_task, NULL); break; case GNUNET_FS_STATUS_UNINDEX_PROGRESS: GNUNET_assert (unindex == event->value.unindex.uc); @@ -125,14 +124,12 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) FPRINTF (stderr, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); break; case GNUNET_FS_STATUS_UNINDEX_ERROR: FPRINTF (stderr, "Error unindexing file: %s\n", event->value.unindex.specifics.error.message); - GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_unindex_task, NULL); break; case GNUNET_FS_STATUS_PUBLISH_START: GNUNET_assert (0 == strcmp ("publish-context", event->value.publish.cctx)); @@ -157,8 +154,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) break; case GNUNET_FS_STATUS_UNINDEX_STOPPED: GNUNET_assert (unindex == event->value.unindex.uc); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); break; default: printf ("Unexpected event: %d\n", event->status); diff --git a/src/fs/test_fs_unindex_persistence.c b/src/fs/test_fs_unindex_persistence.c index 628bc85d2c..ccb628a630 100644 --- a/src/fs/test_fs_unindex_persistence.c +++ b/src/fs/test_fs_unindex_persistence.c @@ -150,8 +150,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (1 + GNUNET_TIME_absolute_get_duration (start).rel_value_us) / 1024)); - GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_unindex_task, NULL); break; case GNUNET_FS_STATUS_UNINDEX_PROGRESS: consider_restart (event->status); @@ -187,15 +186,13 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) FPRINTF (stderr, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); break; case GNUNET_FS_STATUS_UNINDEX_ERROR: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error unindexing file: %s\n", event->value.unindex.specifics.error.message); - GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_unindex_task, NULL); break; case GNUNET_FS_STATUS_PUBLISH_START: GNUNET_assert (0 == strcmp ("publish-context", event->value.publish.cctx)); @@ -221,8 +218,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) break; case GNUNET_FS_STATUS_UNINDEX_STOPPED: GNUNET_assert (unindex == event->value.unindex.uc); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); break; default: printf ("Unexpected event: %d\n", event->status); diff --git a/src/fs/test_gnunet_service_fs_migration.c b/src/fs/test_gnunet_service_fs_migration.c index 94b6452d64..69fd4619ab 100644 --- a/src/fs/test_gnunet_service_fs_migration.c +++ b/src/fs/test_gnunet_service_fs_migration.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2010, 2012 Christian Grothoff (and other contributing authors) + Copyright (C) 2010, 2012, 2015 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -64,13 +64,22 @@ struct DownloadContext static void -do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +do_stop (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) { struct GNUNET_TIME_Relative del; char *fancy; GNUNET_SCHEDULER_shutdown (); - if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) + if (0 == + GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_add (start_time, + TIMEOUT)).rel_value_us) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Timeout during download, shutting down with error\n"); + ok = 1; + } + else { del = GNUNET_TIME_absolute_get_duration (start_time); if (del.rel_value_us == 0) @@ -78,16 +87,13 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) fancy = GNUNET_STRINGS_byte_size_fancy (((unsigned long long) FILESIZE) * 1000000LL / del.rel_value_us); - FPRINTF (stdout, "Download speed was %s/s\n", fancy); + FPRINTF (stdout, + "Download speed was %s/s\n", + fancy); GNUNET_free (fancy); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n", - (unsigned long long) FILESIZE); - } - else - { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Timeout during download, shutting down with error\n"); - ok = 1; + "Finished download, shutting down\n", + (unsigned long long) FILESIZE); } } @@ -110,34 +116,45 @@ do_download (void *cls, if (NULL != emsg) { GNUNET_SCHEDULER_shutdown (); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to stop source daemon: %s\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Failed to stop source daemon: %s\n", emsg); GNUNET_FS_uri_destroy (uri); ok = 1; return; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Downloading %llu bytes\n", (unsigned long long) FILESIZE); start_time = GNUNET_TIME_absolute_get (); - GNUNET_FS_TEST_download (daemons[0], TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop, + GNUNET_FS_TEST_download (daemons[0], + TIMEOUT, + 1, + SEED, + uri, + VERBOSE, + &do_stop, NULL); GNUNET_FS_uri_destroy (uri); } static void -stop_source_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +stop_source_peer (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) { struct DownloadContext *dc = cls; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping source peer\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Stopping source peer\n"); op = GNUNET_TESTBED_peer_stop (NULL, daemons[1], &do_download, dc); GNUNET_assert (NULL != op); } static void -do_wait (void *cls, const struct GNUNET_FS_Uri *uri, +do_wait (void *cls, + const struct GNUNET_FS_Uri *uri, const char *fn) { struct DownloadContext *dc; @@ -150,7 +167,8 @@ do_wait (void *cls, const struct GNUNET_FS_Uri *uri, ok = 1; return; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Waiting to allow content to migrate\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Waiting to allow content to migrate\n"); dc = GNUNET_new (struct DownloadContext); dc->uri = GNUNET_FS_uri_dup (uri); if (NULL != fn) @@ -172,7 +190,8 @@ do_publish (void *cls, GNUNET_assert (2 == num_peers); for (i=0;i<num_peers;i++) daemons[i] = peers[i]; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Publishing %llu bytes\n", (unsigned long long) FILESIZE); GNUNET_FS_TEST_publish (daemons[1], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED, VERBOSE, &do_wait, NULL); @@ -180,7 +199,8 @@ do_publish (void *cls, int -main (int argc, char *argv[]) +main (int argc, + char *argv[]) { (void) GNUNET_TESTBED_test_run ("test-gnunet-service-fs-migration", "fs_test_lib_data.conf", diff --git a/src/fs/test_gnunet_service_fs_p2p.c b/src/fs/test_gnunet_service_fs_p2p.c index ba3b8daab2..57efbdcd63 100644 --- a/src/fs/test_gnunet_service_fs_p2p.c +++ b/src/fs/test_gnunet_service_fs_p2p.c @@ -61,24 +61,29 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) char *fancy; GNUNET_SCHEDULER_shutdown (); - if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) + if (0 == + GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_add (start_time, + TIMEOUT)).rel_value_us) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Timeout during download, shutting down with error\n"); + ok = 1; + } + else { del = GNUNET_TIME_absolute_get_duration (start_time); - if (del.rel_value_us == 0) + if (0 == del.rel_value_us) del.rel_value_us = 1; fancy = GNUNET_STRINGS_byte_size_fancy (((unsigned long long) FILESIZE) * 1000000LL / del.rel_value_us); - FPRINTF (stdout, "Download speed was %s/s\n", fancy); + FPRINTF (stdout, + "Download speed was %s/s\n", + fancy); GNUNET_free (fancy); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n", - (unsigned long long) FILESIZE); - } - else - { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Timeout during download, shutting down with error\n"); - ok = 1; + "Finished download, shutting down\n", + (unsigned long long) FILESIZE); } if (NULL != fn) { |