From 75a33a1499cf60ea4364c9aa673816629a6c1413 Mon Sep 17 00:00:00 2001 From: "Nathan S. Evans" Date: Fri, 5 Nov 2010 18:21:50 +0000 Subject: big scheduler refactoring, expect some issues --- src/arm/arm_api.c | 61 +--- src/arm/gnunet-arm.c | 25 +- src/arm/gnunet-service-arm.c | 36 +- src/arm/gnunet-service-arm.h | 3 +- src/arm/gnunet-service-arm_interceptor.c | 75 ++--- src/arm/mockup-service.c | 6 +- src/arm/test_arm_api.c | 9 +- src/arm/test_exponential_backoff.c | 37 +- src/arm/test_gnunet_service_manager.c | 10 +- src/core/core_api.c | 30 +- src/core/core_api_iterate_peers.c | 6 +- src/core/core_api_peer_get_info.c | 6 +- src/core/core_api_peer_request.c | 17 +- src/core/gnunet-service-core.c | 94 ++---- src/core/test_core_api.c | 18 +- src/core/test_core_api_reliability.c | 32 +- src/core/test_core_api_start_only.c | 9 +- src/core/test_core_quota_compliance.c | 37 +- src/datacache/datacache.c | 8 +- src/datacache/perf_datacache.c | 4 +- src/datacache/plugin_datacache.h | 4 - src/datacache/test_datacache.c | 4 +- src/datacache/test_datacache_quota.c | 4 +- src/datastore/datastore_api.c | 35 +- src/datastore/gnunet-service-datastore.c | 25 +- src/datastore/perf_datastore_api.c | 23 +- src/datastore/perf_plugin_datastore.c | 21 +- src/datastore/plugin_datastore.h | 4 - src/datastore/plugin_datastore_mysql.c | 6 +- src/datastore/plugin_datastore_postgres.c | 6 +- src/datastore/plugin_datastore_sqlite.c | 6 +- src/datastore/test_datastore_api.c | 31 +- src/datastore/test_datastore_api_management.c | 17 +- src/dht/dht_api.c | 26 +- src/dht/gnunet-dht-driver.c | 220 ++++++------ src/dht/gnunet-dht-get-peer.c | 16 +- src/dht/gnunet-dht-get.c | 14 +- src/dht/gnunet-dht-put.c | 11 +- src/dht/gnunet-service-dht.c | 88 +++-- src/dht/test_dht_api.c | 53 ++- src/dht/test_dht_multipeer.c | 96 +++--- src/dht/test_dht_twopeer.c | 81 ++--- src/dht/test_dht_twopeer_put_get.c | 58 ++-- src/dht/test_dhtlog.c | 1 - src/dv/dv.h | 3 +- src/dv/dv_api.c | 13 +- src/dv/gnunet-service-dv.c | 56 ++- src/dv/plugin_transport_dv.c | 2 +- src/dv/test_transport_api_dv.c | 103 +++--- src/fs/fs.c | 34 +- src/fs/fs.h | 5 - src/fs/fs_download.c | 12 +- src/fs/fs_list_indexed.c | 18 +- src/fs/fs_namespace.c | 16 +- src/fs/fs_publish.c | 46 +-- src/fs/fs_search.c | 52 +-- src/fs/fs_test_lib.c | 87 ++--- src/fs/fs_test_lib.h | 20 +- src/fs/fs_tree.c | 6 +- src/fs/fs_unindex.c | 9 +- src/fs/gnunet-directory.c | 2 - src/fs/gnunet-download.c | 18 +- src/fs/gnunet-pseudonym.c | 5 +- src/fs/gnunet-publish.c | 23 +- src/fs/gnunet-search.c | 16 +- src/fs/gnunet-service-fs.c | 92 ++--- src/fs/gnunet-service-fs_indexing.c | 17 +- src/fs/gnunet-service-fs_indexing.h | 4 +- src/fs/gnunet-unindex.c | 18 +- src/fs/perf_gnunet_service_fs_p2p.c | 36 +- src/fs/test_fs_download.c | 27 +- src/fs/test_fs_download_indexed.c | 27 +- src/fs/test_fs_download_persistence.c | 30 +- src/fs/test_fs_file_information.c | 3 +- src/fs/test_fs_list_indexed.c | 16 +- src/fs/test_fs_namespace.c | 19 +- src/fs/test_fs_namespace_list_updateable.c | 7 +- src/fs/test_fs_publish.c | 13 +- src/fs/test_fs_publish_persistence.c | 19 +- src/fs/test_fs_search.c | 19 +- src/fs/test_fs_search_persistence.c | 25 +- src/fs/test_fs_start_stop.c | 7 +- src/fs/test_fs_test_lib.c | 28 +- src/fs/test_fs_unindex.c | 19 +- src/fs/test_fs_unindex_persistence.c | 25 +- src/fs/test_gnunet_service_fs_migration.c | 31 +- src/fs/test_gnunet_service_fs_p2p.c | 25 +- src/hostlist/gnunet-daemon-hostlist.c | 15 +- src/hostlist/hostlist-client.c | 52 +-- src/hostlist/hostlist-client.h | 2 - src/hostlist/hostlist-server.c | 19 +- src/hostlist/hostlist-server.h | 1 - src/hostlist/test_gnunet_daemon_hostlist.c | 23 +- .../test_gnunet_daemon_hostlist_learning.c | 40 +-- src/include/gnunet_arm_service.h | 2 - src/include/gnunet_client_lib.h | 10 +- src/include/gnunet_connection_lib.h | 23 +- src/include/gnunet_core_service.h | 16 +- src/include/gnunet_crypto_lib.h | 4 +- src/include/gnunet_datacache_lib.h | 4 +- src/include/gnunet_datastore_service.h | 6 +- src/include/gnunet_dht_service.h | 4 +- src/include/gnunet_disk_lib.h | 5 +- src/include/gnunet_fs_service.h | 4 +- src/include/gnunet_nat_lib.h | 4 +- src/include/gnunet_peerinfo_service.h | 6 +- src/include/gnunet_program_lib.h | 2 - src/include/gnunet_resolver_service.h | 12 +- src/include/gnunet_scheduler_lib.h | 93 ++--- src/include/gnunet_server_lib.h | 10 +- src/include/gnunet_service_lib.h | 6 - src/include/gnunet_statistics_service.h | 4 +- src/include/gnunet_testing_lib.h | 13 +- src/include/gnunet_transport_service.h | 14 +- src/include/gnunet_upnp_service.h | 4 +- src/monkey/gnunet-monkey.c | 2 - src/nat/nat.c | 23 +- src/nat/natpmp.c | 5 +- src/nat/natpmp.h | 5 +- src/nat/test_nat.c | 6 +- src/nat/upnp-commands.c | 28 +- src/nat/upnp-commands.h | 20 +- src/nat/upnp-discover.c | 40 +-- src/nat/upnp-discover.h | 4 +- src/nat/upnp.c | 16 +- src/nat/upnp.h | 5 +- src/peerinfo-tool/gnunet-peerinfo.c | 10 +- src/peerinfo/gnunet-service-peerinfo.c | 19 +- src/peerinfo/peerinfo_api.c | 35 +- src/peerinfo/peerinfo_api_notify.c | 17 +- src/peerinfo/perf_peerinfo_api.c | 6 +- src/peerinfo/test_peerinfo_api.c | 6 +- src/statistics/gnunet-service-statistics.c | 5 +- src/statistics/gnunet-statistics.c | 6 +- src/statistics/statistics_api.c | 19 +- src/statistics/test_statistics_api.c | 6 +- src/statistics/test_statistics_api_loop.c | 3 +- src/template/gnunet-service-template.c | 5 +- src/template/gnunet-template.c | 2 - src/testing/test_testing.c | 3 +- src/testing/test_testing_connect.c | 10 +- src/testing/test_testing_group.c | 6 +- src/testing/test_testing_group_remote.c | 7 +- src/testing/test_testing_topology.c | 86 ++--- src/testing/test_testing_topology_blacklist.c | 54 ++- src/testing/test_testing_topology_churn.c | 22 +- src/testing/testing.c | 102 ++---- src/testing/testing_group.c | 51 ++- src/topology/gnunet-daemon-topology.c | 61 ++-- src/topology/test_gnunet_daemon_topology.c | 9 +- src/transport/gnunet-service-transport.c | 90 ++--- src/transport/plugin_transport.h | 5 - src/transport/plugin_transport_http.c | 41 ++- src/transport/plugin_transport_tcp.c | 37 +- src/transport/plugin_transport_udp.c | 42 +-- src/transport/plugin_transport_wlan.c | 14 +- src/transport/test_plugin_transport.c | 12 +- src/transport/test_plugin_transport_http.c | 22 +- src/transport/test_plugin_transport_https.c | 22 +- src/transport/test_plugin_transport_udp.c | 9 - src/transport/test_quota_compliance.c | 41 +-- src/transport/test_transport_api.c | 16 +- src/transport/test_transport_api_reliability.c | 28 +- src/transport/transport_api.c | 52 +-- src/transport/transport_api_address_lookup.c | 6 +- src/transport/transport_api_blacklist.c | 15 +- src/util/client.c | 61 ++-- src/util/connection.c | 112 ++---- src/util/crypto_hash.c | 18 +- src/util/disk.c | 12 +- src/util/gnunet-resolver.c | 4 +- src/util/gnunet-service-resolver.c | 2 - src/util/program.c | 2 +- src/util/resolver_api.c | 37 +- src/util/scheduler.c | 374 +++++++++------------ src/util/server.c | 39 +-- src/util/service.c | 26 +- src/util/test_client.c | 5 +- src/util/test_connection.c | 11 +- src/util/test_connection_addressing.c | 11 +- src/util/test_connection_receive_cancel.c | 13 +- src/util/test_connection_timeout.c | 4 +- src/util/test_connection_timeout_no_connect.c | 2 +- src/util/test_connection_transmit_cancel.c | 2 +- src/util/test_crypto_hash.c | 3 +- src/util/test_disk.c | 3 +- src/util/test_os_start_process.c | 16 +- src/util/test_program.c | 2 - src/util/test_resolver_api.c | 14 +- src/util/test_scheduler.c | 36 +- src/util/test_scheduler_delay.c | 3 +- src/util/test_server.c | 12 +- src/util/test_server_disconnect.c | 15 +- src/util/test_server_with_client.c | 14 +- src/util/test_service.c | 25 +- src/vpn/gnunet-daemon-vpn.c | 41 +-- src/vpn/gnunet-service-dns.c | 138 ++------ 197 files changed, 1664 insertions(+), 3373 deletions(-) diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index e404f8d27..f935c590f 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c @@ -49,11 +49,6 @@ struct GNUNET_ARM_Handle */ struct GNUNET_CONFIGURATION_Handle *cfg; - /** - * Scheduler to use. - */ - struct GNUNET_SCHEDULER_Handle *sched; - }; @@ -62,11 +57,6 @@ struct GNUNET_ARM_Handle */ struct ShutdownContext { - /** - * Scheduler to be used to call continuation - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * Connection to the service that is being shutdown. */ @@ -80,7 +70,7 @@ struct ShutdownContext /** * Task set up to cancel the shutdown request on timeout. */ - GNUNET_SCHEDULER_TaskIdentifier timeout_task; + GNUNET_SCHEDULER_TaskIdentifier cancel_task; /** * Task to call once shutdown complete @@ -99,7 +89,6 @@ struct ShutdownContext }; - /** * Handler receiving response to service shutdown requests. * First call with NULL: service misbehaving, or something. @@ -112,8 +101,7 @@ struct ShutdownContext * @param msg NULL, indicating socket closure. */ static void -service_shutdown_handler (void *cls, - const struct GNUNET_MessageHeader *msg) +service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) { struct ShutdownContext *shutdown_ctx = cls; @@ -124,7 +112,7 @@ service_shutdown_handler (void *cls, "Service handle shutdown before ACK!\n"); if (shutdown_ctx->cont != NULL) shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_SYSERR); - GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->timeout_task); + GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task); GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); GNUNET_free(shutdown_ctx); } @@ -137,7 +125,7 @@ service_shutdown_handler (void *cls, if (shutdown_ctx->cont != NULL) shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_NO); - GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->timeout_task); + GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task); GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); GNUNET_free(shutdown_ctx); } @@ -165,7 +153,7 @@ service_shutdown_handler (void *cls, if (shutdown_ctx->cont != NULL) shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_YES); - GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->timeout_task); + GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task); GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); GNUNET_free(shutdown_ctx); break; @@ -173,21 +161,17 @@ service_shutdown_handler (void *cls, } } - /** * Shutting down took too long, cancel receive and return error. * * @param cls closure * @param tc context information (why was this task triggered now) */ -static void -service_shutdown_timeout (void *cls, - const struct GNUNET_SCHEDULER_TaskContext * tc) +void service_shutdown_cancel (void *cls, + const struct GNUNET_SCHEDULER_TaskContext * tc) { struct ShutdownContext *shutdown_ctx = cls; - - GNUNET_log(GNUNET_ERROR_TYPE_WARNING, - _("Timeout during attempt to shutdown service. Hoping it is simply down already.\n")); + GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "service_shutdown_cancel called!\n"); shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_SYSERR); GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); GNUNET_free(shutdown_ctx); @@ -222,10 +206,9 @@ write_shutdown (void *cls, size_t size, void *buf) GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler, shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL); - shutdown_ctx->timeout_task = GNUNET_SCHEDULER_add_delayed (shutdown_ctx->sched, - GNUNET_TIME_absolute_get_remaining(shutdown_ctx->timeout), - &service_shutdown_timeout, - shutdown_ctx); + shutdown_ctx->cancel_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining(shutdown_ctx->timeout), + &service_shutdown_cancel, + shutdown_ctx); msg = (struct GNUNET_MessageHeader *) buf; msg->type = htons (GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN); msg->size = htons (sizeof (struct GNUNET_MessageHeader)); @@ -240,7 +223,6 @@ write_shutdown (void *cls, size_t size, void *buf) * be used by the caller after this call * (calling this function frees "sock" after a while). * - * @param sched the scheduler to use for calling shutdown continuation * @param sock the socket connected to the service * @param timeout how long to wait before giving up on transmission * @param cont continuation to call once the service is really down @@ -248,16 +230,13 @@ write_shutdown (void *cls, size_t size, void *buf) * */ static void -arm_service_shutdown (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_CLIENT_Connection *sock, +arm_service_shutdown (struct GNUNET_CLIENT_Connection *sock, struct GNUNET_TIME_Relative timeout, GNUNET_CLIENT_ShutdownTask cont, void *cont_cls) { struct ShutdownContext *shutdown_ctx; - shutdown_ctx = GNUNET_malloc(sizeof(struct ShutdownContext)); - shutdown_ctx->sched = sched; shutdown_ctx->cont = cont; shutdown_ctx->cont_cls = cont_cls; shutdown_ctx->sock = sock; @@ -278,20 +257,17 @@ arm_service_shutdown (struct GNUNET_SCHEDULER_Handle *sched, * @param cfg configuration to use (needed to contact ARM; * the ARM service may internally use a different * configuration to determine how to start the service). - * @param sched scheduler to use * @param service service that *this* process is implementing/providing, can be NULL * @return context to use for further ARM operations, NULL on error */ struct GNUNET_ARM_Handle * GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, - struct GNUNET_SCHEDULER_Handle *sched, const char *service) { struct GNUNET_ARM_Handle *ret; ret = GNUNET_malloc (sizeof (struct GNUNET_ARM_Handle)); ret->cfg = GNUNET_CONFIGURATION_dup (cfg); - ret->sched = sched; return ret; } @@ -517,8 +493,7 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg) : "STOP", (const char*) &sc[1]); GNUNET_CLIENT_disconnect (sc->h->client, GNUNET_NO); - sc->h->client = GNUNET_CLIENT_connect (sc->h->sched, - "arm", + sc->h->client = GNUNET_CLIENT_connect ("arm", sc->h->cfg); GNUNET_assert (NULL != sc->h->client); GNUNET_CLIENT_ignore_shutdown (sc->h->client, GNUNET_YES); @@ -641,7 +616,6 @@ GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, struct RequestContext *sctx; struct GNUNET_CLIENT_Connection *client; size_t slen; - #if DEBUG_ARM GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Asked to start service `%s' within %llu ms\n"), service_name, @@ -656,14 +630,13 @@ GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, sctx->cls = cb_cls; sctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); memcpy (&sctx[1], service_name, slen); - GNUNET_CLIENT_service_test (h->sched, - "arm", + GNUNET_CLIENT_service_test ("arm", h->cfg, timeout, &arm_service_report, sctx); return; } if (h->client == NULL) { - client = GNUNET_CLIENT_connect (h->sched, "arm", h->cfg); + client = GNUNET_CLIENT_connect ("arm", h->cfg); if (client == NULL) { cb (cb_cls, GNUNET_SYSERR); @@ -718,7 +691,7 @@ GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h, (unsigned long long) timeout.rel_value); if (h->client == NULL) { - client = GNUNET_CLIENT_connect (h->sched, "arm", h->cfg); + client = GNUNET_CLIENT_connect ("arm", h->cfg); if (client == NULL) { cb (cb_cls, GNUNET_SYSERR); @@ -732,7 +705,7 @@ GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h, arm_shutdown_ctx = GNUNET_malloc(sizeof(struct ARM_ShutdownContext)); arm_shutdown_ctx->cb = cb; arm_shutdown_ctx->cb_cls = cb_cls; - arm_service_shutdown (h->sched, h->client, timeout, &arm_shutdown_callback, arm_shutdown_ctx); + arm_service_shutdown (h->client, timeout, &arm_shutdown_callback, arm_shutdown_ctx); h->client = NULL; return; } diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c index c19020ccb..ba74e8223 100644 --- a/src/arm/gnunet-arm.c +++ b/src/arm/gnunet-arm.c @@ -115,11 +115,6 @@ static int ret; */ static struct GNUNET_ARM_Handle *h; -/** - * Our scheduler. - */ -static struct GNUNET_SCHEDULER_Handle *sched; - /** * Our configuration. */ @@ -184,8 +179,7 @@ confirm_cb (void *cls, int success) break; } - GNUNET_SCHEDULER_add_continuation (sched, - &cps_loop, + GNUNET_SCHEDULER_add_continuation (&cps_loop, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -213,8 +207,7 @@ confirm_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (quiet != GNUNET_YES) fprintf(stdout, _("Service `%s' is not running.\n"), service); } - GNUNET_SCHEDULER_add_continuation (sched, - &cps_loop, + GNUNET_SCHEDULER_add_continuation (&cps_loop, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -224,19 +217,16 @@ confirm_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * Main function that will be run by the scheduler. * * @param cls closure - * @param s the scheduler to use * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param c configuration */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { - sched = s; cfg = c; config_file = cfgfile; if (GNUNET_CONFIGURATION_get_value_string(cfg, "PATHS", "SERVICEHOME", &dir) != GNUNET_OK) @@ -247,7 +237,7 @@ run (void *cls, "PATHS"); return; } - h = GNUNET_ARM_connect (cfg, sched, NULL); + h = GNUNET_ARM_connect (cfg, NULL); if (h == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -255,8 +245,7 @@ run (void *cls, ret = 1; return; } - GNUNET_SCHEDULER_add_continuation (sched, - &cps_loop, + GNUNET_SCHEDULER_add_continuation (&cps_loop, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -330,7 +319,7 @@ cps_loop (void *cls, case 4: if (test != NULL) { - GNUNET_CLIENT_service_test (sched, test, cfg, TEST_TIMEOUT, &confirm_task, test); + GNUNET_CLIENT_service_test (test, cfg, TEST_TIMEOUT, &confirm_task, test); return; } break; @@ -342,7 +331,7 @@ cps_loop (void *cls, end = 0; start = 1; restart = 0; - h = GNUNET_ARM_connect (cfg, sched, NULL); + h = GNUNET_ARM_connect (cfg, NULL); if (h == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -350,7 +339,7 @@ cps_loop (void *cls, ret = 1; return; } - GNUNET_SCHEDULER_add_now(sched, &cps_loop, NULL); + GNUNET_SCHEDULER_add_now(&cps_loop, NULL); return; } /* Fall through */ diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c index ab4db97c7..c967c64e6 100644 --- a/src/arm/gnunet-service-arm.c +++ b/src/arm/gnunet-service-arm.c @@ -123,11 +123,6 @@ static struct ServiceList *running; */ static const struct GNUNET_CONFIGURATION_Handle *cfg; -/** - * Our scheduler. - */ -static struct GNUNET_SCHEDULER_Handle *sched; - /** * Command to prepend to each actual command. */ @@ -695,7 +690,7 @@ do_shutdown () { GNUNET_SERVER_destroy (server); server = NULL; - GNUNET_SCHEDULER_cancel (sched, child_death_task); + GNUNET_SCHEDULER_cancel (child_death_task); child_death_task = GNUNET_SCHEDULER_NO_TASK; } @@ -741,7 +736,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) pos = pos->next; } #if DELAY_SHUTDOWN - GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &dummy_task, NULL); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &dummy_task, NULL); #endif if (running == NULL) do_shutdown (); @@ -802,8 +797,7 @@ delayed_restart_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) (unsigned long long) lowestRestartDelay.rel_value); #endif child_restart_task - = GNUNET_SCHEDULER_add_delayed (sched, - lowestRestartDelay, + = GNUNET_SCHEDULER_add_delayed (lowestRestartDelay, &delayed_restart_task, NULL); } @@ -834,7 +828,7 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) { child_death_task = - GNUNET_SCHEDULER_add_read_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, pr, + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, pr, &maint_child_death, NULL); return; } @@ -909,10 +903,9 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) pos->backoff = GNUNET_TIME_relative_multiply (pos->backoff, 2); if (GNUNET_SCHEDULER_NO_TASK != child_restart_task) - GNUNET_SCHEDULER_cancel (sched, child_restart_task); + GNUNET_SCHEDULER_cancel (child_restart_task); child_restart_task - = GNUNET_SCHEDULER_add_with_priority (sched, - GNUNET_SCHEDULER_PRIORITY_IDLE, + = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, &delayed_restart_task, NULL); } @@ -934,7 +927,7 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) else { child_death_task = - GNUNET_SCHEDULER_add_read_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, pr, + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, pr, &maint_child_death, NULL); } } @@ -986,7 +979,7 @@ handle_shutdown (void *cls, GNUNET_TIME_UNIT_FOREVER_REL, &transmit_shutdown_ack, client); GNUNET_SERVER_client_persist_ (client); - GNUNET_SCHEDULER_shutdown (sched); + GNUNET_SCHEDULER_shutdown (); } @@ -1011,13 +1004,11 @@ sighandler_child_death () * Process arm requests. * * @param cls closure - * @param s scheduler to use * @param serv the initialized server * @param c configuration to use */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, struct GNUNET_SERVER_Handle *serv, const struct GNUNET_CONFIGURATION_Handle *c) { @@ -1032,18 +1023,16 @@ run (void *cls, char *pos; cfg = c; - sched = s; server = serv; GNUNET_assert (serv != NULL); pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ); GNUNET_assert (pr != NULL); GNUNET_SERVER_ignore_shutdown (serv, GNUNET_YES); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); child_death_task = - GNUNET_SCHEDULER_add_read_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, pr, + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, pr, &maint_child_death, NULL); if (GNUNET_OK != @@ -1089,14 +1078,13 @@ run (void *cls, } /* create listening sockets for future services*/ - prepareServices (cfg, sched); + prepareServices (cfg); /* process client requests */ GNUNET_SERVER_add_handlers (server, handlers); /* manage services */ - GNUNET_SCHEDULER_add_with_priority (sched, - GNUNET_SCHEDULER_PRIORITY_IDLE, + GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, &config_change_task, NULL); } diff --git a/src/arm/gnunet-service-arm.h b/src/arm/gnunet-service-arm.h index 1f9085889..0ef557157 100644 --- a/src/arm/gnunet-service-arm.h +++ b/src/arm/gnunet-service-arm.h @@ -49,7 +49,6 @@ int start_service (struct GNUNET_SERVER_Client *client, int stop_listening (const char *serviceName); void prepareServices (const struct GNUNET_CONFIGURATION_Handle - *configurationHandle, - struct GNUNET_SCHEDULER_Handle *sched); + *configurationHandle); #endif diff --git a/src/arm/gnunet-service-arm_interceptor.c b/src/arm/gnunet-service-arm_interceptor.c index 8f79db6c5..56268b2d0 100644 --- a/src/arm/gnunet-service-arm_interceptor.c +++ b/src/arm/gnunet-service-arm_interceptor.c @@ -205,11 +205,6 @@ static unsigned int numDefaultServices; */ static const struct GNUNET_CONFIGURATION_Handle *cfg; -/** - * - */ -static struct GNUNET_SCHEDULER_Handle *scheduler; - /** * */ @@ -293,7 +288,7 @@ closeClientAndServiceSockets (struct ForwardedConnection *fc, #endif if (fc->service_to_client_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (scheduler, fc->service_to_client_task); + GNUNET_SCHEDULER_cancel (fc->service_to_client_task); fc->service_to_client_task = GNUNET_SCHEDULER_NO_TASK; } if (fc->armClientSocket != NULL) @@ -312,8 +307,7 @@ closeClientAndServiceSockets (struct ForwardedConnection *fc, #endif if (fc->client_to_service_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (scheduler, - fc->client_to_service_task); + GNUNET_SCHEDULER_cancel ( fc->client_to_service_task); fc->client_to_service_task = GNUNET_SCHEDULER_NO_TASK; } if (fc->armClientSocket != NULL) @@ -331,8 +325,7 @@ closeClientAndServiceSockets (struct ForwardedConnection *fc, "Closing forwarding connection (done with both directions)\n"); #endif if (fc->start_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (scheduler, - fc->start_task); + GNUNET_SCHEDULER_cancel ( fc->start_task); if ( (NULL != fc->armClientSocket) && (GNUNET_SYSERR == GNUNET_NETWORK_socket_close (fc->armClientSocket)) ) @@ -388,7 +381,7 @@ forwardToClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) fc->armClientSocket)) { fc->service_to_client_task = - GNUNET_SCHEDULER_add_write_net (scheduler, + GNUNET_SCHEDULER_add_write_net ( GNUNET_TIME_UNIT_FOREVER_REL, fc->armClientSocket, &forwardToClient, fc); @@ -421,7 +414,7 @@ forwardToClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) fc->service_to_client_bufferPos += numberOfBytesSent; fc->service_to_client_bufferDataLength -= numberOfBytesSent; fc->service_to_client_task = - GNUNET_SCHEDULER_add_write_net (scheduler, + GNUNET_SCHEDULER_add_write_net ( GNUNET_TIME_UNIT_FOREVER_REL, fc->armClientSocket, &forwardToClient, @@ -429,8 +422,7 @@ forwardToClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; } fc->service_to_client_task = - GNUNET_SCHEDULER_add_read_net (scheduler, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, fc->armServiceSocket, &receiveFromService, fc); @@ -461,7 +453,7 @@ receiveFromService (void *cls, fc->armServiceSocket)) { fc->service_to_client_task = - GNUNET_SCHEDULER_add_read_net (scheduler, + GNUNET_SCHEDULER_add_read_net ( GNUNET_TIME_UNIT_FOREVER_REL, fc->armServiceSocket, &receiveFromService, fc); @@ -491,8 +483,7 @@ receiveFromService (void *cls, if ( (fc->client_to_service_bufferDataLength > 0) && (fc->client_to_service_task != GNUNET_SCHEDULER_NO_TASK) ) { - GNUNET_SCHEDULER_cancel (scheduler, - fc->client_to_service_task); + GNUNET_SCHEDULER_cancel (fc->client_to_service_task); fc->client_to_service_task = GNUNET_SCHEDULER_NO_TASK; } fc->back_off = GNUNET_TIME_relative_multiply (fc->back_off, 2); @@ -508,7 +499,7 @@ receiveFromService (void *cls, rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); fc->start_task - = GNUNET_SCHEDULER_add_delayed (scheduler, + = GNUNET_SCHEDULER_add_delayed ( GNUNET_TIME_relative_min (fc->back_off, rem), &start_forwarding, @@ -533,7 +524,7 @@ receiveFromService (void *cls, fc->service_to_client_bufferDataLength); #endif fc->service_to_client_task = - GNUNET_SCHEDULER_add_write_net (scheduler, + GNUNET_SCHEDULER_add_write_net ( GNUNET_TIME_UNIT_FOREVER_REL, fc->armClientSocket, &forwardToClient, fc); @@ -565,7 +556,7 @@ forwardToService (void *cls, fc->armServiceSocket)) { fc->client_to_service_task = - GNUNET_SCHEDULER_add_write_net (scheduler, + GNUNET_SCHEDULER_add_write_net ( GNUNET_TIME_UNIT_FOREVER_REL, fc->armServiceSocket, &forwardToService, fc); @@ -585,8 +576,7 @@ forwardToService (void *cls, if ( (fc->service_to_client_bufferDataLength == 0) && (fc->service_to_client_task != GNUNET_SCHEDULER_NO_TASK) ) { - GNUNET_SCHEDULER_cancel (scheduler, - fc->service_to_client_task); + GNUNET_SCHEDULER_cancel (fc->service_to_client_task); fc->service_to_client_task = GNUNET_SCHEDULER_NO_TASK; } fc->back_off = GNUNET_TIME_relative_multiply (fc->back_off, 2); @@ -602,8 +592,7 @@ forwardToService (void *cls, rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); fc->start_task - = GNUNET_SCHEDULER_add_delayed (scheduler, - GNUNET_TIME_relative_min (fc->back_off, + = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_min (fc->back_off, rem), &start_forwarding, fc); @@ -631,15 +620,14 @@ forwardToService (void *cls, fc->client_to_service_bufferPos += numberOfBytesSent; fc->client_to_service_bufferDataLength -= numberOfBytesSent; fc->client_to_service_task = - GNUNET_SCHEDULER_add_write_net (scheduler, + GNUNET_SCHEDULER_add_write_net ( GNUNET_TIME_UNIT_FOREVER_REL, fc->armServiceSocket, &forwardToService, fc); return; } fc->client_to_service_task = - GNUNET_SCHEDULER_add_read_net (scheduler, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, fc->armClientSocket, &receiveFromClient, fc); } @@ -661,7 +649,7 @@ receiveFromClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) fc->armClientSocket)) { fc->client_to_service_task = - GNUNET_SCHEDULER_add_read_net (scheduler, + GNUNET_SCHEDULER_add_read_net ( GNUNET_TIME_UNIT_FOREVER_REL, fc->armClientSocket, &receiveFromClient, fc); @@ -700,7 +688,7 @@ receiveFromClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #endif if (fc->armServiceSocket != NULL) fc->client_to_service_task = - GNUNET_SCHEDULER_add_write_net (scheduler, + GNUNET_SCHEDULER_add_write_net ( GNUNET_TIME_UNIT_FOREVER_REL, fc->armServiceSocket, &forwardToService, fc); @@ -769,8 +757,7 @@ start_forwarding (void *cls, #endif GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); fc->start_task - = GNUNET_SCHEDULER_add_delayed (scheduler, - GNUNET_TIME_relative_min (fc->back_off, + = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_min (fc->back_off, rem), &start_forwarding, fc); @@ -784,13 +771,13 @@ start_forwarding (void *cls, { if (fc->client_to_service_bufferDataLength == 0) fc->client_to_service_task = - GNUNET_SCHEDULER_add_read_net (scheduler, + GNUNET_SCHEDULER_add_read_net ( GNUNET_TIME_UNIT_FOREVER_REL, fc->armClientSocket, &receiveFromClient, fc); else fc->client_to_service_task = - GNUNET_SCHEDULER_add_write_net (scheduler, + GNUNET_SCHEDULER_add_write_net ( GNUNET_TIME_UNIT_FOREVER_REL, fc->armServiceSocket, &forwardToService, fc); @@ -799,13 +786,13 @@ start_forwarding (void *cls, { if (fc->service_to_client_bufferDataLength == 0) fc->service_to_client_task = - GNUNET_SCHEDULER_add_read_net (scheduler, + GNUNET_SCHEDULER_add_read_net ( GNUNET_TIME_UNIT_FOREVER_REL, fc->armServiceSocket, &receiveFromService, fc); else fc->service_to_client_task = - GNUNET_SCHEDULER_add_write_net (scheduler, + GNUNET_SCHEDULER_add_write_net ( GNUNET_TIME_UNIT_FOREVER_REL, fc->armClientSocket, &forwardToClient, fc); @@ -833,7 +820,7 @@ stop_listening (const char *serviceName) (strcmp (pos->serviceName, serviceName) != 0) ) continue; if (pos->acceptTask != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (scheduler, pos->acceptTask); + GNUNET_SCHEDULER_cancel (pos->acceptTask); GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->listeningSocket)); GNUNET_CONTAINER_DLL_remove (serviceListeningInfoList_head, @@ -882,7 +869,7 @@ accept_and_forward (struct ServiceListeningInfo *serviceListeningInfo) serviceListeningInfoList_tail, serviceListeningInfo); serviceListeningInfo->acceptTask = - GNUNET_SCHEDULER_add_read_net (scheduler, + GNUNET_SCHEDULER_add_read_net ( GNUNET_TIME_UNIT_FOREVER_REL, serviceListeningInfo->listeningSocket, &acceptConnection, @@ -898,14 +885,13 @@ accept_and_forward (struct ServiceListeningInfo *serviceListeningInfo) fc->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_SERVICE_TIMEOUT); fc->back_off = GNUNET_TIME_UNIT_MILLISECONDS; fc->client_to_service_task = - GNUNET_SCHEDULER_add_read_net (scheduler, + GNUNET_SCHEDULER_add_read_net ( GNUNET_TIME_UNIT_FOREVER_REL, fc->armClientSocket, &receiveFromClient, fc); GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); fc->start_task - = GNUNET_SCHEDULER_add_now (scheduler, - &start_forwarding, + = GNUNET_SCHEDULER_add_now (&start_forwarding, fc); } @@ -963,8 +949,7 @@ acceptConnection (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_free (pos->listeningSocket); /* deliberately no closing! */ GNUNET_free (pos->service_addr); GNUNET_free (pos->serviceName); - GNUNET_SCHEDULER_cancel (scheduler, - pos->acceptTask); + GNUNET_SCHEDULER_cancel ( pos->acceptTask); GNUNET_CONTAINER_DLL_remove (serviceListeningInfoList_head, serviceListeningInfoList_tail, pos); @@ -1073,7 +1058,7 @@ createListeningSocket (struct sockaddr *sa, serviceListeningInfo->service_addr_len = addr_len; serviceListeningInfo->listeningSocket = sock; serviceListeningInfo->acceptTask = - GNUNET_SCHEDULER_add_read_net (scheduler, + GNUNET_SCHEDULER_add_read_net ( GNUNET_TIME_UNIT_FOREVER_REL, sock, &acceptConnection, serviceListeningInfo); @@ -1123,15 +1108,13 @@ checkPortNumberCB (void *cls, * Entry point to the Service Manager * * @param configurationHandle configuration to use to get services - * @param sched scheduler to handle clients and services communications */ void prepareServices (const struct GNUNET_CONFIGURATION_Handle - *configurationHandle, struct GNUNET_SCHEDULER_Handle *sched) + *configurationHandle) { char *defaultServicesString; - scheduler = sched; cfg = configurationHandle; /* Split the default services into a list */ if (GNUNET_OK == diff --git a/src/arm/mockup-service.c b/src/arm/mockup-service.c index da8ada1db..4dae8ffb4 100644 --- a/src/arm/mockup-service.c +++ b/src/arm/mockup-service.c @@ -28,8 +28,6 @@ #include "gnunet_strings_lib.h" #include "gnunet_time_lib.h" -static struct GNUNET_SCHEDULER_Handle *sched; - static size_t transmit_shutdown_ack (void *cls, size_t size, void *buf) @@ -77,13 +75,12 @@ handle_shutdown (void *cls, GNUNET_TIME_UNIT_FOREVER_REL, &transmit_shutdown_ack, client); GNUNET_SERVER_client_persist_ (client); - GNUNET_SCHEDULER_shutdown (sched); + GNUNET_SCHEDULER_shutdown (); } static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg) { @@ -92,7 +89,6 @@ run (void *cls, sizeof (struct GNUNET_MessageHeader)}, {NULL, NULL, 0, 0} }; - sched = s; /* process client requests */ GNUNET_SERVER_ignore_shutdown (server, GNUNET_YES); GNUNET_SERVER_add_handlers (server, handlers); diff --git a/src/arm/test_arm_api.c b/src/arm/test_arm_api.c index 6ec95f4a0..6952b2e59 100644 --- a/src/arm/test_arm_api.c +++ b/src/arm/test_arm_api.c @@ -38,8 +38,6 @@ #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) -static struct GNUNET_SCHEDULER_Handle *sched; - static const struct GNUNET_CONFIGURATION_Handle *cfg; static struct GNUNET_ARM_Handle *arm; @@ -95,8 +93,7 @@ resolver_notify (void *cls, int success) #endif return; } - GNUNET_RESOLVER_ip_get (sched, - cfg, + GNUNET_RESOLVER_ip_get (cfg, "localhost", AF_INET, TIMEOUT, &dns_notify, NULL); } @@ -118,14 +115,12 @@ arm_notify (void *cls, int success) static void task (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { cfg = c; - sched = s; - arm = GNUNET_ARM_connect (cfg, sched, NULL); + arm = GNUNET_ARM_connect (cfg, NULL); #if START_ARM GNUNET_ARM_start_service (arm, "arm", START_TIMEOUT, &arm_notify, NULL); #else diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c index dd32f6a5d..8e5ac9bc1 100644 --- a/src/arm/test_exponential_backoff.c +++ b/src/arm/test_exponential_backoff.c @@ -35,7 +35,6 @@ #define SERVICE_TEST_TIMEOUT GNUNET_TIME_UNIT_FOREVER_REL #define FIVE_MILLISECONDS GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 5) -static struct GNUNET_SCHEDULER_Handle *sched; static const struct GNUNET_CONFIGURATION_Handle *cfg; static struct GNUNET_ARM_Handle *arm; static int ok = 1; @@ -55,10 +54,6 @@ static char *killLogFileName; */ struct ShutdownContext { - /** - * Scheduler to be used to call continuation - */ - struct GNUNET_SCHEDULER_Handle *sched; /** * Connection to the service that is being shutdown. */ @@ -114,7 +109,7 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) "Service handle shutdown before ACK!\n"); if (shutdown_ctx->cont != NULL) shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_SYSERR); - GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->cancel_task); + GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task); GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); GNUNET_free(shutdown_ctx); } @@ -127,7 +122,7 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) if (shutdown_ctx->cont != NULL) shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_NO); - GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->cancel_task); + GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task); GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); GNUNET_free(shutdown_ctx); } @@ -153,7 +148,7 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) if (shutdown_ctx->cont != NULL) shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_YES); - GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->cancel_task); + GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task); GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); GNUNET_free(shutdown_ctx); break; @@ -206,8 +201,7 @@ write_shutdown (void *cls, size_t size, void *buf) GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler, shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL); - shutdown_ctx->cancel_task = GNUNET_SCHEDULER_add_delayed (shutdown_ctx->sched, - GNUNET_TIME_absolute_get_remaining(shutdown_ctx->timeout), + shutdown_ctx->cancel_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining(shutdown_ctx->timeout), &service_shutdown_cancel, shutdown_ctx); msg = (struct GNUNET_MessageHeader *) buf; @@ -224,7 +218,6 @@ write_shutdown (void *cls, size_t size, void *buf) * be used by the caller after this call * (calling this function frees "sock" after a while). * - * @param sched the scheduler to use for calling shutdown continuation * @param sock the socket connected to the service * @param timeout how long to wait before giving up on transmission * @param cont continuation to call once the service is really down @@ -232,15 +225,13 @@ write_shutdown (void *cls, size_t size, void *buf) * */ static void -arm_service_shutdown (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_CLIENT_Connection *sock, +arm_service_shutdown (struct GNUNET_CLIENT_Connection *sock, struct GNUNET_TIME_Relative timeout, GNUNET_CLIENT_ShutdownTask cont, void *cont_cls) { struct ShutdownContext *shutdown_ctx; shutdown_ctx = GNUNET_malloc(sizeof(struct ShutdownContext)); - shutdown_ctx->sched = sched; shutdown_ctx->cont = cont; shutdown_ctx->cont_cls = cont_cls; shutdown_ctx->sock = sock; @@ -274,7 +265,7 @@ do_nothing_notify (void *cls, int success) { GNUNET_assert (success == GNUNET_YES); ok = 1; - GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_UNIT_SECONDS, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &kill_task, NULL); } @@ -322,7 +313,7 @@ do_nothing_restarted_notify_task (void *cls, trialCount); } #endif - GNUNET_SCHEDULER_add_now (sched, &kill_task, &a); + GNUNET_SCHEDULER_add_now (&kill_task, &a); } @@ -330,7 +321,7 @@ static void do_test (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc) { - GNUNET_CLIENT_service_test(sched, "do-nothing", + GNUNET_CLIENT_service_test("do-nothing", cfg, TIMEOUT, &do_nothing_restarted_notify_task, NULL); } @@ -341,8 +332,7 @@ shutdown_cont (void *cls, int reason) { trialCount++; startedWaitingAt = GNUNET_TIME_absolute_get(); - GNUNET_SCHEDULER_add_delayed (sched, - waitedFor, + GNUNET_SCHEDULER_add_delayed (waitedFor, &do_test, NULL); } @@ -369,7 +359,7 @@ kill_task (void *cbData, waitedFor.rel_value = 0; } /* Connect to the doNothing task */ - doNothingConnection = GNUNET_CLIENT_connect (sched, "do-nothing", cfg); + doNothingConnection = GNUNET_CLIENT_connect ("do-nothing", cfg); #if LOG_BACKOFF if (NULL == doNothingConnection) fprintf(killLogFilePtr, @@ -385,8 +375,7 @@ kill_task (void *cbData, } /* Use the created connection to kill the doNothingTask */ - arm_service_shutdown(sched, - doNothingConnection, + arm_service_shutdown(doNothingConnection, TIMEOUT, &shutdown_cont, NULL); } @@ -394,15 +383,13 @@ kill_task (void *cbData, static void task (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { cfg = c; - sched = s; - arm = GNUNET_ARM_connect (cfg, sched, NULL); + arm = GNUNET_ARM_connect (cfg,NULL); #if START_ARM GNUNET_ARM_start_service (arm, "arm", GNUNET_TIME_UNIT_ZERO, &arm_notify, NULL); #else diff --git a/src/arm/test_gnunet_service_manager.c b/src/arm/test_gnunet_service_manager.c index 26ea774d6..e4aecb8c4 100644 --- a/src/arm/test_gnunet_service_manager.c +++ b/src/arm/test_gnunet_service_manager.c @@ -43,7 +43,6 @@ static int ret = 1; -static struct GNUNET_SCHEDULER_Handle *sched; static const struct GNUNET_CONFIGURATION_Handle *cfg; @@ -108,8 +107,7 @@ arm_notify (void *cls, int success) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to resolve our own hostname!\n"); /* connect to the resolver service */ - if (NULL == GNUNET_RESOLVER_hostname_resolve (sched, - cfg, AF_UNSPEC, + if (NULL == GNUNET_RESOLVER_hostname_resolve (cfg, AF_UNSPEC, TIMEOUT, &hostNameResolveCB, NULL)) @@ -125,16 +123,14 @@ arm_notify (void *cls, int success) static void -run(void *cls, - struct GNUNET_SCHEDULER_Handle *s, +run(void *cls, char * const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { cfg = c; - sched = s; #if START_ARM - arm = GNUNET_ARM_connect (cfg, sched, NULL); + arm = GNUNET_ARM_connect (cfg, NULL); GNUNET_ARM_start_service (arm, "arm", START_TIMEOUT, &arm_notify, NULL); #else arm_notify (NULL, GNUNET_YES); diff --git a/src/core/core_api.c b/src/core/core_api.c index dd8919ea1..cb5ba3ecb 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c @@ -36,10 +36,6 @@ struct GNUNET_CORE_Handle { - /** - * Our scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; /** * Configuration we're using. @@ -263,10 +259,9 @@ reconnect (struct GNUNET_CORE_Handle *h) if (h->client_notifications != NULL) GNUNET_CLIENT_disconnect (h->client_notifications, GNUNET_NO); h->currently_down = GNUNET_YES; - h->client_notifications = GNUNET_CLIENT_connect (h->sched, "core", h->cfg); + h->client_notifications = GNUNET_CLIENT_connect ("core", h->cfg); if (h->client_notifications == NULL) - h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->sched, - GNUNET_TIME_UNIT_SECONDS, + h->reconnect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect_task, h); else @@ -328,7 +323,7 @@ request_start (void *cls, size_t size, void *buf) { if (th->timeout_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(h->sched, th->timeout_task); + GNUNET_SCHEDULER_cancel(th->timeout_task); th->timeout_task = GNUNET_SCHEDULER_NO_TASK; } timeout_request (th, NULL); @@ -673,8 +668,7 @@ transmit_start (void *cls, size_t size, void *buf) h->startup_timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); h->reconnect_task = - GNUNET_SCHEDULER_add_delayed (h->sched, - delay, &reconnect_task, h); + GNUNET_SCHEDULER_add_delayed (delay, &reconnect_task, h); return 0; } /* timeout on initial connect */ @@ -727,7 +721,6 @@ transmit_start (void *cls, size_t size, void *buf) * Connect to the core service. Note that the connection may * complete (or fail) asynchronously. * - * @param sched scheduler to use * @param cfg configuration to use * @param timeout after how long should we give up trying to connect to the core service? * @param cls closure for the various callbacks that follow (including handlers in the handlers array) @@ -749,8 +742,7 @@ transmit_start (void *cls, size_t size, void *buf) * NULL on error (in this case, init is never called) */ struct GNUNET_CORE_Handle * -GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TIME_Relative timeout, void *cls, GNUNET_CORE_StartupCallback init, @@ -766,7 +758,6 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_CORE_Handle *h; h = GNUNET_malloc (sizeof (struct GNUNET_CORE_Handle)); - h->sched = sched; h->cfg = cfg; h->cls = cls; h->init = init; @@ -778,7 +769,7 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, h->inbound_hdr_only = inbound_hdr_only; h->outbound_hdr_only = outbound_hdr_only; h->handlers = handlers; - h->client_notifications = GNUNET_CLIENT_connect (sched, "core", cfg); + h->client_notifications = GNUNET_CLIENT_connect ("core", cfg); if (h->client_notifications == NULL) { GNUNET_free (h); @@ -819,7 +810,7 @@ GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle) if (handle->solicit_transmit_req != NULL) GNUNET_CORE_notify_transmit_ready_cancel (handle->solicit_transmit_req); if (handle->reconnect_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (handle->sched, handle->reconnect_task); + GNUNET_SCHEDULER_cancel (handle->reconnect_task); if (handle->client_notifications != NULL) GNUNET_CLIENT_disconnect (handle->client_notifications, GNUNET_NO); GNUNET_break (handle->pending_head == NULL); @@ -950,8 +941,7 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, th->notify_cls = notify_cls; th->peer = *target; th->timeout = GNUNET_TIME_relative_to_absolute (maxdelay); - th->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->sched, - maxdelay, + th->timeout_task = GNUNET_SCHEDULER_add_delayed (maxdelay, &timeout_request, th); th->priority = priority; th->msize = sizeof (struct SendMessage) + notify_size; @@ -965,7 +955,7 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, /** * Cancel the specified transmission-ready notification. - * + *s * @param th handle that was returned by "notify_transmit_ready". */ void @@ -981,7 +971,7 @@ GNUNET_CORE_notify_transmit_ready_cancel (struct GNUNET_CORE_TransmitHandle h->pending_tail, th); if (th->timeout_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (h->sched, th->timeout_task); + GNUNET_SCHEDULER_cancel (th->timeout_task); GNUNET_free (th); } diff --git a/src/core/core_api_iterate_peers.c b/src/core/core_api_iterate_peers.c index 08cb9797c..aeef67f88 100644 --- a/src/core/core_api_iterate_peers.c +++ b/src/core/core_api_iterate_peers.c @@ -134,22 +134,20 @@ transmit_request(void *cls, /** * Obtain statistics and/or change preferences for the given peer. * - * @param sched scheduler to use * @param cfg configuration to use * @param peer_cb function to call with the peer information * @param cb_cls closure for peer_cb * @return GNUNET_OK if iterating, GNUNET_SYSERR on error */ int -GNUNET_CORE_iterate_peers (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CORE_ConnectEventHandler peer_cb, void *cb_cls) { struct GNUNET_CORE_RequestContext *request_context; struct GNUNET_CLIENT_Connection *client; - client = GNUNET_CLIENT_connect (sched, "core", cfg); + client = GNUNET_CLIENT_connect ("core", cfg); if (client == NULL) return GNUNET_SYSERR; request_context = GNUNET_malloc (sizeof (struct GNUNET_CORE_RequestContext)); diff --git a/src/core/core_api_peer_get_info.c b/src/core/core_api_peer_get_info.c index 68cf2da11..1ca8d82af 100644 --- a/src/core/core_api_peer_get_info.c +++ b/src/core/core_api_peer_get_info.c @@ -99,7 +99,6 @@ receive_info (void *cls, /** * Obtain statistics and/or change preferences for the given peer. * - * @param sched scheduler to use * @param cfg configuration to use * @param peer identifies the peer * @param timeout after how long should we give up (and call "info" with NULL @@ -122,8 +121,7 @@ receive_info (void *cls, * @return NULL on error */ struct GNUNET_CORE_InformationRequestContext * -GNUNET_CORE_peer_change_preference (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_CORE_peer_change_preference (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *peer, struct GNUNET_TIME_Relative timeout, struct GNUNET_BANDWIDTH_Value32NBO bw_out, @@ -137,7 +135,7 @@ GNUNET_CORE_peer_change_preference (struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_CLIENT_Connection *client; int retry; - client = GNUNET_CLIENT_connect (sched, "core", cfg); + client = GNUNET_CLIENT_connect ("core", cfg); if (client == NULL) return NULL; irc = GNUNET_malloc (sizeof (struct GNUNET_CORE_InformationRequestContext)); diff --git a/src/core/core_api_peer_request.c b/src/core/core_api_peer_request.c index 96640990a..0f13f15f9 100644 --- a/src/core/core_api_peer_request.c +++ b/src/core/core_api_peer_request.c @@ -41,10 +41,6 @@ struct GNUNET_CORE_PeerRequestHandle */ struct GNUNET_CLIENT_Connection *client; - /** - * Scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; /** * Function to call once done. @@ -92,8 +88,7 @@ send_request (void *cls, if (buf == NULL) { if (prh->cont != NULL) - GNUNET_SCHEDULER_add_continuation (prh->sched, - prh->cont, + GNUNET_SCHEDULER_add_continuation (prh->cont, prh->cont_cls, GNUNET_SCHEDULER_REASON_TIMEOUT); GNUNET_CLIENT_disconnect (prh->client, GNUNET_NO); @@ -109,8 +104,7 @@ send_request (void *cls, memcpy (buf, &msg, sizeof (msg)); if (prh->cont != NULL) { - GNUNET_SCHEDULER_add_continuation (prh->sched, - prh->cont, + GNUNET_SCHEDULER_add_continuation (prh->cont, prh->cont_cls, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -131,7 +125,6 @@ send_request (void *cls, * to our connection attempt within the given time frame, 'cont' will * be called with the TIMEOUT reason code. * - * @param sched scheduler to use * @param cfg configuration to use * @param timeout how long to try to talk to core * @param peer who should we connect to @@ -140,8 +133,7 @@ send_request (void *cls, * @return NULL on error (cont will not be called), otherwise handle for cancellation */ struct GNUNET_CORE_PeerRequestHandle * -GNUNET_CORE_peer_request_connect (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_CORE_peer_request_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TIME_Relative timeout, const struct GNUNET_PeerIdentity * peer, GNUNET_SCHEDULER_Task cont, @@ -150,12 +142,11 @@ GNUNET_CORE_peer_request_connect (struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_CORE_PeerRequestHandle *ret; struct GNUNET_CLIENT_Connection *client; - client = GNUNET_CLIENT_connect (sched, "core", cfg); + client = GNUNET_CLIENT_connect ("core", cfg); if (client == NULL) return NULL; ret = GNUNET_malloc (sizeof (struct GNUNET_CORE_PeerRequestHandle)); ret->client = client; - ret->sched = sched; ret->cont = cont; ret->cont_cls = cont_cls; ret->peer = *peer; diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 6b662982d..c1ebdb9df 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c @@ -657,10 +657,6 @@ static struct GNUNET_PeerIdentity my_identity; */ static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key; -/** - * Our scheduler. - */ -struct GNUNET_SCHEDULER_Handle *sched; /** * Handle to peerinfo service. @@ -1259,15 +1255,15 @@ free_neighbour (struct Neighbour *n) n->th = NULL; } if (n->retry_plaintext_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched, n->retry_plaintext_task); + GNUNET_SCHEDULER_cancel (n->retry_plaintext_task); if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task); + GNUNET_SCHEDULER_cancel (n->retry_set_key_task); if (n->quota_update_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched, n->quota_update_task); + GNUNET_SCHEDULER_cancel (n->quota_update_task); if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched, n->dead_clean_task); + GNUNET_SCHEDULER_cancel (n->dead_clean_task); if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched, n->keep_alive_task); + GNUNET_SCHEDULER_cancel (n->keep_alive_task); if (n->status == PEER_STATE_KEY_CONFIRMED) GNUNET_STATISTICS_update (stats, gettext_noop ("# established sessions"), -1, GNUNET_NO); GNUNET_free_non_null (n->public_key); @@ -1397,8 +1393,7 @@ send_keep_alive (void *cls, retry = GNUNET_TIME_relative_max (GNUNET_TIME_relative_divide (left, 2), MIN_PING_FREQUENCY); n->keep_alive_task - = GNUNET_SCHEDULER_add_delayed (sched, - retry, + = GNUNET_SCHEDULER_add_delayed (retry, &send_keep_alive, n); @@ -1445,9 +1440,8 @@ consider_free_neighbour (struct Neighbour *n) if (left.rel_value > 0) { if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched, n->dead_clean_task); - n->dead_clean_task = GNUNET_SCHEDULER_add_delayed (sched, - left, + GNUNET_SCHEDULER_cancel (n->dead_clean_task); + n->dead_clean_task = GNUNET_SCHEDULER_add_delayed (left, &consider_free_task, n); return; @@ -2087,7 +2081,7 @@ process_plaintext_neighbour_queue (struct Neighbour *n) if (n->retry_plaintext_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, n->retry_plaintext_task); + GNUNET_SCHEDULER_cancel (n->retry_plaintext_task); n->retry_plaintext_task = GNUNET_SCHEDULER_NO_TASK; } switch (n->status) @@ -2103,8 +2097,7 @@ process_plaintext_neighbour_queue (struct Neighbour *n) case PEER_STATE_KEY_SENT: if (n->retry_set_key_task == GNUNET_SCHEDULER_NO_TASK) n->retry_set_key_task - = GNUNET_SCHEDULER_add_delayed (sched, - n->set_key_retry_frequency, + = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency, &set_key_retry_task, n); #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -2115,8 +2108,7 @@ process_plaintext_neighbour_queue (struct Neighbour *n) case PEER_STATE_KEY_RECEIVED: if (n->retry_set_key_task == GNUNET_SCHEDULER_NO_TASK) n->retry_set_key_task - = GNUNET_SCHEDULER_add_delayed (sched, - n->set_key_retry_frequency, + = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency, &set_key_retry_task, n); #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -2165,8 +2157,7 @@ process_plaintext_neighbour_queue (struct Neighbour *n) #endif /* no messages selected for sending, try again later... */ n->retry_plaintext_task = - GNUNET_SCHEDULER_add_delayed (sched, - retry_time, + GNUNET_SCHEDULER_add_delayed (retry_time, &retry_plaintext_processing, n); return; } @@ -2252,8 +2243,7 @@ schedule_quota_update (struct Neighbour *n) GNUNET_assert (n->quota_update_task == GNUNET_SCHEDULER_NO_TASK); n->quota_update_task - = GNUNET_SCHEDULER_add_delayed (sched, - QUOTA_UPDATE_FREQUENCY, + = GNUNET_SCHEDULER_add_delayed (QUOTA_UPDATE_FREQUENCY, &neighbour_quota_update, n); } @@ -2475,10 +2465,8 @@ notify_transport_connect_done (void *cls, size_t size, void *buf) _("TRANSPORT connection to peer `%4s' is up, trying to establish CORE connection\n"), GNUNET_i2s (&n->peer)); if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched, - n->retry_set_key_task); - n->retry_set_key_task = GNUNET_SCHEDULER_add_now (sched, - &set_key_retry_task, + GNUNET_SCHEDULER_cancel (n->retry_set_key_task); + n->retry_set_key_task = GNUNET_SCHEDULER_add_now (&set_key_retry_task, n); return 0; } @@ -2567,7 +2555,7 @@ process_hello_retry_send_key (void *cls, { if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task); + GNUNET_SCHEDULER_cancel (n->retry_set_key_task); n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK; } GNUNET_STATISTICS_update (stats, @@ -2589,8 +2577,7 @@ process_hello_retry_send_key (void *cls, GNUNET_NO); if (GNUNET_SCHEDULER_NO_TASK == n->retry_set_key_task) n->retry_set_key_task - = GNUNET_SCHEDULER_add_delayed (sched, - n->set_key_retry_frequency, + = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency, &set_key_retry_task, n); } return; @@ -2651,7 +2638,7 @@ send_key (struct Neighbour *n) if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task); + GNUNET_SCHEDULER_cancel (n->retry_set_key_task); n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK; } if (n->pitr != NULL) @@ -2829,8 +2816,7 @@ send_key (struct Neighbour *n) if ( (n->status != PEER_STATE_KEY_CONFIRMED) && (GNUNET_SCHEDULER_NO_TASK == n->retry_set_key_task) ) n->retry_set_key_task - = GNUNET_SCHEDULER_add_delayed (sched, - n->set_key_retry_frequency, + = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency, &set_key_retry_task, n); } @@ -3096,7 +3082,7 @@ handle_pong (struct Neighbour *n, #endif if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task); + GNUNET_SCHEDULER_cancel (n->retry_set_key_task); n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK; } cnm.header.size = htons (sizeof (struct ConnectNotifyMessage)); @@ -3110,10 +3096,9 @@ handle_pong (struct Neighbour *n, case PEER_STATE_KEY_CONFIRMED: n->last_activity = GNUNET_TIME_absolute_get (); if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched, n->keep_alive_task); + GNUNET_SCHEDULER_cancel (n->keep_alive_task); n->keep_alive_task - = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2), + = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2), &send_keep_alive, n); handle_peer_status_change (n); @@ -3560,10 +3545,9 @@ handle_encrypted_message (struct Neighbour *n, } n->last_activity = GNUNET_TIME_absolute_get (); if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched, n->keep_alive_task); + GNUNET_SCHEDULER_cancel (n->keep_alive_task); n->keep_alive_task - = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2), + = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2), &send_keep_alive, n); GNUNET_STATISTICS_set (stats, @@ -3711,10 +3695,9 @@ handle_transport_receive (void *cls, n->time_established = now; } if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched, n->keep_alive_task); + GNUNET_SCHEDULER_cancel (n->keep_alive_task); n->keep_alive_task - = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2), + = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2), &send_keep_alive, n); } @@ -3912,14 +3895,12 @@ handle_transport_notify_disconnect (void *cls, -1, GNUNET_NO); if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched, - n->dead_clean_task); + GNUNET_SCHEDULER_cancel (n->dead_clean_task); left = GNUNET_TIME_relative_subtract (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_CONSTANTS_DISCONNECT_SESSION_TIMEOUT); n->last_activity = GNUNET_TIME_absolute_subtract (GNUNET_TIME_absolute_get (), left); - n->dead_clean_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_CONSTANTS_DISCONNECT_SESSION_TIMEOUT, + n->dead_clean_task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_DISCONNECT_SESSION_TIMEOUT, &consider_free_task, n); } @@ -3969,13 +3950,11 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * Initiate core service. * * @param cls closure - * @param s scheduler to use * @param server the initialized server * @param c configuration to use */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { @@ -3997,7 +3976,6 @@ run (void *cls, }; char *keyfile; - sched = s; cfg = c; /* parse configuration */ if ( @@ -4019,15 +3997,15 @@ run (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Core service is lacking key configuration settings. Exiting.\n")); - GNUNET_SCHEDULER_shutdown (s); + GNUNET_SCHEDULER_shutdown (); return; } - peerinfo = GNUNET_PEERINFO_connect (sched, cfg); + peerinfo = GNUNET_PEERINFO_connect (cfg); if (NULL == peerinfo) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not access PEERINFO service. Exiting.\n")); - GNUNET_SCHEDULER_shutdown (s); + GNUNET_SCHEDULER_shutdown (); GNUNET_free (keyfile); return; } @@ -4038,7 +4016,7 @@ run (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Core service could not access hostkey. Exiting.\n")); GNUNET_PEERINFO_disconnect (peerinfo); - GNUNET_SCHEDULER_shutdown (s); + GNUNET_SCHEDULER_shutdown (); return; } GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); @@ -4049,23 +4027,21 @@ run (void *cls, MAX_NOTIFY_QUEUE); GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); /* setup transport connection */ - transport = GNUNET_TRANSPORT_connect (sched, - cfg, + transport = GNUNET_TRANSPORT_connect (cfg, &my_identity, NULL, &handle_transport_receive, &handle_transport_notify_connect, &handle_transport_notify_disconnect); GNUNET_assert (NULL != transport); - stats = GNUNET_STATISTICS_create (sched, "core", cfg); + stats = GNUNET_STATISTICS_create ("core", cfg); GNUNET_STATISTICS_set (stats, gettext_noop ("# discarded CORE_SEND requests"), 0, GNUNET_NO); GNUNET_STATISTICS_set (stats, gettext_noop ("# discarded lower priority CORE_SEND requests"), 0, GNUNET_NO); mst = GNUNET_SERVER_mst_create (&deliver_message, NULL); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task, NULL); /* process client requests */ GNUNET_SERVER_add_handlers (server, handlers); diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index 3fbeca419..65b09c835 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c @@ -62,7 +62,6 @@ static struct PeerContext p1; static struct PeerContext p2; -static struct GNUNET_SCHEDULER_Handle *sched; static int ok; @@ -168,8 +167,8 @@ process_mtype (void *cls, "Receiving message from `%4s'.\n", GNUNET_i2s (peer)); GNUNET_assert (ok == 5); OKPP; - GNUNET_SCHEDULER_cancel (sched, err_task); - GNUNET_SCHEDULER_add_now (sched, &terminate_task, NULL); + GNUNET_SCHEDULER_cancel (err_task); + GNUNET_SCHEDULER_add_now (&terminate_task, NULL); return GNUNET_OK; } @@ -194,8 +193,7 @@ transmit_ready (void *cls, size_t size, void *buf) m->type = htons (MTYPE); m->size = htons (sizeof (struct GNUNET_MessageHeader)); err_task = - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 120), &terminate_task_error, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 120), &terminate_task_error, NULL); return sizeof (struct GNUNET_MessageHeader); } @@ -221,8 +219,7 @@ init_notify (void *cls, GNUNET_assert (ok == 2); OKPP; /* connect p2 */ - GNUNET_CORE_connect (sched, - p2.cfg, + GNUNET_CORE_connect (p2.cfg, TIMEOUT, &p2, &init_notify, @@ -297,7 +294,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); - p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, p, NULL, NULL, NULL); + p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); GNUNET_assert (p->th != NULL); GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); } @@ -305,18 +302,15 @@ setup_peer (struct PeerContext *p, const char *cfgname) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; - sched = s; setup_peer (&p1, "test_core_api_peer1.conf"); setup_peer (&p2, "test_core_api_peer2.conf"); - GNUNET_CORE_connect (sched, - p1.cfg, + GNUNET_CORE_connect (p1.cfg, TIMEOUT, &p1, &init_notify, diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index 49fe8f9de..da67bb4d4 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c @@ -82,8 +82,6 @@ static struct PeerContext p1; static struct PeerContext p2; -static struct GNUNET_SCHEDULER_Handle *sched; - static int ok; #if VERBOSE @@ -235,8 +233,8 @@ process_mtype (void *cls, n, s, ntohs (message->size), ntohl (hdr->num)); - GNUNET_SCHEDULER_cancel (sched, err_task); - err_task = GNUNET_SCHEDULER_add_now (sched, &terminate_task_error, NULL); + GNUNET_SCHEDULER_cancel (err_task); + err_task = GNUNET_SCHEDULER_add_now (&terminate_task_error, NULL); return GNUNET_SYSERR; } if (ntohl (hdr->num) != n) @@ -246,8 +244,8 @@ process_mtype (void *cls, n, s, ntohs (message->size), ntohl (hdr->num)); - GNUNET_SCHEDULER_cancel (sched, err_task); - err_task = GNUNET_SCHEDULER_add_now (sched, &terminate_task_error, NULL); + GNUNET_SCHEDULER_cancel (err_task); + err_task = GNUNET_SCHEDULER_add_now (&terminate_task_error, NULL); return GNUNET_SYSERR; } #if VERBOSE @@ -261,8 +259,8 @@ process_mtype (void *cls, fprintf (stderr, "."); if (n == TOTAL_MSGS) { - GNUNET_SCHEDULER_cancel (sched, err_task); - GNUNET_SCHEDULER_add_now (sched, &terminate_task, NULL); + GNUNET_SCHEDULER_cancel (err_task); + GNUNET_SCHEDULER_add_now (&terminate_task, NULL); } else { @@ -334,10 +332,9 @@ transmit_ready (void *cls, size_t size, void *buf) break; /* sometimes pack buffer full, sometimes not */ } while (size - ret >= s); - GNUNET_SCHEDULER_cancel (sched, err_task); + GNUNET_SCHEDULER_cancel (err_task); err_task = - GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -368,8 +365,7 @@ init_notify (void *cls, GNUNET_assert (ok == 2); OKPP; /* connect p2 */ - GNUNET_CORE_connect (sched, - p2.cfg, + GNUNET_CORE_connect (p2.cfg, TIMEOUT, &p2, &init_notify, @@ -389,8 +385,7 @@ init_notify (void *cls, "Asking core (1) for transmission to peer `%4s'\n", GNUNET_i2s (&p2.id)); err_task = - GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); start_time = GNUNET_TIME_absolute_get (); @@ -444,7 +439,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); - p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, p, NULL, NULL, NULL); + p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); GNUNET_assert (p->th != NULL); GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); } @@ -452,18 +447,15 @@ setup_peer (struct PeerContext *p, const char *cfgname) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; - sched = s; setup_peer (&p1, "test_core_api_peer1.conf"); setup_peer (&p2, "test_core_api_peer2.conf"); - GNUNET_CORE_connect (sched, - p1.cfg, + GNUNET_CORE_connect (p1.cfg, TIMEOUT, &p1, &init_notify, diff --git a/src/core/test_core_api_start_only.c b/src/core/test_core_api_start_only.c index 958defbf9..da7217f39 100644 --- a/src/core/test_core_api_start_only.c +++ b/src/core/test_core_api_start_only.c @@ -57,7 +57,6 @@ static struct PeerContext p1; static struct PeerContext p2; -static struct GNUNET_SCHEDULER_Handle *sched; static int ok; @@ -126,8 +125,7 @@ init_notify (void *cls, if (cls == &p1) { /* connect p2 */ - GNUNET_CORE_connect (sched, - p2.cfg, + GNUNET_CORE_connect (p2.cfg, TIMEOUT, &p2, &init_notify, @@ -166,18 +164,15 @@ setup_peer (struct PeerContext *p, const char *cfgname) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; - sched = s; setup_peer (&p1, "test_core_api_peer1.conf"); setup_peer (&p2, "test_core_api_peer2.conf"); - GNUNET_CORE_connect (sched, - p1.cfg, + GNUNET_CORE_connect (p1.cfg, TIMEOUT, &p1, &init_notify, diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c index d69fb0905..822dc2c46 100644 --- a/src/core/test_core_quota_compliance.c +++ b/src/core/test_core_quota_compliance.c @@ -105,8 +105,6 @@ static struct PeerContext p1; static struct PeerContext p2; -static struct GNUNET_SCHEDULER_Handle *sched; - static int ok; static int measurement_running; @@ -147,7 +145,7 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_break (0); if (send_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched,send_task); + GNUNET_SCHEDULER_cancel (send_task); GNUNET_CORE_disconnect (p1.ch); p1.ch = NULL; GNUNET_CORE_disconnect (p2.ch); @@ -247,9 +245,9 @@ measurement_end (void *cls, return; if (err_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched, err_task); + GNUNET_SCHEDULER_cancel (err_task); if (send_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched,send_task); + GNUNET_SCHEDULER_cancel (send_task); GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1); GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2); @@ -271,7 +269,7 @@ measurement_end (void *cls, (total_bytes_sent/(duration.rel_value / 1000)/1024),current_quota_p1_in/1024); - GNUNET_SCHEDULER_add_now (sched, &terminate_task, NULL); + GNUNET_SCHEDULER_add_now (&terminate_task, NULL); } static size_t @@ -307,12 +305,10 @@ static void measure (unsigned long long quota_p1, unsigned long long quota_p2 ) "Asking core (1) for transmission to peer `%4s'\n", GNUNET_i2s (&p2.id)); #endif - err_task = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); - measure_task = GNUNET_SCHEDULER_add_delayed (sched, - MEASUREMENT_INTERVALL, + measure_task = GNUNET_SCHEDULER_add_delayed (MEASUREMENT_INTERVALL, &measurement_end, NULL); start_time = GNUNET_TIME_absolute_get (); @@ -420,17 +416,16 @@ transmit_ready (void *cls, size_t size, void *buf) break; /* sometimes pack buffer full, sometimes not */ } while (size - ret >= s); - GNUNET_SCHEDULER_cancel (sched, err_task); - err_task = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + GNUNET_SCHEDULER_cancel (err_task); + err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); total_bytes += ret; total_bytes_sent += ret; if (send_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, send_task); - send_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 20), &send_tsk, NULL); + GNUNET_SCHEDULER_cancel(send_task); + send_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 20), &send_tsk, NULL); return ret; } @@ -457,8 +452,7 @@ init_notify (void *cls, GNUNET_assert (ok == 2); OKPP; /* connect p2 */ - GNUNET_CORE_connect (sched, - p2.cfg, + GNUNET_CORE_connect (p2.cfg, TIMEOUT, &p2, &init_notify, @@ -521,9 +515,9 @@ setup_peer (struct PeerContext *p, const char *cfgname) "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); - p->stats = GNUNET_STATISTICS_create (sched, "core", p->cfg); + p->stats = GNUNET_STATISTICS_create ("core", p->cfg); GNUNET_assert (p->stats != NULL); - p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, p, NULL, NULL, NULL); + p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); GNUNET_assert (p->th != NULL); GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); } @@ -531,18 +525,15 @@ setup_peer (struct PeerContext *p, const char *cfgname) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; - sched = s; setup_peer (&p1, "test_core_quota_peer1.conf"); setup_peer (&p2, "test_core_quota_peer2.conf"); - GNUNET_CORE_connect (sched, - p1.cfg, + GNUNET_CORE_connect (p1.cfg, TIMEOUT, &p1, &init_notify, diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c index d2aa2616a..9bb0f14b9 100644 --- a/src/datacache/datacache.c +++ b/src/datacache/datacache.c @@ -116,14 +116,12 @@ env_delete_notify (void *cls, /** * Create a data cache. * - * @param sched scheduler to use * @param cfg configuration to use * @param section section in the configuration that contains our options * @return handle to use to access the service */ struct GNUNET_DATACACHE_Handle * -GNUNET_DATACACHE_create (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section) { unsigned int bf_size; @@ -167,11 +165,9 @@ GNUNET_DATACACHE_create (struct GNUNET_SCHEDULER_Handle *sched, { ret->filter = GNUNET_CONTAINER_bloomfilter_load (NULL, bf_size, 5); /* approx. 3% false positives at max use */ } - ret->stats = GNUNET_STATISTICS_create (sched, - "datacache", + ret->stats = GNUNET_STATISTICS_create ("datacache", cfg); ret->section = GNUNET_strdup (section); - ret->env.sched = sched; ret->env.cfg = cfg; ret->env.delete_notify = &env_delete_notify; ret->env.section = ret->section; diff --git a/src/datacache/perf_datacache.c b/src/datacache/perf_datacache.c index 904238f85..f32574019 100644 --- a/src/datacache/perf_datacache.c +++ b/src/datacache/perf_datacache.c @@ -59,7 +59,6 @@ checkIt (void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -72,8 +71,7 @@ run (void *cls, unsigned int i; ok = 0; - h = GNUNET_DATACACHE_create (sched, - cfg, + h = GNUNET_DATACACHE_create (cfg, "perfcache"); if (h == NULL) diff --git a/src/datacache/plugin_datacache.h b/src/datacache/plugin_datacache.h index bf35b2619..850d3961e 100644 --- a/src/datacache/plugin_datacache.h +++ b/src/datacache/plugin_datacache.h @@ -58,10 +58,6 @@ typedef void (*GNUNET_DATACACHE_DeleteNotifyCallback)(void *cls, struct GNUNET_DATACACHE_PluginEnvironment { - /** - * Scheduler to use. - */ - struct GNUNET_SCHEDULER_Handle *sched; /** * Configuration to use. diff --git a/src/datacache/test_datacache.c b/src/datacache/test_datacache.c index d0785173e..b626ce67d 100644 --- a/src/datacache/test_datacache.c +++ b/src/datacache/test_datacache.c @@ -62,7 +62,6 @@ checkIt (void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -74,8 +73,7 @@ run (void *cls, unsigned int i; ok = 0; - h = GNUNET_DATACACHE_create (sched, - cfg, + h = GNUNET_DATACACHE_create (cfg, "testcache"); if (h == NULL) { diff --git a/src/datacache/test_datacache_quota.c b/src/datacache/test_datacache_quota.c index 4674a7da9..77ad63815 100644 --- a/src/datacache/test_datacache_quota.c +++ b/src/datacache/test_datacache_quota.c @@ -45,7 +45,6 @@ static const char *plugin_name; */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -59,8 +58,7 @@ run (void *cls, struct GNUNET_TIME_Absolute exp; ok = 0; - h = GNUNET_DATACACHE_create (sched, - cfg, + h = GNUNET_DATACACHE_create (cfg, "testcache"); if (h == NULL) diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c index 6c817a840..f9b3db81b 100644 --- a/src/datastore/datastore_api.c +++ b/src/datastore/datastore_api.c @@ -181,10 +181,6 @@ struct GNUNET_DATASTORE_Handle */ const struct GNUNET_CONFIGURATION_Handle *cfg; - /** - * Our scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; /** * Current connection to the datastore service. @@ -247,30 +243,24 @@ struct GNUNET_DATASTORE_Handle * Connect to the datastore service. * * @param cfg configuration to use - * @param sched scheduler to use * @return handle to use to access the service */ struct GNUNET_DATASTORE_Handle * GNUNET_DATASTORE_connect (const struct GNUNET_CONFIGURATION_Handle - *cfg, - struct - GNUNET_SCHEDULER_Handle - *sched) + *cfg) { struct GNUNET_CLIENT_Connection *c; struct GNUNET_DATASTORE_Handle *h; - c = GNUNET_CLIENT_connect (sched, "datastore", cfg); + c = GNUNET_CLIENT_connect ("datastore", cfg); if (c == NULL) return NULL; /* oops */ h = GNUNET_malloc (sizeof(struct GNUNET_DATASTORE_Handle) + GNUNET_SERVER_MAX_MESSAGE_SIZE - 1); h->client = c; h->cfg = cfg; - h->sched = sched; - h->stats = GNUNET_STATISTICS_create (sched, - "datastore-api", + h->stats = GNUNET_STATISTICS_create ("datastore-api", cfg); return h; } @@ -327,8 +317,7 @@ void GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h, } if (h->reconnect_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (h->sched, - h->reconnect_task); + GNUNET_SCHEDULER_cancel (h->reconnect_task); h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; } while (NULL != (qe = h->queue_head)) @@ -338,7 +327,7 @@ void GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h, } if (GNUNET_YES == drop) { - h->client = GNUNET_CLIENT_connect (h->sched, "datastore", h->cfg); + h->client = GNUNET_CLIENT_connect ("datastore", h->cfg); if (h->client != NULL) { if (NULL != @@ -459,8 +448,7 @@ make_queue_entry (struct GNUNET_DATASTORE_Handle *h, response_proc (ret, NULL); return NULL; } - ret->task = GNUNET_SCHEDULER_add_delayed (h->sched, - timeout, + ret->task = GNUNET_SCHEDULER_add_delayed (timeout, &timeout_queue_entry, ret); pos = ret->next; @@ -507,7 +495,7 @@ try_reconnect (void *cls, if (h->retry_time.rel_value > GNUNET_CONSTANTS_SERVICE_TIMEOUT.rel_value) h->retry_time = GNUNET_CONSTANTS_SERVICE_TIMEOUT; h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; - h->client = GNUNET_CLIENT_connect (h->sched, "datastore", h->cfg); + h->client = GNUNET_CLIENT_connect ("datastore", h->cfg); if (h->client == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -551,8 +539,7 @@ do_disconnect (struct GNUNET_DATASTORE_Handle *h) #endif GNUNET_CLIENT_disconnect (h->client, GNUNET_NO); h->client = NULL; - h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->sched, - h->retry_time, + h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->retry_time, &try_reconnect, h); } @@ -601,8 +588,7 @@ transmit_request (void *cls, #endif memcpy (buf, &qe[1], msize); qe->was_transmitted = GNUNET_YES; - GNUNET_SCHEDULER_cancel (h->sched, - qe->task); + GNUNET_SCHEDULER_cancel (qe->task); qe->task = GNUNET_SCHEDULER_NO_TASK; h->in_receive = GNUNET_YES; GNUNET_CLIENT_receive (h->client, @@ -698,8 +684,7 @@ free_queue_entry (struct GNUNET_DATASTORE_QueueEntry *qe) qe); if (qe->task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (h->sched, - qe->task); + GNUNET_SCHEDULER_cancel (qe->task); qe->task = GNUNET_SCHEDULER_NO_TASK; } h->queue_size--; diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index 6c064743e..09df51d9b 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c @@ -179,10 +179,6 @@ static GNUNET_SCHEDULER_TaskIdentifier expired_kill_task; */ const struct GNUNET_CONFIGURATION_Handle *cfg; -/** - * Our scheduler. - */ -struct GNUNET_SCHEDULER_Handle *sched; /** * Handle for reporting statistics. @@ -343,8 +339,7 @@ expired_processor (void *cls, if (key == NULL) { expired_kill_task - = GNUNET_SCHEDULER_add_delayed (sched, - MAX_EXPIRE_DELAY, + = GNUNET_SCHEDULER_add_delayed (MAX_EXPIRE_DELAY, &delete_expired, NULL); return GNUNET_SYSERR; @@ -1527,7 +1522,6 @@ load_plugin () } ret = GNUNET_malloc (sizeof(struct DatastorePlugin)); ret->env.cfg = cfg; - ret->env.sched = sched; ret->env.duc = &disk_utilization_change_cb; ret->env.cls = NULL; GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -1625,12 +1619,10 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } if (expired_kill_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, - expired_kill_task); + GNUNET_SCHEDULER_cancel (expired_kill_task); expired_kill_task = GNUNET_SCHEDULER_NO_TASK; } - GNUNET_SCHEDULER_add_continuation (sched, - &unload_task, + GNUNET_SCHEDULER_add_continuation (&unload_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -1686,13 +1678,11 @@ cleanup_reservations (void *cls, * Process datastore requests. * * @param cls closure - * @param s scheduler to use * @param server the initialized server * @param c configuration to use */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { @@ -1717,7 +1707,6 @@ run (void *cls, char *fn; unsigned int bf_size; - sched = s; cfg = c; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, @@ -1729,7 +1718,7 @@ run (void *cls, "DATASTORE"); return; } - stats = GNUNET_STATISTICS_create (sched, "datastore", cfg); + stats = GNUNET_STATISTICS_create ("datastore", cfg); GNUNET_STATISTICS_set (stats, gettext_noop ("# quota"), quota, @@ -1790,11 +1779,9 @@ run (void *cls, GNUNET_SERVER_disconnect_notify (server, &cleanup_reservations, NULL); GNUNET_SERVER_add_handlers (server, handlers); expired_kill_task - = GNUNET_SCHEDULER_add_with_priority (sched, - GNUNET_SCHEDULER_PRIORITY_IDLE, + = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, &delete_expired, NULL); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task, NULL); } diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c index 8dd7e6680..1f7c828e0 100644 --- a/src/datastore/perf_datastore_api.c +++ b/src/datastore/perf_datastore_api.c @@ -93,7 +93,6 @@ enum RunPhase struct CpsRunContext { - struct GNUNET_SCHEDULER_Handle *sched; const struct GNUNET_CONFIGURATION_Handle *cfg; enum RunPhase phase; int j; @@ -140,8 +139,7 @@ check_success (void *cls, else crc->phase = RP_CUT; } - GNUNET_SCHEDULER_add_continuation (crc->sched, - &run_continuation, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -166,8 +164,7 @@ remove_next(void *cls, fprintf (stderr, "D"); #endif GNUNET_assert (GNUNET_OK == success); - GNUNET_SCHEDULER_add_continuation (crc->sched, - &run_continuation, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -212,14 +209,12 @@ delete_value (void *cls, if (stored_bytes < MAX_SIZE) { crc->phase = RP_REPORT; - GNUNET_SCHEDULER_add_continuation (crc->sched, - &run_continuation, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); return; } - GNUNET_SCHEDULER_add_with_priority (crc->sched, - GNUNET_SCHEDULER_PRIORITY_HIGH, + GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_HIGH, &do_delete, crc); return; @@ -298,8 +293,7 @@ run_continuation (void *cls, 1000 * stored_ops / (1 + GNUNET_TIME_absolute_get_duration(start_time).rel_value)); crc->phase = RP_PUT; crc->j = 0; - GNUNET_SCHEDULER_add_continuation (crc->sched, - &run_continuation, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -330,8 +324,7 @@ run_tests (void *cls, GNUNET_free (crc); return; } - GNUNET_SCHEDULER_add_continuation (crc->sched, - &run_continuation, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -339,7 +332,6 @@ run_tests (void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -347,10 +339,9 @@ run (void *cls, struct CpsRunContext *crc; static GNUNET_HashCode zkey; - datastore = GNUNET_DATASTORE_connect (cfg, sched); + datastore = GNUNET_DATASTORE_connect (cfg); start_time = GNUNET_TIME_absolute_get (); crc = GNUNET_malloc(sizeof(struct CpsRunContext)); - crc->sched = sched; crc->cfg = cfg; crc->phase = RP_PUT; if (NULL == diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c index d870c0da3..b60bb07c6 100644 --- a/src/datastore/perf_plugin_datastore.c +++ b/src/datastore/perf_plugin_datastore.c @@ -72,7 +72,6 @@ struct CpsRunContext unsigned int i; struct GNUNET_TIME_Absolute start; struct GNUNET_TIME_Absolute end; - struct GNUNET_SCHEDULER_Handle *sched; const struct GNUNET_CONFIGURATION_Handle *cfg; struct GNUNET_DATASTORE_PluginFunctions * api; const char *msg; @@ -183,8 +182,7 @@ iterateDummy (void *cls, else crc->phase = RP_PUT; } - GNUNET_SCHEDULER_add_after (crc->sched, - GNUNET_SCHEDULER_NO_TASK, + GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, &test, crc); return GNUNET_OK; } @@ -267,8 +265,7 @@ test (void *cls, (unsigned int) PUT_10); crc->i++; crc->phase = RP_LP_GET; - GNUNET_SCHEDULER_add_after (crc->sched, - GNUNET_SCHEDULER_NO_TASK, + GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, &test, crc); break; case RP_LP_GET: @@ -313,8 +310,7 @@ test (void *cls, break; case RP_DONE: crc->api->drop (crc->api->cls); - GNUNET_SCHEDULER_add_with_priority (crc->sched, - GNUNET_SCHEDULER_PRIORITY_IDLE, + GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, &cleaning_task, crc); break; } @@ -325,8 +321,7 @@ test (void *cls, * Load the datastore plugin. */ static struct GNUNET_DATASTORE_PluginFunctions * -load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg, - struct GNUNET_SCHEDULER_Handle *sched) +load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg) { static struct GNUNET_DATASTORE_PluginEnvironment env; struct GNUNET_DATASTORE_PluginFunctions * ret; @@ -344,7 +339,6 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg, return NULL; } env.cfg = cfg; - env.sched = sched; env.duc = &disk_utilization_change_cb; env.cls = NULL; GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -365,7 +359,6 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) @@ -373,7 +366,7 @@ run (void *cls, struct GNUNET_DATASTORE_PluginFunctions *api; struct CpsRunContext *crc; - api = load_plugin (c, s); + api = load_plugin (c); if (api == NULL) { fprintf (stderr, @@ -382,11 +375,9 @@ run (void *cls, } crc = GNUNET_malloc(sizeof(struct CpsRunContext)); crc->api = api; - crc->sched = s; crc->cfg = c; crc->phase = RP_PUT; - GNUNET_SCHEDULER_add_now (crc->sched, - &test, crc); + GNUNET_SCHEDULER_add_now (&test, crc); } diff --git a/src/datastore/plugin_datastore.h b/src/datastore/plugin_datastore.h index fa08501cc..cb8686c62 100644 --- a/src/datastore/plugin_datastore.h +++ b/src/datastore/plugin_datastore.h @@ -64,10 +64,6 @@ struct GNUNET_DATASTORE_PluginEnvironment */ const struct GNUNET_CONFIGURATION_Handle *cfg; - /** - * Scheduler to use. - */ - struct GNUNET_SCHEDULER_Handle *sched; /** * Function to call on disk utilization change. diff --git a/src/datastore/plugin_datastore_mysql.c b/src/datastore/plugin_datastore_mysql.c index 0aefbb75d..ae6a98c6e 100644 --- a/src/datastore/plugin_datastore_mysql.c +++ b/src/datastore/plugin_datastore_mysql.c @@ -1258,8 +1258,7 @@ mysql_plugin_next_request (void *next_cls, if (GNUNET_YES == end_it) nrc->end_it = GNUNET_YES; nrc->plugin->next_task_nc = nrc; - nrc->plugin->next_task = GNUNET_SCHEDULER_add_now (nrc->plugin->env->sched, - &mysql_next_request_cont, + nrc->plugin->next_task = GNUNET_SCHEDULER_add_now (&mysql_next_request_cont, nrc); } @@ -1968,8 +1967,7 @@ libgnunet_plugin_datastore_mysql_done (void *cls) iclose (plugin); if (plugin->next_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (plugin->env->sched, - plugin->next_task); + GNUNET_SCHEDULER_cancel (plugin->next_task); plugin->next_task = GNUNET_SCHEDULER_NO_TASK; plugin->next_task_nc->prep (plugin->next_task_nc->prep_cls, NULL); GNUNET_free (plugin->next_task_nc); diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c index 44a01fcb8..9886b1c8b 100644 --- a/src/datastore/plugin_datastore_postgres.c +++ b/src/datastore/plugin_datastore_postgres.c @@ -847,8 +847,7 @@ postgres_plugin_next_request (void *next_cls, if (GNUNET_YES == end_it) nrc->end_it = GNUNET_YES; nrc->plugin->next_task_nc = nrc; - nrc->plugin->next_task = GNUNET_SCHEDULER_add_now (nrc->plugin->env->sched, - &postgres_next_request_cont, + nrc->plugin->next_task = GNUNET_SCHEDULER_add_now (&postgres_next_request_cont, nrc); } @@ -1358,8 +1357,7 @@ libgnunet_plugin_datastore_postgres_done (void *cls) if (plugin->next_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (plugin->env->sched, - plugin->next_task); + GNUNET_SCHEDULER_cancel (plugin->next_task); plugin->next_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_free (plugin->next_task_nc); plugin->next_task_nc = NULL; diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c index 01df7b670..b9edb4e57 100644 --- a/src/datastore/plugin_datastore_sqlite.c +++ b/src/datastore/plugin_datastore_sqlite.c @@ -623,8 +623,7 @@ sqlite_next_request (void *next_cls, if (GNUNET_YES == end_it) nc->end_it = GNUNET_YES; nc->plugin->next_task_nc = nc; - nc->plugin->next_task = GNUNET_SCHEDULER_add_now (nc->plugin->env->sched, - &sqlite_next_request_cont, + nc->plugin->next_task = GNUNET_SCHEDULER_add_now (&sqlite_next_request_cont, nc); } @@ -1598,8 +1597,7 @@ libgnunet_plugin_datastore_sqlite_done (void *cls) if (plugin->next_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (plugin->env->sched, - plugin->next_task); + GNUNET_SCHEDULER_cancel (plugin->next_task); plugin->next_task = GNUNET_SCHEDULER_NO_TASK; plugin->next_task_nc->prep (plugin->next_task_nc->prep_cls, NULL); GNUNET_free (plugin->next_task_nc); diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c index 3b7202005..06abc0c0f 100644 --- a/src/datastore/test_datastore_api.c +++ b/src/datastore/test_datastore_api.c @@ -125,7 +125,6 @@ struct CpsRunContext GNUNET_HashCode key; int i; int rid; - struct GNUNET_SCHEDULER_Handle *sched; const struct GNUNET_CONFIGURATION_Handle *cfg; void *data; size_t size; @@ -150,13 +149,12 @@ check_success (void *cls, ok = 42; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", msg); - GNUNET_SCHEDULER_shutdown (crc->sched); + GNUNET_SCHEDULER_shutdown (); return; } GNUNET_free_non_null (crc->data); crc->data = NULL; - GNUNET_SCHEDULER_add_continuation (crc->sched, - &run_continuation, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -173,8 +171,7 @@ get_reserved (void *cls, "%s\n", msg); GNUNET_assert (0 < success); crc->rid = success; - GNUNET_SCHEDULER_add_continuation (crc->sched, - &run_continuation, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -201,8 +198,7 @@ check_value (void *cls, crc->phase = RP_DEL; crc->i = ITERATIONS; } - GNUNET_SCHEDULER_add_continuation (crc->sched, - &run_continuation, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); return; @@ -243,8 +239,7 @@ delete_value (void *cls, { crc->phase = RP_DO_DEL; } - GNUNET_SCHEDULER_add_continuation (crc->sched, - &run_continuation, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); return; @@ -275,8 +270,7 @@ check_nothing (void *cls, { crc->phase = RP_RESERVE; } - GNUNET_SCHEDULER_add_continuation (crc->sched, - &run_continuation, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -309,8 +303,7 @@ check_multiple (void *cls, { crc->phase = RP_UPDATE; } - GNUNET_SCHEDULER_add_continuation (crc->sched, - &run_continuation, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); return; @@ -364,8 +357,7 @@ check_update (void *cls, { crc->phase = RP_DONE; } - GNUNET_SCHEDULER_add_continuation (crc->sched, - &run_continuation, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); return; @@ -597,8 +589,7 @@ run_tests (void *cls, GNUNET_free (crc); return; } - GNUNET_SCHEDULER_add_continuation (crc->sched, - &run_continuation, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -606,7 +597,6 @@ run_tests (void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -615,11 +605,10 @@ run (void *cls, static GNUNET_HashCode zkey; crc = GNUNET_malloc(sizeof(struct CpsRunContext)); - crc->sched = sched; crc->cfg = cfg; crc->phase = RP_PUT; now = GNUNET_TIME_absolute_get (); - datastore = GNUNET_DATASTORE_connect (cfg, sched); + datastore = GNUNET_DATASTORE_connect (cfg); if (NULL == GNUNET_DATASTORE_put (datastore, 0, &zkey, 4, "TEST", diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c index 81450d12a..d17d8fbc8 100644 --- a/src/datastore/test_datastore_api_management.c +++ b/src/datastore/test_datastore_api_management.c @@ -109,7 +109,6 @@ struct CpsRunContext GNUNET_HashCode key; int i; int found; - struct GNUNET_SCHEDULER_Handle *sched; const struct GNUNET_CONFIGURATION_Handle *cfg; void *data; enum RunPhase phase; @@ -133,8 +132,7 @@ check_success (void *cls, GNUNET_assert (GNUNET_OK == success); GNUNET_free_non_null (crc->data); crc->data = NULL; - GNUNET_SCHEDULER_add_continuation (crc->sched, - &run_continuation, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -170,8 +168,7 @@ check_value (void *cls, } if (0 == crc->i) crc->phase = RP_DONE; - GNUNET_SCHEDULER_add_continuation (crc->sched, - &run_continuation, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); return; @@ -204,8 +201,7 @@ check_nothing (void *cls, GNUNET_assert (key == NULL); if (0 == --crc->i) crc->phase = RP_DONE; - GNUNET_SCHEDULER_add_continuation (crc->sched, - &run_continuation, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -307,8 +303,7 @@ run_tests (void *cls, GNUNET_free (crc); return; } - GNUNET_SCHEDULER_add_continuation (crc->sched, - &run_continuation, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -316,7 +311,6 @@ run_tests (void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -325,11 +319,10 @@ run (void *cls, static GNUNET_HashCode zkey; crc = GNUNET_malloc(sizeof(struct CpsRunContext)); - crc->sched = sched; crc->cfg = cfg; crc->phase = RP_PUT; now = GNUNET_TIME_absolute_get (); - datastore = GNUNET_DATASTORE_connect (cfg, sched); + datastore = GNUNET_DATASTORE_connect (cfg); if (NULL == GNUNET_DATASTORE_put (datastore, 0, &zkey, 4, "TEST", diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c index d04e4d206..68e662269 100644 --- a/src/dht/dht_api.c +++ b/src/dht/dht_api.c @@ -149,10 +149,6 @@ struct GNUNET_DHT_RouteHandle */ struct GNUNET_DHT_Handle { - /** - * Our scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; /** * Configuration to use. @@ -224,7 +220,7 @@ try_connect (struct GNUNET_DHT_Handle *handle) { if (handle->client != NULL) return GNUNET_OK; - handle->client = GNUNET_CLIENT_connect (handle->sched, "dht", handle->cfg); + handle->client = GNUNET_CLIENT_connect ("dht", handle->cfg); if (handle->client == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -359,14 +355,12 @@ transmit_pending (void *cls, head); if (head->timeout_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (handle->sched, - head->timeout_task); + GNUNET_SCHEDULER_cancel (head->timeout_task); head->timeout_task = GNUNET_SCHEDULER_NO_TASK; } if (NULL != head->cont) { - GNUNET_SCHEDULER_add_continuation (handle->sched, - head->cont, + GNUNET_SCHEDULER_add_continuation (head->cont, head->cont_cls, GNUNET_SCHEDULER_REASON_PREREQ_DONE); head->cont = NULL; @@ -527,7 +521,6 @@ service_message_handler (void *cls, /** * Initialize the connection with the DHT service. * - * @param sched scheduler to use * @param cfg configuration to use * @param ht_len size of the internal hash table to use for * processing multiple GET/FIND requests in parallel @@ -535,15 +528,13 @@ service_message_handler (void *cls, * @return handle to the DHT service, or NULL on error */ struct GNUNET_DHT_Handle * -GNUNET_DHT_connect (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_DHT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len) { struct GNUNET_DHT_Handle *handle; handle = GNUNET_malloc (sizeof (struct GNUNET_DHT_Handle)); handle->cfg = cfg; - handle->sched = sched; handle->uid_gen = GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); handle->active_requests = GNUNET_CONTAINER_multihashmap_create (ht_len); if (GNUNET_NO == try_connect (handle)) @@ -578,11 +569,9 @@ GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle) pm); GNUNET_assert (GNUNET_YES == pm->free_on_send); if (GNUNET_SCHEDULER_NO_TASK != pm->timeout_task) - GNUNET_SCHEDULER_cancel (handle->sched, - pm->timeout_task); + GNUNET_SCHEDULER_cancel (pm->timeout_task); if (NULL != pm->cont) - GNUNET_SCHEDULER_add_continuation (handle->sched, - pm->cont, + GNUNET_SCHEDULER_add_continuation (pm->cont, pm->cont_cls, GNUNET_SCHEDULER_REASON_TIMEOUT); pm->in_pending_queue = GNUNET_NO; @@ -713,8 +702,7 @@ GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle, { route_handle = NULL; pending->free_on_send = GNUNET_YES; - pending->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->sched, - timeout, + pending->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, &timeout_route_request, pending); } diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c index 649d8ff13..b74e8a367 100644 --- a/src/dht/gnunet-dht-driver.c +++ b/src/dht/gnunet-dht-driver.c @@ -503,10 +503,6 @@ static unsigned long long peers_left; */ static struct GNUNET_TESTING_PeerGroup *pg; -/** - * Global scheduler, used for all GNUNET_SCHEDULER_* functions. - */ -static struct GNUNET_SCHEDULER_Handle *sched; /** * Global config handle. @@ -743,7 +739,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) while (test_put != NULL) { if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, test_put->disconnect_task); + GNUNET_SCHEDULER_cancel(test_put->disconnect_task); if (test_put->dht_handle != NULL) GNUNET_DHT_disconnect(test_put->dht_handle); test_put = test_put->next; @@ -752,7 +748,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) while (test_get != NULL) { if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, test_get->disconnect_task); + GNUNET_SCHEDULER_cancel(test_get->disconnect_task); if (test_get->get_handle != NULL) GNUNET_DHT_get_stop(test_get->get_handle); if (test_get->dht_handle != NULL) @@ -813,7 +809,7 @@ log_topology_cb (void *cls, GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Topology iteration (%u/%u) finished (%u connections, %u peers)\n", topo_ctx->current_iteration, topo_ctx->total_iterations, topo_ctx->total_connections, topo_ctx->total_peers); dhtlog_handle->update_topology(topo_ctx->total_connections); if (topo_ctx->cont != NULL) - GNUNET_SCHEDULER_add_now (sched, topo_ctx->cont, topo_ctx->cls); + GNUNET_SCHEDULER_add_now (topo_ctx->cont, topo_ctx->cls); if (topo_ctx->peers_seen != NULL) GNUNET_CONTAINER_multihashmap_destroy(topo_ctx->peers_seen); GNUNET_free(topo_ctx); @@ -854,7 +850,7 @@ stats_finished (void *cls, int result) fprintf(stderr, "Finished getting all peers statistics, iterating!\n"); GNUNET_CONTAINER_multihashmap_iterate(stats_map, &stats_iterate, NULL); GNUNET_CONTAINER_multihashmap_destroy(stats_map); - GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); + GNUNET_SCHEDULER_add_now (&finish_testing, NULL); } /** @@ -969,7 +965,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) while (test_put != NULL) { if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, test_put->disconnect_task); + GNUNET_SCHEDULER_cancel(test_put->disconnect_task); if (test_put->dht_handle != NULL) GNUNET_DHT_disconnect(test_put->dht_handle); test_put = test_put->next; @@ -978,7 +974,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) while (test_get != NULL) { if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, test_get->disconnect_task); + GNUNET_SCHEDULER_cancel(test_get->disconnect_task); if (test_get->get_handle != NULL) GNUNET_DHT_get_stop(test_get->get_handle); if (test_get->dht_handle != NULL) @@ -1067,7 +1063,7 @@ decrement_find_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) if ((0 == test_find_peer->find_peer_context->total) && (GNUNET_TIME_absolute_get_remaining(test_find_peer->find_peer_context->endtime).rel_value > 60)) { - GNUNET_SCHEDULER_add_now(sched, &count_new_peers, test_find_peer->find_peer_context); + GNUNET_SCHEDULER_add_now(&count_new_peers, test_find_peer->find_peer_context); } GNUNET_free(test_find_peer); } @@ -1085,7 +1081,7 @@ handle_find_peer_sent (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc struct TestFindPeer *test_find_peer = cls; GNUNET_DHT_disconnect(test_find_peer->dht_handle); - GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_divide(find_peer_delay, 2), &decrement_find_peers, test_find_peer); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_divide(find_peer_delay, 2), &decrement_find_peers, test_find_peer); } @@ -1096,18 +1092,18 @@ send_find_peer_request (void *cls, const struct GNUNET_SCHEDULER_TaskContext * t if (test_find_peer->find_peer_context->outstanding > max_outstanding_find_peers) { - GNUNET_SCHEDULER_add_delayed(sched, find_peer_offset, &send_find_peer_request, test_find_peer); + GNUNET_SCHEDULER_add_delayed(find_peer_offset, &send_find_peer_request, test_find_peer); return; } test_find_peer->find_peer_context->outstanding++; if (GNUNET_TIME_absolute_get_remaining(test_find_peer->find_peer_context->endtime).rel_value == 0) { - GNUNET_SCHEDULER_add_now(sched, &decrement_find_peers, test_find_peer); + GNUNET_SCHEDULER_add_now(&decrement_find_peers, test_find_peer); return; } - test_find_peer->dht_handle = GNUNET_DHT_connect(sched, test_find_peer->daemon->cfg, 1); + test_find_peer->dht_handle = GNUNET_DHT_connect(test_find_peer->daemon->cfg, 1); GNUNET_assert(test_find_peer->dht_handle != NULL); GNUNET_DHT_find_peers (test_find_peer->dht_handle, &handle_find_peer_sent, test_find_peer); @@ -1290,11 +1286,11 @@ count_peers_churn_cb (void *cls, { GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Found peer with no connections, will choose some peer(s) at random to connect to!\n"); GNUNET_CONTAINER_heap_iterate (find_peer_context->peer_min_heap, &iterate_min_heap_peers, find_peer_context); - GNUNET_SCHEDULER_add_now(sched, &schedule_churn_find_peer_requests, find_peer_context); + GNUNET_SCHEDULER_add_now(&schedule_churn_find_peer_requests, find_peer_context); } else if ((GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0) && (find_peer_context->last_sent != 0)) { - GNUNET_SCHEDULER_add_now(sched, &schedule_churn_find_peer_requests, find_peer_context); + GNUNET_SCHEDULER_add_now(&schedule_churn_find_peer_requests, find_peer_context); } else { @@ -1310,15 +1306,15 @@ count_peers_churn_cb (void *cls, topo_ctx->cls = all_gets; topo_ctx->timeout = DEFAULT_GET_TIMEOUT; topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); - die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), &end_badly, "from do gets (count_peers_churn_cb)"); - GNUNET_SCHEDULER_add_now(sched, &capture_current_topology, topo_ctx); + GNUNET_SCHEDULER_add_now(&capture_current_topology, topo_ctx); } else { - die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), &end_badly, "from do gets (count_peers_churn_cb)"); - GNUNET_SCHEDULER_add_now(sched, &do_get, all_gets); + GNUNET_SCHEDULER_add_now(&do_get, all_gets); } } } @@ -1372,7 +1368,7 @@ schedule_churn_find_peer_requests (void *cls, const struct GNUNET_SCHEDULER_Task test_find_peer->daemon = GNUNET_TESTING_daemon_get_by_id(pg, &peer_count->peer_id); GNUNET_assert(test_find_peer->daemon != NULL); test_find_peer->find_peer_context = find_peer_ctx; - GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(find_peer_offset, i), &send_find_peer_request, test_find_peer); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(find_peer_offset, i), &send_find_peer_request, test_find_peer); } if ((find_peer_ctx->peer_hash == NULL) && (find_peer_ctx->peer_min_heap == NULL)) @@ -1416,7 +1412,7 @@ static void churn_complete (void *cls, const char *emsg) if (emsg != NULL) { GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Ending test, churning of peers failed with error `%s'", emsg); - GNUNET_SCHEDULER_add_now(sched, &end_badly, (void *)emsg); + GNUNET_SCHEDULER_add_now(&end_badly, (void *)emsg); return; } @@ -1443,7 +1439,7 @@ static void churn_complete (void *cls, const char *emsg) } } GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Added %d peers to heap, total size %d\n", count_added, GNUNET_CONTAINER_heap_get_size(find_peer_context->peer_min_heap)); - GNUNET_SCHEDULER_add_delayed(sched, DEFAULT_PEER_DISCONNECT_TIMEOUT, &schedule_churn_get_topology, find_peer_context); + GNUNET_SCHEDULER_add_delayed(DEFAULT_PEER_DISCONNECT_TIMEOUT, &schedule_churn_get_topology, find_peer_context); //GNUNET_TESTING_get_topology (pg, &count_peers_churn_cb, find_peer_context); } else @@ -1459,19 +1455,19 @@ static void churn_complete (void *cls, const char *emsg) calc_timeout = GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout); calc_timeout = GNUNET_TIME_relative_add(calc_timeout, DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT); calc_timeout = GNUNET_TIME_relative_add(calc_timeout, DEFAULT_PEER_DISCONNECT_TIMEOUT); - die_task = GNUNET_SCHEDULER_add_delayed (sched, calc_timeout, + die_task = GNUNET_SCHEDULER_add_delayed (calc_timeout, &end_badly, "from do gets (churn_complete)"); - GNUNET_SCHEDULER_add_delayed(sched, DEFAULT_PEER_DISCONNECT_TIMEOUT, &capture_current_topology, topo_ctx); + GNUNET_SCHEDULER_add_delayed(DEFAULT_PEER_DISCONNECT_TIMEOUT, &capture_current_topology, topo_ctx); } else { calc_timeout = GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout); calc_timeout = GNUNET_TIME_relative_add(calc_timeout, DEFAULT_PEER_DISCONNECT_TIMEOUT); - die_task = GNUNET_SCHEDULER_add_delayed (sched, calc_timeout, + die_task = GNUNET_SCHEDULER_add_delayed (calc_timeout, &end_badly, "from do gets (churn_complete)"); if (dhtlog_handle != NULL) dhtlog_handle->insert_round(DHT_ROUND_GET, rounds_finished); - GNUNET_SCHEDULER_add_delayed(sched, DEFAULT_PEER_DISCONNECT_TIMEOUT, &do_get, all_gets); + GNUNET_SCHEDULER_add_delayed(DEFAULT_PEER_DISCONNECT_TIMEOUT, &do_get, all_gets); } } } @@ -1565,7 +1561,7 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) if ((gets_completed + gets_failed == num_gets) && (outstanding_gets == 0)) { fprintf(stderr, "Canceling die task (get_stop_finished) %llu gets completed, %llu gets failed\n", gets_completed, gets_failed); - GNUNET_SCHEDULER_cancel(sched, die_task); + GNUNET_SCHEDULER_cancel(die_task); reset_meter(put_meter); reset_meter(get_meter); /** @@ -1581,10 +1577,10 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext)); topo_ctx->cont = &log_dht_statistics; topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); - GNUNET_SCHEDULER_add_now(sched, &capture_current_topology, topo_ctx); + GNUNET_SCHEDULER_add_now(&capture_current_topology, topo_ctx); } else - GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); + GNUNET_SCHEDULER_add_now (&finish_testing, NULL); } else if (current_churn_round < churns_per_round * (rounds_finished + 1)) /* Do next round of churn */ { @@ -1595,7 +1591,7 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) if (dhtlog_handle != NULL) dhtlog_handle->insert_round(DHT_ROUND_CHURN, rounds_finished); - GNUNET_SCHEDULER_add_now(sched, &churn_peers, NULL); + GNUNET_SCHEDULER_add_now(&churn_peers, NULL); } else if (rounds_finished < total_rounds - 1) /* Start a new complete round */ { @@ -1610,17 +1606,17 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) if (dhtlog_handle != NULL) dhtlog_handle->insert_round(DHT_ROUND_GET, rounds_finished); - die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), &end_badly, "from do gets (next round)"); - GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), &do_get, all_gets); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), &do_get, all_gets); } else { if (dhtlog_handle != NULL) dhtlog_handle->insert_round(DHT_ROUND_NORMAL, rounds_finished); - die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_add(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, num_puts * 2)), + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, num_puts * 2)), &end_badly, "from do puts"); - GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), &do_put, all_puts); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), &do_put, all_puts); } } } @@ -1640,7 +1636,7 @@ get_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) GNUNET_DHT_get_stop(test_get->get_handle); test_get->get_handle = NULL; test_get->disconnect_task = GNUNET_SCHEDULER_NO_TASK; - GNUNET_SCHEDULER_add_now (sched, &get_stop_finished, test_get); + GNUNET_SCHEDULER_add_now (&get_stop_finished, test_get); } /** @@ -1685,8 +1681,8 @@ get_result_iterator (void *cls, #if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received correct GET response!\n"); #endif - GNUNET_SCHEDULER_cancel(sched, test_get->disconnect_task); - GNUNET_SCHEDULER_add_continuation(sched, &get_stop_task, test_get, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_cancel(test_get->disconnect_task); + GNUNET_SCHEDULER_add_continuation(&get_stop_task, test_get, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -1701,8 +1697,8 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) if (num_gets == 0) { - GNUNET_SCHEDULER_cancel(sched, die_task); - GNUNET_SCHEDULER_add_now(sched, &finish_testing, NULL); + GNUNET_SCHEDULER_cancel(die_task); + GNUNET_SCHEDULER_add_now(&finish_testing, NULL); } if (test_get == NULL) @@ -1715,20 +1711,20 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) { GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Peer we should issue get request from is down, skipping.\n"); gets_failed++; - GNUNET_SCHEDULER_add_now (sched, &get_stop_finished, test_get); - GNUNET_SCHEDULER_add_now (sched, &do_get, test_get->next); + GNUNET_SCHEDULER_add_now (&get_stop_finished, test_get); + GNUNET_SCHEDULER_add_now (&do_get, test_get->next); return; } /* Check if more gets are outstanding than should be */ if (outstanding_gets > max_outstanding_gets) { - GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 200), &do_get, test_get); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 200), &do_get, test_get); return; } /* Connect to the first peer's DHT */ - test_get->dht_handle = GNUNET_DHT_connect(sched, test_get->daemon->cfg, 10); + test_get->dht_handle = GNUNET_DHT_connect(test_get->daemon->cfg, 10); GNUNET_assert(test_get->dht_handle != NULL); outstanding_gets++; @@ -1748,10 +1744,10 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) test_get->uid, test_get->daemon->shortname); #endif - test_get->disconnect_task = GNUNET_SCHEDULER_add_delayed(sched, get_timeout, &get_stop_task, test_get); + test_get->disconnect_task = GNUNET_SCHEDULER_add_delayed(get_timeout, &get_stop_task, test_get); /* Schedule the next request in the linked list of get requests */ - GNUNET_SCHEDULER_add_now (sched, &do_get, test_get->next); + GNUNET_SCHEDULER_add_now (&do_get, test_get->next); } /** @@ -1773,12 +1769,12 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) if (replicate_same == GNUNET_NO) test_put->daemon = GNUNET_TESTING_daemon_get(pg, GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers)); - GNUNET_SCHEDULER_cancel(sched, test_put->disconnect_task); - test_put->disconnect_task = GNUNET_SCHEDULER_add_now(sched, &put_disconnect_task, test_put); + GNUNET_SCHEDULER_cancel(test_put->disconnect_task); + test_put->disconnect_task = GNUNET_SCHEDULER_add_now(&put_disconnect_task, test_put); if (GNUNET_YES == update_meter(put_meter)) { GNUNET_assert(outstanding_puts == 0); - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); if (dhtlog_handle != NULL) { topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext)); @@ -1786,16 +1782,16 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) topo_ctx->cls = all_gets; topo_ctx->timeout = DEFAULT_GET_TIMEOUT; topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); - die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), &end_badly, "from do gets (put finished)"); - GNUNET_SCHEDULER_add_now(sched, &capture_current_topology, topo_ctx); + GNUNET_SCHEDULER_add_now(&capture_current_topology, topo_ctx); } else { fprintf(stderr, "Scheduling die task (put finished)\n"); - die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), &end_badly, "from do gets (put finished)"); - GNUNET_SCHEDULER_add_delayed(sched, DEFAULT_GET_TIMEOUT, &do_get, all_gets); + GNUNET_SCHEDULER_add_delayed(DEFAULT_GET_TIMEOUT, &do_get, all_gets); } return; } @@ -1819,7 +1815,7 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) { GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Peer we should issue put request at is down, skipping.\n"); update_meter(put_meter); - GNUNET_SCHEDULER_add_now (sched, &do_put, test_put->next); + GNUNET_SCHEDULER_add_now (&do_put, test_put->next); return; } @@ -1830,7 +1826,7 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) if (outstanding_puts > max_outstanding_puts) { - GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 200), &do_put, test_put); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 200), &do_put, test_put); return; } @@ -1839,7 +1835,7 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) test_put->uid, test_put->daemon->shortname); #endif - test_put->dht_handle = GNUNET_DHT_connect(sched, test_put->daemon->cfg, 10); + test_put->dht_handle = GNUNET_DHT_connect(test_put->daemon->cfg, 10); GNUNET_assert(test_put->dht_handle != NULL); outstanding_puts++; @@ -1851,9 +1847,9 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) GNUNET_TIME_UNIT_FOREVER_ABS, put_delay, &put_finished, test_put); - test_put->disconnect_task = GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_get_forever(), &put_disconnect_task, test_put); + test_put->disconnect_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_get_forever(), &put_disconnect_task, test_put); rand = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 2); - GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, rand), &do_put, test_put->next); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, rand), &do_put, test_put->next); } static void @@ -1911,7 +1907,7 @@ count_peers_cb (void *cls, (find_peer_context->current_peers < 2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)) && (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0)) { - GNUNET_SCHEDULER_add_now(sched, &schedule_find_peer_requests, find_peer_context); + GNUNET_SCHEDULER_add_now(&schedule_find_peer_requests, find_peer_context); } else { @@ -1993,7 +1989,7 @@ schedule_find_peer_requests (void *cls, const struct GNUNET_SCHEDULER_TaskContex } test_find_peer->find_peer_context = find_peer_ctx; - GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(find_peer_offset, i), &send_find_peer_request, test_find_peer); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(find_peer_offset, i), &send_find_peer_request, test_find_peer); } if ((find_peer_ctx->peer_hash == NULL) && (find_peer_ctx->peer_min_heap == NULL)) @@ -2055,10 +2051,10 @@ setup_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) all_gets = test_get; } - /*GNUNET_SCHEDULER_cancel (sched, die_task);*/ - die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, num_puts * 2), + /*GNUNET_SCHEDULER_cancel (die_task);*/ + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, num_puts * 2), &end_badly, "from do puts"); - GNUNET_SCHEDULER_add_now (sched, &do_put, all_puts); + GNUNET_SCHEDULER_add_now (&do_put, all_puts); } @@ -2087,15 +2083,15 @@ continue_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext * t topo_ctx->total_iterations = max; topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); //fprintf(stderr, "scheduled topology iteration in %d minutes\n", i); - GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, i * 3), &capture_current_topology, topo_ctx); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, i * 3), &capture_current_topology, topo_ctx); } topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext)); topo_ctx->cont = &setup_puts_and_gets; topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); - GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, (settle_time + 90)), &capture_current_topology, topo_ctx); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, (settle_time + 90)), &capture_current_topology, topo_ctx); } else - GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, (settle_time + 90)), &setup_puts_and_gets, NULL); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, (settle_time + 90)), &setup_puts_and_gets, NULL); if (dhtlog_handle != NULL) dhtlog_handle->insert_round(DHT_ROUND_NORMAL, rounds_finished); @@ -2106,7 +2102,7 @@ continue_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext * t find_peer_context = GNUNET_malloc(sizeof(struct FindPeerContext)); find_peer_context->count_peers_cb = &count_peers_cb; find_peer_context->endtime = GNUNET_TIME_relative_to_absolute(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time)); - GNUNET_SCHEDULER_add_now(sched, &schedule_find_peer_requests, find_peer_context); + GNUNET_SCHEDULER_add_now(&schedule_find_peer_requests, find_peer_context); } else { @@ -2130,14 +2126,12 @@ malicious_disconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext if (malicious_completed == malicious_getters + malicious_putters + malicious_droppers) { - GNUNET_SCHEDULER_cancel(sched, die_task); + GNUNET_SCHEDULER_cancel(die_task); fprintf(stderr, "Finished setting all malicious peers up, calling continuation!\n"); if (dhtlog_handle != NULL) - GNUNET_SCHEDULER_add_now (sched, - &continue_puts_and_gets, NULL); + GNUNET_SCHEDULER_add_now (&continue_puts_and_gets, NULL); else - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time), + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time), &continue_puts_and_gets, NULL); } @@ -2150,8 +2144,8 @@ static void malicious_done_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) { struct MaliciousContext *ctx = cls; - GNUNET_SCHEDULER_cancel(sched, ctx->disconnect_task); - GNUNET_SCHEDULER_add_now(sched, &malicious_disconnect_task, ctx); + GNUNET_SCHEDULER_cancel(ctx->disconnect_task); + GNUNET_SCHEDULER_add_now(&malicious_disconnect_task, ctx); } /** @@ -2164,13 +2158,13 @@ set_malicious (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) if (outstanding_malicious > DEFAULT_MAX_OUTSTANDING_GETS) { - GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &set_malicious, ctx); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &set_malicious, ctx); return; } if (ctx->dht_handle == NULL) { - ctx->dht_handle = GNUNET_DHT_connect(sched, ctx->daemon->cfg, 1); + ctx->dht_handle = GNUNET_DHT_connect(ctx->daemon->cfg, 1); outstanding_malicious++; } @@ -2186,24 +2180,21 @@ set_malicious (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) { case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET: GNUNET_DHT_set_malicious_getter(ctx->dht_handle, malicious_get_frequency); - GNUNET_SCHEDULER_add_now (sched, - &malicious_done_task, ctx); + GNUNET_SCHEDULER_add_now (&malicious_done_task, ctx); break; case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT: GNUNET_DHT_set_malicious_putter(ctx->dht_handle, malicious_put_frequency); - GNUNET_SCHEDULER_add_now (sched, - &malicious_done_task, ctx); + GNUNET_SCHEDULER_add_now (&malicious_done_task, ctx); break; case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_DROP: GNUNET_DHT_set_malicious_dropper(ctx->dht_handle); - GNUNET_SCHEDULER_add_now (sched, &malicious_done_task, ctx); + GNUNET_SCHEDULER_add_now (&malicious_done_task, ctx); break; default: break; } - ctx->disconnect_task = GNUNET_SCHEDULER_add_delayed(sched, - GNUNET_TIME_UNIT_FOREVER_REL, + ctx->disconnect_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_FOREVER_REL, &malicious_disconnect_task, ctx); } @@ -2225,7 +2216,7 @@ setup_malicious_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers); ctx->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon); ctx->malicious_type = GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET; - GNUNET_SCHEDULER_add_now (sched, &set_malicious, ctx); + GNUNET_SCHEDULER_add_now (&set_malicious, ctx); } @@ -2235,7 +2226,7 @@ setup_malicious_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers); ctx->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon); ctx->malicious_type = GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT; - GNUNET_SCHEDULER_add_now (sched, &set_malicious, ctx); + GNUNET_SCHEDULER_add_now (&set_malicious, ctx); } @@ -2245,7 +2236,7 @@ setup_malicious_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers); ctx->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon); ctx->malicious_type = GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_DROP; - GNUNET_SCHEDULER_add_now (sched, &set_malicious, ctx); + GNUNET_SCHEDULER_add_now (&set_malicious, ctx); } /** @@ -2255,14 +2246,13 @@ setup_malicious_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc if (malicious_getters + malicious_putters + malicious_droppers > 0) { GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Giving malicious set tasks some time before starting testing!\n"); - die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, (malicious_getters + malicious_putters + malicious_droppers) * 2), + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, (malicious_getters + malicious_putters + malicious_droppers) * 2), &end_badly, "from set malicious"); } else /* Otherwise, continue testing */ { GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Scheduling continue_puts_and_gets now!\n"); - GNUNET_SCHEDULER_add_now (sched, - &continue_puts_and_gets, NULL); + GNUNET_SCHEDULER_add_now (&continue_puts_and_gets, NULL); } } @@ -2321,8 +2311,8 @@ topology_callback (void *cls, dhtlog_handle->insert_topology(expected_connections); } - GNUNET_SCHEDULER_cancel (sched, die_task); - /*die_task = GNUNET_SCHEDULER_add_delayed (sched, DEFAULT_TIMEOUT, + GNUNET_SCHEDULER_cancel (die_task); + /*die_task = GNUNET_SCHEDULER_add_delayed (DEFAULT_TIMEOUT, &end_badly, "from setup puts/gets");*/ if ((dhtlog_handle != NULL) && (settle_time > 0)) { @@ -2330,21 +2320,19 @@ topology_callback (void *cls, topo_ctx->cont = &setup_malicious_peers; topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); //topo_ctx->cont = &continue_puts_and_gets; - GNUNET_SCHEDULER_add_now(sched, &capture_current_topology, topo_ctx); + GNUNET_SCHEDULER_add_now(&capture_current_topology, topo_ctx); } else { - GNUNET_SCHEDULER_add_now(sched, &setup_malicious_peers, NULL); - /*GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time), + GNUNET_SCHEDULER_add_now(&setup_malicious_peers, NULL); + /*GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time), &continue_puts_and_gets, NULL);*/ } } else if (total_connections + failed_connections == expected_connections) { - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from topology_callback (too many failed connections)"); + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many failed connections)"); } } @@ -2376,7 +2364,7 @@ peers_started_callback (void *cls, "All %d daemons started, now connecting peers!\n", num_peers); #endif - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); expected_connections = UINT_MAX; if ((pg != NULL) && (peers_left == 0)) @@ -2389,12 +2377,10 @@ peers_started_callback (void *cls, if (expected_connections == GNUNET_SYSERR) { - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from connect topology (bad return)"); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)"); } - die_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, DEFAULT_CONNECT_TIMEOUT * expected_connections), + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, DEFAULT_CONNECT_TIMEOUT * expected_connections), &end_badly, "from connect topology (timeout)"); ok = 0; @@ -2415,14 +2401,12 @@ create_topology () } else { - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from create topology (bad return)"); + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from create topology (bad return)"); } GNUNET_free_non_null(blacklist_transports); - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers), + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers), &end_badly, "from continue startup (timeout)"); } @@ -2459,13 +2443,12 @@ hostkey_callback (void *cls, "All %d hostkeys created, now creating topology!\n", num_peers); #endif - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, - DEFAULT_TOPOLOGY_TIMEOUT, + die_task = GNUNET_SCHEDULER_add_delayed (DEFAULT_TOPOLOGY_TIMEOUT, &end_badly, "from create_topology"); - GNUNET_SCHEDULER_add_now(sched, &create_topology, NULL); + GNUNET_SCHEDULER_add_now(&create_topology, NULL); ok = 0; } } @@ -2473,7 +2456,6 @@ hostkey_callback (void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { @@ -2503,9 +2485,8 @@ run (void *cls, char *churn_filename; int count; int ret; - unsigned int line_number; + int line_number; - sched = s; config = cfg; rounds_finished = 0; memset(&trial_info, 0, sizeof(struct GNUNET_DHTLOG_TrialInfo)); @@ -2986,8 +2967,7 @@ run (void *cls, /* Set up a task to end testing if peer start fails */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers), + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers), &end_badly, "didn't generate all hostkeys within allowed startup time!"); if (dhtlog_handle == NULL) @@ -3032,7 +3012,7 @@ run (void *cls, put_meter = create_meter(num_puts, "Puts completed ", GNUNET_YES); get_meter = create_meter(num_gets, "Gets completed ", GNUNET_YES); - pg = GNUNET_TESTING_daemons_start (sched, cfg, + pg = GNUNET_TESTING_daemons_start (cfg, peers_left, GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers), &hostkey_callback, NULL, diff --git a/src/dht/gnunet-dht-get-peer.c b/src/dht/gnunet-dht-get-peer.c index f6974cddb..8d318efc2 100644 --- a/src/dht/gnunet-dht-get-peer.c +++ b/src/dht/gnunet-dht-get-peer.c @@ -52,10 +52,6 @@ static int verbose; */ static struct GNUNET_DHT_Handle *dht_handle; -/** - * Global handle of the scheduler - */ -static struct GNUNET_SCHEDULER_Handle *sched; /** * Global handle of the configuration @@ -101,7 +97,7 @@ cleanup_task (void *cls, GNUNET_DHT_find_peer_stop (find_peer_handle); find_peer_handle = NULL; } - GNUNET_SCHEDULER_add_now (sched, &shutdown_task, NULL); + GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); } /** @@ -132,20 +128,17 @@ find_peer_processor (void *cls, * Main function that will be run by the scheduler. * * @param cls closure - * @param s the scheduler to use * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param c configuration */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { struct GNUNET_TIME_Relative timeout; GNUNET_HashCode key; - sched = s; cfg = c; if (query_key == NULL) @@ -156,7 +149,7 @@ run (void *cls, return; } - dht_handle = GNUNET_DHT_connect (sched, cfg, 1); + dht_handle = GNUNET_DHT_connect (cfg, 1); if (dht_handle == NULL) { @@ -185,11 +178,10 @@ run (void *cls, NULL); if (NULL == find_peer_handle) { - GNUNET_SCHEDULER_add_now (sched, &shutdown_task, NULL); + GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); return; } - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_absolute_get_remaining + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining (absolute_timeout), &cleanup_task, NULL); } diff --git a/src/dht/gnunet-dht-get.c b/src/dht/gnunet-dht-get.c index 55d606716..b7dcb6a56 100644 --- a/src/dht/gnunet-dht-get.c +++ b/src/dht/gnunet-dht-get.c @@ -56,10 +56,6 @@ static int verbose; */ static struct GNUNET_DHT_Handle *dht_handle; -/** - * Global handle of the scheduler - */ -static struct GNUNET_SCHEDULER_Handle *sched; /** * Global handle of the configuration @@ -101,7 +97,7 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_DHT_get_stop (get_handle); get_handle = NULL; } - GNUNET_SCHEDULER_add_now (sched, &shutdown_task, NULL); + GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); } @@ -142,20 +138,17 @@ get_result_iterator (void *cls, * Main function that will be run by the scheduler. * * @param cls closure - * @param s the scheduler to use * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param c configuration */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { struct GNUNET_TIME_Relative timeout; GNUNET_HashCode key; - sched = s; cfg = c; if (query_key == NULL) @@ -166,7 +159,7 @@ run (void *cls, return; } - dht_handle = GNUNET_DHT_connect (sched, cfg, 1); + dht_handle = GNUNET_DHT_connect (cfg, 1); if (dht_handle == NULL) { @@ -186,8 +179,7 @@ run (void *cls, if (verbose) fprintf (stderr, "Issuing GET request for %s!\n", query_key); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_absolute_get_remaining + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining (absolute_timeout), &cleanup_task, NULL); get_handle = GNUNET_DHT_get_start (dht_handle, timeout, diff --git a/src/dht/gnunet-dht-put.c b/src/dht/gnunet-dht-put.c index 54c984493..469675409 100644 --- a/src/dht/gnunet-dht-put.c +++ b/src/dht/gnunet-dht-put.c @@ -56,10 +56,6 @@ static int verbose; */ static struct GNUNET_DHT_Handle *dht_handle; -/** - * Global handle of the scheduler - */ -static struct GNUNET_SCHEDULER_Handle *sched; /** * Global handle of the configuration @@ -98,28 +94,25 @@ message_sent_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (verbose) fprintf (stderr, _("PUT request sent!\n")); - GNUNET_SCHEDULER_add_now (sched, &shutdown_task, NULL); + GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); } /** * Main function that will be run by the scheduler. * * @param cls closure - * @param s the scheduler to use * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param c configuration */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { struct GNUNET_TIME_Relative timeout; struct GNUNET_TIME_Absolute expiration; GNUNET_HashCode key; - sched = s; cfg = c; if ( (query_key == NULL) || (data == NULL) ) @@ -130,7 +123,7 @@ run (void *cls, return; } - dht_handle = GNUNET_DHT_connect (sched, cfg, 1); + dht_handle = GNUNET_DHT_connect (cfg, 1); if (dht_handle == NULL) { fprintf (stderr, diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index da82ac841..52e10320c 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c @@ -755,10 +755,6 @@ static struct GNUNET_DATACACHE_Handle *datacache; */ struct GNUNET_STATISTICS_Handle *stats; -/** - * The main scheduler to use for the DHT service - */ -static struct GNUNET_SCHEDULER_Handle *sched; /** * The configuration the DHT service is running with @@ -1094,7 +1090,7 @@ forward_result_message (const struct GNUNET_MessageHeader *msg, #endif GNUNET_CONTAINER_DLL_insert_after(peer->head, peer->tail, peer->tail, pending); if (peer->send_task == GNUNET_SCHEDULER_NO_TASK) - peer->send_task = GNUNET_SCHEDULER_add_now(sched, &try_core_send, peer); + peer->send_task = GNUNET_SCHEDULER_add_now(&try_core_send, peer); } @@ -1164,7 +1160,7 @@ core_transmit_notify (void *cls, } #endif if ((peer->head != NULL) && (peer->send_task == GNUNET_SCHEDULER_NO_TASK)) - peer->send_task = GNUNET_SCHEDULER_add_now(sched, &try_core_send, peer); + peer->send_task = GNUNET_SCHEDULER_add_now(&try_core_send, peer); #if DEBUG_DHT > 1 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "`%s:%s' : transmit_notify (core) called with size %d, available %d, returning %d\n", my_short_id, "dht service", msize, size, off); #endif @@ -1401,7 +1397,7 @@ update_core_preference_finish (void *cls, { struct PeerInfo *peer_info = cls; peer_info->info_ctx = NULL; - GNUNET_SCHEDULER_add_delayed(sched, DHT_DEFAULT_PREFERENCE_INTERVAL, &update_core_preference, peer_info); + GNUNET_SCHEDULER_add_delayed(DHT_DEFAULT_PREFERENCE_INTERVAL, &update_core_preference, peer_info); } static void @@ -1422,7 +1418,7 @@ update_core_preference (void *cls, matching = 63; } preference = 1LL << matching; - peer->info_ctx = GNUNET_CORE_peer_change_preference (sched, cfg, + peer->info_ctx = GNUNET_CORE_peer_change_preference (cfg, &peer->id, GNUNET_TIME_relative_get_forever(), GNUNET_BANDWIDTH_value_init (UINT32_MAX), @@ -1468,7 +1464,7 @@ add_peer(const struct GNUNET_PeerIdentity *peer, if ((GNUNET_CRYPTO_hash_matching_bits(&my_identity.hashPubKey, &peer->hashPubKey) > 0) && (k_buckets[bucket].peers_size <= bucket_size)) { #if DO_UPDATE_PREFERENCE - new_peer->preference_task = GNUNET_SCHEDULER_add_now(sched, &update_core_preference, new_peer); + new_peer->preference_task = GNUNET_SCHEDULER_add_now(&update_core_preference, new_peer); #endif } @@ -1527,7 +1523,7 @@ static void delete_peer (struct PeerInfo *peer, remove_peer(peer, bucket); /* First remove the peer from its bucket */ if (peer->send_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, peer->send_task); + GNUNET_SCHEDULER_cancel(peer->send_task); if (peer->th != NULL) GNUNET_CORE_notify_transmit_ready_cancel(peer->th); @@ -1700,7 +1696,7 @@ static void forward_message (const struct GNUNET_MessageHeader *msg, #endif GNUNET_CONTAINER_DLL_insert_after(peer->head, peer->tail, peer->tail, pending); if (peer->send_task == GNUNET_SCHEDULER_NO_TASK) - peer->send_task = GNUNET_SCHEDULER_add_now(sched, &try_core_send, peer); + peer->send_task = GNUNET_SCHEDULER_add_now(&try_core_send, peer); } #if DO_PING @@ -1729,7 +1725,7 @@ periodic_ping_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s Sending periodic ping to %s\n", my_short_id, "DHT", GNUNET_i2s(&peer->id)); #endif forward_message(&ping_message, peer, &message_context); - peer->ping_task = GNUNET_SCHEDULER_add_delayed(sched, DHT_DEFAULT_PING_DELAY, &periodic_ping_task, peer); + peer->ping_task = GNUNET_SCHEDULER_add_delayed(DHT_DEFAULT_PING_DELAY, &periodic_ping_task, peer); } /** @@ -1748,10 +1744,10 @@ void schedule_ping_messages() while (pos != NULL) { if ((count < bucket_size) && (pos->ping_task == GNUNET_SCHEDULER_NO_TASK)) - GNUNET_SCHEDULER_add_now(sched, &periodic_ping_task, pos); + GNUNET_SCHEDULER_add_now(&periodic_ping_task, pos); else if ((count >= bucket_size) && (pos->ping_task != GNUNET_SCHEDULER_NO_TASK)) { - GNUNET_SCHEDULER_cancel(sched, pos->ping_task); + GNUNET_SCHEDULER_cancel(pos->ping_task); pos->ping_task = GNUNET_SCHEDULER_NO_TASK; } pos = pos->next; @@ -1997,7 +1993,7 @@ static int route_result_message(struct GNUNET_MessageHeader *msg, { increment_stats(STAT_HELLOS_PROVIDED); GNUNET_TRANSPORT_offer_hello(transport_handle, hello_msg); - GNUNET_CORE_peer_request_connect(sched, cfg, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), &new_peer, NULL, NULL); + GNUNET_CORE_peer_request_connect(cfg, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), &new_peer, NULL, NULL); } } } @@ -2426,7 +2422,7 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, { increment_stats(STAT_HELLOS_PROVIDED); GNUNET_TRANSPORT_offer_hello(transport_handle, other_hello); - GNUNET_CORE_peer_request_connect(sched, cfg, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), &peer_id, NULL, NULL); + GNUNET_CORE_peer_request_connect(cfg, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), &peer_id, NULL, NULL); route_message (find_msg, message_context); GNUNET_free (other_hello); return; @@ -2507,7 +2503,7 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, { GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding recent remove task for key `%s`!\n", GNUNET_h2s(&message_context->key)); /* Only add a task if there wasn't one for this key already! */ - GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30), + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30), &remove_recent_find_peer, recent_hash); } else @@ -2675,7 +2671,7 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, put_context = GNUNET_malloc(sizeof(struct RepublishContext)); memcpy(&put_context->key, &message_context->key, sizeof(GNUNET_HashCode)); put_context->type = put_type; - GNUNET_SCHEDULER_add_delayed (sched, dht_republish_frequency, &republish_content, put_context); + GNUNET_SCHEDULER_add_delayed (dht_republish_frequency, &republish_content, put_context); } } else @@ -3377,7 +3373,7 @@ static int cache_response(struct DHT_MessageContext *msg_ctx) GNUNET_free(record); } if (source_info->delete_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, source_info->delete_task); + GNUNET_SCHEDULER_cancel(source_info->delete_task); if (source_info->find_peers_responded != NULL) GNUNET_CONTAINER_bloomfilter_free(source_info->find_peers_responded); GNUNET_free(source_info); @@ -3409,7 +3405,7 @@ static int cache_response(struct DHT_MessageContext *msg_ctx) source_info = GNUNET_malloc(sizeof(struct DHTRouteSource)); source_info->record = record; - source_info->delete_task = GNUNET_SCHEDULER_add_delayed(sched, DHT_FORWARD_TIMEOUT, &remove_forward_entry, source_info); + source_info->delete_task = GNUNET_SCHEDULER_add_delayed(DHT_FORWARD_TIMEOUT, &remove_forward_entry, source_info); source_info->find_peers_responded = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); memcpy(&source_info->source, msg_ctx->peer, sizeof(struct GNUNET_PeerIdentity)); GNUNET_CONTAINER_DLL_insert_after(record->head, record->tail, record->tail, source_info); @@ -3536,7 +3532,7 @@ route_message(const struct GNUNET_MessageHeader *msg, recent_req = GNUNET_malloc(sizeof(struct RecentRequest)); recent_req->uid = message_context->unique_id; memcpy(&recent_req->key, &message_context->key, sizeof(GNUNET_HashCode)); - recent_req->remove_task = GNUNET_SCHEDULER_add_delayed(sched, DEFAULT_RECENT_REMOVAL, &remove_recent, recent_req); + recent_req->remove_task = GNUNET_SCHEDULER_add_delayed(DEFAULT_RECENT_REMOVAL, &remove_recent, recent_req); recent_req->heap_node = GNUNET_CONTAINER_heap_insert(recent.minHeap, recent_req, GNUNET_TIME_absolute_get().abs_value); recent_req->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); GNUNET_CONTAINER_multihashmap_put(recent.hashmap, &unique_hash, recent_req, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); @@ -3546,8 +3542,8 @@ route_message(const struct GNUNET_MessageHeader *msg, { recent_req = GNUNET_CONTAINER_heap_peek(recent.minHeap); GNUNET_assert(recent_req != NULL); - GNUNET_SCHEDULER_cancel(sched, recent_req->remove_task); - GNUNET_SCHEDULER_add_now(sched, &remove_recent, recent_req); + GNUNET_SCHEDULER_cancel(recent_req->remove_task); + GNUNET_SCHEDULER_add_now(&remove_recent, recent_req); } for (i = 0; i < forward_count; i++) @@ -3727,7 +3723,7 @@ republish_content(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (results == 0) /* Data must have expired */ GNUNET_free(put_context); else /* Reschedule task for next time period */ - GNUNET_SCHEDULER_add_delayed(sched, dht_republish_frequency, &republish_content, put_context); + GNUNET_SCHEDULER_add_delayed(dht_republish_frequency, &republish_content, put_context); } @@ -3760,7 +3756,7 @@ static int find_client_records (void *cls, GNUNET_CONTAINER_DLL_remove(record->head, record->tail, pos); GNUNET_CONTAINER_heap_remove_node(forward_list.minHeap, pos->hnode); if (pos->delete_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, pos->delete_task); + GNUNET_SCHEDULER_cancel(pos->delete_task); if (pos->find_peers_responded != NULL) GNUNET_CONTAINER_bloomfilter_free(pos->find_peers_responded); @@ -3886,7 +3882,7 @@ malicious_put_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) increment_stats(STAT_PUT_START); GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious PUT message with hash %s\n", my_short_id, "DHT", GNUNET_h2s(&key)); demultiplex_message(&put_message.header, &message_context); - GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, malicious_put_frequency), &malicious_put_task, NULL); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, malicious_put_frequency), &malicious_put_task, NULL); } @@ -3929,7 +3925,7 @@ malicious_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) increment_stats(STAT_GET_START); GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious GET message with hash %s\n", my_short_id, "DHT", GNUNET_h2s(&key)); demultiplex_message (&get_message.header, &message_context); - GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, malicious_get_frequency), &malicious_get_task, NULL); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, malicious_get_frequency), &malicious_get_task, NULL); } /** @@ -3979,8 +3975,7 @@ send_find_peer_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc if ((newly_found_peers > bucket_size) && (GNUNET_YES == do_find_peer)) /* If we are finding peers already, no need to send out our request right now! */ { GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Have %d newly found peers since last find peer message sent!\n", newly_found_peers); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_MINUTES, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &send_find_peer_message, NULL); newly_found_peers = 0; return; @@ -4049,8 +4044,7 @@ send_find_peer_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc find_peer_context.start = GNUNET_TIME_absolute_get(); if (GNUNET_YES == do_find_peer) { - GNUNET_SCHEDULER_add_delayed (sched, - next_send_time, + GNUNET_SCHEDULER_add_delayed (next_send_time, &send_find_peer_message, NULL); } } @@ -4135,7 +4129,7 @@ handle_dht_control_message (void *cls, struct GNUNET_SERVER_Client *client, { case GNUNET_MESSAGE_TYPE_DHT_FIND_PEER: GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending self seeking find peer request!\n"); - GNUNET_SCHEDULER_add_now(sched, &send_find_peer_message, NULL); + GNUNET_SCHEDULER_add_now(&send_find_peer_message, NULL); break; case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET: if (ntohs(dht_control_msg->variable) > 0) @@ -4143,7 +4137,7 @@ handle_dht_control_message (void *cls, struct GNUNET_SERVER_Client *client, if (malicious_get_frequency == 0) malicious_get_frequency = DEFAULT_MALICIOUS_GET_FREQUENCY; if (malicious_getter != GNUNET_YES) - GNUNET_SCHEDULER_add_now(sched, &malicious_get_task, NULL); + GNUNET_SCHEDULER_add_now(&malicious_get_task, NULL); malicious_getter = GNUNET_YES; GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Initiating malicious GET behavior, frequency %d\n", my_short_id, "DHT", malicious_get_frequency); @@ -4154,7 +4148,7 @@ handle_dht_control_message (void *cls, struct GNUNET_SERVER_Client *client, if (malicious_put_frequency == 0) malicious_put_frequency = DEFAULT_MALICIOUS_PUT_FREQUENCY; if (malicious_putter != GNUNET_YES) - GNUNET_SCHEDULER_add_now(sched, &malicious_put_task, NULL); + GNUNET_SCHEDULER_add_now(&malicious_put_task, NULL); malicious_putter = GNUNET_YES; GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Initiating malicious PUT behavior, frequency %d\n", my_short_id, "DHT", malicious_put_frequency); @@ -4211,9 +4205,9 @@ handle_dht_local_route_stop(void *cls, struct GNUNET_SERVER_Client *client, { if ((pos->client != NULL) && (pos->client->client_handle == client)) { - GNUNET_SCHEDULER_cancel(sched, pos->delete_task); + GNUNET_SCHEDULER_cancel(pos->delete_task); pos->delete_task = GNUNET_SCHEDULER_NO_TASK; - GNUNET_SCHEDULER_add_now(sched, &remove_forward_entry, pos); + GNUNET_SCHEDULER_add_now(&remove_forward_entry, pos); } pos = pos->next; } @@ -4431,8 +4425,8 @@ core_init (void *cls, "%s: Connection to core FAILED!\n", "dht", GNUNET_i2s (identity)); #endif - GNUNET_SCHEDULER_cancel (sched, cleanup_task); - GNUNET_SCHEDULER_add_now (sched, &shutdown_task, NULL); + GNUNET_SCHEDULER_cancel (cleanup_task); + GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); return; } #if DEBUG_DHT @@ -4546,13 +4540,11 @@ void handle_core_disconnect (void *cls, * Process dht requests. * * @param cls closure - * @param scheduler scheduler to use * @param server the initialized server * @param c configuration to use */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *scheduler, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { @@ -4560,13 +4552,11 @@ run (void *cls, unsigned long long temp_config_num; char *converge_modifier_buf; - sched = scheduler; cfg = c; - datacache = GNUNET_DATACACHE_create (sched, cfg, "dhtcache"); + datacache = GNUNET_DATACACHE_create (cfg, "dhtcache"); GNUNET_SERVER_add_handlers (server, plugin_handlers); GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); - coreAPI = GNUNET_CORE_connect (sched, /* Main scheduler */ - cfg, /* Main configuration */ + coreAPI = GNUNET_CORE_connect (cfg, /* Main configuration */ GNUNET_TIME_UNIT_FOREVER_REL, NULL, /* Closure passed to DHT functions */ &core_init, /* Call core_init once connected */ @@ -4581,7 +4571,7 @@ run (void *cls, if (coreAPI == NULL) return; - transport_handle = GNUNET_TRANSPORT_connect(sched, cfg, + transport_handle = GNUNET_TRANSPORT_connect(cfg, NULL, NULL, NULL, NULL, NULL); if (transport_handle != NULL) GNUNET_TRANSPORT_get_hello (transport_handle, &process_hello, NULL); @@ -4744,7 +4734,7 @@ run (void *cls, GNUNET_free(converge_modifier_buf); } - stats = GNUNET_STATISTICS_create(sched, "dht", cfg); + stats = GNUNET_STATISTICS_create("dht", cfg); if (stats != NULL) { @@ -4778,14 +4768,12 @@ run (void *cls, GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, (DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / 2) - DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value); find_peer_context.start = GNUNET_TIME_absolute_get(); - GNUNET_SCHEDULER_add_delayed (sched, - next_send_time, + GNUNET_SCHEDULER_add_delayed (next_send_time, &send_find_peer_message, &find_peer_context); } /* Scheduled the task to clean up when shutdown is called */ - cleanup_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + cleanup_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); } diff --git a/src/dht/test_dht_api.c b/src/dht/test_dht_api.c index 5eeb44d13..de3d97647 100644 --- a/src/dht/test_dht_api.c +++ b/src/dht/test_dht_api.c @@ -93,7 +93,6 @@ static struct PeerContext p1; struct RetryContext retry_context; -static struct GNUNET_SCHEDULER_Handle *sched; static int ok; @@ -109,7 +108,7 @@ GNUNET_SCHEDULER_TaskIdentifier die_task; static void end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); die_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_DHT_disconnect (p1.dht_handle); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -152,7 +151,7 @@ end_badly () GNUNET_DHT_get_stop (retry_context.peer_ctx->get_handle); } if (retry_context.retry_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, retry_context.retry_task); + GNUNET_SCHEDULER_cancel(retry_context.retry_task); GNUNET_DHT_disconnect (p1.dht_handle); ok = 1; } @@ -173,8 +172,8 @@ test_find_peer_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT) { GNUNET_break (0); - GNUNET_SCHEDULER_cancel (sched, die_task); - GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL); + GNUNET_SCHEDULER_cancel (die_task); + GNUNET_SCHEDULER_add_now (&end_badly, NULL); return; } @@ -187,8 +186,7 @@ test_find_peer_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_DHT_set_malicious_putter (peer->dht_handle, GNUNET_TIME_UNIT_SECONDS); GNUNET_DHT_set_malicious_dropper (peer->dht_handle); #endif - GNUNET_SCHEDULER_add_delayed(sched, - GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &end, &p1); } @@ -214,11 +212,11 @@ void test_find_peer_processor (void *cls, if (retry_ctx->retry_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(sched, retry_ctx->retry_task); + GNUNET_SCHEDULER_cancel(retry_ctx->retry_task); retry_ctx->retry_task = GNUNET_SCHEDULER_NO_TASK; } - GNUNET_SCHEDULER_add_continuation (sched, &test_find_peer_stop, &p1, + GNUNET_SCHEDULER_add_continuation (&test_find_peer_stop, &p1, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } else @@ -273,11 +271,11 @@ retry_find_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (retry_ctx->peer_ctx->find_peer_handle == NULL) { GNUNET_break (0); - GNUNET_SCHEDULER_cancel (sched, die_task); - GNUNET_SCHEDULER_add_now (sched, &end_badly, &p1); + GNUNET_SCHEDULER_cancel (die_task); + GNUNET_SCHEDULER_add_now (&end_badly, &p1); return; } - retry_ctx->retry_task = GNUNET_SCHEDULER_add_delayed(sched, retry_ctx->next_timeout, &retry_find_peer_stop, retry_ctx); + retry_ctx->retry_task = GNUNET_SCHEDULER_add_delayed(retry_ctx->next_timeout, &retry_find_peer_stop, retry_ctx); } /** @@ -298,7 +296,7 @@ retry_find_peer_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_DHT_find_peer_stop(retry_ctx->peer_ctx->find_peer_handle); retry_ctx->peer_ctx->find_peer_handle = NULL; } - GNUNET_SCHEDULER_add_now (sched, &retry_find_peer, retry_ctx); + GNUNET_SCHEDULER_add_now (&retry_find_peer, retry_ctx); } /** @@ -330,11 +328,11 @@ test_find_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (peer->find_peer_handle == NULL) { GNUNET_break (0); - GNUNET_SCHEDULER_cancel (sched, die_task); - GNUNET_SCHEDULER_add_now (sched, &end_badly, &p1); + GNUNET_SCHEDULER_cancel (die_task); + GNUNET_SCHEDULER_add_now (&end_badly, &p1); return; } - retry_context.retry_task = GNUNET_SCHEDULER_add_delayed(sched, retry_context.next_timeout, &retry_find_peer_stop, &retry_context); + retry_context.retry_task = GNUNET_SCHEDULER_add_delayed(retry_context.next_timeout, &retry_find_peer_stop, &retry_context); } /** @@ -352,14 +350,13 @@ test_get_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT) { GNUNET_break (0); - GNUNET_SCHEDULER_cancel (sched, die_task); - GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL); + GNUNET_SCHEDULER_cancel (die_task); + GNUNET_SCHEDULER_add_now (&end_badly, NULL); return; } GNUNET_assert (peer->dht_handle != NULL); GNUNET_DHT_get_stop (peer->get_handle); - GNUNET_SCHEDULER_add_now(sched, - &test_find_peer, + GNUNET_SCHEDULER_add_now(&test_find_peer, &p1); } @@ -375,7 +372,7 @@ test_get_iterator (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test_get_iterator called (we got a result), stopping get request!\n"); - GNUNET_SCHEDULER_add_continuation (sched, &test_get_stop, &p1, + GNUNET_SCHEDULER_add_continuation (&test_get_stop, &p1, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -411,8 +408,8 @@ test_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (peer->get_handle == NULL) { GNUNET_break (0); - GNUNET_SCHEDULER_cancel (sched, die_task); - GNUNET_SCHEDULER_add_now (sched, &end_badly, &p1); + GNUNET_SCHEDULER_cancel (die_task); + GNUNET_SCHEDULER_add_now (&end_badly, &p1); return; } @@ -436,7 +433,7 @@ test_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) data = GNUNET_malloc (data_size); memset (data, 43, data_size); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called test_put!\n"); - peer->dht_handle = GNUNET_DHT_connect (sched, peer->cfg, 100); + peer->dht_handle = GNUNET_DHT_connect (peer->cfg, 100); GNUNET_assert (peer->dht_handle != NULL); @@ -468,23 +465,19 @@ setup_peer (struct PeerContext *p, const char *cfgname) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; - sched = s; - die_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1), &end_badly, NULL); setup_peer (&p1, "test_dht_api_peer1.conf"); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), &test_put, &p1); } diff --git a/src/dht/test_dht_multipeer.c b/src/dht/test_dht_multipeer.c index dc877c28b..9c18c4f2e 100644 --- a/src/dht/test_dht_multipeer.c +++ b/src/dht/test_dht_multipeer.c @@ -152,11 +152,6 @@ static unsigned long long peers_left; static struct GNUNET_TESTING_PeerGroup *pg; -/** - * Global scheduler, used for all GNUNET_SCHEDULER_* functions. - */ -static struct GNUNET_SCHEDULER_Handle *sched; - /** * Total number of peers to run, set based on config file. */ @@ -269,7 +264,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) while (test_put != NULL) { if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, test_put->disconnect_task); + GNUNET_SCHEDULER_cancel(test_put->disconnect_task); if (test_put->dht_handle != NULL) GNUNET_DHT_disconnect(test_put->dht_handle); test_put = test_put->next; @@ -278,7 +273,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) while (test_get != NULL) { if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, test_get->disconnect_task); + GNUNET_SCHEDULER_cancel(test_get->disconnect_task); if (test_get->get_handle != NULL) GNUNET_DHT_get_stop(test_get->get_handle); if (test_get->dht_handle != NULL) @@ -307,7 +302,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) while (test_put != NULL) { if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, test_put->disconnect_task); + GNUNET_SCHEDULER_cancel(test_put->disconnect_task); if (test_put->dht_handle != NULL) GNUNET_DHT_disconnect(test_put->dht_handle); test_put = test_put->next; @@ -316,7 +311,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) while (test_get != NULL) { if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, test_get->disconnect_task); + GNUNET_SCHEDULER_cancel(test_get->disconnect_task); if (test_get->get_handle != NULL) GNUNET_DHT_get_stop(test_get->get_handle); if (test_get->dht_handle != NULL) @@ -342,14 +337,14 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%d gets succeeded, %d gets failed!\n", gets_completed, gets_failed); if ((gets_completed == num_gets) && (outstanding_gets == 0))/* All gets successful */ { - GNUNET_SCHEDULER_cancel (sched, die_task); - //GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5), &get_topology, NULL); - GNUNET_SCHEDULER_add_now(sched, &finish_testing, NULL); + GNUNET_SCHEDULER_cancel (die_task); + //GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5), &get_topology, NULL); + GNUNET_SCHEDULER_add_now(&finish_testing, NULL); } else if ((gets_completed + gets_failed == num_gets) && (outstanding_gets == 0)) /* Had some failures */ { - GNUNET_SCHEDULER_cancel(sched, die_task); - GNUNET_SCHEDULER_add_now(sched, &end_badly, "not all gets succeeded!\n"); + GNUNET_SCHEDULER_cancel(die_task); + GNUNET_SCHEDULER_add_now(&end_badly, "not all gets succeeded!\n"); } } @@ -373,7 +368,7 @@ get_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) } GNUNET_assert(test_get->get_handle != NULL); GNUNET_DHT_get_stop(test_get->get_handle); - GNUNET_SCHEDULER_add_now (sched, &get_stop_finished, test_get); + GNUNET_SCHEDULER_add_now (&get_stop_finished, test_get); test_get->get_handle = NULL; test_get->disconnect_task = GNUNET_SCHEDULER_NO_TASK; } @@ -418,8 +413,8 @@ void get_result_iterator (void *cls, } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received correct GET response!\n"); - GNUNET_SCHEDULER_cancel(sched, test_get->disconnect_task); - GNUNET_SCHEDULER_add_continuation(sched, &get_stop_task, test_get, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_cancel(test_get->disconnect_task); + GNUNET_SCHEDULER_add_continuation(&get_stop_task, test_get, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -440,11 +435,11 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) if (outstanding_gets > MAX_OUTSTANDING_GETS) { - GNUNET_SCHEDULER_add_delayed (sched, GET_DELAY, &do_get, test_get); + GNUNET_SCHEDULER_add_delayed (GET_DELAY, &do_get, test_get); return; } - test_get->dht_handle = GNUNET_DHT_connect(sched, test_get->daemon->cfg, 10); + test_get->dht_handle = GNUNET_DHT_connect(test_get->daemon->cfg, 10); /* Insert the data at the first peer */ GNUNET_assert(test_get->dht_handle != NULL); outstanding_gets++; @@ -462,8 +457,8 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) test_get->uid, test_get->daemon->shortname); #endif - test_get->disconnect_task = GNUNET_SCHEDULER_add_delayed(sched, GET_TIMEOUT, &get_stop_task, test_get); - GNUNET_SCHEDULER_add_now (sched, &do_get, test_get->next); + test_get->disconnect_task = GNUNET_SCHEDULER_add_delayed(GET_TIMEOUT, &get_stop_task, test_get); + GNUNET_SCHEDULER_add_now (&do_get, test_get->next); } /** @@ -477,12 +472,12 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) outstanding_puts--; puts_completed++; - GNUNET_SCHEDULER_cancel(sched, test_put->disconnect_task); - test_put->disconnect_task = GNUNET_SCHEDULER_add_now(sched, &put_disconnect_task, test_put); + GNUNET_SCHEDULER_cancel(test_put->disconnect_task); + test_put->disconnect_task = GNUNET_SCHEDULER_add_now(&put_disconnect_task, test_put); if (puts_completed == num_puts) { GNUNET_assert(outstanding_puts == 0); - GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), &do_get, all_gets); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), &do_get, all_gets); return; } } @@ -505,7 +500,7 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) if (outstanding_puts > MAX_OUTSTANDING_PUTS) { - GNUNET_SCHEDULER_add_delayed (sched, PUT_DELAY, &do_put, test_put); + GNUNET_SCHEDULER_add_delayed (PUT_DELAY, &do_put, test_put); return; } @@ -514,7 +509,7 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) test_put->uid, test_put->daemon->shortname); #endif - test_put->dht_handle = GNUNET_DHT_connect(sched, test_put->daemon->cfg, 10); + test_put->dht_handle = GNUNET_DHT_connect(test_put->daemon->cfg, 10); GNUNET_assert(test_put->dht_handle != NULL); outstanding_puts++; @@ -526,8 +521,8 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_FOREVER_REL, &put_finished, test_put); - test_put->disconnect_task = GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_get_forever(), &put_disconnect_task, test_put); - GNUNET_SCHEDULER_add_now(sched, &do_put, test_put->next); + test_put->disconnect_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_get_forever(), &put_disconnect_task, test_put); + GNUNET_SCHEDULER_add_now(&do_put, test_put->next); } @@ -568,7 +563,7 @@ setup_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) all_gets = test_get; } - GNUNET_SCHEDULER_add_now (sched, &do_put, all_puts); + GNUNET_SCHEDULER_add_now (&do_put, all_puts); } @@ -619,17 +614,16 @@ topology_callback (void *cls, "Created %d total connections, which is our target number! Starting next phase of testing.\n", total_connections); #endif - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_delayed (sched, TIMEOUT, + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from setup puts/gets"); - GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &setup_puts_and_gets, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &setup_puts_and_gets, NULL); } else if (total_connections + failed_connections == expected_connections) { - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from topology_callback (too many failed connections)"); + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many failed connections)"); } } @@ -661,7 +655,7 @@ peers_started_callback (void *cls, "All %d daemons started, now connecting peers!\n", num_peers); #endif - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); expected_connections = -1; if ((pg != NULL) && (peers_left == 0)) @@ -675,12 +669,10 @@ peers_started_callback (void *cls, if (expected_connections == GNUNET_SYSERR) { - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from connect topology (bad return)"); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)"); } - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from connect topology (timeout)"); ok = 0; @@ -701,13 +693,11 @@ create_topology () } else { - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from create topology (bad return)"); + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from create topology (bad return)"); } - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from continue startup (timeout)"); } @@ -744,13 +734,12 @@ void hostkey_callback (void *cls, "All %d hostkeys created, now creating topology!\n", num_peers); #endif - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from create_topology"); - GNUNET_SCHEDULER_add_now(sched, &create_topology, NULL); + GNUNET_SCHEDULER_add_now(&create_topology, NULL); ok = 0; } } @@ -758,7 +747,6 @@ void hostkey_callback (void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { @@ -767,7 +755,6 @@ run (void *cls, char * blacklist_topology_str; char * connect_topology_option_str; char * connect_topology_option_modifier_string; - sched = s; /* Get path from configuration file */ if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string(cfg, "paths", "servicehome", &test_directory)) @@ -851,11 +838,10 @@ run (void *cls, peers_left = num_peers; /* Set up a task to end testing if peer start fails */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), &end_badly, "didn't generate all hostkeys within a reasonable amount of time!!!"); - pg = GNUNET_TESTING_daemons_start (sched, cfg, + pg = GNUNET_TESTING_daemons_start (cfg, peers_left, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), &hostkey_callback, NULL, &peers_started_callback, NULL, &topology_callback, NULL, NULL); diff --git a/src/dht/test_dht_twopeer.c b/src/dht/test_dht_twopeer.c index 06807f82a..6f3d5060d 100644 --- a/src/dht/test_dht_twopeer.c +++ b/src/dht/test_dht_twopeer.c @@ -62,8 +62,6 @@ static unsigned long long peers_left; static struct GNUNET_TESTING_PeerGroup *pg; -static struct GNUNET_SCHEDULER_Handle *sched; - static unsigned long long num_peers; static unsigned int total_gets; @@ -124,21 +122,21 @@ end_badly_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); if (curr_get_ctx.retry_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, curr_get_ctx.retry_task); + GNUNET_SCHEDULER_cancel(curr_get_ctx.retry_task); } static void end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) { if (curr_get_ctx.retry_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, curr_get_ctx.retry_task); + GNUNET_SCHEDULER_cancel(curr_get_ctx.retry_task); if (curr_get_ctx.get_handle != NULL) { GNUNET_DHT_get_stop(curr_get_ctx.get_handle); } - GNUNET_SCHEDULER_add_now (sched, &end_badly_cont, NULL); + GNUNET_SCHEDULER_add_now (&end_badly_cont, NULL); ok = 1; } @@ -171,14 +169,14 @@ void get_result_iterator (void *cls, if (0 != memcmp(&get_context->peer->hashPubKey, key, sizeof (GNUNET_HashCode))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Key returned is not the same key as was searched for!\n"); - GNUNET_SCHEDULER_cancel(sched, die_task); - GNUNET_SCHEDULER_add_now(sched, &end_badly, "key mismatch in get response!\n"); + GNUNET_SCHEDULER_cancel(die_task); + GNUNET_SCHEDULER_add_now(&end_badly, "key mismatch in get response!\n"); return; } if (get_context->retry_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(sched, get_context->retry_task); + GNUNET_SCHEDULER_cancel(get_context->retry_task); get_context->retry_task = GNUNET_SCHEDULER_NO_TASK; } @@ -188,14 +186,14 @@ void get_result_iterator (void *cls, get_context->dht_handle = peer2dht; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received first correct GET request response!\n"); GNUNET_DHT_get_stop(get_context->get_handle); - GNUNET_SCHEDULER_add_now (sched, &do_get, get_context); + GNUNET_SCHEDULER_add_now (&do_get, get_context); } else { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received second correct GET request response!\n"); - GNUNET_SCHEDULER_cancel(sched, die_task); + GNUNET_SCHEDULER_cancel(die_task); GNUNET_DHT_get_stop(get_context->get_handle); - GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); + GNUNET_SCHEDULER_add_now (&finish_testing, NULL); } } @@ -213,14 +211,13 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) else { GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Too many attempts failed, ending test!\n", get_context->get_attempts); - GNUNET_SCHEDULER_cancel(sched, die_task); - GNUNET_SCHEDULER_add_now(sched, &end_badly, "key mismatch in get response!\n"); + GNUNET_SCHEDULER_cancel(die_task); + GNUNET_SCHEDULER_add_now(&end_badly, "key mismatch in get response!\n"); return; } get_context->get_attempts++; - get_context->retry_task = GNUNET_SCHEDULER_add_delayed(sched, - GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), - &stop_retry_get, get_context); + get_context->retry_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), + &stop_retry_get, get_context); get_context->get_handle = GNUNET_DHT_get_start(get_context->dht_handle, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), 0 /* fixme: use real type */, &get_context->peer->hashPubKey, @@ -238,7 +235,7 @@ stop_retry_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Get attempt %u failed, canceling request!\n", get_context->get_attempts); GNUNET_DHT_get_stop(get_context->get_handle); get_context->get_handle = NULL; - GNUNET_SCHEDULER_add_now(sched, &get_stop_finished, get_context); + GNUNET_SCHEDULER_add_now(&get_stop_finished, get_context); } static void @@ -246,8 +243,7 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) { struct PeerGetContext *get_context = cls; - get_context->retry_task = GNUNET_SCHEDULER_add_delayed(sched, - GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), + get_context->retry_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), &stop_retry_get, get_context); get_context->get_handle = GNUNET_DHT_get_start(get_context->dht_handle, @@ -299,20 +295,19 @@ topology_callback (void *cls, "Created %d total connections, which is our target number! Starting next phase of testing.\n", total_connections); #endif - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_delayed (sched, TIMEOUT, + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from test gets"); curr_get_ctx.dht_handle = peer1dht; curr_get_ctx.peer = &peer2id; - //GNUNET_SCHEDULER_add_now (sched, &do_get, &curr_get_ctx); - GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &do_get, &curr_get_ctx); + //GNUNET_SCHEDULER_add_now (&do_get, &curr_get_ctx); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &do_get, &curr_get_ctx); } else if (total_connections + failed_connections == expected_connections) { - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from topology_callback (too many failed connections)"); + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many failed connections)"); } } @@ -323,14 +318,12 @@ connect_topology (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) if ((pg != NULL) && (peers_left == 0)) expected_connections = GNUNET_TESTING_connect_topology (pg, GNUNET_TESTING_TOPOLOGY_CLIQUE, GNUNET_TESTING_TOPOLOGY_OPTION_ALL, 0.0, NULL, NULL); - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); if (expected_connections == GNUNET_SYSERR) - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from connect topology (bad return)"); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)"); - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from connect topology (timeout)"); } @@ -350,21 +343,21 @@ peers_started_callback (void *cls, if (peers_left == num_peers) { memcpy(&peer1id, id, sizeof(struct GNUNET_PeerIdentity)); - peer1dht = GNUNET_DHT_connect(sched, cfg, 100); + peer1dht = GNUNET_DHT_connect(cfg, 100); if (peer1dht == NULL) { - GNUNET_SCHEDULER_cancel (sched, die_task); - GNUNET_SCHEDULER_add_now(sched, &end_badly, "Failed to get dht handle!\n"); + GNUNET_SCHEDULER_cancel (die_task); + GNUNET_SCHEDULER_add_now(&end_badly, "Failed to get dht handle!\n"); } } else { memcpy(&peer2id, id, sizeof(struct GNUNET_PeerIdentity)); - peer2dht = GNUNET_DHT_connect(sched, cfg, 100); + peer2dht = GNUNET_DHT_connect(cfg, 100); if (peer2dht == NULL) { - GNUNET_SCHEDULER_cancel (sched, die_task); - GNUNET_SCHEDULER_add_now(sched, &end_badly, "Failed to get dht handle!\n"); + GNUNET_SCHEDULER_cancel (die_task); + GNUNET_SCHEDULER_add_now(&end_badly, "Failed to get dht handle!\n"); } } @@ -378,25 +371,22 @@ peers_started_callback (void *cls, "All %d daemons started, now connecting peers!\n", num_peers); #endif - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from peers_started_callback"); - GNUNET_SCHEDULER_add_now(sched, &connect_topology, NULL); + GNUNET_SCHEDULER_add_now(&connect_topology, NULL); ok = 0; } } static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { - sched = s; if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string(cfg, "paths", "servicehome", &test_directory)) { @@ -413,11 +403,10 @@ run (void *cls, total_gets = num_peers; gets_succeeded = 0; /* Set up a task to end testing if peer start fails */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "didn't start all daemons in reasonable amount of time!!!"); - pg = GNUNET_TESTING_daemons_start (sched, cfg, + pg = GNUNET_TESTING_daemons_start (cfg, num_peers, TIMEOUT, NULL, NULL, &peers_started_callback, NULL, &topology_callback, NULL, NULL); diff --git a/src/dht/test_dht_twopeer_put_get.c b/src/dht/test_dht_twopeer_put_get.c index b57faeb83..0f61f4930 100644 --- a/src/dht/test_dht_twopeer_put_get.c +++ b/src/dht/test_dht_twopeer_put_get.c @@ -80,10 +80,6 @@ static struct GNUNET_TESTING_PeerGroup *pg; */ struct GNUNET_DHT_GetHandle *global_get_handle; -/** - * Global scheduler, used for all GNUNET_SCHEDULER_* functions. - */ -static struct GNUNET_SCHEDULER_Handle *sched; /** * Total number of peers to run, set based on config file. @@ -190,7 +186,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) GNUNET_DHT_get_stop(global_get_handle); global_get_handle = NULL; } - GNUNET_SCHEDULER_add_now(sched, &end_badly_cont, NULL); + GNUNET_SCHEDULER_add_now(&end_badly_cont, NULL); ok = 1; } @@ -221,15 +217,15 @@ void get_result_iterator (void *cls, if ((0 != memcmp(&original_key, key, sizeof (GNUNET_HashCode))) || (0 != memcmp(original_data, data, sizeof(original_data)))) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Key or data is not the same as was inserted!\n"); - GNUNET_SCHEDULER_cancel(sched, die_task); - GNUNET_SCHEDULER_add_now(sched, &end_badly, "key or data mismatch in get response!\n"); + GNUNET_SCHEDULER_cancel(die_task); + GNUNET_SCHEDULER_add_now(&end_badly, "key or data mismatch in get response!\n"); return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received correct GET response!\n"); - GNUNET_SCHEDULER_cancel(sched, die_task); + GNUNET_SCHEDULER_cancel(die_task); GNUNET_DHT_get_stop(global_get_handle); - GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); + GNUNET_SCHEDULER_add_now (&finish_testing, NULL); } /** @@ -256,10 +252,10 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) static void put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) { - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_delayed (sched, GET_TIMEOUT, + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, &end_badly, "waiting for get response (data not found)"); - GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), &do_get, NULL); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), &do_get, NULL); } /** @@ -331,17 +327,16 @@ topology_callback (void *cls, "Created %d total connections, which is our target number! Starting next phase of testing.\n", total_connections); #endif - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_delayed (sched, TIMEOUT, + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from test gets"); - GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &do_put, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &do_put, NULL); } else if (total_connections + failed_connections == expected_connections) { - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from topology_callback (too many failed connections)"); + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many failed connections)"); } } @@ -375,21 +370,21 @@ peers_started_callback (void *cls, if (peers_left == num_peers) { memcpy(&peer1id, id, sizeof(struct GNUNET_PeerIdentity)); /* Save the peer id */ - peer1dht = GNUNET_DHT_connect(sched, cfg, 100); /* Connect to the first peers DHT service */ + peer1dht = GNUNET_DHT_connect(cfg, 100); /* Connect to the first peers DHT service */ if (peer1dht == NULL) /* If DHT connect failed */ { - GNUNET_SCHEDULER_cancel (sched, die_task); - GNUNET_SCHEDULER_add_now(sched, &end_badly, "Failed to get dht handle!\n"); + GNUNET_SCHEDULER_cancel (die_task); + GNUNET_SCHEDULER_add_now(&end_badly, "Failed to get dht handle!\n"); } } else /* This is the second peer started */ { memcpy(&peer2id, id, sizeof(struct GNUNET_PeerIdentity)); /* Same as for first peer... */ - peer2dht = GNUNET_DHT_connect(sched, cfg, 100); + peer2dht = GNUNET_DHT_connect(cfg, 100); if (peer2dht == NULL) { - GNUNET_SCHEDULER_cancel (sched, die_task); - GNUNET_SCHEDULER_add_now(sched, &end_badly, "Failed to get dht handle!\n"); + GNUNET_SCHEDULER_cancel (die_task); + GNUNET_SCHEDULER_add_now(&end_badly, "Failed to get dht handle!\n"); } } @@ -411,14 +406,12 @@ peers_started_callback (void *cls, } /* Cancel current timeout fail task */ - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); if (expected_connections == GNUNET_SYSERR) /* Some error happened */ - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from connect topology (bad return)"); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)"); /* Schedule timeout on failure task */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from connect topology (timeout)"); ok = 0; } @@ -426,11 +419,9 @@ peers_started_callback (void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { - sched = s; /* Get path from configuration file */ if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string(cfg, "paths", "servicehome", &test_directory)) @@ -449,13 +440,12 @@ run (void *cls, peers_left = num_peers; /* Set up a task to end testing if peer start fails */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "didn't start all daemons in reasonable amount of time!!!"); /* Start num_peers peers, call peers_started_callback on peer start, topology_callback on peer connect */ /* Read the API documentation for other parameters! */ - pg = GNUNET_TESTING_daemons_start (sched, cfg, + pg = GNUNET_TESTING_daemons_start (cfg, num_peers, TIMEOUT, NULL, NULL, &peers_started_callback, NULL, &topology_callback, NULL, NULL); diff --git a/src/dht/test_dhtlog.c b/src/dht/test_dhtlog.c index 667bf3d2a..06e2db2c4 100644 --- a/src/dht/test_dhtlog.c +++ b/src/dht/test_dhtlog.c @@ -190,7 +190,6 @@ test (struct GNUNET_DHTLOG_Handle * api) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) diff --git a/src/dv/dv.h b/src/dv/dv.h index 9916e1056..10b531ced 100644 --- a/src/dv/dv.h +++ b/src/dv/dv.h @@ -258,8 +258,7 @@ typedef struct struct GNUNET_DV_Handle * -GNUNET_DV_connect (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_DV_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_DV_MessageReceivedHandler receive_handler, void *receive_handler_cls); diff --git a/src/dv/dv_api.c b/src/dv/dv_api.c index d9aef03c8..28c66af41 100644 --- a/src/dv/dv_api.c +++ b/src/dv/dv_api.c @@ -65,10 +65,6 @@ struct PendingMessages */ struct GNUNET_DV_Handle { - /** - * Our scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; /** * Configuration to use. @@ -175,7 +171,7 @@ try_connect (struct GNUNET_DV_Handle *ret) { if (ret->client != NULL) return GNUNET_OK; - ret->client = GNUNET_CLIENT_connect (ret->sched, "dv", ret->cfg); + ret->client = GNUNET_CLIENT_connect ("dv", ret->cfg); if (ret->client != NULL) return GNUNET_YES; #if DEBUG_DV_MESSAGES @@ -529,7 +525,6 @@ transmit_start (void *cls, size_t size, void *buf) /** * Connect to the DV service * - * @param sched the scheduler to use * @param cfg the configuration to use * @param receive_handler method call when on receipt from the service * @param receive_handler_cls closure for receive_handler @@ -537,8 +532,7 @@ transmit_start (void *cls, size_t size, void *buf) * @return handle to the DV service */ struct GNUNET_DV_Handle * -GNUNET_DV_connect (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_DV_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_DV_MessageReceivedHandler receive_handler, void *receive_handler_cls) { @@ -548,11 +542,10 @@ GNUNET_DV_connect (struct GNUNET_SCHEDULER_Handle *sched, handle = GNUNET_malloc(sizeof(struct GNUNET_DV_Handle)); handle->cfg = cfg; - handle->sched = sched; handle->pending_list = NULL; handle->current = NULL; handle->th = NULL; - handle->client = GNUNET_CLIENT_connect(sched, "dv", cfg); + handle->client = GNUNET_CLIENT_connect("dv", cfg); handle->receive_handler = receive_handler; handle->receive_cls = receive_handler_cls; diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c index 2d91bce41..cfc1cd2d1 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c @@ -565,10 +565,6 @@ static struct GNUNET_PeerIdentity my_identity; */ static const struct GNUNET_CONFIGURATION_Handle *cfg; -/** - * The scheduler for this service. - */ -static struct GNUNET_SCHEDULER_Handle *sched; /** * The client, the DV plugin connected to us. Hopefully @@ -944,7 +940,7 @@ size_t core_transmit_notify (void *cls, } /*reply = core_pending_head;*/ - GNUNET_SCHEDULER_add_now(sched, &try_core_send, NULL); + GNUNET_SCHEDULER_add_now(&try_core_send, NULL); /*if (reply != NULL) core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, reply->importance, reply->timeout, &reply->recipient, reply->msg_size, &core_transmit_notify, NULL);*/ @@ -1043,7 +1039,7 @@ send_message_via (const struct GNUNET_PeerIdentity *sender, core_pending_tail, pending_message); - GNUNET_SCHEDULER_add_now(sched, try_core_send, NULL); + GNUNET_SCHEDULER_add_now(try_core_send, NULL); return GNUNET_YES; } @@ -1199,7 +1195,7 @@ send_message (const struct GNUNET_PeerIdentity * recipient, GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Notifying core of send size %d to destination `%s'\n", "DV SEND MESSAGE", msg_size, GNUNET_i2s(recipient)); #endif - GNUNET_SCHEDULER_add_now(sched, try_core_send, NULL); + GNUNET_SCHEDULER_add_now(try_core_send, NULL); return (int) cost; } @@ -1514,7 +1510,7 @@ static int handle_dv_data_message (void *cls, memcpy(delayed_context->message, packed_message, packed_message_size); delayed_context->message_size = packed_message_size; delayed_context->uid = ntohl(incoming->uid); - GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 2500), &send_message_delayed, delayed_context); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 2500), &send_message_delayed, delayed_context); return GNUNET_OK; } else @@ -1669,7 +1665,7 @@ neighbor_send_task (void *cls, core_pending_tail, pending_message); - GNUNET_SCHEDULER_add_now(sched, try_core_send, NULL); + GNUNET_SCHEDULER_add_now(try_core_send, NULL); /*if (core_transmit_handle == NULL) core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, default_dv_priority, GNUNET_TIME_relative_get_forever(), &to->identity, sizeof(p2p_dv_MESSAGE_NeighborInfo), &core_transmit_notify, NULL);*/ @@ -1680,14 +1676,14 @@ neighbor_send_task (void *cls, #if DEBUG_DV_PEER_NUMBERS GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "DV SERVICE: still in fast send mode\n"); #endif - send_context->task = GNUNET_SCHEDULER_add_now(sched, &neighbor_send_task, send_context); + send_context->task = GNUNET_SCHEDULER_add_now(&neighbor_send_task, send_context); } else { #if DEBUG_DV_PEER_NUMBERS GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "DV SERVICE: entering slow send mode\n"); #endif - send_context->task = GNUNET_SCHEDULER_add_delayed(sched, GNUNET_DV_DEFAULT_SEND_INTERVAL, &neighbor_send_task, send_context); + send_context->task = GNUNET_SCHEDULER_add_delayed(GNUNET_DV_DEFAULT_SEND_INTERVAL, &neighbor_send_task, send_context); } return; @@ -1994,7 +1990,7 @@ direct_neighbor_free (struct DirectNeighbor *direct) send_context = direct->send_context; if (send_context->task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, send_context->task); + GNUNET_SCHEDULER_cancel(send_context->task); about_list = send_context->fast_gossip_list_head; while (about_list != NULL) @@ -2047,7 +2043,7 @@ static int schedule_disconnect_messages (void *cls, core_pending_tail, pending_message); - GNUNET_SCHEDULER_add_now(sched, try_core_send, NULL); + GNUNET_SCHEDULER_add_now(try_core_send, NULL); /*if (core_transmit_handle == NULL) core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, default_dv_priority, GNUNET_TIME_relative_get_forever(), ¬ify->identity, sizeof(p2p_dv_MESSAGE_Disconnect), &core_transmit_notify, NULL);*/ @@ -2133,8 +2129,8 @@ void core_init (void *cls, if (server == NULL) { - GNUNET_SCHEDULER_cancel(sched, cleanup_task); - GNUNET_SCHEDULER_add_now(sched, &shutdown_task, NULL); + GNUNET_SCHEDULER_cancel(cleanup_task); + GNUNET_SCHEDULER_add_now(&shutdown_task, NULL); return; } #if DEBUG_DV @@ -2265,9 +2261,9 @@ static int add_distant_all_direct_neighbors (void *cls, GNUNET_free(encPeerTo); #endif /*if (send_context->task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, send_context->task);*/ + GNUNET_SCHEDULER_cancel(send_context->task);*/ - send_context->task = GNUNET_SCHEDULER_add_now(sched, &neighbor_send_task, send_context); + send_context->task = GNUNET_SCHEDULER_add_now(&neighbor_send_task, send_context); return GNUNET_YES; } @@ -2673,9 +2669,9 @@ static int gossip_all_to_all_iterator (void *cls, GNUNET_CONTAINER_multihashmap_iterate (extended_neighbors, &add_all_extended_peers, direct->send_context); if (direct->send_context->task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, direct->send_context->task); + GNUNET_SCHEDULER_cancel(direct->send_context->task); - direct->send_context->task = GNUNET_SCHEDULER_add_now(sched, &neighbor_send_task, direct->send_context); + direct->send_context->task = GNUNET_SCHEDULER_add_now(&neighbor_send_task, direct->send_context); return GNUNET_YES; } @@ -2691,8 +2687,7 @@ gossip_all_to_all (void *cls, { GNUNET_CONTAINER_multihashmap_iterate (direct_neighbors, &gossip_all_to_all_iterator, NULL); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), &gossip_all_to_all, NULL); @@ -2749,9 +2744,9 @@ static int add_all_direct_neighbors (void *cls, send_context->fast_gossip_list_tail, gossip_entry); if (send_context->task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, send_context->task); + GNUNET_SCHEDULER_cancel(send_context->task); - send_context->task = GNUNET_SCHEDULER_add_now(sched, &neighbor_send_task, send_context); + send_context->task = GNUNET_SCHEDULER_add_now(&neighbor_send_task, send_context); //tc.reason = GNUNET_SCHEDULER_REASON_TIMEOUT; //neighbor_send_task(send_context, &tc); return GNUNET_YES; @@ -2827,7 +2822,7 @@ process_peerinfo (void *cls, GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Gossipped about %s to %d direct peers\n", GNUNET_i2s(&my_identity), neighbor_pid, sent); GNUNET_free(neighbor_pid); #endif - neighbor->send_context->task = GNUNET_SCHEDULER_add_now(sched, &neighbor_send_task, neighbor->send_context); + neighbor->send_context->task = GNUNET_SCHEDULER_add_now(&neighbor_send_task, neighbor->send_context); } } @@ -2951,7 +2946,7 @@ void handle_core_disconnect (void *cls, GNUNET_break(0); } if ((neighbor->send_context != NULL) && (neighbor->send_context->task != GNUNET_SCHEDULER_NO_TASK)) - GNUNET_SCHEDULER_cancel(sched, neighbor->send_context->task); + GNUNET_SCHEDULER_cancel(neighbor->send_context->task); GNUNET_free (neighbor); } @@ -2960,18 +2955,15 @@ void handle_core_disconnect (void *cls, * Process dv requests. * * @param cls closure - * @param scheduler scheduler to use * @param server the initialized server * @param c configuration to use */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *scheduler, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { unsigned long long max_hosts; - sched = scheduler; cfg = c; /* FIXME: Read from config, or calculate, or something other than this! */ @@ -3000,8 +2992,7 @@ run (void *cls, GNUNET_SERVER_add_handlers (server, plugin_handlers); coreAPI = - GNUNET_CORE_connect (sched, - cfg, + GNUNET_CORE_connect (cfg, GNUNET_TIME_relative_get_forever(), NULL, /* FIXME: anything we want to pass around? */ &core_init, @@ -3020,7 +3011,7 @@ run (void *cls, coreMST = GNUNET_SERVER_mst_create (&tokenized_message_handler, NULL); - peerinfo_handle = GNUNET_PEERINFO_connect(sched, cfg); + peerinfo_handle = GNUNET_PEERINFO_connect(cfg); if (peerinfo_handle == NULL) { @@ -3029,8 +3020,7 @@ run (void *cls, } /* Scheduled the task to clean up when shutdown is called */ - cleanup_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + cleanup_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); } diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c index 41f3a5140..b7616d2ac 100644 --- a/src/dv/plugin_transport_dv.c +++ b/src/dv/plugin_transport_dv.c @@ -389,7 +389,7 @@ libgnunet_plugin_transport_dv_init (void *cls) plugin = GNUNET_malloc (sizeof (struct Plugin)); plugin->env = env; - plugin->dv_handle = GNUNET_DV_connect(env->sched, env->cfg, &handle_dv_message_received, plugin); + plugin->dv_handle = GNUNET_DV_connect(env->cfg, &handle_dv_message_received, plugin); if (plugin->dv_handle == NULL) { diff --git a/src/dv/test_transport_api_dv.c b/src/dv/test_transport_api_dv.c index d38f378ba..f53aa48f9 100644 --- a/src/dv/test_transport_api_dv.c +++ b/src/dv/test_transport_api_dv.c @@ -75,8 +75,6 @@ static unsigned long long peers_left; static struct GNUNET_TESTING_PeerGroup *pg; -static struct GNUNET_SCHEDULER_Handle *sched; - const struct GNUNET_CONFIGURATION_Handle *main_cfg; GNUNET_SCHEDULER_TaskIdentifier die_task; @@ -231,7 +229,7 @@ finish_testing () pos = pos->next; if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(sched, free_pos->disconnect_task); + GNUNET_SCHEDULER_cancel(free_pos->disconnect_task); } GNUNET_free(free_pos); } @@ -253,7 +251,7 @@ finish_testing () pos = pos->next; if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(sched, free_pos->disconnect_task); + GNUNET_SCHEDULER_cancel(free_pos->disconnect_task); } GNUNET_free(free_pos); } @@ -364,7 +362,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) pos = pos->next; if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(sched, free_pos->disconnect_task); + GNUNET_SCHEDULER_cancel(free_pos->disconnect_task); } GNUNET_free(free_pos); } @@ -423,28 +421,27 @@ process_mtype (void *cls, if ((total_messages_received == expected_messages) && (total_other_messages == 0)) { - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TEST_TIMEOUT, + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, "waiting for DV peers to connect!"); /* if ((num_peers == 3) && (total_other_expected_messages == 2)) { - GNUNET_SCHEDULER_add_now (sched, &send_other_messages, NULL); + GNUNET_SCHEDULER_add_now (&send_other_messages, NULL); } else { - GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20), &send_other_messages, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20), &send_other_messages, NULL); }*/ } else if ((total_other_expected_messages > 0) && (total_other_messages == total_other_expected_messages)) { - GNUNET_SCHEDULER_cancel (sched, die_task); - GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); + GNUNET_SCHEDULER_cancel (die_task); + GNUNET_SCHEDULER_add_now (&finish_testing, NULL); } else { - pos->disconnect_task = GNUNET_SCHEDULER_add_now(sched, &disconnect_cores, pos); + pos->disconnect_task = GNUNET_SCHEDULER_add_now(&disconnect_cores, pos); } return GNUNET_OK; @@ -531,8 +528,7 @@ init_notify_peer1 (void *cls, /* * Connect to the receiving peer */ - pos->peer2handle = GNUNET_CORE_connect (sched, - pos->peer2->cfg, + pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg, TIMEOUT, pos, &init_notify_peer2, @@ -554,14 +550,13 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) if (die_task == GNUNET_SCHEDULER_NO_TASK) { - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TEST_TIMEOUT, + die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, "from create topology (timeout)"); } if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) { - GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), &send_test_messages, pos); return; /* Otherwise we'll double schedule messages here! */ } @@ -571,8 +566,7 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) /* * Connect to the sending peer */ - pos->peer1handle = GNUNET_CORE_connect (sched, - pos->peer1->cfg, + pos->peer1handle = GNUNET_CORE_connect (pos->peer1->cfg, TIMEOUT, pos, &init_notify_peer1, @@ -585,12 +579,11 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS) { - GNUNET_SCHEDULER_add_now (sched, - &send_test_messages, pos->next); + GNUNET_SCHEDULER_add_now (&send_test_messages, pos->next); } else { - GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), &send_test_messages, pos->next); } } @@ -652,7 +645,7 @@ send_other_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) pos = pos->next; if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(sched, free_pos->disconnect_task); + GNUNET_SCHEDULER_cancel(free_pos->disconnect_task); } GNUNET_free(free_pos); } @@ -661,15 +654,15 @@ send_other_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) total_other_expected_messages = temp_total_other_messages; if (total_other_expected_messages == 0) { - GNUNET_SCHEDULER_add_now (sched, &end_badly, "send_other_messages had 0 messages to send, no DV connections made!"); + GNUNET_SCHEDULER_add_now (&end_badly, "send_other_messages had 0 messages to send, no DV connections made!"); } #if VERBOSE GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Preparing to send %d other test messages\n", total_other_expected_messages); #endif - GNUNET_SCHEDULER_add_now (sched, &send_test_messages, other_test_messages); - GNUNET_SCHEDULER_cancel(sched, die_task); - die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 250), &end_badly, "from send_other_messages"); + GNUNET_SCHEDULER_add_now (&send_test_messages, other_test_messages); + GNUNET_SCHEDULER_cancel(die_task); + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 250), &end_badly, "from send_other_messages"); } void @@ -722,23 +715,22 @@ topology_callback (void *cls, total_connections); #endif - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); die_task = GNUNET_SCHEDULER_NO_TASK; - GNUNET_SCHEDULER_add_now (sched, &send_test_messages, test_messages); + GNUNET_SCHEDULER_add_now (&send_test_messages, test_messages); } else if (total_connections + failed_connections == expected_connections) { if (failed_connections < (unsigned int)(fail_percentage * total_connections)) { - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); die_task = GNUNET_SCHEDULER_NO_TASK; - GNUNET_SCHEDULER_add_now (sched, &send_test_messages, test_messages); + GNUNET_SCHEDULER_add_now (&send_test_messages, test_messages); } else { - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from topology_callback (too many failed connections)"); + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many failed connections)"); } } else @@ -764,15 +756,13 @@ connect_topology () #endif } - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); if (expected_connections == GNUNET_SYSERR) { - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from connect topology (bad return)"); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)"); } - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TEST_TIMEOUT, + die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, "from connect topology (timeout)"); } @@ -790,13 +780,11 @@ create_topology () } else { - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from create topology (bad return)"); + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from create topology (bad return)"); } - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TEST_TIMEOUT, + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, "from continue startup (timeout)"); } @@ -867,7 +855,7 @@ static void all_connect_handler (void *cls, if (temp_total_other_messages == num_additional_messages) { - GNUNET_SCHEDULER_add_now (sched, &send_other_messages, NULL); + GNUNET_SCHEDULER_add_now (&send_other_messages, NULL); } } @@ -892,7 +880,7 @@ peers_started_callback (void *cls, GNUNET_assert(GNUNET_SYSERR != GNUNET_CONTAINER_multihashmap_put(peer_daemon_hash, &id->hashPubKey, d, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); new_peer = GNUNET_malloc(sizeof(struct PeerContext)); - new_peer->peer_handle = GNUNET_CORE_connect(sched, cfg, GNUNET_TIME_UNIT_FOREVER_REL, d, NULL, &all_connect_handler, NULL, NULL, NULL, GNUNET_NO, NULL, GNUNET_NO, no_handlers); + new_peer->peer_handle = GNUNET_CORE_connect(cfg, GNUNET_TIME_UNIT_FOREVER_REL, d, NULL, &all_connect_handler, NULL, NULL, NULL, GNUNET_NO, NULL, GNUNET_NO, no_handlers); new_peer->daemon = d; new_peer->next = all_peers; all_peers = new_peer; @@ -905,11 +893,10 @@ peers_started_callback (void *cls, "All %d daemons started, now creating topology!\n", num_peers); #endif - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, "from peers_started_callback"); @@ -949,21 +936,19 @@ void hostkey_callback (void *cls, "All %d hostkeys created, now creating topology!\n", num_peers); #endif - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, "from hostkey_callback"); - GNUNET_SCHEDULER_add_now(sched, &create_topology, NULL); + GNUNET_SCHEDULER_add_now(&create_topology, NULL); ok = 0; } } static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { @@ -972,7 +957,6 @@ run (void *cls, char * blacklist_topology_str; char * connect_topology_option_str; char * connect_topology_option_modifier_string; - sched = s; ok = 1; dotOutFile = fopen (dotOutFileName, "w"); @@ -1062,13 +1046,12 @@ run (void *cls, peers_left = num_peers; /* Set up a task to end testing if peer start fails */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, "didn't start all daemons in reasonable amount of time!!!"); peer_daemon_hash = GNUNET_CONTAINER_multihashmap_create(peers_left); - pg = GNUNET_TESTING_daemons_start (sched, cfg, + pg = GNUNET_TESTING_daemons_start (cfg, peers_left, TIMEOUT, &hostkey_callback, NULL, &peers_started_callback, NULL, &topology_callback, NULL, NULL); diff --git a/src/fs/fs.c b/src/fs/fs.c index e144a0b89..736c3b026 100644 --- a/src/fs/fs.c +++ b/src/fs/fs.c @@ -40,7 +40,7 @@ static void start_job (struct GNUNET_FS_QueueEntry *qe) { - qe->client = GNUNET_CLIENT_connect (qe->h->sched, "fs", qe->h->cfg); + qe->client = GNUNET_CLIENT_connect ("fs", qe->h->cfg); if (qe->client == NULL) { GNUNET_break (0); @@ -138,8 +138,7 @@ process_job_queue (void *cls, continue; stop_job (qe); } - h->queue_job = GNUNET_SCHEDULER_add_delayed (h->sched, - restart_at, + h->queue_job = GNUNET_SCHEDULER_add_delayed (restart_at, &process_job_queue, h); } @@ -176,11 +175,9 @@ GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h, h->pending_tail, qe); if (h->queue_job != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (h->sched, - h->queue_job); + GNUNET_SCHEDULER_cancel (h->queue_job); h->queue_job - = GNUNET_SCHEDULER_add_now (h->sched, - &process_job_queue, + = GNUNET_SCHEDULER_add_now (&process_job_queue, h); return qe; } @@ -203,11 +200,9 @@ GNUNET_FS_dequeue_ (struct GNUNET_FS_QueueEntry *qh) qh); GNUNET_free (qh); if (h->queue_job != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (h->sched, - h->queue_job); + GNUNET_SCHEDULER_cancel (h->queue_job); h->queue_job - = GNUNET_SCHEDULER_add_now (h->sched, - &process_job_queue, + = GNUNET_SCHEDULER_add_now (&process_job_queue, h); } @@ -1449,8 +1444,7 @@ deserialize_publish_file (void *cls, if ( (0 == (pc->options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) && (GNUNET_YES != pc->all_done) ) { - pc->dsh = GNUNET_DATASTORE_connect (h->cfg, - h->sched); + pc->dsh = GNUNET_DATASTORE_connect (h->cfg); if (NULL == pc->dsh) goto cleanup; } @@ -1478,8 +1472,7 @@ deserialize_publish_file (void *cls, /* re-start publishing (if needed)... */ if (pc->all_done != GNUNET_YES) pc->upload_task - = GNUNET_SCHEDULER_add_with_priority (h->sched, - GNUNET_SCHEDULER_PRIORITY_BACKGROUND, + = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc); if (GNUNET_OK != @@ -2092,8 +2085,7 @@ deserialize_unindex_file (void *cls, switch (uc->state) { case UNINDEX_STATE_HASHING: - uc->fhc = GNUNET_CRYPTO_hash_file (uc->h->sched, - GNUNET_SCHEDULER_PRIORITY_IDLE, + uc->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, uc->filename, HASHING_BLOCKSIZE, &GNUNET_FS_unindex_process_hash_, @@ -2937,7 +2929,6 @@ deserialization_master (const char *master_path, /** * Setup a connection to the file-sharing service. * - * @param sched scheduler to use * @param cfg configuration to use * @param client_name unique identifier for this client * @param upcb function to call to notify about FS actions @@ -2947,8 +2938,7 @@ deserialization_master (const char *master_path, * @return NULL on error */ struct GNUNET_FS_Handle * -GNUNET_FS_start (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *client_name, GNUNET_FS_ProgressCallback upcb, void *upcb_cls, @@ -2960,7 +2950,6 @@ GNUNET_FS_start (struct GNUNET_SCHEDULER_Handle *sched, va_list ap; ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Handle)); - ret->sched = sched; ret->cfg = cfg; ret->client_name = GNUNET_strdup (client_name); ret->upcb = upcb; @@ -3021,8 +3010,7 @@ GNUNET_FS_stop (struct GNUNET_FS_Handle *h) while (h->top_head != NULL) h->top_head->ssf (h->top_head->ssf_cls); if (h->queue_job != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (h->sched, - h->queue_job); + GNUNET_SCHEDULER_cancel (h->queue_job); GNUNET_free (h->client_name); GNUNET_free (h); } diff --git a/src/fs/fs.h b/src/fs/fs.h index 68ed2184e..ccd949c59 100644 --- a/src/fs/fs.h +++ b/src/fs/fs.h @@ -1171,11 +1171,6 @@ GNUNET_FS_end_top (struct GNUNET_FS_Handle *h, */ struct GNUNET_FS_Handle { - /** - * Scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * Configuration to use. */ diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index b62620c3d..617e28103 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c @@ -1459,8 +1459,7 @@ do_reconnect (void *cls, struct GNUNET_CLIENT_Connection *client; dc->task = GNUNET_SCHEDULER_NO_TASK; - client = GNUNET_CLIENT_connect (dc->h->sched, - "fs", + client = GNUNET_CLIENT_connect ("fs", dc->h->cfg); if (NULL == client) { @@ -1543,8 +1542,7 @@ try_reconnect (struct GNUNET_FS_DownloadContext *dc) "Will try to reconnect in 1s\n"); #endif dc->task - = GNUNET_SCHEDULER_add_delayed (dc->h->sched, - GNUNET_TIME_UNIT_SECONDS, + = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_reconnect, dc); } @@ -1658,8 +1656,7 @@ GNUNET_FS_download_signal_suspend_ (void *cls) pi.status = GNUNET_FS_STATUS_DOWNLOAD_SUSPEND; GNUNET_FS_download_make_status_ (&pi, dc); if (GNUNET_SCHEDULER_NO_TASK != dc->task) - GNUNET_SCHEDULER_cancel (dc->h->sched, - dc->task); + GNUNET_SCHEDULER_cancel (dc->task); GNUNET_CONTAINER_multihashmap_iterate (dc->active, &free_entry, NULL); @@ -1992,8 +1989,7 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, pi.status = GNUNET_FS_STATUS_DOWNLOAD_STOPPED; GNUNET_FS_download_make_status_ (&pi, dc); if (GNUNET_SCHEDULER_NO_TASK != dc->task) - GNUNET_SCHEDULER_cancel (dc->h->sched, - dc->task); + GNUNET_SCHEDULER_cancel (dc->task); GNUNET_CONTAINER_multihashmap_iterate (dc->active, &free_entry, NULL); diff --git a/src/fs/fs_list_indexed.c b/src/fs/fs_list_indexed.c index 5850fd94e..fec127763 100644 --- a/src/fs/fs_list_indexed.c +++ b/src/fs/fs_list_indexed.c @@ -90,8 +90,7 @@ handle_index_info (void *cls, _("Failed to receive response for `%s' request from `%s' service.\n"), "GET_INDEXED", "fs"); - GNUNET_SCHEDULER_add_continuation (gic->h->sched, - gic->cont, + GNUNET_SCHEDULER_add_continuation (gic->cont, gic->cont_cls, GNUNET_SCHEDULER_REASON_TIMEOUT); GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO); @@ -101,8 +100,7 @@ handle_index_info (void *cls, if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_END) { /* normal end-of-list */ - GNUNET_SCHEDULER_add_continuation (gic->h->sched, - gic->cont, + GNUNET_SCHEDULER_add_continuation (gic->cont, gic->cont_cls, GNUNET_SCHEDULER_REASON_PREREQ_DONE); GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO); @@ -121,8 +119,7 @@ handle_index_info (void *cls, _("Failed to receive valid response for `%s' request from `%s' service.\n"), "GET_INDEXED", "fs"); - GNUNET_SCHEDULER_add_continuation (gic->h->sched, - gic->cont, + GNUNET_SCHEDULER_add_continuation (gic->cont, gic->cont_cls, GNUNET_SCHEDULER_REASON_TIMEOUT); GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO); @@ -134,8 +131,7 @@ handle_index_info (void *cls, filename, &iim->file_id)) { - GNUNET_SCHEDULER_add_continuation (gic->h->sched, - gic->cont, + GNUNET_SCHEDULER_add_continuation (gic->cont, gic->cont_cls, GNUNET_SCHEDULER_REASON_PREREQ_DONE); GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO); @@ -172,16 +168,14 @@ GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h, struct GetIndexedContext *gic; struct GNUNET_MessageHeader msg; - client = GNUNET_CLIENT_connect (h->sched, - "fs", + client = GNUNET_CLIENT_connect ("fs", h->cfg); if (NULL == client) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to not connect to `%s' service.\n"), "fs"); - GNUNET_SCHEDULER_add_continuation (h->sched, - cont, + GNUNET_SCHEDULER_add_continuation (cont, cont_cls, GNUNET_SCHEDULER_REASON_TIMEOUT); return; diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c index 5c1137eb7..91502e1de 100644 --- a/src/fs/fs_namespace.c +++ b/src/fs/fs_namespace.c @@ -264,11 +264,6 @@ struct AdvertisementContext */ struct GNUNET_DATASTORE_Handle *dsh; - /** - * Our scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * Our KSK URI. */ @@ -357,8 +352,7 @@ advertisement_cont (void *cls, if (GNUNET_OK != success) { /* error! */ - GNUNET_SCHEDULER_add_continuation (ac->sched, - &do_disconnect, + GNUNET_SCHEDULER_add_continuation (&do_disconnect, ac->dsh, GNUNET_SCHEDULER_REASON_PREREQ_DONE); if (ac->cont != NULL) @@ -373,8 +367,7 @@ advertisement_cont (void *cls, if (ac->pos == ac->ksk_uri->data.ksk.keywordCount) { /* done! */ - GNUNET_SCHEDULER_add_continuation (ac->sched, - &do_disconnect, + GNUNET_SCHEDULER_add_continuation (&do_disconnect, ac->dsh, GNUNET_SCHEDULER_REASON_PREREQ_DONE); if (ac->cont != NULL) @@ -501,7 +494,7 @@ GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h, nb->ns_purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK); nb->ksk_purpose.size = htonl (size - sizeof (struct GNUNET_CRYPTO_RsaSignature)); nb->ksk_purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG); - dsh = GNUNET_DATASTORE_connect (h->cfg, h->sched); + dsh = GNUNET_DATASTORE_connect (h->cfg); if (NULL == dsh) { GNUNET_free (nb); @@ -513,7 +506,6 @@ GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h, ctx->cont = cont; ctx->cont_cls = cont_cls; ctx->dsh = dsh; - ctx->sched = h->sched; ctx->ksk_uri = GNUNET_FS_uri_dup (ksk_uri); ctx->nb = nb; ctx->pt = pt; @@ -956,7 +948,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, NULL); return; } - psc->dsh = GNUNET_DATASTORE_connect (h->cfg, h->sched); + psc->dsh = GNUNET_DATASTORE_connect (h->cfg); if (NULL == psc->dsh) { GNUNET_free (sb_enc); diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index ad2258b16..5c1cd0ea2 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c @@ -154,8 +154,7 @@ ds_put_cont (void *cls, if (GNUNET_SYSERR == pcc->sc->in_network_wait) { /* we were aborted in the meantime, finish shutdown! */ - GNUNET_SCHEDULER_add_continuation (pcc->sc->h->sched, - &publish_cleanup, + GNUNET_SCHEDULER_add_continuation (&publish_cleanup, pcc->sc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); GNUNET_free (pcc); @@ -184,8 +183,7 @@ ds_put_cont (void *cls, } if (NULL != pcc->cont) pcc->sc->upload_task - = GNUNET_SCHEDULER_add_with_priority (pcc->sc->h->sched, - GNUNET_SCHEDULER_PRIORITY_BACKGROUND, + = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, pcc->cont, pcc->cont_cls); GNUNET_free (pcc); @@ -365,8 +363,7 @@ publish_kblocks_cont (void *cls, GNUNET_FS_file_information_sync_ (p); GNUNET_FS_publish_sync_ (pc); pc->upload_task - = GNUNET_SCHEDULER_add_with_priority (pc->h->sched, - GNUNET_SCHEDULER_PRIORITY_BACKGROUND, + = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc); return; @@ -384,8 +381,7 @@ publish_kblocks_cont (void *cls, pc->fi_pos = p->dir; GNUNET_FS_publish_sync_ (pc); pc->upload_task - = GNUNET_SCHEDULER_add_with_priority (pc->h->sched, - GNUNET_SCHEDULER_PRIORITY_BACKGROUND, + = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc); } @@ -498,8 +494,7 @@ encode_cont (void *cls, /* continue with main */ sc->upload_task - = GNUNET_SCHEDULER_add_with_priority (sc->h->sched, - GNUNET_SCHEDULER_PRIORITY_BACKGROUND, + = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, sc); } @@ -539,8 +534,7 @@ block_proc (void *cls, "Waiting for datastore connection\n"); #endif sc->upload_task - = GNUNET_SCHEDULER_add_with_priority (sc->h->sched, - GNUNET_SCHEDULER_PRIORITY_BACKGROUND, + = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, sc); return; @@ -841,8 +835,7 @@ hash_for_index_cb (void *cls, p->filename, GNUNET_h2s (res)); #endif - client = GNUNET_CLIENT_connect (sc->h->sched, - "fs", + client = GNUNET_CLIENT_connect ("fs", sc->h->cfg); if (NULL == client) { @@ -1038,8 +1031,7 @@ GNUNET_FS_publish_main_ (void *cls, else { p->start_time = GNUNET_TIME_absolute_get (); - pc->fhc = GNUNET_CRYPTO_hash_file (pc->h->sched, - GNUNET_SCHEDULER_PRIORITY_IDLE, + pc->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, p->filename, HASHING_BLOCKSIZE, &hash_for_index_cb, @@ -1180,7 +1172,7 @@ GNUNET_FS_publish_signal_suspend_ (void *cls) if (GNUNET_SCHEDULER_NO_TASK != pc->upload_task) { - GNUNET_SCHEDULER_cancel (pc->h->sched, pc->upload_task); + GNUNET_SCHEDULER_cancel (pc->upload_task); pc->upload_task = GNUNET_SCHEDULER_NO_TASK; } GNUNET_FS_file_information_inspect (pc->fi, @@ -1220,8 +1212,7 @@ finish_reserve (void *cls, } pc->rid = success; pc->upload_task - = GNUNET_SCHEDULER_add_with_priority (pc->h->sched, - GNUNET_SCHEDULER_PRIORITY_BACKGROUND, + = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc); } @@ -1254,8 +1245,7 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, GNUNET_assert (NULL != h); if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) { - dsh = GNUNET_DATASTORE_connect (h->cfg, - h->sched); + dsh = GNUNET_DATASTORE_connect (h->cfg); if (NULL == dsh) return NULL; } @@ -1301,8 +1291,7 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, else { ret->upload_task - = GNUNET_SCHEDULER_add_with_priority (h->sched, - GNUNET_SCHEDULER_PRIORITY_BACKGROUND, + = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, ret); } @@ -1382,7 +1371,7 @@ GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *pc) } if (GNUNET_SCHEDULER_NO_TASK != pc->upload_task) { - GNUNET_SCHEDULER_cancel (pc->h->sched, pc->upload_task); + GNUNET_SCHEDULER_cancel (pc->upload_task); pc->upload_task = GNUNET_SCHEDULER_NO_TASK; } if (pc->serialization != NULL) @@ -1524,8 +1513,7 @@ kb_put_cont (void *cls, GNUNET_free (pkc); return; } - GNUNET_SCHEDULER_add_continuation (pkc->h->sched, - &publish_ksk_cont, + GNUNET_SCHEDULER_add_continuation (&publish_ksk_cont, pkc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -1649,8 +1637,7 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h, pkc->cont_cls = cont_cls; if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) { - pkc->dsh = GNUNET_DATASTORE_connect (h->cfg, - h->sched); + pkc->dsh = GNUNET_DATASTORE_connect (h->cfg); if (pkc->dsh == NULL) { cont (cont_cls, NULL, _("Could not connect to datastore.")); @@ -1703,8 +1690,7 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h, pkc->slen); pkc->cpy->purpose.purpose = htonl(GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK); pkc->ksk_uri = GNUNET_FS_uri_dup (ksk_uri); - GNUNET_SCHEDULER_add_continuation (h->sched, - &publish_ksk_cont, + GNUNET_SCHEDULER_add_continuation (&publish_ksk_cont, pkc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c index 16e1dd1d5..1ffd681aa 100644 --- a/src/fs/fs_search.c +++ b/src/fs/fs_search.c @@ -279,32 +279,27 @@ GNUNET_FS_search_probe_progress_ (void *cls, case GNUNET_FS_STATUS_DOWNLOAD_ERROR: if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sr->sc->h->sched, - sr->probe_cancel_task); + GNUNET_SCHEDULER_cancel (sr->probe_cancel_task); sr->probe_cancel_task = GNUNET_SCHEDULER_NO_TASK; } - sr->probe_cancel_task = GNUNET_SCHEDULER_add_delayed (sr->sc->h->sched, - sr->remaining_probe_time, + sr->probe_cancel_task = GNUNET_SCHEDULER_add_delayed (sr->remaining_probe_time, &probe_failure_handler, sr); break; case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sr->sc->h->sched, - sr->probe_cancel_task); + GNUNET_SCHEDULER_cancel (sr->probe_cancel_task); sr->probe_cancel_task = GNUNET_SCHEDULER_NO_TASK; } - sr->probe_cancel_task = GNUNET_SCHEDULER_add_delayed (sr->sc->h->sched, - sr->remaining_probe_time, + sr->probe_cancel_task = GNUNET_SCHEDULER_add_delayed (sr->remaining_probe_time, &probe_success_handler, sr); break; case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sr->sc->h->sched, - sr->probe_cancel_task); + GNUNET_SCHEDULER_cancel (sr->probe_cancel_task); sr->probe_cancel_task = GNUNET_SCHEDULER_NO_TASK; } sr = NULL; @@ -312,16 +307,14 @@ GNUNET_FS_search_probe_progress_ (void *cls, case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: GNUNET_assert (sr->probe_cancel_task == GNUNET_SCHEDULER_NO_TASK); sr->probe_active_time = GNUNET_TIME_absolute_get (); - sr->probe_cancel_task = GNUNET_SCHEDULER_add_delayed (sr->sc->h->sched, - sr->remaining_probe_time, + sr->probe_cancel_task = GNUNET_SCHEDULER_add_delayed (sr->remaining_probe_time, &probe_failure_handler, sr); break; case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE: if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sr->sc->h->sched, - sr->probe_cancel_task); + GNUNET_SCHEDULER_cancel (sr->probe_cancel_task); sr->probe_cancel_task = GNUNET_SCHEDULER_NO_TASK; } dur = GNUNET_TIME_absolute_get_duration (sr->probe_active_time); @@ -1022,8 +1015,7 @@ do_reconnect (void *cls, size_t size; sc->task = GNUNET_SCHEDULER_NO_TASK; - client = GNUNET_CLIENT_connect (sc->h->sched, - "fs", + client = GNUNET_CLIENT_connect ("fs", sc->h->cfg); if (NULL == client) { @@ -1060,8 +1052,7 @@ try_reconnect (struct GNUNET_FS_SearchContext *sc) sc->client = NULL; } sc->task - = GNUNET_SCHEDULER_add_delayed (sc->h->sched, - GNUNET_TIME_UNIT_SECONDS, + = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_reconnect, sc); } @@ -1176,8 +1167,7 @@ GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc) &sc->requests[i].key); } } - sc->client = GNUNET_CLIENT_connect (sc->h->sched, - "fs", + sc->client = GNUNET_CLIENT_connect ("fs", sc->h->cfg); if (NULL == sc->client) return GNUNET_SYSERR; @@ -1204,8 +1194,6 @@ search_result_freeze_probes (void *cls, const GNUNET_HashCode * key, void *value) { - struct GNUNET_FS_SearchContext *sc = cls; - struct GNUNET_FS_Handle *h = sc->h; struct GNUNET_FS_SearchResult *sr = value; if (sr->probe_ctx != NULL) @@ -1215,8 +1203,7 @@ search_result_freeze_probes (void *cls, } if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (h->sched, - sr->probe_cancel_task); + GNUNET_SCHEDULER_cancel (sr->probe_cancel_task); sr->probe_cancel_task = GNUNET_SCHEDULER_NO_TASK; } if (sr->update_search != NULL) @@ -1261,7 +1248,6 @@ search_result_suspend (void *cls, void *value) { struct GNUNET_FS_SearchContext *sc = cls; - struct GNUNET_FS_Handle *h = sc->h; struct GNUNET_FS_SearchResult *sr = value; struct GNUNET_FS_ProgressInfo pi; @@ -1281,8 +1267,7 @@ search_result_suspend (void *cls, if (sr->probe_ctx != NULL) GNUNET_FS_download_stop (sr->probe_ctx, GNUNET_YES); if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (h->sched, - sr->probe_cancel_task); + GNUNET_SCHEDULER_cancel (sr->probe_cancel_task); GNUNET_free (sr); return GNUNET_OK; } @@ -1309,8 +1294,7 @@ GNUNET_FS_search_signal_suspend_ (void *cls) sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc); GNUNET_break (NULL == sc->client_info); if (sc->task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sc->h->sched, - sc->task); + GNUNET_SCHEDULER_cancel (sc->task); if (NULL != sc->client) GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO); GNUNET_CONTAINER_multihashmap_destroy (sc->master_result_map); @@ -1366,8 +1350,7 @@ GNUNET_FS_search_pause (struct GNUNET_FS_SearchContext *sc) struct GNUNET_FS_ProgressInfo pi; if (sc->task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sc->h->sched, - sc->task); + GNUNET_SCHEDULER_cancel (sc->task); sc->task = GNUNET_SCHEDULER_NO_TASK; if (NULL != sc->client) GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO); @@ -1417,7 +1400,6 @@ search_result_free (void *cls, void *value) { struct GNUNET_FS_SearchContext *sc = cls; - struct GNUNET_FS_Handle *h = sc->h; struct GNUNET_FS_SearchResult *sr = value; struct GNUNET_FS_ProgressInfo pi; @@ -1458,8 +1440,7 @@ search_result_free (void *cls, if (sr->probe_ctx != NULL) GNUNET_FS_download_stop (sr->probe_ctx, GNUNET_YES); if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (h->sched, - sr->probe_cancel_task); + GNUNET_SCHEDULER_cancel (sr->probe_cancel_task); GNUNET_free (sr); return GNUNET_OK; } @@ -1501,8 +1482,7 @@ GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc) sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc); GNUNET_break (NULL == sc->client_info); if (sc->task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sc->h->sched, - sc->task); + GNUNET_SCHEDULER_cancel (sc->task); if (NULL != sc->client) GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO); GNUNET_CONTAINER_multihashmap_destroy (sc->master_result_map); diff --git a/src/fs/fs_test_lib.c b/src/fs/fs_test_lib.c index f91092c4e..b7f3cb55a 100644 --- a/src/fs/fs_test_lib.c +++ b/src/fs/fs_test_lib.c @@ -71,11 +71,6 @@ struct GNUNET_FS_TestDaemon */ struct GNUNET_PeerIdentity id; - /** - * Scheduler to use (for publish_cont). - */ - struct GNUNET_SCHEDULER_Handle *publish_sched; - /** * Function to call when upload is done. */ @@ -111,11 +106,6 @@ struct GNUNET_FS_TestDaemon */ char *publish_tmp_file; - /** - * Scheduler to use (for download_cont). - */ - struct GNUNET_SCHEDULER_Handle *download_sched; - /** * Function to call when download is done. */ @@ -186,7 +176,6 @@ report_uri (void *cls, GNUNET_FS_publish_stop (daemon->publish_context); daemon->publish_context = NULL; - daemon->publish_sched = NULL; cont = daemon->publish_cont; daemon->publish_cont = NULL; uri = daemon->publish_uri; @@ -204,12 +193,10 @@ report_success (void *cls, GNUNET_FS_download_stop (daemon->download_context, GNUNET_YES); daemon->download_context = NULL; - GNUNET_SCHEDULER_add_continuation (daemon->download_sched, - daemon->download_cont, + GNUNET_SCHEDULER_add_continuation (daemon->download_cont, daemon->download_cont_cls, GNUNET_SCHEDULER_REASON_PREREQ_DONE); daemon->download_cont = NULL; - daemon->download_sched = NULL; } @@ -222,12 +209,10 @@ progress_cb (void *cls, switch (info->status) { case GNUNET_FS_STATUS_PUBLISH_COMPLETED: - GNUNET_SCHEDULER_cancel (daemon->publish_sched, - daemon->publish_timeout_task); + GNUNET_SCHEDULER_cancel (daemon->publish_timeout_task); daemon->publish_timeout_task = GNUNET_SCHEDULER_NO_TASK; daemon->publish_uri = GNUNET_FS_uri_dup (info->value.publish.specifics.completed.chk_uri); - GNUNET_SCHEDULER_add_continuation (daemon->publish_sched, - &report_uri, + GNUNET_SCHEDULER_add_continuation (&report_uri, daemon, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -246,11 +231,9 @@ progress_cb (void *cls, (unsigned long long) info->value.download.size); break; case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: - GNUNET_SCHEDULER_cancel (daemon->download_sched, - daemon->download_timeout_task); + GNUNET_SCHEDULER_cancel (daemon->download_timeout_task); daemon->download_timeout_task = GNUNET_SCHEDULER_NO_TASK; - GNUNET_SCHEDULER_add_continuation (daemon->download_sched, - &report_success, + GNUNET_SCHEDULER_add_continuation (&report_success, daemon, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -269,7 +252,6 @@ progress_cb (void *cls, struct StartContext { - struct GNUNET_SCHEDULER_Handle *sched; struct GNUNET_TIME_Relative timeout; unsigned int total; unsigned int have; @@ -317,17 +299,14 @@ notify_running (void *cls, sctx->have++; if (sctx->have == sctx->total) { - GNUNET_SCHEDULER_add_continuation (sctx->sched, - sctx->cont, + GNUNET_SCHEDULER_add_continuation (sctx->cont, sctx->cont_cls, GNUNET_SCHEDULER_REASON_PREREQ_DONE); sctx->daemons[0]->gcfg = sctx->cfg; - GNUNET_SCHEDULER_cancel (sctx->sched, - sctx->timeout_task); + GNUNET_SCHEDULER_cancel (sctx->timeout_task); for (i=0;itotal;i++) { - sctx->daemons[i]->fs = GNUNET_FS_start (sctx->sched, - sctx->daemons[i]->cfg, + sctx->daemons[i]->fs = GNUNET_FS_start (sctx->daemons[i]->cfg, "", &progress_cb, sctx->daemons[i], @@ -360,8 +339,7 @@ start_timeout (void *cls, sctx->daemons[i] = NULL; } GNUNET_CONFIGURATION_destroy (sctx->cfg); - GNUNET_SCHEDULER_add_continuation (sctx->sched, - sctx->cont, + GNUNET_SCHEDULER_add_continuation (sctx->cont, sctx->cont_cls, GNUNET_SCHEDULER_REASON_TIMEOUT); GNUNET_free (sctx); @@ -371,7 +349,6 @@ start_timeout (void *cls, /** * Start daemons for testing. * - * @param sched scheduler to use * @param template_cfg_file configuration template to use * @param timeout if this operation cannot be completed within the * given period, call the continuation with an error code @@ -382,8 +359,7 @@ start_timeout (void *cls, * @param cont_cls closure for cont */ void -GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, - const char *template_cfg_file, +GNUNET_FS_TEST_daemons_start (const char *template_cfg_file, struct GNUNET_TIME_Relative timeout, unsigned int total, struct GNUNET_FS_TestDaemon **daemons, @@ -395,7 +371,6 @@ GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, GNUNET_assert (total > 0); sctx = GNUNET_malloc (sizeof (struct StartContext)); - sctx->sched = sched; sctx->daemons = daemons; sctx->total = total; sctx->cont = cont; @@ -408,16 +383,14 @@ GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, GNUNET_break (0); GNUNET_CONFIGURATION_destroy (sctx->cfg); GNUNET_free (sctx); - GNUNET_SCHEDULER_add_continuation (sched, - cont, + GNUNET_SCHEDULER_add_continuation (cont, cont_cls, GNUNET_SCHEDULER_REASON_TIMEOUT); return; } for (i=0;igroup = GNUNET_TESTING_daemons_start (sched, - sctx->cfg, + sctx->group = GNUNET_TESTING_daemons_start (sctx->cfg, total, timeout, NULL, @@ -426,8 +399,7 @@ GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, sctx, NULL, NULL, NULL); - sctx->timeout_task = GNUNET_SCHEDULER_add_delayed (sched, - timeout, + sctx->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, &start_timeout, sctx); } @@ -435,7 +407,6 @@ GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, struct ConnectContext { - struct GNUNET_SCHEDULER_Handle *sched; GNUNET_SCHEDULER_Task cont; void *cont_cls; }; @@ -472,8 +443,7 @@ notify_connection (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to connect peers: %s\n", emsg); - GNUNET_SCHEDULER_add_continuation (cc->sched, - cc->cont, + GNUNET_SCHEDULER_add_continuation (cc->cont, cc->cont_cls, (emsg != NULL) ? GNUNET_SCHEDULER_REASON_TIMEOUT @@ -485,7 +455,6 @@ notify_connection (void *cls, /** * Connect two daemons for testing. * - * @param sched scheduler to use * @param daemon1 first daemon to connect * @param daemon2 second first daemon to connect * @param timeout if this operation cannot be completed within the @@ -494,8 +463,7 @@ notify_connection (void *cls, * @param cont_cls closure for cont */ void -GNUNET_FS_TEST_daemons_connect (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_FS_TestDaemon *daemon1, +GNUNET_FS_TEST_daemons_connect (struct GNUNET_FS_TestDaemon *daemon1, struct GNUNET_FS_TestDaemon *daemon2, struct GNUNET_TIME_Relative timeout, GNUNET_SCHEDULER_Task cont, @@ -504,7 +472,6 @@ GNUNET_FS_TEST_daemons_connect (struct GNUNET_SCHEDULER_Handle *sched, struct ConnectContext *ncc; ncc = GNUNET_malloc (sizeof (struct ConnectContext)); - ncc->sched = sched; ncc->cont = cont; ncc->cont_cls = cont_cls; GNUNET_TESTING_daemons_connect (daemon1->daemon, @@ -546,13 +513,11 @@ GNUNET_FS_TEST_get_group (struct GNUNET_FS_TestDaemon **daemons) /** * Stop daemons used for testing. * - * @param sched scheduler to use * @param total number of daemons to stop * @param daemons array with the daemons (values will be clobbered) */ void -GNUNET_FS_TEST_daemons_stop (struct GNUNET_SCHEDULER_Handle *sched, - unsigned int total, +GNUNET_FS_TEST_daemons_stop (unsigned int total, struct GNUNET_FS_TestDaemon **daemons) { unsigned int i; @@ -633,7 +598,6 @@ file_generator (void *cls, /** * Publish a file at the given daemon. * - * @param sched scheduler to use * @param daemon where to publish * @param timeout if this operation cannot be completed within the * given period, call the continuation with an error code @@ -647,8 +611,7 @@ file_generator (void *cls, * @param cont_cls closure for cont */ void -GNUNET_FS_TEST_publish (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_FS_TestDaemon *daemon, +GNUNET_FS_TEST_publish (struct GNUNET_FS_TestDaemon *daemon, struct GNUNET_TIME_Relative timeout, uint32_t anonymity, int do_index, @@ -670,7 +633,6 @@ GNUNET_FS_TEST_publish (struct GNUNET_SCHEDULER_Handle *sched, daemon->publish_cont_cls = cont_cls; daemon->publish_seed = seed; daemon->verbose = verbose; - daemon->publish_sched = sched; if (GNUNET_YES == do_index) { GNUNET_assert (daemon->publish_tmp_file == NULL); @@ -727,8 +689,7 @@ GNUNET_FS_TEST_publish (struct GNUNET_SCHEDULER_Handle *sched, fi, NULL, NULL, NULL, GNUNET_FS_PUBLISH_OPTION_NONE); - daemon->publish_timeout_task = GNUNET_SCHEDULER_add_delayed (sched, - timeout, + daemon->publish_timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, &publish_timeout, daemon); } @@ -745,19 +706,16 @@ download_timeout (void *cls, daemon->download_timeout_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_FS_download_stop (daemon->download_context, GNUNET_YES); daemon->download_context = NULL; - GNUNET_SCHEDULER_add_continuation (daemon->download_sched, - daemon->download_cont, + GNUNET_SCHEDULER_add_continuation (daemon->download_cont, daemon->download_cont_cls, GNUNET_SCHEDULER_REASON_TIMEOUT); daemon->download_cont = NULL; - daemon->download_sched = NULL; } /** * Perform test download. * - * @param sched scheduler to use * @param daemon which peer to download from * @param timeout if this operation cannot be completed within the * given period, call the continuation with an error code @@ -769,8 +727,7 @@ download_timeout (void *cls, * @param cont_cls closure for cont */ void -GNUNET_FS_TEST_download (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_FS_TestDaemon *daemon, +GNUNET_FS_TEST_download (struct GNUNET_FS_TestDaemon *daemon, struct GNUNET_TIME_Relative timeout, uint32_t anonymity, uint32_t seed, @@ -784,7 +741,6 @@ GNUNET_FS_TEST_download (struct GNUNET_SCHEDULER_Handle *sched, GNUNET_assert (daemon->download_cont == NULL); size = GNUNET_FS_uri_chk_get_file_size (uri); daemon->verbose = verbose; - daemon->download_sched = sched; daemon->download_cont = cont; daemon->download_cont_cls = cont_cls; daemon->download_seed = seed; @@ -798,8 +754,7 @@ GNUNET_FS_TEST_download (struct GNUNET_SCHEDULER_Handle *sched, GNUNET_FS_DOWNLOAD_OPTION_NONE, NULL, NULL); - daemon->download_timeout_task = GNUNET_SCHEDULER_add_delayed (sched, - timeout, + daemon->download_timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, &download_timeout, daemon); } diff --git a/src/fs/fs_test_lib.h b/src/fs/fs_test_lib.h index 666fad196..b348dfe78 100644 --- a/src/fs/fs_test_lib.h +++ b/src/fs/fs_test_lib.h @@ -41,7 +41,6 @@ struct GNUNET_FS_TestDaemon; /** * Start daemons for testing. * - * @param sched scheduler to use * @param template_cfg_file configuration template to use * @param timeout if this operation cannot be completed within the * given period, call the continuation with an error code @@ -55,8 +54,7 @@ struct GNUNET_FS_TestDaemon; * @param cont_cls closure for cont */ void -GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, - const char *template_cfg_file, +GNUNET_FS_TEST_daemons_start (const char *template_cfg_file, struct GNUNET_TIME_Relative timeout, unsigned int total, struct GNUNET_FS_TestDaemon **daemons, @@ -67,7 +65,6 @@ GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, /** * Connect two daemons for testing. * - * @param sched scheduler to use * @param daemon1 first daemon to connect * @param daemon2 second first daemon to connect * @param timeout if this operation cannot be completed within the @@ -76,8 +73,7 @@ GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, * @param cont_cls closure for cont */ void -GNUNET_FS_TEST_daemons_connect (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_FS_TestDaemon *daemon1, +GNUNET_FS_TEST_daemons_connect (struct GNUNET_FS_TestDaemon *daemon1, struct GNUNET_FS_TestDaemon *daemon2, struct GNUNET_TIME_Relative timeout, GNUNET_SCHEDULER_Task cont, @@ -109,13 +105,11 @@ GNUNET_FS_TEST_get_configuration (struct GNUNET_FS_TestDaemon **daemons, /** * Stop daemons used for testing. * - * @param sched scheduler to use * @param total number of daemons to stop * @param daemons array with the daemons (values will be clobbered) */ void -GNUNET_FS_TEST_daemons_stop (struct GNUNET_SCHEDULER_Handle *sched, - unsigned int total, +GNUNET_FS_TEST_daemons_stop (unsigned int total, struct GNUNET_FS_TestDaemon **daemons); @@ -133,7 +127,6 @@ typedef void /** * Publish a file at the given daemon. * - * @param sched scheduler to use * @param daemon where to publish * @param timeout if this operation cannot be completed within the * given period, call the continuation with an error code @@ -147,8 +140,7 @@ typedef void * @param cont_cls closure for cont */ void -GNUNET_FS_TEST_publish (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_FS_TestDaemon *daemon, +GNUNET_FS_TEST_publish (struct GNUNET_FS_TestDaemon *daemon, struct GNUNET_TIME_Relative timeout, uint32_t anonymity, int do_index, @@ -162,7 +154,6 @@ GNUNET_FS_TEST_publish (struct GNUNET_SCHEDULER_Handle *sched, /** * Perform test download. * - * @param sched scheduler to use * @param daemon which peer to download from * @param timeout if this operation cannot be completed within the * given period, call the continuation with an error code @@ -174,8 +165,7 @@ GNUNET_FS_TEST_publish (struct GNUNET_SCHEDULER_Handle *sched, * @param cont_cls closure for cont */ void -GNUNET_FS_TEST_download (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_FS_TestDaemon *daemon, +GNUNET_FS_TEST_download (struct GNUNET_FS_TestDaemon *daemon, struct GNUNET_TIME_Relative timeout, uint32_t anonymity, uint32_t seed, diff --git a/src/fs/fs_tree.c b/src/fs/fs_tree.c index 55f7b0e09..b38a9c382 100644 --- a/src/fs/fs_tree.c +++ b/src/fs/fs_tree.c @@ -329,8 +329,7 @@ void GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder * te) iob, &te->emsg)) { - GNUNET_SCHEDULER_add_continuation (te->h->sched, - te->cont, + GNUNET_SCHEDULER_add_continuation (te->cont, te->cls, GNUNET_SCHEDULER_REASON_TIMEOUT); return; @@ -350,8 +349,7 @@ void GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder * te) te->uri->type = chk; te->uri->data.chk.chk = te->chk_tree[0]; te->uri->data.chk.file_length = GNUNET_htonll (te->size); - GNUNET_SCHEDULER_add_continuation (te->h->sched, - te->cont, + GNUNET_SCHEDULER_add_continuation (te->cont, te->cls, GNUNET_SCHEDULER_REASON_PREREQ_DONE); return; diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c index e4ac4efd6..b3bcd48bf 100644 --- a/src/fs/fs_unindex.c +++ b/src/fs/fs_unindex.c @@ -318,8 +318,7 @@ unindex_finish (void *cls, uc->dsh = NULL; uc->state = UNINDEX_STATE_FS_NOTIFY; GNUNET_FS_unindex_sync_ (uc); - uc->client = GNUNET_CLIENT_connect (uc->h->sched, - "fs", + uc->client = GNUNET_CLIENT_connect ("fs", uc->h->cfg); if (uc->client == NULL) { @@ -355,8 +354,7 @@ unindex_finish (void *cls, void GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc) { - uc->dsh = GNUNET_DATASTORE_connect (uc->h->cfg, - uc->h->sched); + uc->dsh = GNUNET_DATASTORE_connect (uc->h->cfg); if (NULL == uc->dsh) { uc->state = UNINDEX_STATE_ERROR; @@ -506,8 +504,7 @@ GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h, pi.status = GNUNET_FS_STATUS_UNINDEX_START; pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL; GNUNET_FS_unindex_make_status_ (&pi, ret, 0); - ret->fhc = GNUNET_CRYPTO_hash_file (h->sched, - GNUNET_SCHEDULER_PRIORITY_IDLE, + ret->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, filename, HASHING_BLOCKSIZE, &GNUNET_FS_unindex_process_hash_, diff --git a/src/fs/gnunet-directory.c b/src/fs/gnunet-directory.c index 8f58025c5..6de8206f1 100644 --- a/src/fs/gnunet-directory.c +++ b/src/fs/gnunet-directory.c @@ -106,14 +106,12 @@ print_entry (void *cls, * Main function that will be run by the scheduler. * * @param cls closure - * @param sched the scheduler to use * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param cfg configuration */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c index 36681e407..99ebb1435 100644 --- a/src/fs/gnunet-download.c +++ b/src/fs/gnunet-download.c @@ -38,8 +38,6 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg; static struct GNUNET_FS_Handle *ctx; -static struct GNUNET_SCHEDULER_Handle *sched; - static struct GNUNET_FS_DownloadContext *dc; static unsigned int anonymity = 1; @@ -122,7 +120,7 @@ progress_cb (void *cls, fprintf (stderr, _("Error downloading: %s.\n"), info->value.download.specifics.error.message); - GNUNET_SCHEDULER_shutdown (sched); + GNUNET_SCHEDULER_shutdown (); break; case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: s = GNUNET_STRINGS_byte_size_fancy(info->value.download.completed * 1000 / (info->value.download.duration.rel_value + 1)); @@ -132,12 +130,11 @@ progress_cb (void *cls, s); GNUNET_free (s); if (info->value.download.dc == dc) - GNUNET_SCHEDULER_shutdown (sched); + GNUNET_SCHEDULER_shutdown (); break; case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: if (info->value.download.dc == dc) - GNUNET_SCHEDULER_add_continuation (sched, - &cleanup_task, + GNUNET_SCHEDULER_add_continuation (&cleanup_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -158,14 +155,12 @@ progress_cb (void *cls, * Main function that will be run by the scheduler. * * @param cls closure - * @param s the scheduler to use * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param c configuration */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) @@ -174,7 +169,6 @@ run (void *cls, char *emsg; enum GNUNET_FS_DownloadOptions options; - sched = s; uri = GNUNET_FS_uri_parse (args[0], &emsg); if (NULL == uri) @@ -204,8 +198,7 @@ run (void *cls, return; } cfg = c; - ctx = GNUNET_FS_start (sched, - cfg, + ctx = GNUNET_FS_start (cfg, "gnunet-download", &progress_cb, NULL, @@ -246,8 +239,7 @@ run (void *cls, ctx = NULL; return; } - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); } diff --git a/src/fs/gnunet-pseudonym.c b/src/fs/gnunet-pseudonym.c index ba9213b5d..b7aba8ef4 100644 --- a/src/fs/gnunet-pseudonym.c +++ b/src/fs/gnunet-pseudonym.c @@ -221,14 +221,12 @@ post_advertising (void *cls, * Main function that will be run by the scheduler. * * @param cls closure - * @param sched the scheduler to use * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param c configuration */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) @@ -237,8 +235,7 @@ run (void *cls, char *emsg; cfg = c; - h = GNUNET_FS_start (sched, - cfg, + h = GNUNET_FS_start (cfg, "gnunet-pseudonym", &progress_cb, NULL, diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c index 79beacc84..36e75a4ea 100644 --- a/src/fs/gnunet-publish.c +++ b/src/fs/gnunet-publish.c @@ -38,8 +38,6 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg; static struct GNUNET_FS_Handle *ctx; -static struct GNUNET_SCHEDULER_Handle *sched; - static struct GNUNET_FS_PublishContext *pc; static struct GNUNET_CONTAINER_MetaData *meta; @@ -135,12 +133,10 @@ progress_cb (void *cls, info->value.publish.specifics.error.message); if (kill_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, - kill_task); + GNUNET_SCHEDULER_cancel (kill_task); kill_task = GNUNET_SCHEDULER_NO_TASK; } - GNUNET_SCHEDULER_add_continuation (sched, - &do_stop_task, + GNUNET_SCHEDULER_add_continuation (&do_stop_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -157,12 +153,10 @@ progress_cb (void *cls, { if (kill_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, - kill_task); + GNUNET_SCHEDULER_cancel (kill_task); kill_task = GNUNET_SCHEDULER_NO_TASK; } - GNUNET_SCHEDULER_add_continuation (sched, - &do_stop_task, + GNUNET_SCHEDULER_add_continuation (&do_stop_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -374,14 +368,12 @@ uri_ksk_continuation (void *cls, * Main function that will be run by the scheduler. * * @param cls closure - * @param s the scheduler to use * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param c configuration */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) @@ -393,7 +385,6 @@ run (void *cls, char *ex; char *emsg; - sched = s; /* check arguments */ if ((uri_string != NULL) && (extract_only)) { @@ -446,8 +437,7 @@ run (void *cls, } } cfg = c; - ctx = GNUNET_FS_start (sched, - cfg, + ctx = GNUNET_FS_start (cfg, "gnunet-publish", &progress_cb, NULL, @@ -600,8 +590,7 @@ run (void *cls, ret = 1; return; } - kill_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + kill_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_stop_task, NULL); } diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c index ab3f6b0c7..dddfe6b75 100644 --- a/src/fs/gnunet-search.c +++ b/src/fs/gnunet-search.c @@ -32,8 +32,6 @@ static int ret; static const struct GNUNET_CONFIGURATION_Handle *cfg; -static struct GNUNET_SCHEDULER_Handle *sched; - static struct GNUNET_FS_Handle *ctx; static struct GNUNET_FS_SearchContext *sc; @@ -185,11 +183,10 @@ progress_cb (void *cls, fprintf (stderr, _("Error searching: %s.\n"), info->value.search.specifics.error.message); - GNUNET_SCHEDULER_shutdown (sched); + GNUNET_SCHEDULER_shutdown (); break; case GNUNET_FS_STATUS_SEARCH_STOPPED: - GNUNET_SCHEDULER_add_continuation (sched, - &clean_task, + GNUNET_SCHEDULER_add_continuation (&clean_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -219,14 +216,12 @@ shutdown_task (void *cls, * Main function that will be run by the scheduler. * * @param cls closure - * @param s the scheduler to use * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param c configuration */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) @@ -235,7 +230,6 @@ run (void *cls, unsigned int argc; enum GNUNET_FS_SearchOptions options; - sched = s; argc = 0; while (NULL != args[argc]) argc++; @@ -250,8 +244,7 @@ run (void *cls, return; } cfg = c; - ctx = GNUNET_FS_start (sched, - cfg, + ctx = GNUNET_FS_start (cfg, "gnunet-search", &progress_cb, NULL, @@ -285,8 +278,7 @@ run (void *cls, ret = 1; return; } - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); } diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 2defec397..0a537576a 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c @@ -770,11 +770,6 @@ static struct GNUNET_BLOCK_Context *block_ctx; */ static struct GNUNET_CONFIGURATION_Handle *block_cfg; -/** - * Our scheduler. - */ -static struct GNUNET_SCHEDULER_Handle *sched; - /** * Our configuration. */ @@ -1106,7 +1101,7 @@ consider_migration (void *cls, #endif if (cp->delayed_transmission_request_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, cp->delayed_transmission_request_task); + GNUNET_SCHEDULER_cancel (cp->delayed_transmission_request_task); cp->delayed_transmission_request_task = GNUNET_SCHEDULER_NO_TASK; } cp->cth @@ -1166,8 +1161,7 @@ consider_migration_gathering () MAX_MIGRATION_QUEUE); delay = GNUNET_TIME_relative_max (delay, min_migration_delay); - mig_task = GNUNET_SCHEDULER_add_delayed (sched, - delay, + mig_task = GNUNET_SCHEDULER_add_delayed (delay, &gather_migration_blocks, NULL); } @@ -1201,8 +1195,7 @@ consider_dht_put_gathering (void *cls) (hopefully) appear */ delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5); } - dht_task = GNUNET_SCHEDULER_add_delayed (sched, - delay, + dht_task = GNUNET_SCHEDULER_add_delayed (delay, &gather_dht_put_blocks, cls); } @@ -1542,8 +1535,7 @@ destroy_pending_request (struct PendingRequest *pr) } if (pr->task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, - pr->task); + GNUNET_SCHEDULER_cancel (pr->task); pr->task = GNUNET_SCHEDULER_NO_TASK; } while (NULL != pr->pending_head) @@ -1743,8 +1735,7 @@ cron_flush_trust (void *cls, return; if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) return; - GNUNET_SCHEDULER_add_delayed (tc->sched, - TRUST_FLUSH_FREQ, &cron_flush_trust, NULL); + GNUNET_SCHEDULER_add_delayed (TRUST_FLUSH_FREQ, &cron_flush_trust, NULL); } @@ -1843,7 +1834,7 @@ peer_disconnect_handler (void *cls, } if (cp->delayed_transmission_request_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, cp->delayed_transmission_request_task); + GNUNET_SCHEDULER_cancel (cp->delayed_transmission_request_task); cp->delayed_transmission_request_task = GNUNET_SCHEDULER_NO_TASK; } while (NULL != (pm = cp->pending_messages_head)) @@ -1984,12 +1975,12 @@ shutdown_task (void *cls, } if (GNUNET_SCHEDULER_NO_TASK != mig_task) { - GNUNET_SCHEDULER_cancel (sched, mig_task); + GNUNET_SCHEDULER_cancel (mig_task); mig_task = GNUNET_SCHEDULER_NO_TASK; } if (GNUNET_SCHEDULER_NO_TASK != dht_task) { - GNUNET_SCHEDULER_cancel (sched, dht_task); + GNUNET_SCHEDULER_cancel (dht_task); dht_task = GNUNET_SCHEDULER_NO_TASK; } while (client_list != NULL) @@ -2039,7 +2030,6 @@ shutdown_task (void *cls, block_ctx = NULL; GNUNET_CONFIGURATION_destroy (block_cfg); block_cfg = NULL; - sched = NULL; cfg = NULL; GNUNET_free_non_null (trustDirectory); trustDirectory = NULL; @@ -2157,8 +2147,7 @@ transmit_to_peer (void *cls, { GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == cp->delayed_transmission_request_task); cp->delayed_transmission_request_task - = GNUNET_SCHEDULER_add_delayed (sched, - min_delay, + = GNUNET_SCHEDULER_add_delayed (min_delay, &delayed_transmission_request, cp); } @@ -2284,7 +2273,7 @@ add_to_pending_messages_for_peer (struct ConnectedPeer *cp, } if (cp->delayed_transmission_request_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, cp->delayed_transmission_request_task); + GNUNET_SCHEDULER_cancel (cp->delayed_transmission_request_task); cp->delayed_transmission_request_task = GNUNET_SCHEDULER_NO_TASK; } /* need to schedule transmission */ @@ -2428,8 +2417,7 @@ transmit_query_continuation (void *cls, "Transmission of request failed, will try again later.\n"); #endif if (pr->task == GNUNET_SCHEDULER_NO_TASK) - pr->task = GNUNET_SCHEDULER_add_delayed (sched, - get_processing_delay (), + pr->task = GNUNET_SCHEDULER_add_delayed (get_processing_delay (), &forward_request_task, pr); return; @@ -2461,8 +2449,7 @@ transmit_query_continuation (void *cls, pr->used_targets[i].last_request_time = GNUNET_TIME_absolute_get (); pr->used_targets[i].num_requests++; if (pr->task == GNUNET_SCHEDULER_NO_TASK) - pr->task = GNUNET_SCHEDULER_add_delayed (sched, - get_processing_delay (), + pr->task = GNUNET_SCHEDULER_add_delayed (get_processing_delay (), &forward_request_task, pr); } @@ -2572,8 +2559,7 @@ target_reservation_cb (void *cls, { /* error in communication with core, try again later */ if (pr->task == GNUNET_SCHEDULER_NO_TASK) - pr->task = GNUNET_SCHEDULER_add_delayed (sched, - get_processing_delay (), + pr->task = GNUNET_SCHEDULER_add_delayed (get_processing_delay (), &forward_request_task, pr); return; @@ -2589,8 +2575,7 @@ target_reservation_cb (void *cls, "Selected peer disconnected!\n"); #endif if (pr->task == GNUNET_SCHEDULER_NO_TASK) - pr->task = GNUNET_SCHEDULER_add_delayed (sched, - get_processing_delay (), + pr->task = GNUNET_SCHEDULER_add_delayed (get_processing_delay (), &forward_request_task, pr); return; @@ -2611,8 +2596,7 @@ target_reservation_cb (void *cls, 1, GNUNET_NO); if (pr->task == GNUNET_SCHEDULER_NO_TASK) - pr->task = GNUNET_SCHEDULER_add_delayed (sched, - get_processing_delay (), + pr->task = GNUNET_SCHEDULER_add_delayed (get_processing_delay (), &forward_request_task, pr); return; /* this target round failed */ @@ -2963,8 +2947,7 @@ forward_request_task (void *cls, GNUNET_h2s (&pr->query), delay.rel_value); #endif - pr->task = GNUNET_SCHEDULER_add_delayed (sched, - delay, + pr->task = GNUNET_SCHEDULER_add_delayed (delay, &forward_request_task, pr); return; /* nobody selected */ @@ -2999,7 +2982,7 @@ forward_request_task (void *cls, cp = GNUNET_CONTAINER_multihashmap_get (connected_peers, &psc.target.hashPubKey); GNUNET_assert (NULL != cp); - pr->irc = GNUNET_CORE_peer_change_preference (sched, cfg, + pr->irc = GNUNET_CORE_peer_change_preference (cfg, &psc.target, GNUNET_CONSTANTS_SERVICE_TIMEOUT, GNUNET_BANDWIDTH_value_init (UINT32_MAX), @@ -3263,8 +3246,7 @@ struct GNUNET_TIME_Relative art_delay; pr->do_remove = GNUNET_YES; if (pr->task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, - pr->task); + GNUNET_SCHEDULER_cancel (pr->task); pr->task = GNUNET_SCHEDULER_NO_TASK; } GNUNET_break (GNUNET_YES == @@ -3779,8 +3761,7 @@ process_local_reply (void *cls, } /* no more results */ if (pr->task == GNUNET_SCHEDULER_NO_TASK) - pr->task = GNUNET_SCHEDULER_add_now (sched, - &forward_request_task, + pr->task = GNUNET_SCHEDULER_add_now (&forward_request_task, pr); return; } @@ -4267,8 +4248,7 @@ handle_p2p_get (void *cls, } default: if (pr->task == GNUNET_SCHEDULER_NO_TASK) - pr->task = GNUNET_SCHEDULER_add_now (sched, - &forward_request_task, + pr->task = GNUNET_SCHEDULER_add_now (&forward_request_task, pr); } @@ -4448,13 +4428,11 @@ handle_start_search (void *cls, /** * Process fs requests. * - * @param s scheduler to use * @param server the initialized server * @param c configuration to use */ static int -main_init (struct GNUNET_SCHEDULER_Handle *s, - struct GNUNET_SERVER_Handle *server, +main_init (struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { static const struct GNUNET_CORE_MessageHandler p2p_handlers[] = @@ -4481,9 +4459,8 @@ main_init (struct GNUNET_SCHEDULER_Handle *s, }; unsigned long long enc = 128; - sched = s; cfg = c; - stats = GNUNET_STATISTICS_create (sched, "fs", cfg); + stats = GNUNET_STATISTICS_create ("fs", cfg); min_migration_delay = GNUNET_TIME_UNIT_SECONDS; if ( (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, @@ -4509,8 +4486,7 @@ main_init (struct GNUNET_SCHEDULER_Handle *s, rt_entry_lifetime = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_FOREVER_REL); peer_request_map = GNUNET_CONTAINER_multihashmap_create (enc); requests_by_expiration_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); - core = GNUNET_CORE_connect (sched, - cfg, + core = GNUNET_CORE_connect (cfg, GNUNET_TIME_UNIT_FOREVER_REL, NULL, NULL, @@ -4559,14 +4535,12 @@ main_init (struct GNUNET_SCHEDULER_Handle *s, "TRUST", &trustDirectory)); GNUNET_DISK_directory_create (trustDirectory); - GNUNET_SCHEDULER_add_with_priority (sched, - GNUNET_SCHEDULER_PRIORITY_HIGH, + GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_HIGH, &cron_flush_trust, NULL); GNUNET_SERVER_add_handlers (server, handlers); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); return GNUNET_OK; @@ -4577,24 +4551,21 @@ main_init (struct GNUNET_SCHEDULER_Handle *s, * Process fs requests. * * @param cls closure - * @param sched scheduler to use * @param server the initialized server * @param cfg configuration to use */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg) { active_migration = GNUNET_CONFIGURATION_get_value_yesno (cfg, "FS", "ACTIVEMIGRATION"); - dsh = GNUNET_DATASTORE_connect (cfg, - sched); + dsh = GNUNET_DATASTORE_connect (cfg); if (dsh == NULL) { - GNUNET_SCHEDULER_shutdown (sched); + GNUNET_SCHEDULER_shutdown (); return; } datastore_get_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE); @@ -4606,13 +4577,12 @@ run (void *cls, "fs"); block_ctx = GNUNET_BLOCK_context_create (block_cfg); GNUNET_assert (NULL != block_ctx); - dht_handle = GNUNET_DHT_connect (sched, - cfg, + dht_handle = GNUNET_DHT_connect (cfg, FS_DHT_HT_SIZE); - if ( (GNUNET_OK != GNUNET_FS_indexing_init (sched, cfg, dsh)) || - (GNUNET_OK != main_init (sched, server, cfg)) ) + if ( (GNUNET_OK != GNUNET_FS_indexing_init (cfg, dsh)) || + (GNUNET_OK != main_init (server, cfg)) ) { - GNUNET_SCHEDULER_shutdown (sched); + GNUNET_SCHEDULER_shutdown (); GNUNET_DATASTORE_disconnect (dsh, GNUNET_NO); dsh = NULL; GNUNET_DHT_disconnect (dht_handle); diff --git a/src/fs/gnunet-service-fs_indexing.c b/src/fs/gnunet-service-fs_indexing.c index 99b5da102..2e95f454f 100644 --- a/src/fs/gnunet-service-fs_indexing.c +++ b/src/fs/gnunet-service-fs_indexing.c @@ -90,11 +90,6 @@ static struct IndexInfo *indexed_files; */ static struct GNUNET_CONTAINER_MultiHashMap *ifm; -/** - * Our scheduler. - */ -static struct GNUNET_SCHEDULER_Handle *sched; - /** * Our configuration. */ @@ -404,8 +399,7 @@ GNUNET_FS_handle_index_start (void *cls, (unsigned int) mydev); #endif /* slow validation, need to hash full file (again) */ - ii->fhc = GNUNET_CRYPTO_hash_file (sched, - GNUNET_SCHEDULER_PRIORITY_IDLE, + ii->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, fn, HASHING_BLOCKSIZE, &hash_for_index_val, @@ -710,7 +704,6 @@ shutdown_task (void *cls, indexed_files = pos->next; GNUNET_free (pos); } - sched = NULL; cfg = NULL; } @@ -718,21 +711,17 @@ shutdown_task (void *cls, /** * Initialize the indexing submodule. * - * @param s scheduler to use * @param c configuration to use * @param d datastore to use */ int -GNUNET_FS_indexing_init (struct GNUNET_SCHEDULER_Handle *s, - const struct GNUNET_CONFIGURATION_Handle *c, +GNUNET_FS_indexing_init (const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_DATASTORE_Handle *d) { - sched = s; cfg = c; dsh = d; ifm = GNUNET_CONTAINER_multihashmap_create (128); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); read_index_list (); diff --git a/src/fs/gnunet-service-fs_indexing.h b/src/fs/gnunet-service-fs_indexing.h index bf063fcbd..885e141e2 100644 --- a/src/fs/gnunet-service-fs_indexing.h +++ b/src/fs/gnunet-service-fs_indexing.h @@ -110,14 +110,12 @@ GNUNET_FS_handle_unindex (void *cls, /** * Initialize the indexing submodule. * - * @param s scheduler to use * @param c configuration to use * @param d datastore to use * @return GNUNET_OK on success */ int -GNUNET_FS_indexing_init (struct GNUNET_SCHEDULER_Handle *s, - const struct GNUNET_CONFIGURATION_Handle *c, +GNUNET_FS_indexing_init (const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_DATASTORE_Handle *d); diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c index 872aa3d3a..f73d2f0cc 100644 --- a/src/fs/gnunet-unindex.c +++ b/src/fs/gnunet-unindex.c @@ -38,8 +38,6 @@ static struct GNUNET_FS_Handle *ctx; static struct GNUNET_FS_UnindexContext *uc; -static struct GNUNET_SCHEDULER_Handle *sched; - static void cleanup_task (void *cls, @@ -103,16 +101,15 @@ progress_cb (void *cls, fprintf (stderr, _("Error unindexing: %s.\n"), info->value.unindex.specifics.error.message); - GNUNET_SCHEDULER_shutdown (sched); + GNUNET_SCHEDULER_shutdown (); break; case GNUNET_FS_STATUS_UNINDEX_COMPLETED: fprintf (stdout, _("Unindexing done.\n")); - GNUNET_SCHEDULER_shutdown (sched); + GNUNET_SCHEDULER_shutdown (); break; case GNUNET_FS_STATUS_UNINDEX_STOPPED: - GNUNET_SCHEDULER_add_continuation (sched, - &cleanup_task, + GNUNET_SCHEDULER_add_continuation (&cleanup_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -130,14 +127,12 @@ progress_cb (void *cls, * Main function that will be run by the scheduler. * * @param cls closure - * @param s the scheduler to use * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param c configuration */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) @@ -150,10 +145,8 @@ run (void *cls, ret = -1; return; } - sched = s; cfg = c; - ctx = GNUNET_FS_start (sched, - cfg, + ctx = GNUNET_FS_start (cfg, "gnunet-unindex", &progress_cb, NULL, @@ -177,8 +170,7 @@ run (void *cls, GNUNET_FS_stop (ctx); return; } - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); } diff --git a/src/fs/perf_gnunet_service_fs_p2p.c b/src/fs/perf_gnunet_service_fs_p2p.c index 8b1c0ad24..8d5ad6587 100644 --- a/src/fs/perf_gnunet_service_fs_p2p.c +++ b/src/fs/perf_gnunet_service_fs_p2p.c @@ -45,8 +45,6 @@ static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS]; -static struct GNUNET_SCHEDULER_Handle *sched; - static int ok; static struct GNUNET_TIME_Absolute start_time; @@ -57,8 +55,7 @@ static void do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - GNUNET_FS_TEST_daemons_stop (sched, - NUM_DAEMONS, + GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); } @@ -152,7 +149,7 @@ get_done (void *cls, struct StatMaster *sm = cls; GNUNET_break (GNUNET_OK == success); sm->value++; - GNUNET_SCHEDULER_add_now (sched, &stat_run, sm); + GNUNET_SCHEDULER_add_now (&stat_run, sm); } @@ -185,13 +182,13 @@ stat_run (void *cls, if (sm->daemon == NUM_DAEMONS) { GNUNET_free (sm); - GNUNET_SCHEDULER_add_now (sched, &do_stop, NULL); + GNUNET_SCHEDULER_add_now (&do_stop, NULL); return; } - sm->stat = GNUNET_STATISTICS_create (sched, "", + sm->stat = GNUNET_STATISTICS_create ("", GNUNET_FS_TEST_get_configuration (daemons, sm->daemon)); - GNUNET_SCHEDULER_add_now (sched, &stat_run, sm); + GNUNET_SCHEDULER_add_now (&stat_run, sm); } @@ -217,17 +214,17 @@ do_report (void *cls, "Finished download, shutting down\n", (unsigned long long) FILESIZE); sm = GNUNET_malloc (sizeof (struct StatMaster)); - sm->stat = GNUNET_STATISTICS_create (sched, "", + sm->stat = GNUNET_STATISTICS_create ("", GNUNET_FS_TEST_get_configuration (daemons, sm->daemon)); - GNUNET_SCHEDULER_add_now (sched, &stat_run, sm); + GNUNET_SCHEDULER_add_now (&stat_run, sm); } else { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Timeout during download, shutting down with error\n"); ok = 1; - GNUNET_SCHEDULER_add_now (sched, &do_stop, NULL); + GNUNET_SCHEDULER_add_now (&do_stop, NULL); } } @@ -240,8 +237,7 @@ do_download (void *cls, if (NULL == uri) { - GNUNET_FS_TEST_daemons_stop (sched, - NUM_DAEMONS, + GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Timeout during upload attempt, shutting down with error\n"); @@ -256,8 +252,7 @@ do_download (void *cls, anonymity = 0; else anonymity = 1; - GNUNET_FS_TEST_download (sched, - daemons[0], + GNUNET_FS_TEST_download (daemons[0], TIMEOUT, anonymity, SEED, uri, VERBOSE, @@ -274,8 +269,7 @@ do_publish (void *cls, if (NULL != emsg) { - GNUNET_FS_TEST_daemons_stop (sched, - NUM_DAEMONS, + GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error trying to connect: %s\n", @@ -295,8 +289,7 @@ do_publish (void *cls, else anonymity = 1; - GNUNET_FS_TEST_publish (sched, - daemons[NUM_DAEMONS-1], + GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS-1], TIMEOUT, anonymity, do_index, FILESIZE, SEED, @@ -331,14 +324,11 @@ do_connect (void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { - sched = s; - GNUNET_FS_TEST_daemons_start (sched, - "fs_test_lib_data.conf", + GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", TIMEOUT, NUM_DAEMONS, daemons, diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c index 4bcedcb4d..549a2eeed 100644 --- a/src/fs/test_fs_download.c +++ b/src/fs/test_fs_download.c @@ -60,8 +60,6 @@ static struct PeerContext p1; static struct GNUNET_TIME_Absolute start; -static struct GNUNET_SCHEDULER_Handle *sched; - static struct GNUNET_FS_Handle *fs; static struct GNUNET_FS_DownloadContext *download; @@ -127,7 +125,7 @@ abort_download_task (void *cls, GNUNET_DISK_directory_remove (fn); GNUNET_free (fn); fn = NULL; - GNUNET_SCHEDULER_cancel (sched, timeout_kill); + GNUNET_SCHEDULER_cancel (timeout_kill); timeout_kill = GNUNET_SCHEDULER_NO_TASK; } @@ -168,8 +166,7 @@ progress_cb (void *cls, case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: printf ("Download complete, %llu kbps.\n", (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024LL)); - GNUNET_SCHEDULER_add_now (sched, - &abort_download_task, + GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); break; case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: @@ -187,8 +184,7 @@ progress_cb (void *cls, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -196,8 +192,7 @@ progress_cb (void *cls, fprintf (stderr, "Error downloading file: %s\n", event->value.download.specifics.error.message); - GNUNET_SCHEDULER_add_now (sched, - &abort_download_task, + GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); break; case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: @@ -214,8 +209,7 @@ progress_cb (void *cls, GNUNET_assert (publish == event->value.publish.pc); GNUNET_assert (FILESIZE == event->value.publish.size); GNUNET_assert (1 == event->value.publish.anonymity); - GNUNET_SCHEDULER_add_now (sched, - &stop_fs_task, + GNUNET_SCHEDULER_add_now (&stop_fs_task, NULL); break; case GNUNET_FS_STATUS_DOWNLOAD_START: @@ -230,8 +224,7 @@ progress_cb (void *cls, break; case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: GNUNET_assert (download == event->value.download.dc); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -279,7 +272,6 @@ stop_arm (struct PeerContext *p) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -294,10 +286,8 @@ run (void *cls, struct GNUNET_FS_FileInformation *fi; size_t i; - sched = s; setup_peer (&p1, "test_fs_download_data.conf"); - fs = GNUNET_FS_start (sched, - cfg, + fs = GNUNET_FS_start (cfg, "test-fs-download", &progress_cb, NULL, @@ -322,8 +312,7 @@ run (void *cls, GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fi); - timeout_kill = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + timeout_kill = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_kill_task, NULL); start = GNUNET_TIME_absolute_get (); diff --git a/src/fs/test_fs_download_indexed.c b/src/fs/test_fs_download_indexed.c index 21d95d584..6e59f97cd 100644 --- a/src/fs/test_fs_download_indexed.c +++ b/src/fs/test_fs_download_indexed.c @@ -60,8 +60,6 @@ static struct PeerContext p1; static struct GNUNET_TIME_Absolute start; -static struct GNUNET_SCHEDULER_Handle *sched; - static struct GNUNET_FS_Handle *fs; static struct GNUNET_FS_DownloadContext *download; @@ -129,7 +127,7 @@ abort_download_task (void *cls, GNUNET_DISK_directory_remove (fn); GNUNET_free (fn); fn = NULL; - GNUNET_SCHEDULER_cancel (sched, timeout_kill); + GNUNET_SCHEDULER_cancel (timeout_kill); timeout_kill = GNUNET_SCHEDULER_NO_TASK; } @@ -170,8 +168,7 @@ progress_cb (void *cls, case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: printf ("Download complete, %llu kbps.\n", (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024LL)); - GNUNET_SCHEDULER_add_now (sched, - &abort_download_task, + GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); break; case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: @@ -189,8 +186,7 @@ progress_cb (void *cls, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -198,8 +194,7 @@ progress_cb (void *cls, fprintf (stderr, "Error downloading file: %s\n", event->value.download.specifics.error.message); - GNUNET_SCHEDULER_add_now (sched, - &abort_download_task, + GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); break; case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: @@ -216,8 +211,7 @@ progress_cb (void *cls, GNUNET_assert (publish == event->value.publish.pc); GNUNET_assert (FILESIZE == event->value.publish.size); GNUNET_assert (1 == event->value.publish.anonymity); - GNUNET_SCHEDULER_add_now (sched, - &stop_fs_task, + GNUNET_SCHEDULER_add_now (&stop_fs_task, NULL); break; case GNUNET_FS_STATUS_DOWNLOAD_START: @@ -232,8 +226,7 @@ progress_cb (void *cls, break; case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: GNUNET_assert (download == event->value.download.dc); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -281,7 +274,6 @@ stop_arm (struct PeerContext *p) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -296,10 +288,8 @@ run (void *cls, struct GNUNET_FS_FileInformation *fi; size_t i; - sched = s; setup_peer (&p1, "test_fs_download_data.conf"); - fs = GNUNET_FS_start (sched, - cfg, + fs = GNUNET_FS_start (cfg, "test-fs-download-indexed", &progress_cb, NULL, @@ -331,8 +321,7 @@ run (void *cls, GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fi); - timeout_kill = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + timeout_kill = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_kill_task, NULL); start = GNUNET_TIME_absolute_get (); diff --git a/src/fs/test_fs_download_persistence.c b/src/fs/test_fs_download_persistence.c index 966d52412..66d1199ca 100644 --- a/src/fs/test_fs_download_persistence.c +++ b/src/fs/test_fs_download_persistence.c @@ -60,8 +60,6 @@ static struct PeerContext p1; static struct GNUNET_TIME_Absolute start; -static struct GNUNET_SCHEDULER_Handle *sched; - static const struct GNUNET_CONFIGURATION_Handle *cfg; static struct GNUNET_FS_Handle *fs; @@ -122,7 +120,7 @@ abort_download_task (void *cls, GNUNET_DISK_directory_remove (fn); GNUNET_free (fn); fn = NULL; - GNUNET_SCHEDULER_cancel (sched, timeout_kill); + GNUNET_SCHEDULER_cancel (timeout_kill); timeout_kill = GNUNET_SCHEDULER_NO_TASK; } @@ -137,8 +135,7 @@ restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_FS_stop (fs); - fs = GNUNET_FS_start (sched, - cfg, + fs = GNUNET_FS_start (cfg, "test-fs-download-persistence", &progress_cb, NULL, @@ -164,8 +161,7 @@ consider_restart (int ev) if (prev[i] == ev) return; prev[off++] = ev; - GNUNET_SCHEDULER_add_with_priority (sched, - GNUNET_SCHEDULER_PRIORITY_URGENT, + GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_URGENT, &restart_fs_task, NULL); } @@ -207,8 +203,7 @@ progress_cb (void *cls, consider_restart (event->status); printf ("Download complete, %llu kbps.\n", (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024LL)); - GNUNET_SCHEDULER_add_now (sched, - &abort_download_task, + GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); break; case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: @@ -227,8 +222,7 @@ progress_cb (void *cls, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -236,8 +230,7 @@ progress_cb (void *cls, fprintf (stderr, "Error downloading file: %s\n", event->value.download.specifics.error.message); - GNUNET_SCHEDULER_add_now (sched, - &abort_download_task, + GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); break; case GNUNET_FS_STATUS_PUBLISH_SUSPEND: @@ -290,8 +283,7 @@ progress_cb (void *cls, break; case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: GNUNET_assert (download == event->value.download.dc); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); download = NULL; @@ -340,7 +332,6 @@ stop_arm (struct PeerContext *p) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) @@ -355,11 +346,9 @@ run (void *cls, struct GNUNET_FS_FileInformation *fi; size_t i; - sched = s; cfg = c; setup_peer (&p1, "test_fs_download_data.conf"); - fs = GNUNET_FS_start (sched, - cfg, + fs = GNUNET_FS_start (cfg, "test-fs-download-persistence", &progress_cb, NULL, @@ -384,8 +373,7 @@ run (void *cls, GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fi); - timeout_kill = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + timeout_kill = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_kill_task, NULL); start = GNUNET_TIME_absolute_get (); diff --git a/src/fs/test_fs_file_information.c b/src/fs/test_fs_file_information.c index 57698165e..914dbad9f 100644 --- a/src/fs/test_fs_file_information.c +++ b/src/fs/test_fs_file_information.c @@ -67,7 +67,6 @@ mycleaner(void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -87,7 +86,7 @@ run (void *cls, struct GNUNET_FS_Handle *fs; size_t i; - fs = GNUNET_FS_start (s, cfg, "test-fs-file-information", NULL, NULL, + fs = GNUNET_FS_start (cfg, "test-fs-file-information", NULL, NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); fn1 = GNUNET_DISK_mktemp ("gnunet-file_information-test-dst"); diff --git a/src/fs/test_fs_list_indexed.c b/src/fs/test_fs_list_indexed.c index 0e46336df..206e58baf 100644 --- a/src/fs/test_fs_list_indexed.c +++ b/src/fs/test_fs_list_indexed.c @@ -64,8 +64,6 @@ static struct PeerContext p1; static struct GNUNET_TIME_Absolute start; -static struct GNUNET_SCHEDULER_Handle *sched; - static struct GNUNET_FS_Handle *fs; static struct GNUNET_FS_PublishContext *publish; @@ -96,8 +94,7 @@ list_indexed_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -118,8 +115,7 @@ progress_cb (void *cls, (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024)); if (0 == strcmp ("list_indexed-context-dir", event->value.publish.cctx)) - GNUNET_SCHEDULER_add_continuation (sched, - &list_indexed_task, + GNUNET_SCHEDULER_add_continuation (&list_indexed_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); @@ -143,8 +139,7 @@ progress_cb (void *cls, err = 1; if (0 == strcmp ("list_indexed-context-dir", event->value.publish.cctx)) - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -229,7 +224,6 @@ stop_arm (struct PeerContext *p) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -246,10 +240,8 @@ run (void *cls, struct GNUNET_FS_FileInformation *fidir; size_t i; - sched = s; setup_peer (&p1, "test_fs_list_indexed_data.conf"); - fs = GNUNET_FS_start (sched, - cfg, + fs = GNUNET_FS_start (cfg, "test-fs-list_indexed", &progress_cb, NULL, diff --git a/src/fs/test_fs_namespace.c b/src/fs/test_fs_namespace.c index b7641ab3b..0d37affa2 100644 --- a/src/fs/test_fs_namespace.c +++ b/src/fs/test_fs_namespace.c @@ -35,8 +35,6 @@ #define START_ARM GNUNET_YES -static struct GNUNET_SCHEDULER_Handle *sched; - static struct PeerContext p1; static GNUNET_HashCode nsid; @@ -151,8 +149,7 @@ progress_cb (void *cls, err = 1; } /* give system 1ms to initiate update search! */ - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_MILLISECONDS, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, &abort_sks_search_task, NULL); } @@ -165,8 +162,7 @@ progress_cb (void *cls, "Wrong result for ksk search!\n"); err = 1; } - GNUNET_SCHEDULER_add_continuation (sched, - &abort_ksk_search_task, + GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -182,13 +178,11 @@ progress_cb (void *cls, "Error searching file: %s\n", event->value.search.specifics.error.message); if (sks_search == event->value.search.sc) - GNUNET_SCHEDULER_add_continuation (sched, - &abort_sks_search_task, + GNUNET_SCHEDULER_add_continuation (&abort_sks_search_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); else if (ksk_search == event->value.search.sc) - GNUNET_SCHEDULER_add_continuation (sched, - &abort_ksk_search_task, + GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); else @@ -384,15 +378,12 @@ testNamespace () static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { - sched = s; setup_peer (&p1, "test_fs_namespace_data.conf"); - fs = GNUNET_FS_start (sched, - cfg, + fs = GNUNET_FS_start (cfg, "test-fs-namespace", &progress_cb, NULL, diff --git a/src/fs/test_fs_namespace_list_updateable.c b/src/fs/test_fs_namespace_list_updateable.c index 2637b1665..359800f56 100644 --- a/src/fs/test_fs_namespace_list_updateable.c +++ b/src/fs/test_fs_namespace_list_updateable.c @@ -32,8 +32,6 @@ #define START_ARM GNUNET_YES -static struct GNUNET_SCHEDULER_Handle *sched; - static struct PeerContext p1; static struct GNUNET_FS_Handle *fs; @@ -226,15 +224,12 @@ testNamespace () static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { - sched = s; setup_peer (&p1, "test_fs_namespace_data.conf"); - fs = GNUNET_FS_start (sched, - cfg, + fs = GNUNET_FS_start (cfg, "test-fs-namespace", &progress_cb, NULL, diff --git a/src/fs/test_fs_publish.c b/src/fs/test_fs_publish.c index b5472ca93..327fa5a69 100644 --- a/src/fs/test_fs_publish.c +++ b/src/fs/test_fs_publish.c @@ -61,8 +61,6 @@ static struct PeerContext p1; static struct GNUNET_TIME_Absolute start; -static struct GNUNET_SCHEDULER_Handle *sched; - static struct GNUNET_FS_Handle *fs; static struct GNUNET_FS_PublishContext *publish; @@ -103,8 +101,7 @@ progress_cb (void *cls, (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024)); if (0 == strcmp ("publish-context-dir", event->value.publish.cctx)) - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -130,8 +127,7 @@ progress_cb (void *cls, { fprintf (stderr, "Scheduling abort task for error on `%s'\n", (const char*) event->value.publish.cctx); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -214,7 +210,6 @@ stop_arm (struct PeerContext *p) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -231,10 +226,8 @@ run (void *cls, struct GNUNET_FS_FileInformation *fidir; size_t i; - sched = s; setup_peer (&p1, "test_fs_publish_data.conf"); - fs = GNUNET_FS_start (sched, - cfg, + fs = GNUNET_FS_start (cfg, "test-fs-publish", &progress_cb, NULL, diff --git a/src/fs/test_fs_publish_persistence.c b/src/fs/test_fs_publish_persistence.c index b1260456b..52b2b270e 100644 --- a/src/fs/test_fs_publish_persistence.c +++ b/src/fs/test_fs_publish_persistence.c @@ -60,8 +60,6 @@ static struct PeerContext p1; static struct GNUNET_TIME_Absolute start; -static struct GNUNET_SCHEDULER_Handle *sched; - static struct GNUNET_FS_Handle *fs; static const struct GNUNET_CONFIGURATION_Handle *cfg; @@ -101,8 +99,7 @@ restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_FS_stop (fs); - fs = GNUNET_FS_start (sched, - cfg, + fs = GNUNET_FS_start (cfg, "test-fs-publish-persistence", &progress_cb, NULL, @@ -128,8 +125,7 @@ consider_restart (int ev) if (prev[i] == ev) return; prev[off++] = ev; - GNUNET_SCHEDULER_add_with_priority (sched, - GNUNET_SCHEDULER_PRIORITY_URGENT, + GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_URGENT, &restart_fs_task, NULL); } @@ -151,8 +147,7 @@ progress_cb (void *cls, (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024)); if (0 == strcmp ("publish-context-dir", event->value.publish.cctx)) - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -187,8 +182,7 @@ progress_cb (void *cls, err = 1; if (0 == strcmp ("publish-context-dir", event->value.publish.cctx)) - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -273,7 +267,6 @@ stop_arm (struct PeerContext *p) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) @@ -290,11 +283,9 @@ run (void *cls, struct GNUNET_FS_FileInformation *fidir; size_t i; - sched = s; cfg = c; setup_peer (&p1, "test_fs_publish_data.conf"); - fs = GNUNET_FS_start (sched, - cfg, + fs = GNUNET_FS_start (cfg, "test-fs-publish-persistence", &progress_cb, NULL, diff --git a/src/fs/test_fs_search.c b/src/fs/test_fs_search.c index 1609cd8e3..b003b75e1 100644 --- a/src/fs/test_fs_search.c +++ b/src/fs/test_fs_search.c @@ -61,8 +61,6 @@ static struct PeerContext p1; static struct GNUNET_TIME_Absolute start; -static struct GNUNET_SCHEDULER_Handle *sched; - static struct GNUNET_FS_Handle *fs; static struct GNUNET_FS_SearchContext *search; @@ -124,8 +122,7 @@ progress_cb (void *cls, #if VERBOSE printf ("Search complete.\n"); #endif - GNUNET_SCHEDULER_add_continuation (sched, - &abort_search_task, + GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -134,8 +131,7 @@ progress_cb (void *cls, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -143,8 +139,7 @@ progress_cb (void *cls, fprintf (stderr, "Error searching file: %s\n", event->value.search.specifics.error.message); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_search_task, + GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -171,8 +166,7 @@ progress_cb (void *cls, break; case GNUNET_FS_STATUS_SEARCH_STOPPED: GNUNET_assert (search == event->value.search.sc); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -221,7 +215,6 @@ stop_arm (struct PeerContext *p) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -236,10 +229,8 @@ run (void *cls, struct GNUNET_FS_FileInformation *fi; size_t i; - sched = s; setup_peer (&p1, "test_fs_search_data.conf"); - fs = GNUNET_FS_start (sched, - cfg, + fs = GNUNET_FS_start (cfg, "test-fs-search", &progress_cb, NULL, diff --git a/src/fs/test_fs_search_persistence.c b/src/fs/test_fs_search_persistence.c index d755a9582..4def3fe6a 100644 --- a/src/fs/test_fs_search_persistence.c +++ b/src/fs/test_fs_search_persistence.c @@ -61,8 +61,6 @@ static struct PeerContext p1; static struct GNUNET_TIME_Absolute start; -static struct GNUNET_SCHEDULER_Handle *sched; - static struct GNUNET_FS_Handle *fs; static struct GNUNET_FS_SearchContext *search; @@ -100,8 +98,7 @@ restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_FS_stop (fs); - fs = GNUNET_FS_start (sched, - cfg, + fs = GNUNET_FS_start (cfg, "test-fs-search-persistence", &progress_cb, NULL, @@ -129,8 +126,7 @@ consider_restart (int ev) if (prev[i] == ev) return; prev[off++] = ev; - GNUNET_SCHEDULER_add_with_priority (sched, - GNUNET_SCHEDULER_PRIORITY_URGENT, + GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_URGENT, &restart_fs_task, NULL); } @@ -181,8 +177,7 @@ progress_cb (void *cls, #if VERBOSE printf ("Search complete.\n"); #endif - GNUNET_SCHEDULER_add_continuation (sched, - &abort_search_task, + GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -191,8 +186,7 @@ progress_cb (void *cls, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -200,8 +194,7 @@ progress_cb (void *cls, fprintf (stderr, "Error searching file: %s\n", event->value.search.specifics.error.message); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_search_task, + GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -241,8 +234,7 @@ progress_cb (void *cls, break; case GNUNET_FS_STATUS_SEARCH_STOPPED: GNUNET_assert (search == event->value.search.sc); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); search = NULL; @@ -292,7 +284,6 @@ stop_arm (struct PeerContext *p) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) @@ -307,11 +298,9 @@ run (void *cls, struct GNUNET_FS_FileInformation *fi; size_t i; - sched = s; cfg = c; setup_peer (&p1, "test_fs_search_data.conf"); - fs = GNUNET_FS_start (sched, - cfg, + fs = GNUNET_FS_start (cfg, "test-fs-search-persistence", &progress_cb, NULL, diff --git a/src/fs/test_fs_start_stop.c b/src/fs/test_fs_start_stop.c index f64596061..71043bf36 100644 --- a/src/fs/test_fs_start_stop.c +++ b/src/fs/test_fs_start_stop.c @@ -33,8 +33,6 @@ #define START_ARM GNUNET_YES -static struct GNUNET_SCHEDULER_Handle *sched; - static struct PeerContext p1; struct PeerContext @@ -89,17 +87,14 @@ stop_arm (struct PeerContext *p) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_FS_Handle *fs; - sched = s; setup_peer (&p1, "test_fs_data.conf"); - fs = GNUNET_FS_start (sched, - cfg, + fs = GNUNET_FS_start (cfg, "test-fs-start-stop", &progress_cb, NULL, diff --git a/src/fs/test_fs_test_lib.c b/src/fs/test_fs_test_lib.c index 930038da5..3c6826181 100644 --- a/src/fs/test_fs_test_lib.c +++ b/src/fs/test_fs_test_lib.c @@ -44,8 +44,6 @@ static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS]; -static struct GNUNET_SCHEDULER_Handle *sched; - static int ret; static void @@ -63,8 +61,7 @@ do_stop (void *cls, "Finished download, shutting down\n", (unsigned long long) FILESIZE); } - GNUNET_FS_TEST_daemons_stop (sched, - NUM_DAEMONS, + GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); } @@ -76,8 +73,7 @@ do_download (void *cls, if (NULL == uri) { GNUNET_break (0); - GNUNET_SCHEDULER_add_now (sched, - &do_stop, + GNUNET_SCHEDULER_add_now (&do_stop, NULL); ret = 1; return; @@ -85,8 +81,7 @@ do_download (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n", (unsigned long long) FILESIZE); - GNUNET_FS_TEST_download (sched, - daemons[0], + GNUNET_FS_TEST_download (daemons[0], TIMEOUT, 1, SEED, uri, VERBOSE, @@ -102,16 +97,14 @@ do_publish (void *cls, { GNUNET_break (0); ret = 1; - GNUNET_SCHEDULER_add_now (sched, - &do_stop, + GNUNET_SCHEDULER_add_now (&do_stop, NULL); return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", (unsigned long long) FILESIZE); - GNUNET_FS_TEST_publish (sched, - daemons[0], + GNUNET_FS_TEST_publish (daemons[0], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED, VERBOSE, @@ -127,15 +120,13 @@ do_connect (void *cls, { GNUNET_break (0); ret = 1; - GNUNET_SCHEDULER_add_now (sched, - &do_stop, + GNUNET_SCHEDULER_add_now (&do_stop, NULL); return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemons started, will now try to connect them\n"); - GNUNET_FS_TEST_daemons_connect (sched, - daemons[0], + GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, &do_publish, @@ -145,14 +136,11 @@ do_connect (void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { - sched = s; - GNUNET_FS_TEST_daemons_start (sched, - "fs_test_lib_data.conf", + GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", TIMEOUT, NUM_DAEMONS, daemons, diff --git a/src/fs/test_fs_unindex.c b/src/fs/test_fs_unindex.c index 7adc4d229..e2c0e86ee 100644 --- a/src/fs/test_fs_unindex.c +++ b/src/fs/test_fs_unindex.c @@ -60,8 +60,6 @@ static struct PeerContext p1; static struct GNUNET_TIME_Absolute start; -static struct GNUNET_SCHEDULER_Handle *sched; - static struct GNUNET_FS_Handle *fs; static struct GNUNET_FS_UnindexContext *unindex; @@ -120,8 +118,7 @@ progress_cb (void *cls, case GNUNET_FS_STATUS_UNINDEX_COMPLETED: printf ("Unindex complete, %llu kbps.\n", (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024)); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_unindex_task, + GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -140,8 +137,7 @@ progress_cb (void *cls, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -149,8 +145,7 @@ progress_cb (void *cls, fprintf (stderr, "Error unindexing file: %s\n", event->value.unindex.specifics.error.message); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_unindex_task, + GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -177,8 +172,7 @@ progress_cb (void *cls, break; case GNUNET_FS_STATUS_UNINDEX_STOPPED: GNUNET_assert (unindex == event->value.unindex.uc); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -226,7 +220,6 @@ stop_arm (struct PeerContext *p) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -241,11 +234,9 @@ run (void *cls, struct GNUNET_FS_FileInformation *fi; size_t i; - sched = s; setup_peer (&p1, "test_fs_unindex_data.conf"); fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst"); - fs = GNUNET_FS_start (sched, - cfg, + fs = GNUNET_FS_start (cfg, "test-fs-unindex", &progress_cb, NULL, diff --git a/src/fs/test_fs_unindex_persistence.c b/src/fs/test_fs_unindex_persistence.c index 42f047b70..eec181544 100644 --- a/src/fs/test_fs_unindex_persistence.c +++ b/src/fs/test_fs_unindex_persistence.c @@ -59,8 +59,6 @@ static struct PeerContext p1; static struct GNUNET_TIME_Absolute start; -static struct GNUNET_SCHEDULER_Handle *sched; - static struct GNUNET_FS_Handle *fs; static struct GNUNET_FS_UnindexContext *unindex; @@ -108,8 +106,7 @@ restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_FS_stop (fs); - fs = GNUNET_FS_start (sched, - cfg, + fs = GNUNET_FS_start (cfg, "test-fs-unindex-persistence", &progress_cb, NULL, @@ -135,8 +132,7 @@ consider_restart (int ev) if (prev[i] == ev) return; prev[off++] = ev; - GNUNET_SCHEDULER_add_with_priority (sched, - GNUNET_SCHEDULER_PRIORITY_URGENT, + GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_URGENT, &restart_fs_task, NULL); } @@ -169,8 +165,7 @@ progress_cb (void *cls, case GNUNET_FS_STATUS_UNINDEX_COMPLETED: printf ("Unindex complete, %llu kbps.\n", (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024)); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_unindex_task, + GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -209,8 +204,7 @@ progress_cb (void *cls, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -218,8 +212,7 @@ progress_cb (void *cls, fprintf (stderr, "Error unindexing file: %s\n", event->value.unindex.specifics.error.message); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_unindex_task, + GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -247,8 +240,7 @@ progress_cb (void *cls, break; case GNUNET_FS_STATUS_UNINDEX_STOPPED: GNUNET_assert (unindex == event->value.unindex.uc); - GNUNET_SCHEDULER_add_continuation (sched, - &abort_publish_task, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -296,7 +288,6 @@ stop_arm (struct PeerContext *p) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) @@ -311,12 +302,10 @@ run (void *cls, struct GNUNET_FS_FileInformation *fi; size_t i; - sched = s; cfg = c; setup_peer (&p1, "test_fs_unindex_data.conf"); fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst"); - fs = GNUNET_FS_start (sched, - cfg, + fs = GNUNET_FS_start (cfg, "test-fs-unindex-persistence", &progress_cb, NULL, diff --git a/src/fs/test_gnunet_service_fs_migration.c b/src/fs/test_gnunet_service_fs_migration.c index 3d6afbdc2..092cedfc2 100644 --- a/src/fs/test_gnunet_service_fs_migration.c +++ b/src/fs/test_gnunet_service_fs_migration.c @@ -48,8 +48,6 @@ static struct GNUNET_FS_TestDaemon *daemons[2]; -static struct GNUNET_SCHEDULER_Handle *sched; - static int ok; static struct GNUNET_TIME_Absolute start_time; @@ -61,8 +59,7 @@ do_stop (void *cls, struct GNUNET_TIME_Relative del; char *fancy; - GNUNET_FS_TEST_daemons_stop (sched, - 2, + GNUNET_FS_TEST_daemons_stop (2, daemons); if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) { @@ -95,8 +92,7 @@ do_download (void *cls, if (emsg != NULL) { - GNUNET_FS_TEST_daemons_stop (sched, - 2, + GNUNET_FS_TEST_daemons_stop (2, daemons); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to stop source daemon: %s\n", @@ -109,8 +105,7 @@ do_download (void *cls, "Downloading %llu bytes\n", (unsigned long long) FILESIZE); start_time = GNUNET_TIME_absolute_get (); - GNUNET_FS_TEST_download (sched, - daemons[0], + GNUNET_FS_TEST_download (daemons[0], TIMEOUT, 1, SEED, uri, VERBOSE, @@ -143,8 +138,7 @@ do_wait (void *cls, if (NULL == uri) { - GNUNET_FS_TEST_daemons_stop (sched, - 2, + GNUNET_FS_TEST_daemons_stop (2, daemons); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Timeout during upload attempt, shutting down with error\n"); @@ -154,8 +148,7 @@ do_wait (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Waiting to allow content to migrate\n"); d = GNUNET_FS_uri_dup (uri); - (void) GNUNET_SCHEDULER_add_delayed (sched, - MIGRATION_DELAY, + (void) GNUNET_SCHEDULER_add_delayed (MIGRATION_DELAY, &stop_source_peer, d); } @@ -167,8 +160,7 @@ do_publish (void *cls, { if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) { - GNUNET_FS_TEST_daemons_stop (sched, - 2, + GNUNET_FS_TEST_daemons_stop (2, daemons); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Timeout during connect attempt, shutting down with error\n"); @@ -178,8 +170,7 @@ do_publish (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", (unsigned long long) FILESIZE); - GNUNET_FS_TEST_publish (sched, - daemons[1], + GNUNET_FS_TEST_publish (daemons[1], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED, VERBOSE, @@ -201,8 +192,7 @@ do_connect (void *cls, } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemons started, will now try to connect them\n"); - GNUNET_FS_TEST_daemons_connect (sched, - daemons[0], + GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, &do_publish, @@ -212,14 +202,11 @@ do_connect (void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { - sched = s; - GNUNET_FS_TEST_daemons_start (sched, - "test_gnunet_service_fs_migration_data.conf", + GNUNET_FS_TEST_daemons_start ("test_gnunet_service_fs_migration_data.conf", TIMEOUT, 2, daemons, diff --git a/src/fs/test_gnunet_service_fs_p2p.c b/src/fs/test_gnunet_service_fs_p2p.c index f026baf6b..3bb808c48 100644 --- a/src/fs/test_gnunet_service_fs_p2p.c +++ b/src/fs/test_gnunet_service_fs_p2p.c @@ -44,8 +44,6 @@ static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS]; -static struct GNUNET_SCHEDULER_Handle *sched; - static int ok; static struct GNUNET_TIME_Absolute start_time; @@ -57,8 +55,7 @@ do_stop (void *cls, struct GNUNET_TIME_Relative del; char *fancy; - GNUNET_FS_TEST_daemons_stop (sched, - NUM_DAEMONS, + GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) { @@ -89,8 +86,7 @@ do_download (void *cls, { if (NULL == uri) { - GNUNET_FS_TEST_daemons_stop (sched, - NUM_DAEMONS, + GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Timeout during upload attempt, shutting down with error\n"); @@ -101,8 +97,7 @@ do_download (void *cls, "Downloading %llu bytes\n", (unsigned long long) FILESIZE); start_time = GNUNET_TIME_absolute_get (); - GNUNET_FS_TEST_download (sched, - daemons[0], + GNUNET_FS_TEST_download (daemons[0], TIMEOUT, 1, SEED, uri, VERBOSE, @@ -116,8 +111,7 @@ do_publish (void *cls, { if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) { - GNUNET_FS_TEST_daemons_stop (sched, - NUM_DAEMONS, + GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Timeout during connect attempt, shutting down with error\n"); @@ -127,8 +121,7 @@ do_publish (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", (unsigned long long) FILESIZE); - GNUNET_FS_TEST_publish (sched, - daemons[1], + GNUNET_FS_TEST_publish (daemons[1], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED, VERBOSE, @@ -143,8 +136,7 @@ do_connect (void *cls, GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemons started, will now try to connect them\n"); - GNUNET_FS_TEST_daemons_connect (sched, - daemons[0], + GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, &do_publish, @@ -154,14 +146,11 @@ do_connect (void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { - sched = s; - GNUNET_FS_TEST_daemons_start (sched, - "fs_test_lib_data.conf", + GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", TIMEOUT, NUM_DAEMONS, daemons, diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c index 52c996aed..f41f0add0 100644 --- a/src/hostlist/gnunet-daemon-hostlist.c +++ b/src/hostlist/gnunet-daemon-hostlist.c @@ -235,14 +235,12 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * Main function that will be run. * * @param cls closure - * @param sched the scheduler to use * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param cfg configuration */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle * sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle * cfg) @@ -268,9 +266,9 @@ run (void *cls, - stats = GNUNET_STATISTICS_create (sched, "hostlist", cfg); + stats = GNUNET_STATISTICS_create ("hostlist", cfg); - core = GNUNET_CORE_connect (sched, cfg, + core = GNUNET_CORE_connect (cfg, GNUNET_TIME_UNIT_FOREVER_REL, NULL, &core_init, @@ -281,18 +279,17 @@ run (void *cls, if (bootstrapping) { - GNUNET_HOSTLIST_client_start (cfg, sched, stats, + GNUNET_HOSTLIST_client_start (cfg, stats, &client_ch, &client_dh, &client_adv_handler, learning); } #if HAVE_MHD if (provide_hostlist) { - GNUNET_HOSTLIST_server_start (cfg, sched, stats, core, &server_ch, &server_dh, advertising ); + GNUNET_HOSTLIST_server_start (cfg, stats, core, &server_ch, &server_dh, advertising ); } #endif - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task, NULL); if (NULL == core) @@ -300,7 +297,7 @@ run (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to connect to `%s' service.\n"), "core"); - GNUNET_SCHEDULER_shutdown (sched); + GNUNET_SCHEDULER_shutdown (); return; } } diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index e41c8ff18..47d625437 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c @@ -108,11 +108,6 @@ struct Hostlist */ static const struct GNUNET_CONFIGURATION_Handle *cfg; -/** - * Our scheduler. - */ -static struct GNUNET_SCHEDULER_Handle *sched; - /** * Statistics handle. */ @@ -769,8 +764,7 @@ download_prepare () "Scheduling task for hostlist download using cURL\n"); #endif ti_download - = GNUNET_SCHEDULER_add_select (sched, - GNUNET_SCHEDULER_PRIORITY_DEFAULT, + = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_SCHEDULER_NO_TASK, rtime, grs, @@ -1036,8 +1030,7 @@ task_download_dispatcher (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download in progess, have to wait...\n"); - ti_download_dispatcher_task = GNUNET_SCHEDULER_add_delayed (sched, - WAITING_INTERVALL, + ti_download_dispatcher_task = GNUNET_SCHEDULER_add_delayed (WAITING_INTERVALL, &task_download_dispatcher, NULL); } @@ -1061,8 +1054,7 @@ task_check (void *cls, if (stat_connection_count < MIN_CONNECTIONS) { - ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now ( sched, - &task_download_dispatcher, + ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now (&task_download_dispatcher, NULL); } @@ -1093,8 +1085,7 @@ task_check (void *cls, stat_connection_count, MIN_CONNECTIONS, (unsigned long long) delay.rel_value); - ti_check_download = GNUNET_SCHEDULER_add_delayed (sched, - delay, + ti_check_download = GNUNET_SCHEDULER_add_delayed (delay, &task_check, NULL); } @@ -1136,8 +1127,7 @@ task_hostlist_saving (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Hostlists will be saved to file again in %llums\n"), (unsigned long long) SAVING_INTERVALL.rel_value); - ti_saving_task = GNUNET_SCHEDULER_add_delayed (sched, - SAVING_INTERVALL, + ti_saving_task = GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, &task_hostlist_saving, NULL); } @@ -1259,8 +1249,7 @@ handler_advertisement (void *cls, stat_testing_hostlist = GNUNET_YES; stat_testing_allowed = GNUNET_NO; - ti_testing_intervall_task = GNUNET_SCHEDULER_add_delayed (sched, - TESTING_INTERVAL, + ti_testing_intervall_task = GNUNET_SCHEDULER_add_delayed (TESTING_INTERVAL, &task_testing_intervall_reset, NULL); @@ -1268,8 +1257,7 @@ handler_advertisement (void *cls, "Testing new hostlist advertisements is locked for the next %u ms\n", TESTING_INTERVAL.rel_value); - ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now (sched, - &task_download_dispatcher, + ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now (&task_download_dispatcher, NULL); return GNUNET_OK; @@ -1294,8 +1282,7 @@ primary_task (void *cls, int success) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Statistics request done, scheduling hostlist download\n"); #endif - ti_check_download = GNUNET_SCHEDULER_add_now (sched, - &task_check, + ti_check_download = GNUNET_SCHEDULER_add_now (&task_check, NULL); } @@ -1502,7 +1489,6 @@ static void save_hostlist_file ( int shutdown ) */ int GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, - struct GNUNET_SCHEDULER_Handle *s, struct GNUNET_STATISTICS_Handle *st, GNUNET_CORE_ConnectEventHandler *ch, GNUNET_CORE_DisconnectEventHandler *dh, @@ -1517,14 +1503,13 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, GNUNET_break (0); return GNUNET_SYSERR; } - transport = GNUNET_TRANSPORT_connect (s, c, NULL, NULL, NULL, NULL, NULL); + transport = GNUNET_TRANSPORT_connect (c, NULL, NULL, NULL, NULL, NULL); if (NULL == transport) { curl_global_cleanup (); return GNUNET_SYSERR; } cfg = c; - sched = s; stats = st; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, @@ -1550,8 +1535,7 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Hostlists will be saved to file again in %llums\n"), (unsigned long long) SAVING_INTERVALL.rel_value); - ti_saving_task = GNUNET_SCHEDULER_add_delayed (sched, - SAVING_INTERVALL, + ti_saving_task = GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, &task_hostlist_saving, NULL); } @@ -1606,29 +1590,24 @@ GNUNET_HOSTLIST_client_stop () if (ti_saving_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, - ti_saving_task); + GNUNET_SCHEDULER_cancel (ti_saving_task); } if (ti_download_dispatcher_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, - ti_download_dispatcher_task); + GNUNET_SCHEDULER_cancel (ti_download_dispatcher_task); } if (ti_testing_intervall_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, - ti_testing_intervall_task); + GNUNET_SCHEDULER_cancel (ti_testing_intervall_task); } if (ti_download != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, - ti_download); + GNUNET_SCHEDULER_cancel (ti_download); } if (ti_check_download != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, - ti_check_download); + GNUNET_SCHEDULER_cancel (ti_check_download); curl_global_cleanup (); } if (transport != NULL) @@ -1640,7 +1619,6 @@ GNUNET_HOSTLIST_client_stop () GNUNET_free_non_null (proxy); proxy = NULL; cfg = NULL; - sched = NULL; } /* end of hostlist-client.c */ diff --git a/src/hostlist/hostlist-client.h b/src/hostlist/hostlist-client.h index 04c3bb60f..b29b96a04 100644 --- a/src/hostlist/hostlist-client.h +++ b/src/hostlist/hostlist-client.h @@ -82,7 +82,6 @@ * Start downloading hostlists from hostlist servers as necessary. * * @param c the configuration to use - * @param s the scheduler to use * @param st hande for publishing statistics * @param ch set to handler for connect notifications * @param dh set to handler for disconnect notifications @@ -92,7 +91,6 @@ */ int GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, - struct GNUNET_SCHEDULER_Handle *s, struct GNUNET_STATISTICS_Handle *st, GNUNET_CORE_ConnectEventHandler *ch, GNUNET_CORE_DisconnectEventHandler *dh, diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c index 8fdee5545..1c85f8f75 100644 --- a/src/hostlist/hostlist-server.c +++ b/src/hostlist/hostlist-server.c @@ -49,11 +49,6 @@ static struct MHD_Daemon *daemon_handle_v4; */ static const struct GNUNET_CONFIGURATION_Handle *cfg; -/** - * Our scheduler. - */ -static struct GNUNET_SCHEDULER_Handle *sched; - /** * For keeping statistics. */ @@ -539,8 +534,7 @@ prepare_daemon (struct MHD_Daemon *daemon_handle) GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1); GNUNET_NETWORK_fdset_copy_native (wws, &ws, max + 1); GNUNET_NETWORK_fdset_copy_native (wes, &es, max + 1); - ret = GNUNET_SCHEDULER_add_select (sched, - GNUNET_SCHEDULER_PRIORITY_HIGH, + ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH, GNUNET_SCHEDULER_NO_TASK, tv, wrs, @@ -562,7 +556,6 @@ prepare_daemon (struct MHD_Daemon *daemon_handle) */ int GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, - struct GNUNET_SCHEDULER_Handle *s, struct GNUNET_STATISTICS_Handle *st, struct GNUNET_CORE_Handle *co, GNUNET_CORE_ConnectEventHandler *server_ch, @@ -580,10 +573,9 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, else GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Advertising enabled on this hostlist server\n"); - sched = s; cfg = c; stats = st; - peerinfo = GNUNET_PEERINFO_connect (sched, cfg); + peerinfo = GNUNET_PEERINFO_connect (cfg); if (peerinfo == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -682,7 +674,7 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, if (daemon_handle_v6 != NULL) hostlist_task_v6 = prepare_daemon (daemon_handle_v6); - notify = GNUNET_PEERINFO_notify ( cfg, sched, process_notify, NULL); + notify = GNUNET_PEERINFO_notify ( cfg, process_notify, NULL); return GNUNET_OK; } @@ -704,12 +696,12 @@ GNUNET_HOSTLIST_server_stop () } if (GNUNET_SCHEDULER_NO_TASK != hostlist_task_v6) { - GNUNET_SCHEDULER_cancel (sched, hostlist_task_v6); + GNUNET_SCHEDULER_cancel (hostlist_task_v6); hostlist_task_v6 = GNUNET_SCHEDULER_NO_TASK; } if (GNUNET_SCHEDULER_NO_TASK != hostlist_task_v4) { - GNUNET_SCHEDULER_cancel (sched, hostlist_task_v4); + GNUNET_SCHEDULER_cancel (hostlist_task_v4); hostlist_task_v4 = GNUNET_SCHEDULER_NO_TASK; } if (pitr != NULL) @@ -738,7 +730,6 @@ GNUNET_HOSTLIST_server_stop () peerinfo = NULL; } cfg = NULL; - sched = NULL; stats = NULL; core = NULL; } diff --git a/src/hostlist/hostlist-server.h b/src/hostlist/hostlist-server.h index 187bdddf0..98ce2179b 100644 --- a/src/hostlist/hostlist-server.h +++ b/src/hostlist/hostlist-server.h @@ -40,7 +40,6 @@ */ int GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, - struct GNUNET_SCHEDULER_Handle *s, struct GNUNET_STATISTICS_Handle *st, struct GNUNET_CORE_Handle *core, GNUNET_CORE_ConnectEventHandler *server_ch, diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c index 63ba53b69..28a8ddfcf 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist.c +++ b/src/hostlist/test_gnunet_daemon_hostlist.c @@ -39,8 +39,6 @@ static int ok; -static struct GNUNET_SCHEDULER_Handle *sched; - static GNUNET_SCHEDULER_TaskIdentifier timeout_task; struct PeerContext @@ -71,7 +69,7 @@ clean_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_TRANSPORT_disconnect (p2.th); p2.th = NULL; } - GNUNET_SCHEDULER_shutdown (sched); + GNUNET_SCHEDULER_shutdown (); } /** @@ -109,12 +107,10 @@ notify_connect (void *cls, ok = 0; if (timeout_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, - timeout_task); + GNUNET_SCHEDULER_cancel (timeout_task); timeout_task = GNUNET_SCHEDULER_NO_TASK; } - GNUNET_SCHEDULER_add_now (sched, - &clean_up, NULL); + GNUNET_SCHEDULER_add_now (&clean_up, NULL); } @@ -143,7 +139,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); - p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, p, NULL, + p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, ¬ify_connect, NULL); GNUNET_assert (p->th != NULL); GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); @@ -177,8 +173,7 @@ stop_arm (struct PeerContext *p) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking ARM to stop core service\n"); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_SECONDS, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &waitpid_task, p); } @@ -196,20 +191,16 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); ok++; - sched = s; - timeout_task = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_error, NULL); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf"); diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c index 16bd91d8b..7e2e2ac9e 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c @@ -30,37 +30,29 @@ #include "gnunet_resolver_service.h" #include "gnunet_statistics_service.h" -#define VERBOSE GNUNET_NO +#define VERBOSE GNUNET_YES #define START_ARM GNUNET_YES - #define MAX_URL_LEN 1000 /** * How long until wait until testcases fails */ #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 180) - #define CHECK_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) static int timeout; - static int adv_sent; - static int adv_arrived; static int learned_hostlist_saved; - static int learned_hostlist_downloaded; static char * current_adv_uri; static const struct GNUNET_CONFIGURATION_Handle *cfg; -static struct GNUNET_SCHEDULER_Handle *sched; - static GNUNET_SCHEDULER_TaskIdentifier timeout_task; - static GNUNET_SCHEDULER_TaskIdentifier check_task; struct PeerContext @@ -80,19 +72,16 @@ static struct PeerContext adv_peer; static struct PeerContext learn_peer; static struct GNUNET_STATISTICS_GetHandle * download_stats; - static struct GNUNET_STATISTICS_GetHandle * urisrecv_stat; - static struct GNUNET_STATISTICS_GetHandle * advsent_stat; - static void shutdown_testcase() { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown testcase....\n"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping Timeout Task.\n"); if (timeout_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, timeout_task); + GNUNET_SCHEDULER_cancel (timeout_task); timeout_task = GNUNET_SCHEDULER_NO_TASK; } @@ -106,9 +95,9 @@ static void shutdown_testcase() GNUNET_STATISTICS_get_cancel (advsent_stat); */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping Statistics Check Task.\n"); - if ((check_task != GNUNET_SCHEDULER_NO_TASK) && (sched !=NULL)) + if (check_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, check_task); + GNUNET_SCHEDULER_cancel (check_task); check_task = GNUNET_SCHEDULER_NO_TASK; } @@ -169,7 +158,7 @@ static void shutdown_testcase() #endif GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down scheduler\n"); - GNUNET_SCHEDULER_shutdown (sched); + GNUNET_SCHEDULER_shutdown (); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown complete....\n"); } @@ -286,8 +275,7 @@ check_statistics (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) &process_adv_sent, NULL); } - check_task = GNUNET_SCHEDULER_add_delayed (sched, - CHECK_INTERVALL, + check_task = GNUNET_SCHEDULER_add_delayed (CHECK_INTERVALL, &check_statistics, NULL); } @@ -381,7 +369,7 @@ setup_learn_peer (struct PeerContext *p, const char *cfgname) } if ( NULL != filename) GNUNET_free ( filename ); - p->core = GNUNET_CORE_connect (sched, p->cfg, + p->core = GNUNET_CORE_connect (p->cfg, GNUNET_TIME_UNIT_FOREVER_REL, NULL, NULL, @@ -390,7 +378,7 @@ setup_learn_peer (struct PeerContext *p, const char *cfgname) NULL, GNUNET_NO, learn_handlers ); GNUNET_assert ( NULL != p->core ); - p->stats = GNUNET_STATISTICS_create (sched, "hostlist", p->cfg); + p->stats = GNUNET_STATISTICS_create ("hostlist", p->cfg); GNUNET_assert ( NULL != p->stats ); } @@ -409,14 +397,13 @@ setup_adv_peer (struct PeerContext *p, const char *cfgname) "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); - p->stats = GNUNET_STATISTICS_create (sched, "hostlist", p->cfg); + p->stats = GNUNET_STATISTICS_create ("hostlist", p->cfg); GNUNET_assert ( NULL != p->stats ); } static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) @@ -429,17 +416,14 @@ run (void *cls, learned_hostlist_downloaded = GNUNET_NO; cfg = c; - sched = s; setup_adv_peer (&adv_peer, "test_learning_adv_peer.conf"); setup_learn_peer (&learn_peer, "test_learning_learn_peer.conf"); - timeout_task = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_error, NULL); - check_task = GNUNET_SCHEDULER_add_delayed (sched, - CHECK_INTERVALL, + check_task = GNUNET_SCHEDULER_add_delayed (CHECK_INTERVALL, &check_statistics, NULL); } @@ -531,4 +515,4 @@ main (int argc, char *argv[]) return ret; } -/* end of test_gnunet_daemon_hostlist_learning.c */ +/* end of test_gnunet_daemon_hostlist.c */ diff --git a/src/include/gnunet_arm_service.h b/src/include/gnunet_arm_service.h index 912db027b..317105520 100644 --- a/src/include/gnunet_arm_service.h +++ b/src/include/gnunet_arm_service.h @@ -70,13 +70,11 @@ struct GNUNET_ARM_Handle; * @param cfg configuration to use (needed to contact ARM; * the ARM service may internally use a different * configuration to determine how to start the service). - * @param sched scheduler to use * @param service service that *this* process is implementing/providing, can be NULL * @return context to use for further ARM operations, NULL on error */ struct GNUNET_ARM_Handle * GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, - struct GNUNET_SCHEDULER_Handle *sched, const char *service); diff --git a/src/include/gnunet_client_lib.h b/src/include/gnunet_client_lib.h index 49ccc6c6b..41dbe4efc 100644 --- a/src/include/gnunet_client_lib.h +++ b/src/include/gnunet_client_lib.h @@ -49,15 +49,11 @@ struct GNUNET_CLIENT_Connection; /** * Get a connection with a service. * - * @param sched scheduler to use * @param service_name name of the service * @param cfg configuration to use * @return NULL on error (service unknown to configuration) */ -struct GNUNET_CLIENT_Connection *GNUNET_CLIENT_connect (struct - GNUNET_SCHEDULER_Handle - *sched, - const char +struct GNUNET_CLIENT_Connection *GNUNET_CLIENT_connect (const char *service_name, const struct GNUNET_CONFIGURATION_Handle @@ -210,7 +206,6 @@ GNUNET_CLIENT_transmit_and_get_response (struct GNUNET_CLIENT_Connection *sock, /** * Wait until the service is running. * - * @param sched scheduler to use * @param service name of the service to wait for * @param cfg configuration to use * @param timeout how long to wait at most in ms @@ -219,8 +214,7 @@ GNUNET_CLIENT_transmit_and_get_response (struct GNUNET_CLIENT_Connection *sock, * or "TIMEOUT" (service not known to be running)) * @param task_cls closure for task */ -void GNUNET_CLIENT_service_test (struct GNUNET_SCHEDULER_Handle *sched, - const char *service, +void GNUNET_CLIENT_service_test (const char *service, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TIME_Relative timeout, GNUNET_SCHEDULER_Task task, void *task_cls); diff --git a/src/include/gnunet_connection_lib.h b/src/include/gnunet_connection_lib.h index d5942236b..33afb0386 100644 --- a/src/include/gnunet_connection_lib.h +++ b/src/include/gnunet_connection_lib.h @@ -99,15 +99,11 @@ GNUNET_CONNECTION_persist_(struct GNUNET_CONNECTION_Handle *sock); * socket should henceforth be no longer used directly. * GNUNET_socket_destroy will close it. * - * @param sched scheduler to use * @param osSocket existing socket to box * @return the boxed socket handle */ struct GNUNET_CONNECTION_Handle *GNUNET_CONNECTION_create_from_existing (struct - GNUNET_SCHEDULER_Handle - *sched, - struct GNUNET_NETWORK_Handle *osSocket); @@ -116,17 +112,13 @@ struct GNUNET_CONNECTION_Handle * Create a socket handle by accepting on a listen socket. This * function may block if the listen socket has no connection ready. * - * @param sched scheduler to use * @param access function to use to check if access is allowed * @param access_cls closure for access * @param lsock listen socket * @return the socket handle, NULL on error (for example, access refused) */ struct GNUNET_CONNECTION_Handle - *GNUNET_CONNECTION_create_from_accept (struct - GNUNET_SCHEDULER_Handle - *sched, - GNUNET_CONNECTION_AccessCheck + *GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access, void *access_cls, struct GNUNET_NETWORK_Handle @@ -138,15 +130,13 @@ struct GNUNET_CONNECTION_Handle * This function returns immediately, even if the connection has not * yet been established. This function only creates TCP connections. * - * @param sched scheduler to use * @param cfg configuration to use * @param hostname name of the host to connect to * @param port port to connect to * @return the socket handle */ struct GNUNET_CONNECTION_Handle - *GNUNET_CONNECTION_create_from_connect (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, + *GNUNET_CONNECTION_create_from_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *hostname, uint16_t port); @@ -156,14 +146,12 @@ struct GNUNET_CONNECTION_Handle * This function returns immediately, even if the connection has not * yet been established. This function only creates UNIX connections. * - * @param sched scheduler to use * @param cfg configuration to use * @param unixpath path to connect to) * @return the socket handle, NULL on systems without UNIX support */ struct GNUNET_CONNECTION_Handle * -GNUNET_CONNECTION_create_from_connect_to_unixpath (struct GNUNET_SCHEDULER_Handle *sched, - const struct +GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *unixpath); @@ -175,16 +163,13 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (struct GNUNET_SCHEDULER_Handl * This function returns immediately, even if the connection has not * yet been established. This function only creates TCP connections. * - * @param sched scheduler to use * @param af_family address family to use * @param serv_addr server address * @param addrlen length of server address * @return the socket handle */ struct GNUNET_CONNECTION_Handle - *GNUNET_CONNECTION_create_from_sockaddr (struct - GNUNET_SCHEDULER_Handle - *sched, int af_family, + *GNUNET_CONNECTION_create_from_sockaddr (int af_family, const struct sockaddr *serv_addr, socklen_t addrlen); diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h index caa02c6b2..7fe871741 100644 --- a/src/include/gnunet_core_service.h +++ b/src/include/gnunet_core_service.h @@ -178,7 +178,6 @@ typedef void * Certain events (such as connect/disconnect notifications) are not * subject to queue size limitations. * - * @param sched scheduler to use * @param cfg configuration to use * @param timeout after how long should we give up trying to connect to the core service? * @param cls closure for the various callbacks that follow (including handlers in the handlers array) @@ -215,8 +214,7 @@ typedef void * NULL on error (in this case, init is never called) */ struct GNUNET_CORE_Handle * -GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TIME_Relative timeout, void *cls, GNUNET_CORE_StartupCallback init, @@ -257,7 +255,6 @@ struct GNUNET_CORE_PeerRequestHandle; * to our connection attempt within the given time frame, 'cont' will * be called with the TIMEOUT reason code. * - * @param sched scheduler to use * @param cfg configuration to use * @param timeout how long to try to talk to core * @param peer who should we connect to @@ -266,8 +263,7 @@ struct GNUNET_CORE_PeerRequestHandle; * @return NULL on error (cont will not be called), otherwise handle for cancellation */ struct GNUNET_CORE_PeerRequestHandle * -GNUNET_CORE_peer_request_connect (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_CORE_peer_request_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TIME_Relative timeout, const struct GNUNET_PeerIdentity * peer, GNUNET_SCHEDULER_Task cont, @@ -317,7 +313,6 @@ struct GNUNET_CORE_InformationRequestContext; /** * Obtain statistics and/or change preferences for the given peer. * - * @param sched scheduler to use * @param cfg configuration to use * @param peer identifies the peer * @param timeout after how long should we give up (and call "info" with NULL @@ -340,8 +335,7 @@ struct GNUNET_CORE_InformationRequestContext; * @return NULL on error */ struct GNUNET_CORE_InformationRequestContext * -GNUNET_CORE_peer_change_preference (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_CORE_peer_change_preference (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *peer, struct GNUNET_TIME_Relative timeout, struct GNUNET_BANDWIDTH_Value32NBO bw_out, @@ -362,15 +356,13 @@ GNUNET_CORE_peer_change_preference_cancel (struct GNUNET_CORE_InformationRequest /** * Obtain statistics and/or change preferences for the given peer. * - * @param sched scheduler to use * @param cfg configuration to use * @param peer_cb function to call with the peer information * @param cb_cls closure for peer_cb * @return GNUNET_OK if iterating, GNUNET_SYSERR on error */ int -GNUNET_CORE_iterate_peers (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CORE_ConnectEventHandler peer_cb, void *cb_cls); diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index 8b1379e45..5d8b4ab8a 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h @@ -436,7 +436,6 @@ struct GNUNET_CRYPTO_FileHashContext; /** * Compute the hash of an entire file. * - * @param sched scheduler to use * @param priority scheduling priority to use * @param filename name of file to hash * @param blocksize number of bytes to process in one task @@ -445,8 +444,7 @@ struct GNUNET_CRYPTO_FileHashContext; * @return NULL on (immediate) errror */ struct GNUNET_CRYPTO_FileHashContext * -GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched, - enum GNUNET_SCHEDULER_Priority priority, +GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, const char *filename, size_t blocksize, GNUNET_CRYPTO_HashCompletedCallback callback, diff --git a/src/include/gnunet_datacache_lib.h b/src/include/gnunet_datacache_lib.h index 74878f08b..5fcd99ad4 100644 --- a/src/include/gnunet_datacache_lib.h +++ b/src/include/gnunet_datacache_lib.h @@ -52,14 +52,12 @@ struct GNUNET_DATACACHE_Handle; /** * Create a data cache. * - * @param sched scheduler to use * @param cfg configuration to use * @param section section in the configuration that contains our options * @return handle to use to access the service */ struct GNUNET_DATACACHE_Handle * -GNUNET_DATACACHE_create (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section); diff --git a/src/include/gnunet_datastore_service.h b/src/include/gnunet_datastore_service.h index 8d35f7900..4c9fad965 100644 --- a/src/include/gnunet_datastore_service.h +++ b/src/include/gnunet_datastore_service.h @@ -57,15 +57,11 @@ struct GNUNET_DATASTORE_Handle; * Connect to the datastore service. * * @param cfg configuration to use - * @param sched scheduler to use * @return handle to use to access the service */ struct GNUNET_DATASTORE_Handle *GNUNET_DATASTORE_connect (const struct GNUNET_CONFIGURATION_Handle - *cfg, - struct - GNUNET_SCHEDULER_Handle - *sched); + *cfg); /** diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h index b3bf2b84b..7ab818de7 100644 --- a/src/include/gnunet_dht_service.h +++ b/src/include/gnunet_dht_service.h @@ -99,15 +99,13 @@ enum GNUNET_DHT_RouteOption /** * Initialize the connection with the DHT service. * - * @param sched scheduler to use * @param cfg configuration to use * @param ht_len size of the internal hash table to use for * processing multiple GET/FIND requests in parallel * @return NULL on error */ struct GNUNET_DHT_Handle * -GNUNET_DHT_connect (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_DHT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len); diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h index b8df9d7b6..6eb666049 100644 --- a/src/include/gnunet_disk_lib.h +++ b/src/include/gnunet_disk_lib.h @@ -496,15 +496,12 @@ int GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator * If a scheduler does not need to be used, GNUNET_DISK_directory_scan * may provide a simpler API. * - * @param sched scheduler to use * @param prio priority to use * @param dirName the name of the directory * @param callback the method to call for each file * @param callback_cls closure for callback */ -void GNUNET_DISK_directory_iterator_start (struct GNUNET_SCHEDULER_Handle - *sched, - enum GNUNET_SCHEDULER_Priority +void GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio, const char *dirName, GNUNET_DISK_DirectoryIteratorCallback callback, void *callback_cls); diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index 0e5dccc2d..68c250e97 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h @@ -1585,7 +1585,6 @@ struct GNUNET_FS_Handle; /** * Setup a connection to the file-sharing service. * - * @param sched scheduler to use * @param cfg configuration to use * @param client_name unique identifier for this client * @param upcb function to call to notify about FS actions @@ -1595,8 +1594,7 @@ struct GNUNET_FS_Handle; * @return NULL on error */ struct GNUNET_FS_Handle * -GNUNET_FS_start (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *client_name, GNUNET_FS_ProgressCallback upcb, void *upcb_cls, diff --git a/src/include/gnunet_nat_lib.h b/src/include/gnunet_nat_lib.h index 9c6e171b6..c1080c586 100644 --- a/src/include/gnunet_nat_lib.h +++ b/src/include/gnunet_nat_lib.h @@ -57,7 +57,6 @@ struct GNUNET_NAT_Handle; * of the local host's addresses should the external port be mapped. The port * is taken from the corresponding sockaddr_in[6] field. * - * @param sched the sheduler used in the program * @param addr the local address packets should be redirected to * @param addrlen actual lenght of the address * @param callback function to call everytime the public IP address changes @@ -65,8 +64,7 @@ struct GNUNET_NAT_Handle; * @return NULL on error, otherwise handle that can be used to unregister */ struct GNUNET_NAT_Handle * -GNUNET_NAT_register (struct GNUNET_SCHEDULER_Handle *sched, - const struct sockaddr *addr, +GNUNET_NAT_register (const struct sockaddr *addr, socklen_t addrlen, GNUNET_NAT_AddressCallback callback, void *callback_cls); diff --git a/src/include/gnunet_peerinfo_service.h b/src/include/gnunet_peerinfo_service.h index d88c6fb41..228e698b3 100644 --- a/src/include/gnunet_peerinfo_service.h +++ b/src/include/gnunet_peerinfo_service.h @@ -50,14 +50,12 @@ struct GNUNET_PEERINFO_Handle; /** * Connect to the peerinfo service. * - * @param sched scheduler to use * @param cfg configuration to use * @return NULL on error (configuration related, actual connection * etablishment may happen asynchronously). */ struct GNUNET_PEERINFO_Handle * -GNUNET_PEERINFO_connect (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg); +GNUNET_PEERINFO_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); @@ -164,14 +162,12 @@ struct GNUNET_PEERINFO_NotifyContext; * twice with the same peer information. * * @param cfg configuration to use - * @param sched scheduler to use * @param callback the method to call for each peer * @param callback_cls closure for callback * @return NULL on error */ struct GNUNET_PEERINFO_NotifyContext * GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg, - struct GNUNET_SCHEDULER_Handle *sched, GNUNET_PEERINFO_Processor callback, void *callback_cls); diff --git a/src/include/gnunet_program_lib.h b/src/include/gnunet_program_lib.h index a44f4f11e..b01703f05 100644 --- a/src/include/gnunet_program_lib.h +++ b/src/include/gnunet_program_lib.h @@ -43,13 +43,11 @@ extern "C" * Main function that will be run. * * @param cls closure - * @param sched the scheduler to use * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param cfg configuration */ typedef void (*GNUNET_PROGRAM_Main) (void *cls, - struct GNUNET_SCHEDULER_Handle * sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle * diff --git a/src/include/gnunet_resolver_service.h b/src/include/gnunet_resolver_service.h index b55ca2f56..79f703553 100644 --- a/src/include/gnunet_resolver_service.h +++ b/src/include/gnunet_resolver_service.h @@ -62,7 +62,6 @@ struct GNUNET_RESOLVER_RequestHandle; /** * Convert a string to one or more IP addresses. * - * @param sched scheduler to use * @param cfg configuration to use * @param hostname the hostname to resolve * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any" @@ -72,8 +71,7 @@ struct GNUNET_RESOLVER_RequestHandle; * @return handle that can be used to cancel the request, NULL on error */ struct GNUNET_RESOLVER_RequestHandle * -GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_RESOLVER_ip_get (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *hostname, int domain, struct GNUNET_TIME_Relative timeout, @@ -84,7 +82,6 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, /** * Resolve our hostname to an IP address. * - * @param sched scheduler to use * @param cfg configuration to use * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any" * @param callback function to call with addresses @@ -93,8 +90,7 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, * @return handle that can be used to cancel the request, NULL on error */ struct GNUNET_RESOLVER_RequestHandle * -GNUNET_RESOLVER_hostname_resolve (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_RESOLVER_hostname_resolve (const struct GNUNET_CONFIGURATION_Handle *cfg, int domain, struct GNUNET_TIME_Relative timeout, GNUNET_RESOLVER_AddressCallback callback, @@ -123,7 +119,6 @@ GNUNET_RESOLVER_local_fqdn_get ( void ); /** * Perform a reverse DNS lookup. * - * @param sched scheduler to use * @param cfg configuration to use * @param sa host address * @param salen length of host address @@ -134,8 +129,7 @@ GNUNET_RESOLVER_local_fqdn_get ( void ); * @return handle that can be used to cancel the request, NULL on error */ struct GNUNET_RESOLVER_RequestHandle * -GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_RESOLVER_hostname_get (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct sockaddr *sa, socklen_t salen, int do_resolve, diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h index b39feb926..774f2f4bc 100644 --- a/src/include/gnunet_scheduler_lib.h +++ b/src/include/gnunet_scheduler_lib.h @@ -35,12 +35,6 @@ extern "C" #endif #endif - -/** - * Opaque handle for the scheduling service. - */ -struct GNUNET_SCHEDULER_Handle; - /** * Opaque reference to a task. */ @@ -167,12 +161,6 @@ enum GNUNET_SCHEDULER_Priority */ struct GNUNET_SCHEDULER_TaskContext { - - /** - * Scheduler running the task - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * Reason why the task is run now */ @@ -229,10 +217,8 @@ void GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls); * cause all tasks to run (as soon as possible, respecting * priorities and prerequisite tasks). Note that tasks * scheduled AFTER this call may still be delayed arbitrarily. - * - * @param sched the scheduler */ -void GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched); +void GNUNET_SCHEDULER_shutdown (); /** @@ -241,14 +227,12 @@ void GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched); * dropped (if the decision should be made based on the number of * tasks ready to run). * - * @param sched scheduler to query - * @param p priority-level to query, use KEEP to query the level + * * @param p priority-level to query, use KEEP to query the level * of the current task, use COUNT to get the sum over * all priority levels * @return number of tasks pending right now */ -unsigned int GNUNET_SCHEDULER_get_load (struct GNUNET_SCHEDULER_Handle *sched, - enum GNUNET_SCHEDULER_Priority p); +unsigned int GNUNET_SCHEDULER_get_load (enum GNUNET_SCHEDULER_Priority p); /** @@ -256,23 +240,20 @@ unsigned int GNUNET_SCHEDULER_get_load (struct GNUNET_SCHEDULER_Handle *sched, * started. Will return the same value as * the GNUNET_SCHEDULER_TaskContext's reason field. * - * @param sched scheduler to query - * @return reason(s) why the current task is run + * * @return reason(s) why the current task is run */ enum GNUNET_SCHEDULER_Reason -GNUNET_SCHEDULER_get_reason (struct GNUNET_SCHEDULER_Handle *sched); +GNUNET_SCHEDULER_get_reason (); /** * Cancel the task with the specified identifier. * The task must not yet have run. * - * @param sched scheduler to use - * @param task id of the task to cancel + * * @param task id of the task to cancel * @return the closure of the callback of the cancelled task */ -void *GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched, - GNUNET_SCHEDULER_TaskIdentifier task); +void *GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_TaskIdentifier task); /** @@ -280,14 +261,12 @@ void *GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched, * similar to the other "add" functions except that there is no delay * and the reason code can be specified. * - * @param sched scheduler to use - * @param task main function of the task + * * @param task main function of the task * @param task_cls closure of task * @param reason reason for task invocation */ void -GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched, - GNUNET_SCHEDULER_Task task, +GNUNET_SCHEDULER_add_continuation (GNUNET_SCHEDULER_Task task, void *task_cls, enum GNUNET_SCHEDULER_Reason reason); @@ -297,8 +276,7 @@ GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched, * has completed. It will be run with the priority of the calling * task. * - * @param sched scheduler to use - * @param prerequisite_task run this task after the task with the given + * * @param prerequisite_task run this task after the task with the given * task identifier completes (and any of our other * conditions, such as delay, read or write-readiness * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency @@ -310,8 +288,7 @@ GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched, * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched, - GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, +GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, GNUNET_SCHEDULER_Task task, void *task_cls); @@ -319,16 +296,14 @@ GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched, /** * Schedule a new task to be run with a specified priority. * - * @param sched scheduler to use - * @param prio how important is the new task? + * * @param prio how important is the new task? * @param task main function of the task * @param task_cls closure of task * @return unique task identifier for the job * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -GNUNET_SCHEDULER_add_with_priority (struct GNUNET_SCHEDULER_Handle *sched, - enum GNUNET_SCHEDULER_Priority prio, +GNUNET_SCHEDULER_add_with_priority (enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_Task task, void *task_cls); @@ -337,15 +312,13 @@ GNUNET_SCHEDULER_add_with_priority (struct GNUNET_SCHEDULER_Handle *sched, * Schedule a new task to be run as soon as possible. The task * will be run with the priority of the calling task. * - * @param sched scheduler to use - * @param task main function of the task + * * @param task main function of the task * @param task_cls closure of task * @return unique task identifier for the job * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -GNUNET_SCHEDULER_add_now (struct GNUNET_SCHEDULER_Handle *sched, - GNUNET_SCHEDULER_Task task, +GNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_Task task, void *task_cls); @@ -354,8 +327,7 @@ GNUNET_SCHEDULER_add_now (struct GNUNET_SCHEDULER_Handle *sched, * will be scheduled for execution once the delay has expired. It * will be run with the priority of the calling task. * - * @param sched scheduler to use - * @param delay when should this operation time out? Use + * * @param delay when should this operation time out? Use * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" * @param task main function of the task * @param task_cls closure of task @@ -363,8 +335,7 @@ GNUNET_SCHEDULER_add_now (struct GNUNET_SCHEDULER_Handle *sched, * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_TIME_Relative delay, +GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_Task task, void *task_cls); @@ -377,8 +348,7 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle *sched, * socket operation is ready. It will be run with the priority of * the calling task. * - * @param sched scheduler to use - * @param delay when should this operation time out? Use + * * @param delay when should this operation time out? Use * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" * @param rfd read file-descriptor * @param task main function of the task @@ -387,8 +357,7 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle *sched, * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_TIME_Relative delay, +GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay, struct GNUNET_NETWORK_Handle *rfd, GNUNET_SCHEDULER_Task task, void *task_cls); @@ -402,8 +371,7 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle *sched, * socket operation is ready. It will be run with the priority of * the calling task. * - * @param sched scheduler to use - * @param delay when should this operation time out? Use + * * @param delay when should this operation time out? Use * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" * @param wfd write file-descriptor * @param task main function of the task @@ -412,8 +380,7 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle *sched, * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_TIME_Relative delay, +GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay, struct GNUNET_NETWORK_Handle *wfd, GNUNET_SCHEDULER_Task task, void *task_cls); @@ -427,8 +394,7 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle *sched, * socket operation is ready. It will be run with the priority of * the calling task. * - * @param sched scheduler to use - * @param delay when should this operation time out? Use + * * @param delay when should this operation time out? Use * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" * @param rfd read file-descriptor * @param task main function of the task @@ -437,8 +403,7 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle *sched, * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_TIME_Relative delay, +GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay, const struct GNUNET_DISK_FileHandle *rfd, GNUNET_SCHEDULER_Task task, void *task_cls); @@ -452,8 +417,7 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle *sched, * socket operation is ready. It will be run with the priority of * the calling task. * - * @param sched scheduler to use - * @param delay when should this operation time out? Use + * * @param delay when should this operation time out? Use * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" * @param wfd write file-descriptor * @param task main function of the task @@ -462,8 +426,7 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle *sched, * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_TIME_Relative delay, +GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, const struct GNUNET_DISK_FileHandle *wfd, GNUNET_SCHEDULER_Task task, void *task_cls); @@ -486,8 +449,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle *sched, * || shutdown-active) * * - * @param sched scheduler to use - * @param prio how important is this task? + * * @param prio how important is this task? * @param prerequisite_task run this task after the task with the given * task identifier completes (and any of our other * conditions, such as delay, read or write-readiness @@ -503,8 +465,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle *sched, * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle *sched, - enum GNUNET_SCHEDULER_Priority prio, +GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, struct GNUNET_TIME_Relative delay, diff --git a/src/include/gnunet_server_lib.h b/src/include/gnunet_server_lib.h index 20ed78bab..6f671754d 100644 --- a/src/include/gnunet_server_lib.h +++ b/src/include/gnunet_server_lib.h @@ -115,7 +115,6 @@ struct GNUNET_SERVER_MessageHandler /** * Create a new server. * - * @param sched scheduler to use * @param access function for access control * @param access_cls closure for access * @param lsocks NULL-terminated array of listen sockets @@ -126,8 +125,7 @@ struct GNUNET_SERVER_MessageHandler * (typically, "port" already in use) */ struct GNUNET_SERVER_Handle * -GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched, - GNUNET_CONNECTION_AccessCheck access, void *access_cls, +GNUNET_SERVER_create_with_sockets (GNUNET_CONNECTION_AccessCheck access, void *access_cls, struct GNUNET_NETWORK_Handle **lsocks, struct GNUNET_TIME_Relative idle_timeout, @@ -136,7 +134,6 @@ GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched, /** * Create a new server. * - * @param sched scheduler to use * @param access function for access control * @param access_cls closure for access * @param serverAddr address toes listen on (including port), NULL terminated array @@ -147,10 +144,7 @@ GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched, * @return handle for the new server, NULL on error * (typically, "port" already in use) */ -struct GNUNET_SERVER_Handle *GNUNET_SERVER_create (struct - GNUNET_SCHEDULER_Handle - *sched, - GNUNET_CONNECTION_AccessCheck +struct GNUNET_SERVER_Handle *GNUNET_SERVER_create (GNUNET_CONNECTION_AccessCheck access, void *access_cls, struct sockaddr *const*serverAddr, const socklen_t *socklen, diff --git a/src/include/gnunet_service_lib.h b/src/include/gnunet_service_lib.h index c17af065f..883ad462f 100644 --- a/src/include/gnunet_service_lib.h +++ b/src/include/gnunet_service_lib.h @@ -71,12 +71,10 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, * method to run service-specific setup code. * * @param cls closure - * @param sched scheduler to use * @param server the initialized server * @param cfg configuration to use */ typedef void (*GNUNET_SERVICE_Main) (void *cls, - struct GNUNET_SCHEDULER_Handle * sched, struct GNUNET_SERVER_Handle * server, const struct GNUNET_CONFIGURATION_Handle * cfg); @@ -128,14 +126,10 @@ struct GNUNET_SERVICE_Context; * initialized system. * * @param serviceName our service name - * @param sched scheduler to use * @param cfg configuration to use * @return NULL on error, service handle */ struct GNUNET_SERVICE_Context *GNUNET_SERVICE_start (const char *serviceName, - struct - GNUNET_SCHEDULER_Handle - *sched, const struct GNUNET_CONFIGURATION_Handle *cfg); diff --git a/src/include/gnunet_statistics_service.h b/src/include/gnunet_statistics_service.h index 71c834f2a..e22fe16d4 100644 --- a/src/include/gnunet_statistics_service.h +++ b/src/include/gnunet_statistics_service.h @@ -70,14 +70,12 @@ typedef int (*GNUNET_STATISTICS_Iterator) (void *cls, /** * Get handle for the statistics service. * - * @param sched scheduler to use * @param subsystem name of subsystem using the service * @param cfg services configuration in use * @return handle to use */ struct GNUNET_STATISTICS_Handle - *GNUNET_STATISTICS_create (struct GNUNET_SCHEDULER_Handle *sched, - const char *subsystem, + *GNUNET_STATISTICS_create (const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg); diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h index a00e59976..97bc36a79 100644 --- a/src/include/gnunet_testing_lib.h +++ b/src/include/gnunet_testing_lib.h @@ -204,11 +204,6 @@ typedef void (*GNUNET_TESTING_NotifyConnections)(void *cls, */ struct GNUNET_TESTING_Daemon { - /** - * Our scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * Our configuration. */ @@ -410,7 +405,6 @@ typedef void (*GNUNET_TESTING_NotifyTopology)(void *cls, * reachable via "ssh" (unless the hostname is "NULL") without the * need to enter a password. * - * @param sched scheduler to use * @param cfg configuration to use * @param timeout how long to wait starting up peers * @param hostname name of the machine where to run GNUnet @@ -426,8 +420,7 @@ typedef void (*GNUNET_TESTING_NotifyTopology)(void *cls, * @return handle to the daemon (actual start will be completed asynchronously) */ struct GNUNET_TESTING_Daemon * -GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TIME_Relative timeout, const char *hostname, const char *ssh_username, @@ -569,7 +562,6 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, * adjusted to ensure that no two peers running on the same system * have the same port(s) in their respective configurations. * - * @param sched scheduler to use * @param cfg configuration template to use * @param total number of daemons to start * @param timeout total time allowed for peers to start @@ -587,8 +579,7 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, * @return NULL on error, otherwise handle to control peer group */ struct GNUNET_TESTING_PeerGroup * -GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int total, struct GNUNET_TIME_Relative timeout, GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback, diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h index 2ee9fb718..eddd8f8af 100644 --- a/src/include/gnunet_transport_service.h +++ b/src/include/gnunet_transport_service.h @@ -118,7 +118,6 @@ typedef void * Connect to the transport service. Note that the connection may * complete (or fail) asynchronously. * - * @param sched scheduler to use * @param cfg configuration to use * @param self our own identity (API should check that it matches * the identity found by transport), or NULL (no check) @@ -128,10 +127,7 @@ typedef void * @param nd function to call on disconnect events * @return NULL on error */ -struct GNUNET_TRANSPORT_Handle *GNUNET_TRANSPORT_connect (struct - GNUNET_SCHEDULER_Handle - *sched, - const struct +struct GNUNET_TRANSPORT_Handle *GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *self, @@ -278,7 +274,6 @@ GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle, /** * Convert a binary address into a human readable address. * - * @param sched scheduler to use * @param cfg configuration to use * @param address address to convert (binary format) * @param addressLen number of bytes in address @@ -290,8 +285,7 @@ GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle, * @param aluc_cls closure for aluc */ void -GNUNET_TRANSPORT_address_lookup (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, const char * address, size_t addressLen, int numeric, @@ -328,15 +322,13 @@ typedef int (*GNUNET_TRANSPORT_BlacklistCallback)(void *cls, * only way to re-enable connections from peers that were previously * blacklisted. * - * @param sched scheduler to use * @param cfg configuration to use * @param cb callback to invoke to check if connections are allowed * @param cb_cls closure for cb * @return NULL on error, otherwise handle for cancellation */ struct GNUNET_TRANSPORT_Blacklist * -GNUNET_TRANSPORT_blacklist (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_TRANSPORT_BlacklistCallback cb, void *cb_cls); diff --git a/src/include/gnunet_upnp_service.h b/src/include/gnunet_upnp_service.h index b57f76697..7e6ea5180 100644 --- a/src/include/gnunet_upnp_service.h +++ b/src/include/gnunet_upnp_service.h @@ -43,7 +43,6 @@ extern "C" * install a port mapping if possible. The external port * will be returned as part of the address. * - * @param sched scheduler to use * @param cfg configuration to use * @param domain communication domain (i.e. PF_INET or PF_INET6) * @param type communication semantics (SOCK_STREAM, SOCK_DGRAM) @@ -55,8 +54,7 @@ extern "C" * function will be called with NULL on error * @param cls closure for callback */ -int GNUNET_UPNP_get_ip (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_CONFIGURATION_Handle *cfg, +int GNUNET_UPNP_get_ip (struct GNUNET_CONFIGURATION_Handle *cfg, int domain, int type, int protocol, diff --git a/src/monkey/gnunet-monkey.c b/src/monkey/gnunet-monkey.c index d3018cf3e..f3dc238c8 100644 --- a/src/monkey/gnunet-monkey.c +++ b/src/monkey/gnunet-monkey.c @@ -115,14 +115,12 @@ int wait_for_stop(mi_h *h) * Main function that will be run by the scheduler. * * @param cls closure - * @param s the scheduler to use * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param c configuration */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) diff --git a/src/nat/nat.c b/src/nat/nat.c index 74d08bd6f..eb203265c 100644 --- a/src/nat/nat.c +++ b/src/nat/nat.c @@ -53,11 +53,6 @@ struct GNUNET_NAT_Handle */ struct GNUNET_NAT_NATPMP_Handle *natpmp; - /** - * Scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * LAN address as passed by the caller */ @@ -296,8 +291,7 @@ pulse_cb (struct GNUNET_NAT_Handle *h) notify_change (h, h->ext_addr_natpmp, addrlen, port_mapped); } - h->pulse_timer = GNUNET_SCHEDULER_add_delayed (h->sched, - GNUNET_TIME_UNIT_SECONDS, + h->pulse_timer = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &nat_pulse, h); } @@ -372,7 +366,6 @@ nat_pulse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * of the local host's addresses should the external port be mapped. The port * is taken from the corresponding sockaddr_in[6] field. * - * @param sched the sheduler used in the program * @param addr the local address packets should be redirected to * @param addrlen actual lenght of the address * @param callback function to call everytime the public IP address changes @@ -380,9 +373,7 @@ nat_pulse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @return NULL on error, otherwise handle that can be used to unregister */ struct GNUNET_NAT_Handle * -GNUNET_NAT_register (struct GNUNET_SCHEDULER_Handle - *sched, - const struct sockaddr *addr, +GNUNET_NAT_register (const struct sockaddr *addr, socklen_t addrlen, GNUNET_NAT_AddressCallback callback, void *callback_cls) { @@ -408,22 +399,20 @@ GNUNET_NAT_register (struct GNUNET_SCHEDULER_Handle } } h->should_change = GNUNET_YES; - h->sched = sched; h->is_enabled = GNUNET_YES; h->upnp_status = GNUNET_NAT_PORT_UNMAPPED; h->natpmp_status = GNUNET_NAT_PORT_UNMAPPED; h->callback = callback; h->callback_cls = callback_cls; h->upnp = - GNUNET_NAT_UPNP_init (h->sched, h->local_addr, addrlen, h->public_port, + GNUNET_NAT_UPNP_init (h->local_addr, addrlen, h->public_port, &upnp_pulse_cb, h); #if 0 h->natpmp = - GNUNET_NAT_NATPMP_init (h->sched, h->local_addr, addrlen, h->public_port, + GNUNET_NAT_NATPMP_init (h->local_addr, addrlen, h->public_port, &natpmp_pulse_cb, h); #endif - h->pulse_timer = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_SECONDS, + h->pulse_timer = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &nat_pulse, h); return h; } @@ -447,7 +436,7 @@ GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h) #endif if (GNUNET_SCHEDULER_NO_TASK != h->pulse_timer) - GNUNET_SCHEDULER_cancel (h->sched, h->pulse_timer); + GNUNET_SCHEDULER_cancel (h->pulse_timer); GNUNET_free_non_null (h->local_addr); GNUNET_free_non_null (h->ext_addr); diff --git a/src/nat/natpmp.c b/src/nat/natpmp.c index 79a6bfd33..c6a5604d8 100644 --- a/src/nat/natpmp.c +++ b/src/nat/natpmp.c @@ -74,7 +74,6 @@ struct GNUNET_NAT_NATPMP_Handle time_t command_time; enum NATPMP_state state; struct natpmp_t natpmp; - struct GNUNET_SCHEDULER_Handle *sched; }; @@ -97,14 +96,12 @@ log_val (const char *func, int ret) } struct GNUNET_NAT_NATPMP_Handle * -GNUNET_NAT_NATPMP_init (struct GNUNET_SCHEDULER_Handle *sched, - const struct sockaddr *addr, socklen_t addrlen, +GNUNET_NAT_NATPMP_init (const struct sockaddr *addr, socklen_t addrlen, u_short port) { struct GNUNET_NAT_NATPMP_Handle *nat; nat = GNUNET_malloc (sizeof (struct GNUNET_NAT_NATPMP_Handle)); - nat->sched = sched; nat->state = NATPMP_DISCOVER; nat->port = port; nat->addr = addr; diff --git a/src/nat/natpmp.h b/src/nat/natpmp.h index 0c198e203..56d5f0034 100644 --- a/src/nat/natpmp.h +++ b/src/nat/natpmp.h @@ -32,10 +32,7 @@ struct GNUNET_NAT_NATPMP_Handle; -struct GNUNET_NAT_NATPMP_Handle *GNUNET_NAT_NATPMP_init (struct - GNUNET_SCHEDULER_Handle - *sched, - const struct sockaddr +struct GNUNET_NAT_NATPMP_Handle *GNUNET_NAT_NATPMP_init (const struct sockaddr *addr, socklen_t addrlen, unsigned short port); diff --git a/src/nat/test_nat.c b/src/nat/test_nat.c index e42d76b7f..6f2226929 100644 --- a/src/nat/test_nat.c +++ b/src/nat/test_nat.c @@ -96,7 +96,6 @@ process_if (void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { @@ -128,11 +127,10 @@ run (void *cls, "Requesting NAT redirection from address %s...\n", GNUNET_a2s (addr, data.addrlen)); - nat = GNUNET_NAT_register (sched, addr, data.addrlen, addr_callback, NULL); + nat = GNUNET_NAT_register (addr, data.addrlen, addr_callback, NULL); GNUNET_free (addr); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, TIMEOUT), stop, nat); } diff --git a/src/nat/upnp-commands.c b/src/nat/upnp-commands.c index 09b004968..d9962117d 100644 --- a/src/nat/upnp-commands.c +++ b/src/nat/upnp-commands.c @@ -344,7 +344,6 @@ parse_url (const char *url, char *hostname, unsigned short *port, char **path) /** * Send UPnP command to the device identified by url and service. * - * @param sched scheduler to use for network tasks * @param url control URL of the device * @param service type of the service corresponding to the command * @param action action to send @@ -353,8 +352,7 @@ parse_url (const char *url, char *hostname, unsigned short *port, char **path) * @param caller_cls closure to pass to caller_cb */ void -UPNP_command_ (struct GNUNET_SCHEDULER_Handle *sched, - const char *url, const char *service, +UPNP_command_ (const char *url, const char *service, const char *action, struct UPNP_Arg_ *args, char *buffer, size_t buf_size, UPNP_command_cb_ caller_cb, void *caller_cls) @@ -470,7 +468,7 @@ UPNP_command_ (struct GNUNET_SCHEDULER_Handle *sched, dest.sin_len = sizeof (dest); #endif - s = GNUNET_CONNECTION_create_from_sockaddr (sched, PF_INET, + s = GNUNET_CONNECTION_create_from_sockaddr (PF_INET, (struct sockaddr *) &dest, sizeof (dest)); } @@ -482,7 +480,7 @@ UPNP_command_ (struct GNUNET_SCHEDULER_Handle *sched, dest6.sin6_len = sizeof (dest6); #endif - s = GNUNET_CONNECTION_create_from_sockaddr (sched, PF_INET6, + s = GNUNET_CONNECTION_create_from_sockaddr (PF_INET6, (struct sockaddr *) &dest6, sizeof (dest6)); } @@ -602,8 +600,7 @@ get_external_ip_address_receiver (char *response, size_t received, void *data) * 501 Action Failed - See UPnP Device Architecture section on Control. */ void -UPNP_get_external_ip_address_ (struct GNUNET_SCHEDULER_Handle *sched, - const char *control_url, +UPNP_get_external_ip_address_ (const char *control_url, const char *service_type, UPNP_get_external_ip_address_cb_ caller_cb, void *caller_cls) @@ -620,7 +617,7 @@ UPNP_get_external_ip_address_ (struct GNUNET_SCHEDULER_Handle *sched, buffer = GNUNET_malloc (UPNP_COMMAND_BUFSIZE); - UPNP_command_ (sched, control_url, service_type, "GetExternalIPAddress", + UPNP_command_ (control_url, service_type, "GetExternalIPAddress", NULL, buffer, UPNP_COMMAND_BUFSIZE, (UPNP_command_cb_) get_external_ip_address_receiver, cls); } @@ -667,8 +664,7 @@ add_delete_port_mapping_receiver (char *response, size_t received, void *data) } void -UPNP_add_port_mapping_ (struct GNUNET_SCHEDULER_Handle *sched, - const char *control_url, const char *service_type, +UPNP_add_port_mapping_ (const char *control_url, const char *service_type, const char *ext_port, const char *in_port, const char *inClient, @@ -718,14 +714,13 @@ UPNP_add_port_mapping_ (struct GNUNET_SCHEDULER_Handle *sched, buffer = GNUNET_malloc (UPNP_COMMAND_BUFSIZE); - UPNP_command_ (sched, control_url, service_type, "AddPortMapping", + UPNP_command_ (control_url, service_type, "AddPortMapping", args, buffer, UPNP_COMMAND_BUFSIZE, add_delete_port_mapping_receiver, cls); } void -UPNP_delete_port_mapping_ (struct GNUNET_SCHEDULER_Handle *sched, - const char *control_url, const char *service_type, +UPNP_delete_port_mapping_ (const char *control_url, const char *service_type, const char *ext_port, const char *proto, const char *remoteHost, UPNP_port_mapping_cb_ caller_cb, void *caller_cls) @@ -762,7 +757,7 @@ UPNP_delete_port_mapping_ (struct GNUNET_SCHEDULER_Handle *sched, buffer = GNUNET_malloc (UPNP_COMMAND_BUFSIZE); - UPNP_command_ (sched, control_url, service_type, + UPNP_command_ (control_url, service_type, "DeletePortMapping", args, buffer, UPNP_COMMAND_BUFSIZE, add_delete_port_mapping_receiver, cls); @@ -836,8 +831,7 @@ get_specific_port_mapping_entry_receiver (char *response, size_t received, * the result is returned in the in_client and in_port strings * please provide 128 and 6 bytes of data */ void -UPNP_get_specific_port_mapping_entry_ (struct GNUNET_SCHEDULER_Handle *sched, - const char *control_url, +UPNP_get_specific_port_mapping_entry_ (const char *control_url, const char *service_type, const char *ext_port, const char *proto, @@ -874,7 +868,7 @@ UPNP_get_specific_port_mapping_entry_ (struct GNUNET_SCHEDULER_Handle *sched, buffer = GNUNET_malloc (UPNP_COMMAND_BUFSIZE); - UPNP_command_ (sched, control_url, service_type, + UPNP_command_ (control_url, service_type, "GetSpecificPortMappingEntry", args, buffer, UPNP_COMMAND_BUFSIZE, get_specific_port_mapping_entry_receiver, cls); diff --git a/src/nat/upnp-commands.h b/src/nat/upnp-commands.h index 8e7510dbf..4f3cdc33c 100644 --- a/src/nat/upnp-commands.h +++ b/src/nat/upnp-commands.h @@ -94,7 +94,6 @@ typedef void (*UPNP_command_cb_) (char *response, size_t received, void *cls); /** * Send UPnP command to the device identified by url and service. * - * @param sched scheduler to use for network tasks * @param url control URL of the device * @param service type of the service corresponding to the command * @param action action to send @@ -102,8 +101,7 @@ typedef void (*UPNP_command_cb_) (char *response, size_t received, void *cls); * @param caller_cb user callback to trigger when done * @param caller_cls closure to pass to caller_cb */ -void UPNP_command_ (struct GNUNET_SCHEDULER_Handle *sched, - const char *url, const char *service, +void UPNP_command_ (const char *url, const char *service, const char *action, struct UPNP_Arg_ *args, char *buffer, size_t buf_size, UPNP_command_cb_ caller_cb, void *caller_cls); @@ -127,15 +125,13 @@ typedef void (*UPNP_get_external_ip_address_cb_) (int error, * Get the IP address associated with the WAN connection of the device. * See UPNP_get_external_ip_address_cb_. * - * @param sched the scheduler to use for networking * @param control_url the control URL corresponding to service_type on the device * @param service_type service type to call the command on * @param caller_cb function to call when done * @param cls closure passed to caller_cb */ void -UPNP_get_external_ip_address_ (struct GNUNET_SCHEDULER_Handle *sched, - const char *control_url, +UPNP_get_external_ip_address_ (const char *control_url, const char *service_type, UPNP_get_external_ip_address_cb_ caller_cb, void *caller_cls); @@ -185,7 +181,6 @@ typedef void (*UPNP_port_mapping_cb_) (int error, * Request opening a port on the IGD device. * (remote_host is usually NULL because IGDs don't support it.) * - * @param sched the scheduler to use for networking * @param control_url the control URL corresponding to service_type on the device * @param service_type service type to call the command on * @param ext_port port that should be opened on the WAN side @@ -197,8 +192,7 @@ typedef void (*UPNP_port_mapping_cb_) (int error, * @param cls closure passed to caller_cb */ void -UPNP_add_port_mapping_ (struct GNUNET_SCHEDULER_Handle *sched, - const char *control_url, const char *service_type, +UPNP_add_port_mapping_ (const char *control_url, const char *service_type, const char *ext_port, const char *in_port, const char *in_client, @@ -212,7 +206,6 @@ UPNP_add_port_mapping_ (struct GNUNET_SCHEDULER_Handle *sched, * used when opening the port. * (remote_host is usually NULL because IGDs don't support it.) * - * @param sched the scheduler to use for networking * @param control_url the control URL the command was called on * @param service_type service the command was called on * @param in_port port on the gateway on the LAN side which was requested @@ -223,8 +216,7 @@ UPNP_add_port_mapping_ (struct GNUNET_SCHEDULER_Handle *sched, * @param cls closure passed to caller_cb */ void -UPNP_delete_port_mapping_ (struct GNUNET_SCHEDULER_Handle *sched, - const char *control_url, const char *service_type, +UPNP_delete_port_mapping_ (const char *control_url, const char *service_type, const char *ext_port, const char *proto, const char *remote_host, UPNP_port_mapping_cb_ caller_cb, void *caller_cls); @@ -259,7 +251,6 @@ typedef void (*UPNP_get_specific_port_mapping_entry_cb_) (int error, * Check that a port mapping set up with UPNP_add_port_mapping_() * is alive. * - * @param sched the scheduler to use for networking * @param control_url the control URL the command was called on * @param service_type service the command was called on * @param in_port port on the gateway on the LAN side which was requested @@ -270,8 +261,7 @@ typedef void (*UPNP_get_specific_port_mapping_entry_cb_) (int error, * @param cls closure passed to caller_cb */ void -UPNP_get_specific_port_mapping_entry_ (struct GNUNET_SCHEDULER_Handle *sched, - const char *control_url, +UPNP_get_specific_port_mapping_entry_ (const char *control_url, const char *service_type, const char *ext_port, const char *proto, diff --git a/src/nat/upnp-discover.c b/src/nat/upnp-discover.c index ba9594462..d915fb622 100644 --- a/src/nat/upnp-discover.c +++ b/src/nat/upnp-discover.c @@ -85,11 +85,6 @@ typedef void (*download_cb) (char *data, void *cls); */ struct download_cls { - /** - * Scheduler used for the download task. - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * curl_easy handle. */ @@ -243,8 +238,7 @@ download_prepare (struct download_cls *cls) GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1); GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1); - GNUNET_SCHEDULER_add_select (cls->sched, - GNUNET_SCHEDULER_PRIORITY_DEFAULT, + GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_SCHEDULER_NO_TASK, rtime, grs, @@ -352,14 +346,12 @@ task_download (struct download_cls *cls, /** * Download description from devices. * - * @param sched the scheduler to use for the download task * @param url URL of the file to download * @param caller_cb user function to call when done * @caller_cls closure to pass to caller_cb */ void -download_device_description (struct GNUNET_SCHEDULER_Handle *sched, - char *url, download_cb caller_cb, +download_device_description (char *url, download_cb caller_cb, void *caller_cls) { CURL *curl; @@ -425,7 +417,6 @@ download_device_description (struct GNUNET_SCHEDULER_Handle *sched, url); #endif - cls->sched = sched; cls->curl = curl; cls->multi = multi; cls->url = url; @@ -587,11 +578,6 @@ struct UPNP_Dev_ */ struct UPNP_discover_cls { - /** - * Scheduler to use for networking tasks. - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * Remote address used for multicast emission and reception. */ @@ -818,8 +804,7 @@ get_valid_igd_receive (char *desc, void *data) /* Check whether device is connected */ buffer = GNUNET_malloc (UPNP_COMMAND_BUFSIZE); - UPNP_command_ (cls->sched, - cls->current_dev->control_url, + UPNP_command_ (cls->current_dev->control_url, cls->current_dev->data->service_type, "GetStatusInfo", NULL, buffer, UPNP_COMMAND_BUFSIZE, get_valid_igd_connected_cb, cls); @@ -900,7 +885,7 @@ get_valid_igd (struct UPNP_discover_cls *cls) } /* There are still devices to ask, go on */ - download_device_description (cls->sched, cls->current_dev->desc_url, + download_device_description (cls->current_dev->desc_url, get_valid_igd_receive, cls); } @@ -999,16 +984,14 @@ discover_recv (void *data, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_NETWORK_fdset_zero (cls->fdset); GNUNET_NETWORK_fdset_set (cls->fdset, cls->sudp); - task_w = GNUNET_SCHEDULER_add_select (cls->sched, - GNUNET_SCHEDULER_PRIORITY_DEFAULT, + task_w = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15), NULL, cls->fdset, &discover_send, cls); - GNUNET_SCHEDULER_add_select (cls->sched, - GNUNET_SCHEDULER_PRIORITY_DEFAULT, + GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, task_w, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), cls->fdset, @@ -1079,15 +1062,13 @@ discover_send (void *data, const struct GNUNET_SCHEDULER_TaskContext *tc) * If several devices are found, a device that is connected to the WAN * is returned first (if any). * - * @param sched scheduler to use for network tasks * @param multicastif network interface to send discovery messages, or NULL * @param addr address used to send messages on multicastif, or NULL * @param caller_cb user function to call when done * @param caller_cls closure to pass to caller_cb */ void -UPNP_discover_ (struct GNUNET_SCHEDULER_Handle *sched, - const char *multicastif, +UPNP_discover_ (const char *multicastif, const struct sockaddr *addr, UPNP_discover_cb_ caller_cb, void *caller_cls) { @@ -1129,7 +1110,6 @@ UPNP_discover_ (struct GNUNET_SCHEDULER_Handle *sched, cls = GNUNET_malloc (sizeof (struct UPNP_discover_cls)); - cls->sched = sched; cls->sudp = sudp; cls->type_index = 0; cls->dev_list = NULL; @@ -1270,15 +1250,13 @@ UPNP_discover_ (struct GNUNET_SCHEDULER_Handle *sched, GNUNET_NETWORK_fdset_zero (cls->fdset); GNUNET_NETWORK_fdset_set (cls->fdset, sudp); - task_w = GNUNET_SCHEDULER_add_select (sched, - GNUNET_SCHEDULER_PRIORITY_DEFAULT, + task_w = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15), NULL, cls->fdset, &discover_send, cls); - GNUNET_SCHEDULER_add_select (sched, - GNUNET_SCHEDULER_PRIORITY_DEFAULT, + GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, task_w, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15), cls->fdset, diff --git a/src/nat/upnp-discover.h b/src/nat/upnp-discover.h index 2e996cd88..39b704bcf 100644 --- a/src/nat/upnp-discover.h +++ b/src/nat/upnp-discover.h @@ -70,14 +70,12 @@ typedef void (*UPNP_discover_cb_) (const char *control_urls, * If several devices are found, a device that is connected to the WAN * is returned first (if any). * - * @param sched scheduler to use for network tasks * @param multicastif network interface to send discovery messages, or NULL * @param addr address used to send messages on multicastif, or NULL * @param caller_cb user function to call when done * @param caller_cls closure to pass to caller_cb */ -void UPNP_discover_ (struct GNUNET_SCHEDULER_Handle *sched, - const char *multicastif, +void UPNP_discover_ (const char *multicastif, const struct sockaddr *addr, UPNP_discover_cb_ caller_cb, void *caller_cls); diff --git a/src/nat/upnp.c b/src/nat/upnp.c index e383055b5..8dd7d626c 100644 --- a/src/nat/upnp.c +++ b/src/nat/upnp.c @@ -57,7 +57,6 @@ enum UPNP_State struct GNUNET_NAT_UPNP_Handle { - struct GNUNET_SCHEDULER_Handle *sched; int hasDiscovered; char *control_url; char *service_type; @@ -91,8 +90,7 @@ process_if (void *cls, struct GNUNET_NAT_UPNP_Handle * -GNUNET_NAT_UPNP_init (struct GNUNET_SCHEDULER_Handle *sched, - const struct sockaddr *addr, +GNUNET_NAT_UPNP_init (const struct sockaddr *addr, socklen_t addrlen, u_short port, GNUNET_NAT_UPNP_pulse_cb pulse_cb, void *pulse_cls) @@ -100,7 +98,6 @@ GNUNET_NAT_UPNP_init (struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_NAT_UPNP_Handle *handle; handle = GNUNET_malloc (sizeof (struct GNUNET_NAT_UPNP_Handle)); - handle->sched = sched; handle->processing = GNUNET_NO; handle->state = UPNP_DISCOVER; handle->addr = addr; @@ -350,7 +347,7 @@ GNUNET_NAT_UPNP_pulse (struct GNUNET_NAT_UPNP_Handle *handle, if (is_enabled && (handle->state == UPNP_DISCOVER)) { handle->processing = GNUNET_YES; - UPNP_discover_ (handle->sched, handle->iface, handle->addr, discover_cb, + UPNP_discover_ (handle->iface, handle->addr, discover_cb, handle); } @@ -367,8 +364,7 @@ GNUNET_NAT_UPNP_pulse (struct GNUNET_NAT_UPNP_Handle *handle, GNUNET_snprintf (portStr, sizeof (portStr), "%d", handle->port); handle->processing = GNUNET_YES; - UPNP_get_specific_port_mapping_entry_ (handle->sched, - handle->control_url, + UPNP_get_specific_port_mapping_entry_ (handle->control_url, handle->service_type, portStr, "TCP", check_port_mapping_cb, handle); @@ -380,7 +376,7 @@ GNUNET_NAT_UPNP_pulse (struct GNUNET_NAT_UPNP_Handle *handle, GNUNET_snprintf (portStr, sizeof (portStr), "%d", handle->port); handle->processing = GNUNET_YES; - UPNP_delete_port_mapping_ (handle->sched, handle->control_url, + UPNP_delete_port_mapping_ (handle->control_url, handle->service_type, portStr, "TCP", NULL, delete_port_mapping_cb, handle); } @@ -403,7 +399,7 @@ GNUNET_NAT_UPNP_pulse (struct GNUNET_NAT_UPNP_Handle *handle, GNUNET_snprintf (desc, sizeof (desc), "GNUnet at %d", handle->port); handle->processing = GNUNET_YES; - UPNP_add_port_mapping_ (handle->sched, handle->control_url, + UPNP_add_port_mapping_ (handle->control_url, handle->service_type, portStr, portStr, GNUNET_a2s (handle->addr, handle->addrlen), @@ -415,7 +411,7 @@ GNUNET_NAT_UPNP_pulse (struct GNUNET_NAT_UPNP_Handle *handle, if (handle->state != UPNP_DISCOVER) { handle->processing = GNUNET_YES; - UPNP_get_external_ip_address_ (handle->sched, handle->control_url, + UPNP_get_external_ip_address_ (handle->control_url, handle->service_type, get_ip_address_cb, handle); } diff --git a/src/nat/upnp.h b/src/nat/upnp.h index da95106a0..dc6ba0d45 100644 --- a/src/nat/upnp.h +++ b/src/nat/upnp.h @@ -36,10 +36,7 @@ typedef void (*GNUNET_NAT_UPNP_pulse_cb) (int status, struct sockaddr * ext_addr, void *cls); -struct GNUNET_NAT_UPNP_Handle *GNUNET_NAT_UPNP_init (struct - GNUNET_SCHEDULER_Handle - *sched, - const struct sockaddr +struct GNUNET_NAT_UPNP_Handle *GNUNET_NAT_UPNP_init (const struct sockaddr *addr, socklen_t addrlen, unsigned short port, GNUNET_NAT_UPNP_pulse_cb diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index 28f2284ce..1963d6a98 100644 --- a/src/peerinfo-tool/gnunet-peerinfo.c +++ b/src/peerinfo-tool/gnunet-peerinfo.c @@ -37,8 +37,6 @@ static int be_quiet; static int get_self; -static struct GNUNET_SCHEDULER_Handle *sched; - static struct GNUNET_PEERINFO_Handle *peerinfo; static const struct GNUNET_CONFIGURATION_Handle *cfg; @@ -139,8 +137,7 @@ print_address (void *cls, const void *addr, uint16_t addrlen) { struct PrintContext *pc = cls; - GNUNET_TRANSPORT_address_lookup (sched, - cfg, + GNUNET_TRANSPORT_address_lookup (cfg, addr, addrlen, no_resolve, @@ -194,14 +191,12 @@ print_peer_info (void *cls, * Main function that will be run by the scheduler. * * @param cls closure - * @param s the scheduler to use * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param c configuration */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) @@ -212,7 +207,6 @@ run (void *cls, struct GNUNET_CRYPTO_HashAsciiEncoded enc; char *fn; - sched = s; cfg = c; if (args[0] != NULL) { @@ -223,7 +217,7 @@ run (void *cls, } if (get_self != GNUNET_YES) { - peerinfo = GNUNET_PEERINFO_connect (sched, cfg); + peerinfo = GNUNET_PEERINFO_connect (cfg); if (peerinfo == NULL) { fprintf (stderr, diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index 698c7dc30..31b0199f4 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c @@ -311,8 +311,7 @@ cron_scan_directory_data_hosts (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, _("Still no peers found in `%s'!\n"), networkIdDirectory); - GNUNET_SCHEDULER_add_delayed (tc->sched, - DATA_HOST_FREQ, + GNUNET_SCHEDULER_add_delayed (DATA_HOST_FREQ, &cron_scan_directory_data_hosts, NULL); } @@ -464,8 +463,7 @@ cron_clean_data_hosts (void *cls, now = GNUNET_TIME_absolute_get (); GNUNET_DISK_directory_scan (networkIdDirectory, &discard_hosts_helper, &now); - GNUNET_SCHEDULER_add_delayed (tc->sched, - DATA_HOST_CLEAN_FREQ, + GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ, &cron_clean_data_hosts, NULL); } @@ -650,13 +648,11 @@ shutdown_task (void *cls, * Process statistics requests. * * @param cls closure - * @param sched scheduler to use * @param server the initialized server * @param cfg configuration to use */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg) { @@ -672,7 +668,7 @@ run (void *cls, }; hostmap = GNUNET_CONTAINER_multihashmap_create (1024); - stats = GNUNET_STATISTICS_create (sched, "peerinfo", cfg); + stats = GNUNET_STATISTICS_create ("peerinfo", cfg); notify_list = GNUNET_SERVER_notification_context_create (server, 0); GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (cfg, @@ -680,14 +676,11 @@ run (void *cls, "HOSTS", &networkIdDirectory)); GNUNET_DISK_directory_create (networkIdDirectory); - GNUNET_SCHEDULER_add_with_priority (sched, - GNUNET_SCHEDULER_PRIORITY_IDLE, + GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, &cron_scan_directory_data_hosts, NULL); - GNUNET_SCHEDULER_add_with_priority (sched, - GNUNET_SCHEDULER_PRIORITY_IDLE, + GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, &cron_clean_data_hosts, NULL); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); GNUNET_SERVER_add_handlers (server, handlers); } diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c index 5803b076a..e7f095eac 100644 --- a/src/peerinfo/peerinfo_api.c +++ b/src/peerinfo/peerinfo_api.c @@ -90,11 +90,6 @@ struct GNUNET_PEERINFO_Handle */ const struct GNUNET_CONFIGURATION_Handle *cfg; - /** - * Our scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * Connection to the service. */ @@ -127,25 +122,22 @@ struct GNUNET_PEERINFO_Handle /** * Connect to the peerinfo service. * - * @param sched scheduler to use * @param cfg configuration to use * @return NULL on error (configuration related, actual connection * establishment may happen asynchronously). */ struct GNUNET_PEERINFO_Handle * -GNUNET_PEERINFO_connect (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg) +GNUNET_PEERINFO_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_CLIENT_Connection *client; struct GNUNET_PEERINFO_Handle *ret; - client = GNUNET_CLIENT_connect (sched, "peerinfo", cfg); + client = GNUNET_CLIENT_connect ("peerinfo", cfg); if (client == NULL) return NULL; ret = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_Handle)); ret->client = client; ret->cfg = cfg; - ret->sched = sched; return ret; } @@ -203,7 +195,7 @@ reconnect (struct GNUNET_PEERINFO_Handle *h) { GNUNET_CLIENT_disconnect (h->client, GNUNET_SYSERR); h->th = NULL; - h->client = GNUNET_CLIENT_connect (h->sched, "peerinfo", h->cfg); + h->client = GNUNET_CLIENT_connect ("peerinfo", h->cfg); GNUNET_assert (h->client != NULL); } @@ -395,8 +387,7 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg) reconnect (ic->h); trigger_transmit (ic->h); if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (ic->h->sched, - ic->timeout_task); + GNUNET_SCHEDULER_cancel (ic->timeout_task); if (ic->callback != NULL) ic->callback (ic->callback_cls, NULL, NULL); GNUNET_free (ic); @@ -411,8 +402,7 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg) #endif trigger_transmit (ic->h); if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (ic->h->sched, - ic->timeout_task); + GNUNET_SCHEDULER_cancel (ic->timeout_task); if (ic->callback != NULL) ic->callback (ic->callback_cls, NULL, NULL); GNUNET_free (ic); @@ -426,8 +416,7 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg) reconnect (ic->h); trigger_transmit (ic->h); if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (ic->h->sched, - ic->timeout_task); + GNUNET_SCHEDULER_cancel (ic->timeout_task); if (ic->callback != NULL) ic->callback (ic->callback_cls, NULL, NULL); GNUNET_free (ic); @@ -445,8 +434,7 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg) reconnect (ic->h); trigger_transmit (ic->h); if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (ic->h->sched, - ic->timeout_task); + GNUNET_SCHEDULER_cancel (ic->timeout_task); if (ic->callback != NULL) ic->callback (ic->callback_cls, NULL, NULL); GNUNET_free (ic); @@ -492,8 +480,7 @@ iterator_start_receive (void *cls, transmit_success); if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (ic->h->sched, - ic->timeout_task); + GNUNET_SCHEDULER_cancel (ic->timeout_task); ic->timeout_task = GNUNET_SCHEDULER_NO_TASK; } reconnect (ic->h); @@ -609,8 +596,7 @@ GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h, ic->callback = callback; ic->callback_cls = callback_cls; ic->timeout = GNUNET_TIME_relative_to_absolute (timeout); - ic->timeout_task = GNUNET_SCHEDULER_add_delayed (h->sched, - timeout, + ic->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, &signal_timeout, ic); tqe->timeout = ic->timeout; @@ -637,8 +623,7 @@ GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic) { if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (ic->h->sched, - ic->timeout_task); + GNUNET_SCHEDULER_cancel (ic->timeout_task); ic->timeout_task = GNUNET_SCHEDULER_NO_TASK; } ic->callback = NULL; diff --git a/src/peerinfo/peerinfo_api_notify.c b/src/peerinfo/peerinfo_api_notify.c index c7a9c6145..25f2b9d5e 100644 --- a/src/peerinfo/peerinfo_api_notify.c +++ b/src/peerinfo/peerinfo_api_notify.c @@ -62,10 +62,6 @@ struct GNUNET_PEERINFO_NotifyContext */ const struct GNUNET_CONFIGURATION_Handle *cfg; - /** - * Scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; }; @@ -109,7 +105,7 @@ process_notification (void *cls, if (msg == NULL) { GNUNET_CLIENT_disconnect (nc->client, GNUNET_NO); - nc->client = GNUNET_CLIENT_connect (nc->sched, "peerinfo", nc->cfg); + nc->client = GNUNET_CLIENT_connect ("peerinfo", nc->cfg); request_notifications (nc); return; } @@ -119,7 +115,7 @@ process_notification (void *cls, { GNUNET_break (0); GNUNET_CLIENT_disconnect (nc->client, GNUNET_NO); - nc->client = GNUNET_CLIENT_connect (nc->sched, "peerinfo", nc->cfg); + nc->client = GNUNET_CLIENT_connect ("peerinfo", nc->cfg); request_notifications (nc); return; } @@ -132,7 +128,7 @@ process_notification (void *cls, { GNUNET_break (0); GNUNET_CLIENT_disconnect (nc->client, GNUNET_NO); - nc->client = GNUNET_CLIENT_connect (nc->sched, "peerinfo", nc->cfg); + nc->client = GNUNET_CLIENT_connect ("peerinfo", nc->cfg); request_notifications (nc); return; } @@ -183,7 +179,7 @@ transmit_notify_request (void *cls, if (buf == NULL) { GNUNET_CLIENT_disconnect (nc->client, GNUNET_NO); - nc->client = GNUNET_CLIENT_connect (nc->sched, "peerinfo", nc->cfg); + nc->client = GNUNET_CLIENT_connect ("peerinfo", nc->cfg); request_notifications (nc); return 0; } @@ -221,21 +217,19 @@ request_notifications (struct GNUNET_PEERINFO_NotifyContext *nc) * peers and then only signals changes. * * @param cfg configuration to use - * @param sched scheduler to use * @param callback the method to call for each peer * @param callback_cls closure for callback * @return NULL on error */ struct GNUNET_PEERINFO_NotifyContext * GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg, - struct GNUNET_SCHEDULER_Handle *sched, GNUNET_PEERINFO_Processor callback, void *callback_cls) { struct GNUNET_PEERINFO_NotifyContext *nc; struct GNUNET_CLIENT_Connection *client; - client = GNUNET_CLIENT_connect (sched, "peerinfo", cfg); + client = GNUNET_CLIENT_connect ("peerinfo", cfg); if (client == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -243,7 +237,6 @@ GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg, return NULL; } nc = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_NotifyContext)); - nc->sched = sched; nc->cfg = cfg; nc->client = client; nc->callback = callback; diff --git a/src/peerinfo/perf_peerinfo_api.c b/src/peerinfo/perf_peerinfo_api.c index 2c3d54109..1c2f81d76 100755 --- a/src/peerinfo/perf_peerinfo_api.c +++ b/src/peerinfo/perf_peerinfo_api.c @@ -37,8 +37,6 @@ #define NUM_REQUESTS 5000 -static struct GNUNET_SCHEDULER_Handle *sched; - static const struct GNUNET_CONFIGURATION_Handle *cfg; static struct GNUNET_PEERINFO_IteratorContext *ic[NUM_REQUESTS]; @@ -132,15 +130,13 @@ process (void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { size_t i; - sched = s; cfg = c; - h = GNUNET_PEERINFO_connect (sched, cfg); + h = GNUNET_PEERINFO_connect (cfg); GNUNET_assert (h != NULL); for (i = 0; i < NUM_REQUESTS; i++) { diff --git a/src/peerinfo/test_peerinfo_api.c b/src/peerinfo/test_peerinfo_api.c index eae448bbf..fdd0dc460 100644 --- a/src/peerinfo/test_peerinfo_api.c +++ b/src/peerinfo/test_peerinfo_api.c @@ -36,8 +36,6 @@ #include "gnunet_time_lib.h" #include "peerinfo.h" -static struct GNUNET_SCHEDULER_Handle *sched; - static const struct GNUNET_CONFIGURATION_Handle *cfg; static struct GNUNET_PEERINFO_IteratorContext *ic; @@ -143,14 +141,12 @@ process (void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { - sched = s; cfg = c; - h = GNUNET_PEERINFO_connect (sched, cfg); + h = GNUNET_PEERINFO_connect (cfg); GNUNET_assert (h != NULL); add_peer (); ic = GNUNET_PEERINFO_iterate (h, diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c index 92f79cc91..c506dee7b 100644 --- a/src/statistics/gnunet-service-statistics.c +++ b/src/statistics/gnunet-service-statistics.c @@ -730,13 +730,11 @@ handle_client_disconnect (void *cls, * Process statistics requests. * * @param cls closure - * @param sched scheduler to use * @param server the initialized server * @param c configuration to use */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { @@ -753,8 +751,7 @@ run (void *cls, &handle_client_disconnect, NULL); load (server); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); } diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c index 3742a496d..0cbafa68f 100644 --- a/src/statistics/gnunet-statistics.c +++ b/src/statistics/gnunet-statistics.c @@ -104,14 +104,12 @@ cleanup (void *cls, int success) * Main function that will be run by the scheduler. * * @param cls closure - * @param sched the scheduler to use * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param cfg configuration */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -128,7 +126,7 @@ run (void *cls, ret = 1; return; } - h = GNUNET_STATISTICS_create (sched, subsystem, cfg); + h = GNUNET_STATISTICS_create (subsystem, cfg); if (h == NULL) { ret = 1; @@ -138,7 +136,7 @@ run (void *cls, GNUNET_STATISTICS_destroy (h, GNUNET_YES); return; } - h = GNUNET_STATISTICS_create (sched, "gnunet-statistics", cfg); + h = GNUNET_STATISTICS_create ("gnunet-statistics", cfg); if (h == NULL) { ret = 1; diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index ef9865e02..5bca6c786 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c @@ -166,11 +166,6 @@ struct GNUNET_STATISTICS_GetHandle */ struct GNUNET_STATISTICS_Handle { - /** - * Our scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * Name of our subsystem. */ @@ -318,7 +313,7 @@ try_connect (struct GNUNET_STATISTICS_Handle *ret) unsigned int i; if (ret->client != NULL) return GNUNET_YES; - ret->client = GNUNET_CLIENT_connect (ret->sched, "statistics", ret->cfg); + ret->client = GNUNET_CLIENT_connect ("statistics", ret->cfg); if (ret->client != NULL) { for (i=0;iwatches_size;i++) @@ -727,23 +722,19 @@ transmit_action (void *cls, size_t size, void *buf) /** * Get handle for the statistics service. * - * @param sched scheduler to use * @param subsystem name of subsystem using the service * @param cfg services configuration in use * @return handle to use */ struct GNUNET_STATISTICS_Handle * -GNUNET_STATISTICS_create (struct GNUNET_SCHEDULER_Handle *sched, - const char *subsystem, +GNUNET_STATISTICS_create (const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_STATISTICS_Handle *ret; GNUNET_assert (subsystem != NULL); - GNUNET_assert (sched != NULL); GNUNET_assert (cfg != NULL); ret = GNUNET_malloc (sizeof (struct GNUNET_STATISTICS_Handle)); - ret->sched = sched; ret->cfg = cfg; ret->subsystem = GNUNET_strdup (subsystem); ret->backoff = GNUNET_TIME_UNIT_MILLISECONDS; @@ -771,8 +762,7 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, int i; if (GNUNET_SCHEDULER_NO_TASK != h->backoff_task) - GNUNET_SCHEDULER_cancel (h->sched, - h->backoff_task); + GNUNET_SCHEDULER_cancel (h->backoff_task); if (sync_first) { if (h->current != NULL) @@ -884,8 +874,7 @@ schedule_action (struct GNUNET_STATISTICS_Handle *h) return; /* action already pending */ if (GNUNET_YES != try_connect (h)) { - h->backoff_task = GNUNET_SCHEDULER_add_delayed (h->sched, - h->backoff, + h->backoff_task = GNUNET_SCHEDULER_add_delayed (h->backoff, &finish_task, h); h->backoff = GNUNET_TIME_relative_multiply (h->backoff, 2); diff --git a/src/statistics/test_statistics_api.c b/src/statistics/test_statistics_api.c index cce90146c..7b01ff00f 100644 --- a/src/statistics/test_statistics_api.c +++ b/src/statistics/test_statistics_api.c @@ -109,12 +109,11 @@ next (void *cls, int success) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { - h = GNUNET_STATISTICS_create (sched, "test-statistics-api", cfg); + h = GNUNET_STATISTICS_create ("test-statistics-api", cfg); GNUNET_STATISTICS_set (h, "test-1", 1, GNUNET_NO); GNUNET_STATISTICS_set (h, "test-2", 2, GNUNET_NO); GNUNET_STATISTICS_set (h, "test-3", 2, GNUNET_NO); @@ -128,12 +127,11 @@ run (void *cls, static void run_more (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { - h = GNUNET_STATISTICS_create (sched, "test-statistics-api", cfg); + h = GNUNET_STATISTICS_create ("test-statistics-api", cfg); GNUNET_break (NULL != GNUNET_STATISTICS_get (h, NULL, "test-3", GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_3, cls)); diff --git a/src/statistics/test_statistics_api_loop.c b/src/statistics/test_statistics_api_loop.c index 7eaa9d27b..02f4aca44 100644 --- a/src/statistics/test_statistics_api_loop.c +++ b/src/statistics/test_statistics_api_loop.c @@ -60,7 +60,6 @@ next (void *cls, int success) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -68,7 +67,7 @@ run (void *cls, int i; char name[128]; - h = GNUNET_STATISTICS_create (sched, "test-statistics-api-loop", cfg); + h = GNUNET_STATISTICS_create ("test-statistics-api-loop", cfg); for (i=0;inext; if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(sched, free_pos->disconnect_task); + GNUNET_SCHEDULER_cancel(free_pos->disconnect_task); } GNUNET_free(free_pos); } @@ -272,7 +270,7 @@ disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) static void stats_finished (void *cls, int result) { - GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); + GNUNET_SCHEDULER_add_now (&finish_testing, NULL); } /** @@ -323,7 +321,7 @@ static void topology_cb (void *cls, fprintf(outfile, "}\n"); fclose(outfile); GNUNET_TESTING_get_statistics(pg, &stats_finished, &stats_print, NULL); - //GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); + //GNUNET_SCHEDULER_add_now (&finish_testing, NULL); } } } @@ -373,7 +371,7 @@ process_mtype (void *cls, #if VERBOSE fprintf(stdout, "100%%]\n"); #endif - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); GNUNET_asprintf(&dotOutFileNameFinished, "%s.dot", "final_topology"); dotOutFileFinished = fopen (dotOutFileNameFinished, "w"); GNUNET_free(dotOutFileNameFinished); @@ -383,11 +381,11 @@ process_mtype (void *cls, } topology_connections = 0; GNUNET_TESTING_get_topology (pg, &topology_cb, dotOutFileFinished); - //GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); + //GNUNET_SCHEDULER_add_now (&finish_testing, NULL); } else { - pos->disconnect_task = GNUNET_SCHEDULER_add_now(sched, &disconnect_cores, pos); + pos->disconnect_task = GNUNET_SCHEDULER_add_now(&disconnect_cores, pos); } return GNUNET_OK; @@ -523,8 +521,7 @@ init_notify_peer1 (void *cls, /* * Connect to the receiving peer */ - pos->peer2handle = GNUNET_CORE_connect (sched, - pos->peer2->cfg, + pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg, TIMEOUT, pos, &init_notify_peer2, @@ -551,14 +548,13 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) if (die_task == GNUNET_SCHEDULER_NO_TASK) { - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TEST_TIMEOUT, + die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, "from send test messages (timeout)"); } if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) { - GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), &send_test_messages, pos); return; /* Otherwise we'll double schedule messages here! */ } @@ -566,8 +562,7 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) /* * Connect to the sending peer */ - pos->peer1handle = GNUNET_CORE_connect (sched, - pos->peer1->cfg, + pos->peer1handle = GNUNET_CORE_connect (pos->peer1->cfg, TIMEOUT, pos, &init_notify_peer1, @@ -580,12 +575,11 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS) { - GNUNET_SCHEDULER_add_now (sched, - &send_test_messages, pos->next); + GNUNET_SCHEDULER_add_now (&send_test_messages, pos->next); } else { - GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), &send_test_messages, pos->next); } } @@ -662,12 +656,11 @@ topology_callback (void *cls, #endif modnum = expected_messages / 4; dotnum = (expected_messages / 50) + 1; - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); die_task = GNUNET_SCHEDULER_NO_TASK; #if DELAY_FOR_LOGGING fprintf(stdout, "Sending test messages in 10 seconds.\n"); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), &send_test_messages, test_messages); gather_log_data(); @@ -676,7 +669,7 @@ topology_callback (void *cls, { GNUNET_TESTING_get_topology (pg, &topology_cb, NULL); } - GNUNET_SCHEDULER_add_delayed (sched, settle_time, &send_test_messages, test_messages); + GNUNET_SCHEDULER_add_delayed (settle_time, &send_test_messages, test_messages); #endif #if VERBOSE fprintf(stdout, "Test message progress: ["); @@ -687,15 +680,14 @@ topology_callback (void *cls, { if (failed_connections < (unsigned int)(fail_percentage * total_connections)) { - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); die_task = GNUNET_SCHEDULER_NO_TASK; - GNUNET_SCHEDULER_add_now (sched, &send_test_messages, test_messages); + GNUNET_SCHEDULER_add_now (&send_test_messages, test_messages); } else { - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from topology_callback (too many failed connections)"); + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many failed connections)"); } } else @@ -730,15 +722,13 @@ connect_topology () #endif } - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); if (expected_connections == GNUNET_SYSERR) { - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from connect topology (bad return)"); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)"); } - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TEST_TIMEOUT, + die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, "from connect topology (timeout)"); modnum = expected_connections / 4; dotnum = (expected_connections / 50) + 1; @@ -762,13 +752,11 @@ create_topology () } else { - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from create topology (bad return)"); + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from create topology (bad return)"); } - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TEST_TIMEOUT, + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, "from continue startup (timeout)"); } @@ -818,18 +806,16 @@ peers_started_callback (void *cls, "All %d daemons started, now connecting peers!\n", num_peers); #endif - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 8), &end_badly, "from peers_started_callback"); #if DELAY_FOR_LOGGING fprintf(stdout, "Connecting topology in 10 seconds\n"); gather_log_data(); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), &connect_topology, NULL); #else @@ -889,20 +875,18 @@ void hostkey_callback (void *cls, "All %d hostkeys created, now creating topology!\n", num_peers); #endif - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from create_topology"); - GNUNET_SCHEDULER_add_now(sched, &create_topology, NULL); + GNUNET_SCHEDULER_add_now(&create_topology, NULL); ok = 0; } } static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { @@ -912,7 +896,6 @@ run (void *cls, char * connect_topology_option_str; char * connect_topology_option_modifier_string; unsigned long long temp_settle; - sched = s; ok = 1; dotOutFile = fopen (dotOutFileName, "w"); @@ -1006,12 +989,11 @@ run (void *cls, fprintf (stdout, "Hostkey generation progress: ["); #endif /* Set up a task to end testing if peer start fails */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), &end_badly, "didn't generate all hostkeys within a reasonable amount of time!!!"); GNUNET_assert(num_peers > 0 && num_peers < (unsigned int)-1); - pg = GNUNET_TESTING_daemons_start (sched, cfg, + pg = GNUNET_TESTING_daemons_start (cfg, peers_left, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), &hostkey_callback, NULL, &peers_started_callback, NULL, &topology_callback, NULL, NULL); diff --git a/src/testing/test_testing_topology_blacklist.c b/src/testing/test_testing_topology_blacklist.c index 8f9a469e5..13df683e9 100644 --- a/src/testing/test_testing_topology_blacklist.c +++ b/src/testing/test_testing_topology_blacklist.c @@ -57,8 +57,6 @@ static unsigned long long peers_left; static struct GNUNET_TESTING_PeerGroup *pg; -static struct GNUNET_SCHEDULER_Handle *sched; - const struct GNUNET_CONFIGURATION_Handle *main_cfg; GNUNET_SCHEDULER_TaskIdentifier die_task; @@ -213,25 +211,22 @@ topology_callback (void *cls, total_connections); #endif - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); die_task = GNUNET_SCHEDULER_NO_TASK; - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from topology_callback (too many successful connections)"); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many successful connections)"); } else if (total_connections + failed_connections == expected_connections) { if ((failed_connections == expected_failed_connections) && (total_connections == expected_connections - expected_failed_connections)) { - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); die_task = GNUNET_SCHEDULER_NO_TASK; - die_task = GNUNET_SCHEDULER_add_now (sched, - &finish_testing, NULL); + die_task = GNUNET_SCHEDULER_add_now (&finish_testing, NULL); } else { - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from topology_callback (wrong number of failed connections)"); + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (wrong number of failed connections)"); } } else @@ -257,15 +252,13 @@ connect_topology () #endif } - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); if (expected_connections == GNUNET_SYSERR) { - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from connect topology (bad return)"); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)"); } - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TEST_TIMEOUT, + die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, "from connect topology (timeout)"); } @@ -283,13 +276,11 @@ create_topology () } else { - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_now (sched, - &end_badly, "from create topology (bad return)"); + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from create topology (bad return)"); } - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TEST_TIMEOUT, + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, "from continue startup (timeout)"); } @@ -319,11 +310,10 @@ peers_started_callback (void *cls, "All %d daemons started, now creating topology!\n", num_peers); #endif - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, "from peers_started_callback"); connect_topology (); @@ -362,21 +352,19 @@ void hostkey_callback (void *cls, "All %d hostkeys created, now creating topology!\n", num_peers); #endif - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, "from hostkey_callback"); - GNUNET_SCHEDULER_add_now(sched, &create_topology, NULL); + GNUNET_SCHEDULER_add_now(&create_topology, NULL); ok = 0; } } static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { @@ -385,7 +373,6 @@ run (void *cls, unsigned long long blacklist_topology_num; unsigned long long connect_topology_option_num; char *connect_topology_option_modifier_string; - sched = s; ok = 1; dotOutFile = fopen (dotOutFileName, "w"); @@ -483,12 +470,11 @@ run (void *cls, /* Set up a task to end testing if peer start fails */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, "didn't start all daemons in reasonable amount of time!!!"); - pg = GNUNET_TESTING_daemons_start (sched, cfg, + pg = GNUNET_TESTING_daemons_start (cfg, peers_left, TIMEOUT, &hostkey_callback, NULL, &peers_started_callback, NULL, &topology_callback, NULL, NULL); diff --git a/src/testing/test_testing_topology_churn.c b/src/testing/test_testing_topology_churn.c index a4b80e4a4..0e3647015 100644 --- a/src/testing/test_testing_topology_churn.c +++ b/src/testing/test_testing_topology_churn.c @@ -51,8 +51,6 @@ static unsigned long long peers_left; static struct GNUNET_TESTING_PeerGroup *pg; -static struct GNUNET_SCHEDULER_Handle *sched; - const struct GNUNET_CONFIGURATION_Handle *main_cfg; GNUNET_SCHEDULER_TaskIdentifier die_task; @@ -104,7 +102,7 @@ finish_testing () GNUNET_assert (pg != NULL); if (die_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel(sched, die_task); + GNUNET_SCHEDULER_cancel(die_task); #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -161,13 +159,13 @@ void churn_callback(void *cls, if (emsg == NULL) { GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Successfully churned peers!\n", emsg); - GNUNET_SCHEDULER_add_now(sched, churn_ctx.next_task, NULL); + GNUNET_SCHEDULER_add_now(churn_ctx.next_task, NULL); } else { GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Failed to churn peers with error `%s'\n", emsg); - GNUNET_SCHEDULER_cancel(sched, die_task); - die_task = GNUNET_SCHEDULER_add_now(sched, &end_badly, NULL); + GNUNET_SCHEDULER_cancel(die_task); + die_task = GNUNET_SCHEDULER_add_now(&end_badly, NULL); } } @@ -225,11 +223,10 @@ peers_started_callback (void *cls, "All %d daemons started, now testing churn!\n", num_peers); #endif - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, "from peers_started_callback"); churn_peers_off (); @@ -240,11 +237,9 @@ peers_started_callback (void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { - sched = s; ok = 1; #if VERBOSE @@ -278,12 +273,11 @@ run (void *cls, /* Set up a task to end testing if peer start fails */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, "didn't start all daemons in reasonable amount of time!!!"); - pg = GNUNET_TESTING_daemons_start (sched, cfg, + pg = GNUNET_TESTING_daemons_start (cfg, peers_left, TIMEOUT, NULL, NULL, &peers_started_callback, NULL, NULL, NULL, NULL); diff --git a/src/testing/testing.c b/src/testing/testing.c index 89272f3c2..d5b585a62 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -160,8 +160,7 @@ testing_init (void *cls, #endif - d->th = GNUNET_TRANSPORT_connect (d->sched, - d->cfg, + d->th = GNUNET_TRANSPORT_connect (d->cfg, &d->id, d, NULL, NULL, NULL); if (d->th == NULL) @@ -219,8 +218,7 @@ start_fsm (void *cls, } /* wait some more */ d->task - = GNUNET_SCHEDULER_add_delayed (d->sched, - GNUNET_CONSTANTS_EXEC_WAIT, + = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d); return; } @@ -333,8 +331,7 @@ start_fsm (void *cls, #endif d->phase = SP_HOSTKEY_CREATE; d->task - = GNUNET_SCHEDULER_add_read_file (d->sched, - GNUNET_TIME_absolute_get_remaining(d->max_timeout), + = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining(d->max_timeout), GNUNET_DISK_pipe_handle(d->pipe_stdout, GNUNET_DISK_PIPE_END_READ), &start_fsm, @@ -353,8 +350,7 @@ start_fsm (void *cls, { /* keep reading */ d->task - = GNUNET_SCHEDULER_add_read_file (d->sched, - GNUNET_TIME_absolute_get_remaining(d->max_timeout), + = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining(d->max_timeout), GNUNET_DISK_pipe_handle(d->pipe_stdout, GNUNET_DISK_PIPE_END_READ), &start_fsm, @@ -426,8 +422,7 @@ start_fsm (void *cls, } d->task - = GNUNET_SCHEDULER_add_delayed (d->sched, - GNUNET_CONSTANTS_EXEC_WAIT, + = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d); break; case SP_TOPOLOGY_SETUP: @@ -517,8 +512,7 @@ start_fsm (void *cls, #endif d->phase = SP_START_ARMING; d->task - = GNUNET_SCHEDULER_add_delayed (d->sched, - GNUNET_CONSTANTS_EXEC_WAIT, + = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d); break; case SP_START_ARMING: @@ -540,8 +534,7 @@ start_fsm (void *cls, } /* wait some more */ d->task - = GNUNET_SCHEDULER_add_delayed (d->sched, - GNUNET_CONSTANTS_EXEC_WAIT, + = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d); return; } @@ -550,8 +543,7 @@ start_fsm (void *cls, "Successfully started `%s'.\n", "gnunet-arm"); #endif d->phase = SP_START_CORE; - d->server = GNUNET_CORE_connect (d->sched, - d->cfg, + d->server = GNUNET_CORE_connect (d->cfg, ARM_START_WAIT, d, &testing_init, @@ -591,8 +583,7 @@ start_fsm (void *cls, } /* wait some more */ d->task - = GNUNET_SCHEDULER_add_delayed (d->sched, - GNUNET_CONSTANTS_EXEC_WAIT, + = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d); return; } @@ -661,8 +652,7 @@ start_fsm (void *cls, } /* wait some more */ d->task - = GNUNET_SCHEDULER_add_delayed (d->sched, - GNUNET_CONSTANTS_EXEC_WAIT, + = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d); return; } @@ -744,8 +734,7 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon, daemon->phase = SP_TOPOLOGY_SETUP; daemon->max_timeout = GNUNET_TIME_relative_to_absolute(timeout); - GNUNET_SCHEDULER_add_continuation (daemon->sched, - &start_fsm, + GNUNET_SCHEDULER_add_continuation (&start_fsm, daemon, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -756,7 +745,6 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon, * reachable via "ssh" (unless the hostname is "NULL") without the * need to enter a password. * - * @param sched scheduler to use * @param cfg configuration to use * @param timeout how long to wait starting up peers * @param hostname name of the machine where to run GNUnet @@ -772,8 +760,7 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon, * @return handle to the daemon (actual start will be completed asynchronously) */ struct GNUNET_TESTING_Daemon * -GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TIME_Relative timeout, const char *hostname, const char *ssh_username, @@ -788,7 +775,6 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, char *username; ret = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Daemon)); - ret->sched = sched; ret->hostname = (hostname == NULL) ? NULL : GNUNET_strdup (hostname); if (sshport != 0) { @@ -892,8 +878,7 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, return NULL; } ret->task - = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_CONSTANTS_EXEC_WAIT, + = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, ret); return ret; } @@ -902,8 +887,7 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, "No need to copy configuration file since we are running locally.\n"); #endif ret->phase = SP_COPIED; - GNUNET_SCHEDULER_add_continuation (sched, - &start_fsm, + GNUNET_SCHEDULER_add_continuation (&start_fsm, ret, GNUNET_SCHEDULER_REASON_PREREQ_DONE); return ret; @@ -936,7 +920,7 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d, if (d->phase == SP_CONFIG_UPDATE) { - GNUNET_SCHEDULER_cancel (d->sched, d->task); + GNUNET_SCHEDULER_cancel (d->task); d->phase = SP_START_DONE; } if (d->server != NULL) @@ -1003,8 +987,7 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d, GNUNET_free_non_null(del_arg); d->task - = GNUNET_SCHEDULER_add_delayed (d->sched, - GNUNET_CONSTANTS_EXEC_WAIT, + = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d); } @@ -1073,7 +1056,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, if (d->phase == SP_CONFIG_UPDATE) { - GNUNET_SCHEDULER_cancel (d->sched, d->task); + GNUNET_SCHEDULER_cancel (d->task); d->phase = SP_START_DONE; } if (d->server != NULL) @@ -1140,8 +1123,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, GNUNET_free_non_null(del_arg); d->max_timeout = GNUNET_TIME_relative_to_absolute(timeout); d->task - = GNUNET_SCHEDULER_add_now (d->sched, - &start_fsm, d); + = GNUNET_SCHEDULER_add_now (&start_fsm, d); } @@ -1216,8 +1198,7 @@ GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d, d->update_cb = cb; d->update_cb_cls = cb_cls; d->task - = GNUNET_SCHEDULER_add_delayed (d->sched, - GNUNET_CONSTANTS_EXEC_WAIT, + = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d); } @@ -1331,7 +1312,7 @@ notify_connect_result (void *cls, ctx->timeout_task = GNUNET_SCHEDULER_NO_TASK; if (ctx->hello_send_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(ctx->d1->sched, ctx->hello_send_task); + GNUNET_SCHEDULER_cancel(ctx->hello_send_task); ctx->hello_send_task = GNUNET_SCHEDULER_NO_TASK; } @@ -1388,7 +1369,7 @@ notify_connect_result (void *cls, GNUNET_TRANSPORT_disconnect(ctx->d2th); ctx->d2th = NULL; } - GNUNET_SCHEDULER_add_now(ctx->d1->sched, &reattempt_daemons_connect, ctx); + GNUNET_SCHEDULER_add_now(&reattempt_daemons_connect, ctx); return; } else @@ -1428,9 +1409,8 @@ connect_notify (void *cls, const struct GNUNET_PeerIdentity * peer, struct GNUNE { ctx->connected = GNUNET_YES; ctx->distance = distance; - GNUNET_SCHEDULER_cancel(ctx->d1->sched, ctx->timeout_task); - ctx->timeout_task = GNUNET_SCHEDULER_add_now (ctx->d1->sched, - ¬ify_connect_result, + GNUNET_SCHEDULER_cancel(ctx->timeout_task); + ctx->timeout_task = GNUNET_SCHEDULER_add_now (¬ify_connect_result, ctx); } @@ -1456,9 +1436,8 @@ connect_notify_core2 (void *cls, const struct GNUNET_PeerIdentity * peer, struct { ctx->connected = GNUNET_YES; ctx->distance = distance; - GNUNET_SCHEDULER_cancel(ctx->d1->sched, ctx->timeout_task); - ctx->timeout_task = GNUNET_SCHEDULER_add_now (ctx->d1->sched, - ¬ify_connect_result, + GNUNET_SCHEDULER_cancel(ctx->timeout_task); + ctx->timeout_task = GNUNET_SCHEDULER_add_now (¬ify_connect_result, ctx); } @@ -1496,8 +1475,7 @@ send_hello(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert(hello != NULL); GNUNET_TRANSPORT_offer_hello (ctx->d2th, hello); - ctx->connect_request_handle = GNUNET_CORE_peer_request_connect (ctx->d1->sched, - ctx->d2->cfg, + ctx->connect_request_handle = GNUNET_CORE_peer_request_connect (ctx->d2->cfg, GNUNET_TIME_relative_divide(ctx->relative_timeout, ctx->max_connect_attempts + 1), &ctx->d1->id, @@ -1508,8 +1486,7 @@ send_hello(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 500)); } - ctx->hello_send_task = GNUNET_SCHEDULER_add_delayed(ctx->d1->sched, - ctx->timeout_hello, + ctx->hello_send_task = GNUNET_SCHEDULER_add_delayed(ctx->timeout_hello, &send_hello, ctx); } @@ -1558,8 +1535,7 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, d1->shortname, d2->shortname); #endif - ctx->d1core = GNUNET_CORE_connect (d1->sched, - d1->cfg, + ctx->d1core = GNUNET_CORE_connect (d1->cfg, timeout, ctx, NULL, @@ -1576,8 +1552,7 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, } #if CONNECT_CORE2 - ctx->d2core = GNUNET_CORE_connect (d2->sched, - d2->cfg, + ctx->d2core = GNUNET_CORE_connect (d2->cfg, timeout, ctx, NULL, @@ -1603,8 +1578,7 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, #endif - ctx->d2th = GNUNET_TRANSPORT_connect (d2->sched, - d2->cfg, + ctx->d2th = GNUNET_TRANSPORT_connect (d2->cfg, &d2->id, d2, NULL, NULL, NULL); if (ctx->d2th == NULL) @@ -1617,12 +1591,11 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, return; } - ctx->timeout_task = GNUNET_SCHEDULER_add_delayed (d1->sched, - GNUNET_TIME_relative_divide(ctx->relative_timeout, + ctx->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide(ctx->relative_timeout, ctx->max_connect_attempts), ¬ify_connect_result, ctx); - ctx->hello_send_task = GNUNET_SCHEDULER_add_now(ctx->d1->sched, &send_hello, ctx); + ctx->hello_send_task = GNUNET_SCHEDULER_add_now(&send_hello, ctx); } static void @@ -1641,8 +1614,7 @@ reattempt_daemons_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext GNUNET_assert(ctx->d1core == NULL); - ctx->d1core = GNUNET_CORE_connect (ctx->d1->sched, - ctx->d1->cfg, + ctx->d1core = GNUNET_CORE_connect (ctx->d1->cfg, GNUNET_TIME_absolute_get_remaining(ctx->timeout), ctx, NULL, @@ -1658,8 +1630,7 @@ reattempt_daemons_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext return; } - ctx->d2th = GNUNET_TRANSPORT_connect (ctx->d2->sched, - ctx->d2->cfg, + ctx->d2th = GNUNET_TRANSPORT_connect (ctx->d2->cfg, &ctx->d2->id, ctx->d2, NULL, NULL, NULL); if (ctx->d2th == NULL) @@ -1672,11 +1643,10 @@ reattempt_daemons_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext return; } - ctx->timeout_task = GNUNET_SCHEDULER_add_delayed (ctx->d1->sched, - GNUNET_TIME_relative_divide(ctx->relative_timeout, ctx->max_connect_attempts), + ctx->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide(ctx->relative_timeout, ctx->max_connect_attempts), ¬ify_connect_result, ctx); - ctx->hello_send_task = GNUNET_SCHEDULER_add_now(ctx->d1->sched, &send_hello, ctx); + ctx->hello_send_task = GNUNET_SCHEDULER_add_now(&send_hello, ctx); } /* end of testing.c */ diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index 7322fc44a..8697044e3 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c @@ -480,11 +480,6 @@ struct StatsCoreContext */ struct GNUNET_TESTING_PeerGroup { - /** - * Our scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * Configuration template. */ @@ -2252,7 +2247,7 @@ static void schedule_connect(void *cls, const struct GNUNET_SCHEDULER_TaskContex GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Delaying connect, we have too many outstanding connections!\n")); #endif - GNUNET_SCHEDULER_add_delayed(connect_context->ct_ctx->pg->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_connect, connect_context); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_connect, connect_context); } else { @@ -2296,7 +2291,7 @@ connect_iterator (void *cls, connect_context->first = first->daemon; connect_context->second = second; connect_context->ct_ctx = ct_ctx; - GNUNET_SCHEDULER_add_now(first->pg->sched, &schedule_connect, connect_context); + GNUNET_SCHEDULER_add_now(&schedule_connect, connect_context); return GNUNET_YES; } @@ -2404,7 +2399,7 @@ connect_topology (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_NotifyComp connect_context->pg = pg; connect_context->first = FIXME; connect_context->second = connection_iter->daemon; - GNUNET_SCHEDULER_add_now(pg->sched, &schedule_connect, connect_context); + GNUNET_SCHEDULER_add_now(&schedule_connect, connect_context); connection_iter = connection_iter->next; } #endif @@ -3156,7 +3151,7 @@ schedule_get_topology(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Delaying connect, we have too many outstanding connections!\n")); #endif - GNUNET_SCHEDULER_add_delayed(core_context->daemon->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_get_topology, core_context); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_get_topology, core_context); } else { @@ -3165,7 +3160,7 @@ schedule_get_topology(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) _("Creating connection, outstanding_connections is %d\n"), outstanding_connects); #endif topology_context->connected++; - if (GNUNET_OK != GNUNET_CORE_iterate_peers (core_context->daemon->sched, core_context->daemon->cfg, &internal_topology_callback, core_context)) + if (GNUNET_OK != GNUNET_CORE_iterate_peers (core_context->daemon->cfg, &internal_topology_callback, core_context)) internal_topology_callback(core_context, NULL, GNUNET_TIME_relative_get_zero(), 0); } @@ -3197,7 +3192,7 @@ GNUNET_TESTING_get_topology (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING core_ctx->daemon = pg->peers[i].daemon; /* Set back pointer to topology iteration context */ core_ctx->iter_context = topology_context; - GNUNET_SCHEDULER_add_now(pg->sched, &schedule_get_topology, core_ctx); + GNUNET_SCHEDULER_add_now(&schedule_get_topology, core_ctx); total_count++; } } @@ -3276,7 +3271,7 @@ schedule_get_statistics(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Delaying connect, we have too many outstanding connections!\n")); #endif - GNUNET_SCHEDULER_add_delayed(core_context->daemon->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_get_statistics, core_context); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_get_statistics, core_context); } else { @@ -3286,7 +3281,7 @@ schedule_get_statistics(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc #endif stats_context->connected++; - core_context->stats_handle = GNUNET_STATISTICS_create(core_context->daemon->sched, "testing", core_context->daemon->cfg); + core_context->stats_handle = GNUNET_STATISTICS_create("testing", core_context->daemon->cfg); if (core_context->stats_handle == NULL) { internal_stats_cont (core_context, GNUNET_NO); @@ -3394,7 +3389,7 @@ GNUNET_TESTING_get_statistics (struct GNUNET_TESTING_PeerGroup *pg, core_ctx->daemon = pg->peers[i].daemon; /* Set back pointer to topology iteration context */ core_ctx->iter_context = stats_context; - GNUNET_SCHEDULER_add_now(pg->sched, &schedule_get_statistics, core_ctx); + GNUNET_SCHEDULER_add_now(&schedule_get_statistics, core_ctx); total_count++; } } @@ -3626,7 +3621,7 @@ internal_continue_startup (void *cls, const struct GNUNET_SCHEDULER_TaskContext } else { - GNUNET_SCHEDULER_add_delayed(internal_context->peer->pg->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &internal_continue_startup, internal_context); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &internal_continue_startup, internal_context); } } @@ -3697,7 +3692,7 @@ static void schedule_churn_restart(void *cls, const struct GNUNET_SCHEDULER_Task struct ChurnRestartContext *startup_ctx = peer_restart_ctx->churn_restart_ctx; if (startup_ctx->outstanding > MAX_CONCURRENT_STARTING) - GNUNET_SCHEDULER_add_delayed(peer_restart_ctx->daemon->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_churn_restart, peer_restart_ctx); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_churn_restart, peer_restart_ctx); else { GNUNET_TESTING_daemon_start_stopped(peer_restart_ctx->daemon, @@ -3721,8 +3716,7 @@ internal_start (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) if (internal_context->peer->pg->starting < MAX_CONCURRENT_HOSTKEYS) { internal_context->peer->pg->starting++; - internal_context->peer->daemon = GNUNET_TESTING_daemon_start (internal_context->peer->pg->sched, - internal_context->peer->cfg, + internal_context->peer->daemon = GNUNET_TESTING_daemon_start (internal_context->peer->cfg, internal_context->timeout, internal_context->hostname, internal_context->username, @@ -3734,7 +3728,7 @@ internal_start (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) } else { - GNUNET_SCHEDULER_add_delayed(internal_context->peer->pg->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &internal_start, internal_context); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &internal_start, internal_context); } } @@ -3753,7 +3747,7 @@ GNUNET_TESTING_daemons_continue_startup(struct GNUNET_TESTING_PeerGroup *pg) pg->starting = 0; for (i = 0; i < pg->total; i++) { - GNUNET_SCHEDULER_add_now (pg->sched, &internal_continue_startup, &pg->peers[i].internal_context); + GNUNET_SCHEDULER_add_now (&internal_continue_startup, &pg->peers[i].internal_context); //GNUNET_TESTING_daemon_continue_startup(pg->peers[i].daemon); } } @@ -3764,7 +3758,6 @@ GNUNET_TESTING_daemons_continue_startup(struct GNUNET_TESTING_PeerGroup *pg) * adjusted to ensure that no two peers running on the same system * have the same port(s) in their respective configurations. * - * @param sched scheduler to use * @param cfg configuration template to use * @param total number of daemons to start * @param timeout total time allowed for peers to start @@ -3782,8 +3775,7 @@ GNUNET_TESTING_daemons_continue_startup(struct GNUNET_TESTING_PeerGroup *pg) * @return NULL on error, otherwise handle to control peer group */ struct GNUNET_TESTING_PeerGroup * -GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int total, struct GNUNET_TIME_Relative timeout, GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback, @@ -3822,7 +3814,6 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, upnum = 0; fdnum = 0; pg = GNUNET_malloc (sizeof (struct GNUNET_TESTING_PeerGroup)); - pg->sched = sched; pg->cfg = cfg; pg->notify_connection = connect_callback; pg->notify_connection_cls = connect_callback_cls; @@ -3980,7 +3971,7 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, pg->peers[off].internal_context.start_cb = cb; pg->peers[off].internal_context.start_cb_cls = cb_cls; - GNUNET_SCHEDULER_add_now (sched, &internal_start, &pg->peers[off].internal_context); + GNUNET_SCHEDULER_add_now (&internal_start, &pg->peers[off].internal_context); } return pg; @@ -4156,7 +4147,7 @@ schedule_churn_shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskConte GNUNET_assert(shutdown_ctx != NULL); if (shutdown_ctx->outstanding > MAX_CONCURRENT_SHUTDOWN) - GNUNET_SCHEDULER_add_delayed(peer_shutdown_ctx->daemon->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_churn_shutdown_task, peer_shutdown_ctx); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_churn_shutdown_task, peer_shutdown_ctx); else { shutdown_ctx->outstanding++; @@ -4309,7 +4300,7 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg, peer_shutdown_ctx = GNUNET_malloc(sizeof(struct PeerShutdownContext)); peer_shutdown_ctx->daemon = pg->peers[running_arr[running_permute[i]]].daemon; peer_shutdown_ctx->shutdown_ctx = shutdown_ctx; - GNUNET_SCHEDULER_add_now(peer_shutdown_ctx->daemon->sched, &schedule_churn_shutdown_task, peer_shutdown_ctx); + GNUNET_SCHEDULER_add_now(&schedule_churn_shutdown_task, peer_shutdown_ctx); /* GNUNET_TESTING_daemon_stop (pg->peers[running_arr[running_permute[i]]].daemon, @@ -4334,7 +4325,7 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg, peer_restart_ctx = GNUNET_malloc(sizeof(struct PeerRestartContext)); peer_restart_ctx->churn_restart_ctx = churn_startup_ctx; peer_restart_ctx->daemon = pg->peers[stopped_arr[stopped_permute[i]]].daemon; - GNUNET_SCHEDULER_add_now(peer_restart_ctx->daemon->sched, &schedule_churn_restart, peer_restart_ctx); + GNUNET_SCHEDULER_add_now(&schedule_churn_restart, peer_restart_ctx); /* GNUNET_TESTING_daemon_start_stopped(pg->peers[stopped_arr[stopped_permute[i]]].daemon, timeout, &churn_start_callback, churn_ctx);*/ @@ -4485,7 +4476,7 @@ schedule_shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * t GNUNET_assert(shutdown_ctx != NULL); if (shutdown_ctx->outstanding > MAX_CONCURRENT_SHUTDOWN) - GNUNET_SCHEDULER_add_delayed(peer_shutdown_ctx->daemon->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_shutdown_task, peer_shutdown_ctx); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_shutdown_task, peer_shutdown_ctx); else { shutdown_ctx->outstanding++; @@ -4527,7 +4518,7 @@ GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg, peer_shutdown_ctx = GNUNET_malloc(sizeof(struct PeerShutdownContext)); peer_shutdown_ctx->daemon = pg->peers[off].daemon; peer_shutdown_ctx->shutdown_ctx = shutdown_ctx; - GNUNET_SCHEDULER_add_now(pg->peers[off].daemon->sched, &schedule_shutdown_task, peer_shutdown_ctx); + GNUNET_SCHEDULER_add_now(&schedule_shutdown_task, peer_shutdown_ctx); //GNUNET_TESTING_daemon_stop (pg->peers[off].daemon, timeout, shutdown_cb, shutdown_ctx, GNUNET_YES, GNUNET_NO); if (NULL != pg->peers[off].cfg) GNUNET_CONFIGURATION_destroy (pg->peers[off].cfg); diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index dc7face2d..b8bad46a6 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c @@ -156,11 +156,6 @@ struct Peer */ static struct GNUNET_PEERINFO_NotifyContext *peerinfo_notify; -/** - * Our scheduler. - */ -static struct GNUNET_SCHEDULER_Handle *sched; - /** * Our configuration. */ @@ -347,11 +342,9 @@ free_peer (void *cls, if (pos->connect_req != NULL) GNUNET_CORE_peer_request_connect_cancel (pos->connect_req); if (pos->hello_delay_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched, - pos->hello_delay_task); + GNUNET_SCHEDULER_cancel (pos->hello_delay_task); if (pos->greylist_clean_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched, - pos->greylist_clean_task); + GNUNET_SCHEDULER_cancel (pos->greylist_clean_task); GNUNET_free_non_null (pos->hello); if (pos->filter != NULL) GNUNET_CONTAINER_bloomfilter_free (pos->filter); @@ -406,11 +399,9 @@ attempt_connect (struct Peer *pos) GREYLIST_AFTER_ATTEMPT_MAX); pos->greylisted_until = GNUNET_TIME_relative_to_absolute (rem); if (pos->greylist_clean_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched, - pos->greylist_clean_task); + GNUNET_SCHEDULER_cancel (pos->greylist_clean_task); pos->greylist_clean_task - = GNUNET_SCHEDULER_add_delayed (sched, - rem, + = GNUNET_SCHEDULER_add_delayed (rem, &remove_from_greylist, pos); #if DEBUG_TOPOLOGY @@ -422,7 +413,7 @@ attempt_connect (struct Peer *pos) gettext_noop ("# connect requests issued to core"), 1, GNUNET_NO); - pos->connect_req = GNUNET_CORE_peer_request_connect (sched, cfg, + pos->connect_req = GNUNET_CORE_peer_request_connect (cfg, GNUNET_TIME_UNIT_MINUTES, &pos->pid, &connect_completed_callback, @@ -453,8 +444,7 @@ remove_from_greylist (void *cls, else { pos->greylist_clean_task - = GNUNET_SCHEDULER_add_delayed (sched, - rem, + = GNUNET_SCHEDULER_add_delayed (rem, &remove_from_greylist, pos); } @@ -635,8 +625,7 @@ schedule_next_hello (void *cls, &find_advertisable_hello, &fah); pl->hello_delay_task - = GNUNET_SCHEDULER_add_delayed (sched, - fah.next_adv, + = GNUNET_SCHEDULER_add_delayed (fah.next_adv, &schedule_next_hello, pl); if (fah.result == NULL) @@ -685,13 +674,11 @@ reschedule_hellos (void *cls, } if (peer->hello_delay_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, - peer->hello_delay_task); + GNUNET_SCHEDULER_cancel (peer->hello_delay_task); peer->hello_delay_task = GNUNET_SCHEDULER_NO_TASK; } peer->hello_delay_task - = GNUNET_SCHEDULER_add_now (sched, - &schedule_next_hello, + = GNUNET_SCHEDULER_add_now (&schedule_next_hello, peer); return GNUNET_YES; } @@ -822,7 +809,7 @@ disconnect_notify (void *cls, NULL); if ( (friend_count < minimum_friend_count) && (blacklist == NULL) ) - blacklist = GNUNET_TRANSPORT_blacklist (sched, cfg, + blacklist = GNUNET_TRANSPORT_blacklist (cfg, &blacklist_check, NULL); } @@ -1021,7 +1008,7 @@ core_init (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to connect to core service, can not manage topology!\n")); - GNUNET_SCHEDULER_shutdown (sched); + GNUNET_SCHEDULER_shutdown (); return; } handle = server; @@ -1031,8 +1018,7 @@ core_init (void *cls, "I am peer `%s'\n", GNUNET_i2s (my_id)); #endif - peerinfo_notify = GNUNET_PEERINFO_notify (cfg, sched, - &process_peer, + peerinfo_notify = GNUNET_PEERINFO_notify (cfg, &process_peer, NULL); } @@ -1285,8 +1271,7 @@ hello_advertising_ready (void *cls, } pl->next_hello_allowed = GNUNET_TIME_relative_to_absolute (HELLO_ADVERTISEMENT_MIN_FREQUENCY); pl->hello_delay_task - = GNUNET_SCHEDULER_add_now (sched, - &schedule_next_hello, + = GNUNET_SCHEDULER_add_now (&schedule_next_hello, pl); return want; } @@ -1332,14 +1317,12 @@ cleaning_task (void *cls, * Main function that will be run. * * @param cls closure - * @param s the scheduler to use * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param c configuration */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle * s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle * c) @@ -1351,9 +1334,8 @@ run (void *cls, }; unsigned long long opt; - sched = s; cfg = c; - stats = GNUNET_STATISTICS_create (sched, "topology", cfg); + stats = GNUNET_STATISTICS_create ("topology", cfg); autoconnect = GNUNET_CONFIGURATION_get_value_yesno (cfg, "TOPOLOGY", "AUTOCONNECT"); @@ -1387,17 +1369,15 @@ run (void *cls, autoconnect ? "autoconnect enabled" : "autoconnect disabled"); #endif if (friend_count < minimum_friend_count) - blacklist = GNUNET_TRANSPORT_blacklist (sched, cfg, + blacklist = GNUNET_TRANSPORT_blacklist (cfg, &blacklist_check, NULL); - transport = GNUNET_TRANSPORT_connect (sched, - cfg, + transport = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, NULL, NULL); - handle = GNUNET_CORE_connect (sched, - cfg, + handle = GNUNET_CORE_connect (cfg, GNUNET_TIME_UNIT_FOREVER_REL, NULL, &core_init, @@ -1407,15 +1387,14 @@ run (void *cls, NULL, GNUNET_NO, NULL, GNUNET_NO, handlers); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task, NULL); if (NULL == transport) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to connect to `%s' service.\n"), "transport"); - GNUNET_SCHEDULER_shutdown (sched); + GNUNET_SCHEDULER_shutdown (); return; } if (NULL == handle) @@ -1423,7 +1402,7 @@ run (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to connect to `%s' service.\n"), "core"); - GNUNET_SCHEDULER_shutdown (sched); + GNUNET_SCHEDULER_shutdown (); return; } } diff --git a/src/topology/test_gnunet_daemon_topology.c b/src/topology/test_gnunet_daemon_topology.c index f6b671dc0..529496f11 100644 --- a/src/topology/test_gnunet_daemon_topology.c +++ b/src/topology/test_gnunet_daemon_topology.c @@ -48,8 +48,6 @@ static struct GNUNET_TESTING_Daemon *first; static struct GNUNET_TESTING_Daemon *last; -static struct GNUNET_SCHEDULER_Handle *sched; - /** * Check whether peers successfully shut down. */ @@ -108,8 +106,7 @@ notify_connect_complete(void *cls, { /* FIXME: check that topology adds a few more links in addition to those that were seeded */ - GNUNET_SCHEDULER_add_now (sched, - &clean_up_task, + GNUNET_SCHEDULER_add_now (&clean_up_task, NULL); } } @@ -145,19 +142,17 @@ static void my_cb(void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { - sched = s; ok = 1; #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); #endif peers_left = NUM_PEERS; - pg = GNUNET_TESTING_daemons_start (sched, cfg, + pg = GNUNET_TESTING_daemons_start (cfg, peers_left, TIMEOUT, NULL, NULL, diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 87d73baf4..0ade42512 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -842,11 +842,6 @@ static struct GNUNET_PeerIdentity my_identity; */ static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key; -/** - * Our scheduler. - */ -struct GNUNET_SCHEDULER_Handle *sched; - /** * Our configuration. */ @@ -1656,10 +1651,8 @@ try_transmission_to_peer (struct NeighbourList *neighbour) 1, GNUNET_NO); if (neighbour->retry_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched, - neighbour->retry_task); - neighbour->retry_task = GNUNET_SCHEDULER_add_delayed (sched, - timeout, + GNUNET_SCHEDULER_cancel (neighbour->retry_task); + neighbour->retry_task = GNUNET_SCHEDULER_add_delayed (timeout, &retry_transmission_task, neighbour); #if DEBUG_TRANSPORT @@ -1924,7 +1917,7 @@ update_addresses (struct TransportPlugin *plugin, int fresh) int expired; if (plugin->address_update_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (plugin->env.sched, plugin->address_update_task); + GNUNET_SCHEDULER_cancel (plugin->address_update_task); plugin->address_update_task = GNUNET_SCHEDULER_NO_TASK; now = GNUNET_TIME_absolute_get (); min_remaining = GNUNET_TIME_UNIT_FOREVER_REL; @@ -1962,8 +1955,7 @@ update_addresses (struct TransportPlugin *plugin, int fresh) GNUNET_TIME_relative_divide (HELLO_ADDRESS_EXPIRATION, 2)); plugin->address_update_task - = GNUNET_SCHEDULER_add_delayed (plugin->env.sched, - min_remaining, + = GNUNET_SCHEDULER_add_delayed (min_remaining, &expire_address_task, plugin); } @@ -2126,8 +2118,7 @@ plugin_env_session_end (void *cls, prev->next = pos->next; if (GNUNET_SCHEDULER_NO_TASK != pos->revalidate_task) { - GNUNET_SCHEDULER_cancel (sched, - pos->revalidate_task); + GNUNET_SCHEDULER_cancel (pos->revalidate_task); pos->revalidate_task = GNUNET_SCHEDULER_NO_TASK; } GNUNET_free (pos); @@ -2518,7 +2509,7 @@ abort_validation (void *cls, struct ValidationEntry *va = value; if (GNUNET_SCHEDULER_NO_TASK != va->timeout_task) - GNUNET_SCHEDULER_cancel (sched, va->timeout_task); + GNUNET_SCHEDULER_cancel (va->timeout_task); GNUNET_free (va->transport_name); if (va->chvc != NULL) { @@ -2776,8 +2767,7 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer, } n->latency = GNUNET_TIME_UNIT_FOREVER_REL; n->distance = -1; - n->timeout_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, + n->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &neighbour_timeout_task, n); if (do_hello) { @@ -2954,8 +2944,7 @@ transmit_blacklist_message (void *cls, if (size == 0) { GNUNET_assert (bc->task == GNUNET_SCHEDULER_NO_TASK); - bc->task = GNUNET_SCHEDULER_add_now (sched, - &do_blacklist_check, + bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, bc); return 0; } @@ -3047,8 +3036,7 @@ setup_peer_check_blacklist (const struct GNUNET_PeerIdentity *peer, bc->cont = cont; bc->cont_cls = cont_cls; bc->bl_pos = bl_head; - bc->task = GNUNET_SCHEDULER_add_now (sched, - &do_blacklist_check, + bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, bc); } @@ -3120,8 +3108,7 @@ handle_blacklist_init (void *cls, bc->bl_pos = bl; if (n == neighbours) /* all would wait for the same client, no need to create more than just the first task right now */ - bc->task = GNUNET_SCHEDULER_add_now (sched, - &do_blacklist_check, + bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, bc); n = n->next; } @@ -3164,8 +3151,7 @@ handle_blacklist_reply (void *cls, else { bc->bl_pos = bc->bl_pos->next; - bc->task = GNUNET_SCHEDULER_add_now (sched, - &do_blacklist_check, + bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, bc); } /* check if any other bc's are waiting for this blacklister */ @@ -3174,8 +3160,7 @@ handle_blacklist_reply (void *cls, { if ( (bc->bl_pos == bl) && (GNUNET_SCHEDULER_NO_TASK == bc->task) ) - bc->task = GNUNET_SCHEDULER_add_now (sched, - &do_blacklist_check, + bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, bc); bc = bc->next; } @@ -3258,8 +3243,7 @@ send_periodic_ping (void *cls, &neighbour->publicKey, sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); - va->timeout_task = GNUNET_SCHEDULER_add_delayed (sched, - HELLO_VERIFICATION_TIMEOUT, + va->timeout_task = GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT, &timeout_hello_validation, va); GNUNET_CONTAINER_multihashmap_put (validation_map, @@ -3384,8 +3368,7 @@ schedule_next_ping (struct ForeignAddressList *fal) GNUNET_TIME_UNIT_SECONDS); /* randomize a bit (to avoid doing all at the same time) */ delay.rel_value += GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000); - fal->revalidate_task = GNUNET_SCHEDULER_add_delayed(sched, - delay, + fal->revalidate_task = GNUNET_SCHEDULER_add_delayed(delay, &send_periodic_ping, fal); } @@ -3691,8 +3674,7 @@ check_pending_validation (void *cls, } if (n->retry_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, - n->retry_task); + GNUNET_SCHEDULER_cancel (n->retry_task); n->retry_task = GNUNET_SCHEDULER_NO_TASK; try_transmission_to_peer (n); } @@ -3981,8 +3963,7 @@ run_validation (void *cls, va->addrlen = addrlen; GNUNET_HELLO_get_key (chvc->hello, &va->publicKey); - va->timeout_task = GNUNET_SCHEDULER_add_delayed (sched, - HELLO_VERIFICATION_TIMEOUT, + va->timeout_task = GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT, &timeout_hello_validation, va); GNUNET_CONTAINER_multihashmap_put (validation_map, @@ -4146,8 +4127,7 @@ process_hello (struct TransportPlugin *plugin, GNUNET_NO); /* first, check if load is too high */ - if (GNUNET_SCHEDULER_get_load (sched, - GNUNET_SCHEDULER_PRIORITY_BACKGROUND) > MAX_HELLO_LOAD) + if (GNUNET_SCHEDULER_get_load (GNUNET_SCHEDULER_PRIORITY_BACKGROUND) > MAX_HELLO_LOAD) { GNUNET_STATISTICS_update (stats, gettext_noop ("# HELLOs ignored due to high load"), @@ -4351,8 +4331,7 @@ disconnect_neighbour (struct NeighbourList *n, int check) GNUNET_NO); if (GNUNET_SCHEDULER_NO_TASK != peer_pos->revalidate_task) { - GNUNET_SCHEDULER_cancel (sched, - peer_pos->revalidate_task); + GNUNET_SCHEDULER_cancel (peer_pos->revalidate_task); peer_pos->revalidate_task = GNUNET_SCHEDULER_NO_TASK; } GNUNET_free(peer_pos); @@ -4381,12 +4360,12 @@ disconnect_neighbour (struct NeighbourList *n, int check) } if (n->timeout_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, n->timeout_task); + GNUNET_SCHEDULER_cancel (n->timeout_task); n->timeout_task = GNUNET_SCHEDULER_NO_TASK; } if (n->retry_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, n->retry_task); + GNUNET_SCHEDULER_cancel (n->retry_task); n->retry_task = GNUNET_SCHEDULER_NO_TASK; } if (n->piter != NULL) @@ -4736,11 +4715,9 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, n->peer_timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); - GNUNET_SCHEDULER_cancel (sched, - n->timeout_task); + GNUNET_SCHEDULER_cancel (n->timeout_task); n->timeout_task = - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, + GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &neighbour_timeout_task, n); if (n->quota_violation_count > QUOTA_VIOLATION_DROP_THRESHOLD) { @@ -5191,7 +5168,6 @@ static void create_environment (struct TransportPlugin *plug) { plug->env.cfg = cfg; - plug->env.sched = sched; plug->env.my_identity = &my_identity; plug->env.our_hello = &our_hello; plug->env.cls = plug; @@ -5276,8 +5252,7 @@ client_disconnect_notification (void *cls, bc->th = NULL; } if (bc->task == GNUNET_SCHEDULER_NO_TASK) - bc->task = GNUNET_SCHEDULER_add_now (sched, - &do_blacklist_check, + bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, bc); break; } @@ -5359,8 +5334,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) plugins = plug->next; if (plug->address_update_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (plug->env.sched, - plug->address_update_task); + GNUNET_SCHEDULER_cancel (plug->address_update_task); plug->address_update_task = GNUNET_SCHEDULER_NO_TASK; } GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api)); @@ -5423,13 +5397,11 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * Initiate transport service. * * @param cls closure - * @param s scheduler to use * @param server the initialized server * @param c configuration to use */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { @@ -5459,9 +5431,8 @@ run (void *cls, unsigned long long tneigh; char *keyfile; - sched = s; cfg = c; - stats = GNUNET_STATISTICS_create (sched, "transport", cfg); + stats = GNUNET_STATISTICS_create ("transport", cfg); validation_map = GNUNET_CONTAINER_multihashmap_create (64); /* parse configuration */ if ((GNUNET_OK != @@ -5477,7 +5448,7 @@ run (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Transport service is lacking key configuration settings. Exiting.\n")); - GNUNET_SCHEDULER_shutdown (s); + GNUNET_SCHEDULER_shutdown (); if (stats != NULL) { GNUNET_STATISTICS_destroy (stats, GNUNET_NO); @@ -5488,12 +5459,12 @@ run (void *cls, return; } max_connect_per_transport = (uint32_t) tneigh; - peerinfo = GNUNET_PEERINFO_connect (sched, cfg); + peerinfo = GNUNET_PEERINFO_connect (cfg); if (peerinfo == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not access PEERINFO service. Exiting.\n")); - GNUNET_SCHEDULER_shutdown (s); + GNUNET_SCHEDULER_shutdown (); if (stats != NULL) { GNUNET_STATISTICS_destroy (stats, GNUNET_NO); @@ -5511,7 +5482,7 @@ run (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Transport service could not access hostkey. Exiting.\n")); - GNUNET_SCHEDULER_shutdown (s); + GNUNET_SCHEDULER_shutdown (); if (stats != NULL) { GNUNET_STATISTICS_destroy (stats, GNUNET_NO); @@ -5544,8 +5515,7 @@ run (void *cls, } GNUNET_free (plugs); } - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); if (no_transports) refresh_hello (); diff --git a/src/transport/plugin_transport.h b/src/transport/plugin_transport.h index a8e15ac8a..5f6d6fcfb 100644 --- a/src/transport/plugin_transport.h +++ b/src/transport/plugin_transport.h @@ -189,11 +189,6 @@ struct GNUNET_TRANSPORT_PluginEnvironment */ const struct GNUNET_CONFIGURATION_Handle *cfg; - /** - * Scheduler to use. - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * Identity of this peer. */ diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index e4c88903f..ad8ced567 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -880,14 +880,14 @@ static void mhd_write_mst_cb (void *cls, 0); pc->delay = delay; if (pc->reset_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (pc->plugin->env->sched, pc->reset_task); + GNUNET_SCHEDULER_cancel (pc->reset_task); if (delay.rel_value > 0) { #if DEBUG_HTTP GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: Inbound quota management: delay next read for %llu ms \n", ps, delay.rel_value); #endif - pc->reset_task = GNUNET_SCHEDULER_add_delayed (pc->plugin->env->sched, delay, &reset_inbound_quota_delay, pc); + pc->reset_task = GNUNET_SCHEDULER_add_delayed (delay, &reset_inbound_quota_delay, pc); } } @@ -1274,12 +1274,11 @@ http_server_daemon_prepare (struct Plugin *plugin , struct MHD_Daemon *daemon_ha { if (plugin->http_server_task_v4 != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_server_task_v4); + GNUNET_SCHEDULER_cancel(plugin->http_server_task_v4); plugin->http_server_daemon_v4 = GNUNET_SCHEDULER_NO_TASK; } - ret = GNUNET_SCHEDULER_add_select (plugin->env->sched, - GNUNET_SCHEDULER_PRIORITY_DEFAULT, + ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_SCHEDULER_NO_TASK, tv, wrs, @@ -1291,12 +1290,11 @@ http_server_daemon_prepare (struct Plugin *plugin , struct MHD_Daemon *daemon_ha { if (plugin->http_server_task_v6 != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_server_task_v6); + GNUNET_SCHEDULER_cancel(plugin->http_server_task_v6); plugin->http_server_task_v6 = GNUNET_SCHEDULER_NO_TASK; } - ret = GNUNET_SCHEDULER_add_select (plugin->env->sched, - GNUNET_SCHEDULER_PRIORITY_DEFAULT, + ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_SCHEDULER_NO_TASK, tv, wrs, @@ -1586,14 +1584,14 @@ static void curl_receive_mst_cb (void *cls, pc->delay = delay; if (pc->reset_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (pc->plugin->env->sched, pc->reset_task); + GNUNET_SCHEDULER_cancel (pc->reset_task); if (delay.rel_value > 0) { #if DEBUG_HTTP GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: Inbound quota management: delay next read for %llu ms \n", ps, delay.abs_value); #endif - pc->reset_task = GNUNET_SCHEDULER_add_delayed (pc->plugin->env->sched, delay, &reset_inbound_quota_delay, pc); + pc->reset_task = GNUNET_SCHEDULER_add_delayed (delay, &reset_inbound_quota_delay, pc); } } @@ -1820,7 +1818,7 @@ static int curl_schedule(struct Plugin *plugin) /* Cancel previous scheduled task */ if (plugin->http_curl_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_curl_task); + GNUNET_SCHEDULER_cancel(plugin->http_curl_task); plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK; } @@ -1851,8 +1849,7 @@ static int curl_schedule(struct Plugin *plugin) gws = GNUNET_NETWORK_fdset_create (); GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1); GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1); - plugin->http_curl_task = GNUNET_SCHEDULER_add_select (plugin->env->sched, - GNUNET_SCHEDULER_PRIORITY_DEFAULT, + plugin->http_curl_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_SCHEDULER_NO_TASK, (to == -1) ? GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) : GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, to), grs, @@ -1958,10 +1955,10 @@ static int send_check_connections (struct Plugin *plugin, struct Session *ps) } if (plugin->http_curl_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_curl_task); + GNUNET_SCHEDULER_cancel(plugin->http_curl_task); plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK; } - plugin->http_curl_task = GNUNET_SCHEDULER_add_now (plugin->env->sched, &curl_perform, plugin); + plugin->http_curl_task = GNUNET_SCHEDULER_add_now (&curl_perform, plugin); } /* waiting for receive direction */ @@ -1989,10 +1986,10 @@ static int send_check_connections (struct Plugin *plugin, struct Session *ps) ps->send_active=GNUNET_YES; if (plugin->http_curl_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_curl_task); + GNUNET_SCHEDULER_cancel(plugin->http_curl_task); plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK; } - plugin->http_curl_task = GNUNET_SCHEDULER_add_now (plugin->env->sched, &curl_perform, plugin); + plugin->http_curl_task = GNUNET_SCHEDULER_add_now (&curl_perform, plugin); return GNUNET_YES; } else @@ -2058,10 +2055,10 @@ static int send_check_connections (struct Plugin *plugin, struct Session *ps) } if (plugin->http_curl_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_curl_task); + GNUNET_SCHEDULER_cancel(plugin->http_curl_task); plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK; } - plugin->http_curl_task = GNUNET_SCHEDULER_add_now (plugin->env->sched, &curl_perform, plugin); + plugin->http_curl_task = GNUNET_SCHEDULER_add_now (&curl_perform, plugin); return GNUNET_YES; } if (ps->direction == INBOUND) @@ -2658,13 +2655,13 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls) if ( plugin->http_server_task_v4 != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_server_task_v4); + GNUNET_SCHEDULER_cancel(plugin->http_server_task_v4); plugin->http_server_task_v4 = GNUNET_SCHEDULER_NO_TASK; } if ( plugin->http_server_task_v6 != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_server_task_v6); + GNUNET_SCHEDULER_cancel(plugin->http_server_task_v6); plugin->http_server_task_v6 = GNUNET_SCHEDULER_NO_TASK; } @@ -2703,7 +2700,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls) if ( plugin->http_curl_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_curl_task); + GNUNET_SCHEDULER_cancel(plugin->http_curl_task); plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK; } diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 1073b24b7..b4d332d48 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -892,8 +892,7 @@ disconnect_session (struct Session *session) GNUNET_break (session->client != NULL); if (session->receive_delay_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (session->plugin->env->sched, - session->receive_delay_task); + GNUNET_SCHEDULER_cancel (session->receive_delay_task); if (session->client != NULL) GNUNET_SERVER_receive_done (session->client, GNUNET_SYSERR); @@ -1228,8 +1227,7 @@ tcp_plugin_send (void *cls, /* Only do one NAT punch attempt per peer identity */ return -1; } - sa = GNUNET_CONNECTION_create_from_sockaddr (plugin->env->sched, - af, sb, sbs); + sa = GNUNET_CONNECTION_create_from_sockaddr (af, sb, sbs); if (sa == NULL) { #if DEBUG_TCP @@ -1456,8 +1454,7 @@ tcp_plugin_address_pretty_printer (void *cls, ppc->asc = asc; ppc->asc_cls = asc_cls; ppc->port = port; - GNUNET_RESOLVER_hostname_get (plugin->env->sched, - plugin->env->cfg, + GNUNET_RESOLVER_hostname_get (plugin->env->cfg, sb, sbs, !numeric, timeout, &append_port, ppc); @@ -1812,8 +1809,7 @@ delayed_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_SERVER_receive_done (session->client, GNUNET_OK); else session->receive_delay_task = - GNUNET_SCHEDULER_add_delayed (session->plugin->env->sched, - delay, &delayed_done, session); + GNUNET_SCHEDULER_add_delayed (delay, &delayed_done, session); } @@ -1866,8 +1862,7 @@ handle_tcp_data (void *cls, GNUNET_SERVER_receive_done (client, GNUNET_OK); else session->receive_delay_task = - GNUNET_SCHEDULER_add_delayed (session->plugin->env->sched, - delay, &delayed_done, session); + GNUNET_SCHEDULER_add_delayed (delay, &delayed_done, session); } @@ -2115,8 +2110,7 @@ tcp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc else { plugin->server_read_task = - GNUNET_SCHEDULER_add_read_file (plugin->env->sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, plugin->server_stdout_handle, &tcp_plugin_server_read, plugin); return; } @@ -2134,8 +2128,7 @@ tcp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc _("nat-server-read malformed address\n"), &mybuf, port); plugin->server_read_task = - GNUNET_SCHEDULER_add_read_file (plugin->env->sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, plugin->server_stdout_handle, &tcp_plugin_server_read, plugin); return; } @@ -2146,15 +2139,14 @@ tcp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc * We have received an ICMP response, ostensibly from a non-NAT'd peer * that wants to connect to us! Send a message to establish a connection. */ - sock = GNUNET_CONNECTION_create_from_sockaddr (plugin->env->sched, AF_INET, (struct sockaddr *)&in_addr, + sock = GNUNET_CONNECTION_create_from_sockaddr (AF_INET, (struct sockaddr *)&in_addr, sizeof(in_addr)); if (sock == NULL) { plugin->server_read_task = - GNUNET_SCHEDULER_add_read_file (plugin->env->sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, plugin->server_stdout_handle, &tcp_plugin_server_read, plugin); return; } @@ -2178,8 +2170,7 @@ tcp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc /*GNUNET_SERVER_connect_socket(plugin->server, sock);*/ plugin->server_read_task = - GNUNET_SCHEDULER_add_read_file (plugin->env->sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, plugin->server_stdout_handle, &tcp_plugin_server_read, plugin); } @@ -2217,8 +2208,7 @@ tcp_transport_start_nat_server(struct Plugin *plugin) plugin->server_stdout_handle = GNUNET_DISK_pipe_handle(plugin->server_stdout, GNUNET_DISK_PIPE_END_READ); plugin->server_read_task = - GNUNET_SCHEDULER_add_read_file (plugin->env->sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, plugin->server_stdout_handle, &tcp_plugin_server_read, plugin); return GNUNET_YES; } @@ -2363,7 +2353,7 @@ libgnunet_plugin_transport_tcp_init (void *cls) struct sockaddr_in in_addr; struct IPv4TcpAddress t4; - service = GNUNET_SERVICE_start ("transport-tcp", env->sched, env->cfg); + service = GNUNET_SERVICE_start ("transport-tcp", env->cfg); if (service == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -2545,8 +2535,7 @@ libgnunet_plugin_transport_tcp_init (void *cls) GNUNET_OS_network_interfaces_list (&process_interfaces, plugin); } - plugin->hostname_dns = GNUNET_RESOLVER_hostname_resolve (env->sched, - env->cfg, + plugin->hostname_dns = GNUNET_RESOLVER_hostname_resolve (env->cfg, AF_UNSPEC, HOSTNAME_RESOLVE_TIMEOUT, &process_hostname_ips, diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 4bd8c36d3..5c3682e2a 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -513,7 +513,7 @@ udp_transport_server_stop (void *cls) if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (plugin->env->sched, plugin->select_task); + GNUNET_SCHEDULER_cancel (plugin->select_task); plugin->select_task = GNUNET_SCHEDULER_NO_TASK; } if (plugin->udp_sockv4.desc != NULL) @@ -1107,7 +1107,7 @@ void udp_probe_continuation (void *cls, const struct GNUNET_PeerIdentity *target, int result) { struct UDP_NAT_Probes *probe = cls; - struct Plugin *plugin = probe->plugin; + /*struct Plugin *plugin = probe->plugin;*/ if ((result == GNUNET_OK) && (probe->count < MAX_PROBES)) { @@ -1115,7 +1115,7 @@ udp_probe_continuation (void *cls, const struct GNUNET_PeerIdentity *target, int GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Scheduling next probe for 10000 milliseconds\n")); #endif - probe->task = GNUNET_SCHEDULER_add_delayed(plugin->env->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 10000), &send_udp_probe_message, probe); + probe->task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 10000), &send_udp_probe_message, probe); } else /* Destroy the probe context. */ { @@ -1200,8 +1200,7 @@ udp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc else { plugin->server_read_task = - GNUNET_SCHEDULER_add_read_file (plugin->env->sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, plugin->server_stdout_handle, &udp_plugin_server_read, plugin); return; } @@ -1222,8 +1221,7 @@ udp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc _("nat-server-read malformed address\n"), &mybuf, port); plugin->server_read_task = - GNUNET_SCHEDULER_add_read_file (plugin->env->sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, plugin->server_stdout_handle, &udp_plugin_server_read, plugin); return; } @@ -1238,13 +1236,12 @@ udp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc temp_probe->addr.u_port = htons(port); temp_probe->next = plugin->probes; temp_probe->plugin = plugin; - temp_probe->task = GNUNET_SCHEDULER_add_delayed(plugin->env->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 500), &send_udp_probe_message, temp_probe); + temp_probe->task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 500), &send_udp_probe_message, temp_probe); plugin->probes = temp_probe; } plugin->server_read_task = - GNUNET_SCHEDULER_add_read_file (plugin->env->sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, plugin->server_stdout_handle, &udp_plugin_server_read, plugin); } @@ -1358,7 +1355,7 @@ udp_demultiplexer(struct Plugin *plugin, struct GNUNET_PeerIdentity *sender, if (outgoing_probe->task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(plugin->env->sched, outgoing_probe->task); + GNUNET_SCHEDULER_cancel(outgoing_probe->task); outgoing_probe->task = GNUNET_SCHEDULER_NO_TASK; /* Schedule task to timeout and remove probe if confirmation not received */ } @@ -1569,8 +1566,7 @@ udp_plugin_select (void *cls, { GNUNET_break_op (0); plugin->select_task = - GNUNET_SCHEDULER_add_select (plugin->env->sched, - GNUNET_SCHEDULER_PRIORITY_DEFAULT, + GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, NULL, &udp_plugin_select, plugin); @@ -1581,8 +1577,7 @@ udp_plugin_select (void *cls, { GNUNET_break_op (0); plugin->select_task = - GNUNET_SCHEDULER_add_select (plugin->env->sched, - GNUNET_SCHEDULER_PRIORITY_DEFAULT, + GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, NULL, &udp_plugin_select, plugin); @@ -1601,8 +1596,7 @@ udp_plugin_select (void *cls, count++; } plugin->select_task = - GNUNET_SCHEDULER_add_select (plugin->env->sched, - GNUNET_SCHEDULER_PRIORITY_DEFAULT, + GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, NULL, &udp_plugin_select, plugin); @@ -1659,8 +1653,7 @@ udp_transport_server_start (void *cls) plugin->server_stdout_handle = GNUNET_DISK_pipe_handle(plugin->server_stdout, GNUNET_DISK_PIPE_END_READ); plugin->server_read_task = - GNUNET_SCHEDULER_add_read_file (plugin->env->sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, plugin->server_stdout_handle, &udp_plugin_server_read, plugin); } @@ -1783,8 +1776,7 @@ udp_transport_server_start (void *cls) plugin->udp_sockv6.desc); plugin->select_task = - GNUNET_SCHEDULER_add_select (plugin->env->sched, - GNUNET_SCHEDULER_PRIORITY_DEFAULT, + GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, NULL, &udp_plugin_select, plugin); @@ -1992,8 +1984,7 @@ udp_plugin_address_pretty_printer (void *cls, ppc->asc = asc; ppc->asc_cls = asc_cls; ppc->port = port; - GNUNET_RESOLVER_hostname_get (plugin->env->sched, - plugin->env->cfg, + GNUNET_RESOLVER_hostname_get (plugin->env->cfg, sb, sbs, !numeric, timeout, &append_port, ppc); @@ -2167,7 +2158,7 @@ libgnunet_plugin_transport_udp_init (void *cls) char *external_address; struct IPv4UdpAddress v4_address; - service = GNUNET_SERVICE_start ("transport-udp", env->sched, env->cfg); + service = GNUNET_SERVICE_start ("transport-udp", env->cfg); if (service == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ @@ -2308,8 +2299,7 @@ libgnunet_plugin_transport_udp_init (void *cls) GNUNET_OS_network_interfaces_list (&process_interfaces, plugin); } - plugin->hostname_dns = GNUNET_RESOLVER_hostname_resolve (env->sched, - env->cfg, + plugin->hostname_dns = GNUNET_RESOLVER_hostname_resolve (env->cfg, AF_UNSPEC, HOSTNAME_RESOLVE_TIMEOUT, &process_hostname_ips, diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index 0f95f48c7..41f2958a2 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c @@ -682,8 +682,7 @@ do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } else { //nothing to send at the moment plugin->server_read_task = - GNUNET_SCHEDULER_add_delayed (plugin->env->sched, - GNUNET_TIME_absolute_get_remaining(nextsend), + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining(nextsend), &do_transmit, plugin); } @@ -804,8 +803,7 @@ do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } //plugin->server_read_task = - //GNUNET_SCHEDULER_add_read_file (plugin->env->sched, - // GNUNET_TIME_UNIT_FOREVER_REL, + //GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, // plugin->server_stdout_handle, &wlan_plugin_helper_read, plugin); } @@ -837,8 +835,7 @@ process_pending_messages (struct Plugin * plugin) // GNUNET_TIME_UNIT_FOREVER_REL is needed to clean up old msg plugin->server_write_task - = GNUNET_SCHEDULER_add_write_file(plugin->env->sched, - GNUNET_TIME_UNIT_FOREVER_REL, + = GNUNET_SCHEDULER_add_write_file(GNUNET_TIME_UNIT_FOREVER_REL, plugin->server_stdin_handle, &do_transmit, plugin); @@ -1264,8 +1261,7 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin) plugin->server_stdin_handle = GNUNET_DISK_pipe_handle(plugin->server_stdin, GNUNET_DISK_PIPE_END_WRITE); plugin->server_read_task = - GNUNET_SCHEDULER_add_read_file (plugin->env->sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, plugin->server_stdout_handle, &wlan_plugin_helper_read, plugin); return GNUNET_YES; } @@ -1288,7 +1284,7 @@ gnunet_plugin_transport_wlan_init (void *cls) GNUNET_assert(cls !=NULL); - service = GNUNET_SERVICE_start ("transport-wlan", env->sched, env->cfg); + service = GNUNET_SERVICE_start ("transport-wlan", env->cfg); if (service == NULL){ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to start service for `%s' transport plugin.\n"), diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c index 398dcf92b..11e00b80e 100644 --- a/src/transport/test_plugin_transport.c +++ b/src/transport/test_plugin_transport.c @@ -59,11 +59,6 @@ static struct GNUNET_PeerIdentity my_identity; */ static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key; -/** - * Our scheduler. - */ -struct GNUNET_SCHEDULER_Handle *sched; - /** * Our configuration. */ @@ -168,8 +163,7 @@ test_validation () api->check_address (api->cls, &soaddr, sizeof (soaddr))); ok = 0; - GNUNET_SCHEDULER_add_continuation (sched, - &unload_task, + GNUNET_SCHEDULER_add_continuation (&unload_task, (void *) cfg, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -179,7 +173,6 @@ static void setup_plugin_environment () { env.cfg = cfg; - env.sched = sched; env.my_identity = &my_identity; env.cls = &env; env.receive = &receive; @@ -192,12 +185,10 @@ setup_plugin_environment () * Runs the test. * * @param cls closure - * @param s scheduler to use * @param c configuration to use */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { @@ -205,7 +196,6 @@ run (void *cls, char *keyfile; char *libname; - sched = s; cfg = c; /* parse configuration */ if ((GNUNET_OK != diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c index a178f16a0..7da64e295 100644 --- a/src/transport/test_plugin_transport_http.c +++ b/src/transport/test_plugin_transport_http.c @@ -231,11 +231,6 @@ static long long unsigned int port; */ static char * test_addr; -/** - * Our scheduler. - */ -struct GNUNET_SCHEDULER_Handle *sched; - /** * Our statistics handle. */ @@ -446,19 +441,19 @@ shutdown_clean () if (ti_send != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(sched,ti_send); + GNUNET_SCHEDULER_cancel(ti_send); ti_send = GNUNET_SCHEDULER_NO_TASK; } if (http_task_send != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(sched,http_task_send); + GNUNET_SCHEDULER_cancel(http_task_send); http_task_send = GNUNET_SCHEDULER_NO_TASK; } if (ti_timeout != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(sched,ti_timeout); + GNUNET_SCHEDULER_cancel(ti_timeout); ti_timeout = GNUNET_SCHEDULER_NO_TASK; } @@ -466,7 +461,7 @@ shutdown_clean () GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unloading http plugin\n"); GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_plugin_transport_http", api)); - GNUNET_SCHEDULER_shutdown(sched); + GNUNET_SCHEDULER_shutdown(); GNUNET_DISK_directory_remove ("/tmp/test_plugin_transport_http"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Exiting testcase\n"); @@ -781,8 +776,7 @@ static size_t send_prepare( struct HTTP_Transfer * result) gws = GNUNET_NETWORK_fdset_create (); GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1); GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1); - http_task_send = GNUNET_SCHEDULER_add_select (sched, - GNUNET_SCHEDULER_PRIORITY_DEFAULT, + http_task_send = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 0), grs, @@ -907,7 +901,6 @@ static void setup_plugin_environment () { env.cfg = cfg; - env.sched = sched; env.stats = stats; env.my_identity = &my_identity; env.cls = &env; @@ -1123,17 +1116,14 @@ static void run_connection_tests( int phase , void * cls) * Runs the test. * * @param cls closure - * @param s scheduler to use * @param c configuration to use */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { char * libname; - sched = s; cfg = c; char *keyfile; unsigned long long tneigh; @@ -1223,7 +1213,7 @@ run (void *cls, } - ti_timeout = GNUNET_SCHEDULER_add_delayed (sched, TEST_TIMEOUT, &task_timeout, NULL); + ti_timeout = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &task_timeout, NULL); /* testing plugin functionality */ GNUNET_assert (0!=fail_notify_address_count); diff --git a/src/transport/test_plugin_transport_https.c b/src/transport/test_plugin_transport_https.c index 192ca764d..0ca13ad5c 100644 --- a/src/transport/test_plugin_transport_https.c +++ b/src/transport/test_plugin_transport_https.c @@ -230,11 +230,6 @@ static long long unsigned int port; */ static char * test_addr; -/** - * Our scheduler. - */ -struct GNUNET_SCHEDULER_Handle *sched; - /** * Our statistics handle. */ @@ -449,19 +444,19 @@ shutdown_clean () if (ti_send != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(sched,ti_send); + GNUNET_SCHEDULER_cancel(ti_send); ti_send = GNUNET_SCHEDULER_NO_TASK; } if (http_task_send != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(sched,http_task_send); + GNUNET_SCHEDULER_cancel(http_task_send); http_task_send = GNUNET_SCHEDULER_NO_TASK; } if (ti_timeout != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel(sched,ti_timeout); + GNUNET_SCHEDULER_cancel(ti_timeout); ti_timeout = GNUNET_SCHEDULER_NO_TASK; } @@ -469,7 +464,7 @@ shutdown_clean () GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unloading https plugin\n"); GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_plugin_transport_https", api)); - GNUNET_SCHEDULER_shutdown(sched); + GNUNET_SCHEDULER_shutdown(); GNUNET_DISK_directory_remove ("/tmp/test_plugin_transport_http"); struct stat sbuf; @@ -804,8 +799,7 @@ static size_t send_prepare( struct HTTP_Transfer * result) gws = GNUNET_NETWORK_fdset_create (); GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1); GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1); - http_task_send = GNUNET_SCHEDULER_add_select (sched, - GNUNET_SCHEDULER_PRIORITY_DEFAULT, + http_task_send = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 0), grs, @@ -933,7 +927,6 @@ static void setup_plugin_environment () { env.cfg = cfg; - env.sched = sched; env.stats = stats; env.my_identity = &my_identity; env.cls = &env; @@ -1149,17 +1142,14 @@ static void run_connection_tests( int phase , void * cls) * Runs the test. * * @param cls closure - * @param s scheduler to use * @param c configuration to use */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { char * libname; - sched = s; cfg = c; char *keyfile; unsigned long long tneigh; @@ -1288,7 +1278,7 @@ run (void *cls, return; } - ti_timeout = GNUNET_SCHEDULER_add_delayed (sched, TEST_TIMEOUT, &task_timeout, NULL); + ti_timeout = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &task_timeout, NULL); /* testing plugin functionality */ GNUNET_assert (0!=fail_notify_address_count); diff --git a/src/transport/test_plugin_transport_udp.c b/src/transport/test_plugin_transport_udp.c index aaa6c18d3..f297a05c1 100644 --- a/src/transport/test_plugin_transport_udp.c +++ b/src/transport/test_plugin_transport_udp.c @@ -60,11 +60,6 @@ static struct GNUNET_PeerIdentity my_identity; */ static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key; -/** - * Our scheduler. - */ -struct GNUNET_SCHEDULER_Handle *sched; - /** * Our configuration. */ @@ -162,7 +157,6 @@ static void setup_plugin_environment () { env.cfg = cfg; - env.sched = sched; env.my_identity = &my_identity; env.cls = &env; env.receive = &receive; @@ -174,12 +168,10 @@ setup_plugin_environment () * Runs the test. * * @param cls closure - * @param s scheduler to use * @param c configuration to use */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { @@ -187,7 +179,6 @@ run (void *cls, char *keyfile; char *libname; - sched = s; cfg = c; /* parse configuration */ if ((GNUNET_OK != diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index 77279897d..041bd0968 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c @@ -121,8 +121,6 @@ static struct PeerContext p1; static struct PeerContext p2; -static struct GNUNET_SCHEDULER_Handle *sched; - static int ok; static int connected; @@ -165,20 +163,20 @@ end_send () static void end () { - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); die_task = GNUNET_SCHEDULER_NO_TASK; if (measurement_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, measurement_task); + GNUNET_SCHEDULER_cancel (measurement_task); measurement_task = GNUNET_SCHEDULER_NO_TASK; } if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, measurement_counter_task); + GNUNET_SCHEDULER_cancel (measurement_counter_task); measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; } - GNUNET_SCHEDULER_shutdown (sched); + GNUNET_SCHEDULER_shutdown (); #if DEBUG_CONNECTIONS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); #endif @@ -188,7 +186,7 @@ end () GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transports disconnected, returning success!\n"); #endif - GNUNET_SCHEDULER_shutdown (sched); + GNUNET_SCHEDULER_shutdown (); } @@ -213,12 +211,12 @@ end_badly (void *cls, { if (measurement_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, measurement_task); + GNUNET_SCHEDULER_cancel (measurement_task); measurement_task = GNUNET_SCHEDULER_NO_TASK; } if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, measurement_counter_task); + GNUNET_SCHEDULER_cancel (measurement_counter_task); measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; } GNUNET_break (0); @@ -355,8 +353,7 @@ static void measurement_counter #if VERBOSE fprintf(stderr,"."); #endif - measurement_counter_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_SECONDS, + measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &measurement_counter, NULL); } @@ -379,7 +376,7 @@ measurement_end (void *cls, if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sched, measurement_counter_task); + GNUNET_SCHEDULER_cancel (measurement_counter_task); measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; } #if VERBOSE @@ -498,19 +495,16 @@ static void measure (unsigned long long quota_p1, unsigned long long quota_p2 ) GNUNET_TIME_UNIT_FOREVER_REL, NULL, NULL); - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sched, measurement_counter_task); - measurement_counter_task = GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_SECONDS, + GNUNET_SCHEDULER_cancel (measurement_counter_task); + measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &measurement_counter, NULL); - measurement_task = GNUNET_SCHEDULER_add_delayed (sched, - MEASUREMENT_INTERVALL, + measurement_task = GNUNET_SCHEDULER_add_delayed (MEASUREMENT_INTERVALL, &measurement_end, NULL); total_bytes_sent = 0; @@ -588,7 +582,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); - p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, + p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, ¬ify_receive_new, ¬ify_connect, @@ -634,16 +628,13 @@ exchange_hello (void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; - sched = s; - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); measurement_running = GNUNET_NO; diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c index cee1da25b..e429ad7a7 100644 --- a/src/transport/test_transport_api.c +++ b/src/transport/test_transport_api.c @@ -68,8 +68,6 @@ static struct PeerContext p1; static struct PeerContext p2; -static struct GNUNET_SCHEDULER_Handle *sched; - static int ok; static int is_tcp; @@ -104,7 +102,7 @@ end () { /* do work here */ GNUNET_assert (ok == 6); - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); GNUNET_TRANSPORT_disconnect (p1.th); GNUNET_TRANSPORT_disconnect (p2.th); @@ -193,9 +191,8 @@ notify_connect (void *cls, { if (cls == &p1) { - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT_TRANSMIT, + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT, &end_badly, NULL); GNUNET_TRANSPORT_notify_transmit_ready (p1.th, @@ -288,7 +285,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) } } - p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, + p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, ¬ify_receive, ¬ify_connect, ¬ify_disconnect); @@ -341,15 +338,12 @@ exchange_hello (void *cls, static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; - sched = s; - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); if (is_udp) diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c index a8633e089..ce031af7f 100644 --- a/src/transport/test_transport_api_reliability.c +++ b/src/transport/test_transport_api_reliability.c @@ -70,8 +70,6 @@ static struct PeerContext p1; static struct PeerContext p2; -static struct GNUNET_SCHEDULER_Handle *sched; - static int ok; static int is_tcp; @@ -116,7 +114,7 @@ end () { unsigned long long delta; - GNUNET_SCHEDULER_cancel (sched, die_task); + GNUNET_SCHEDULER_cancel (die_task); die_task = GNUNET_SCHEDULER_NO_TASK; #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); @@ -208,8 +206,8 @@ notify_receive (void *cls, n, s, ntohs (message->size), ntohl (hdr->num)); - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL); + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); return; } if (ntohl (hdr->num) != n) @@ -219,8 +217,8 @@ notify_receive (void *cls, n, s, ntohs (message->size), ntohl (hdr->num)); - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL); + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); return; } memset (cbuf, n, s - sizeof (struct TestMessage)); @@ -231,8 +229,8 @@ notify_receive (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Expected message %u with bits %u, but body did not match\n", n, (unsigned char) n); - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL); + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); return; } #if VERBOSE @@ -248,9 +246,8 @@ notify_receive (void *cls, if (0 == (n % (TOTAL_MSGS/100))) { fprintf (stderr, "."); - GNUNET_SCHEDULER_cancel (sched, die_task); - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); } @@ -450,7 +447,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) } } - p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, + p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, ¬ify_receive, ¬ify_connect, @@ -622,15 +619,12 @@ check_gnunet_nat_binary(char *binary) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; - sched = s; - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TIMEOUT, + die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); if (is_tcp) diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index c0f32f93d..6fb35b5d6 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c @@ -326,11 +326,6 @@ struct GNUNET_TRANSPORT_Handle */ struct HelloWaitList *hwl_head; - /** - * My scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * My configuration. */ @@ -444,8 +439,7 @@ schedule_peer_transmission (struct GNUNET_TRANSPORT_Handle *h) if (h->quota_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (h->sched, - h->quota_task); + GNUNET_SCHEDULER_cancel (h->quota_task); h->quota_task = GNUNET_SCHEDULER_NO_TASK; } retry_time = GNUNET_TIME_UNIT_FOREVER_REL; @@ -476,7 +470,7 @@ schedule_peer_transmission (struct GNUNET_TRANSPORT_Handle *h) #endif if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); + GNUNET_SCHEDULER_cancel (th->notify_delay_task); th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; } n->transmit_stage = TS_NEW; @@ -510,8 +504,7 @@ schedule_peer_transmission (struct GNUNET_TRANSPORT_Handle *h) ret = th; } if (ret == NULL) - h->quota_task = GNUNET_SCHEDULER_add_delayed (h->sched, - retry_time, + h->quota_task = GNUNET_SCHEDULER_add_delayed (retry_time, "a_transmit_ready, h); return ret; @@ -556,7 +549,7 @@ transport_notify_ready (void *cls, size_t size, void *buf) { if (cm->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (h->sched, cm->notify_delay_task); + GNUNET_SCHEDULER_cancel (cm->notify_delay_task); cm->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; } GNUNET_CONTAINER_DLL_remove (h->control_head, @@ -578,7 +571,7 @@ transport_notify_ready (void *cls, size_t size, void *buf) { if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); + GNUNET_SCHEDULER_cancel (th->notify_delay_task); th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; } n = th->neighbour; @@ -763,8 +756,7 @@ schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h, th->notify_cls = notify_cls; th->notify_size = size; th->notify_delay_task - = GNUNET_SCHEDULER_add_delayed (h->sched, - timeout, &control_transmit_timeout, th); + = GNUNET_SCHEDULER_add_delayed (timeout, &control_transmit_timeout, th); if (at_head) GNUNET_CONTAINER_DLL_insert (h->control_head, h->control_tail, @@ -810,8 +802,7 @@ send_set_quota (void *cls, size_t size, void *buf) if (buf == NULL) { - GNUNET_SCHEDULER_add_continuation (sqc->handle->sched, - sqc->cont, + GNUNET_SCHEDULER_add_continuation (sqc->cont, sqc->cont_cls, GNUNET_SCHEDULER_REASON_TIMEOUT); GNUNET_free (sqc); @@ -830,8 +821,7 @@ send_set_quota (void *cls, size_t size, void *buf) msg->quota = sqc->quota_in; memcpy (&msg->peer, &sqc->target, sizeof (struct GNUNET_PeerIdentity)); if (sqc->cont != NULL) - GNUNET_SCHEDULER_add_continuation (sqc->handle->sched, - sqc->cont, + GNUNET_SCHEDULER_add_continuation (sqc->cont, sqc->cont_cls, GNUNET_SCHEDULER_REASON_PREREQ_DONE); GNUNET_free (sqc); @@ -1192,7 +1182,7 @@ reconnect (void *cls, "Connecting to transport service.\n"); #endif GNUNET_assert (h->client == NULL); - h->client = GNUNET_CLIENT_connect (h->sched, "transport", h->cfg); + h->client = GNUNET_CLIENT_connect ("transport", h->cfg); GNUNET_assert (h->client != NULL); /* make sure we don't send "START" twice, remove existing entry from queue (if present) */ @@ -1206,7 +1196,7 @@ reconnect (void *cls, pos); if (GNUNET_SCHEDULER_NO_TASK != pos->notify_delay_task) { - GNUNET_SCHEDULER_cancel (h->sched, pos->notify_delay_task); + GNUNET_SCHEDULER_cancel (pos->notify_delay_task); pos->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; } GNUNET_free (pos); @@ -1240,8 +1230,7 @@ schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h) GNUNET_assert (h->client == NULL); GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK); h->reconnect_task - = GNUNET_SCHEDULER_add_delayed (h->sched, - h->reconnect_delay, &reconnect, h); + = GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); if (h->reconnect_delay.rel_value == 0) { h->reconnect_delay = GNUNET_TIME_UNIT_MILLISECONDS; @@ -1353,7 +1342,6 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h, * Connect to the transport service. Note that the connection may * complete (or fail) asynchronously. * - * @param sched scheduler to use * @param cfg configuration to use * @param self our own identity (API should check that it matches * the identity found by transport), or NULL (no check) @@ -1363,8 +1351,7 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h, * @param nd function to call on disconnect events */ struct GNUNET_TRANSPORT_Handle * -GNUNET_TRANSPORT_connect (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *self, void *cls, GNUNET_TRANSPORT_ReceiveCallback rec, @@ -1379,7 +1366,6 @@ GNUNET_TRANSPORT_connect (struct GNUNET_SCHEDULER_Handle *sched, ret->self = *self; ret->check_self = GNUNET_YES; } - ret->sched = sched; ret->cfg = cfg; ret->cls = cls; ret->rec = rec; @@ -1421,8 +1407,7 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) th = &n->transmit_handle; if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (handle->sched, - th->notify_delay_task); + GNUNET_SCHEDULER_cancel (th->notify_delay_task); th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; } GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); @@ -1454,7 +1439,7 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) #endif if (cm->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (handle->sched, cm->notify_delay_task); + GNUNET_SCHEDULER_cancel (cm->notify_delay_task); cm->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; } GNUNET_CONTAINER_DLL_remove (handle->control_head, @@ -1466,12 +1451,12 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) if (handle->reconnect_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (handle->sched, handle->reconnect_task); + GNUNET_SCHEDULER_cancel (handle->reconnect_task); handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK; } if (handle->quota_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (handle->sched, handle->quota_task); + GNUNET_SCHEDULER_cancel (handle->quota_task); handle->quota_task = GNUNET_SCHEDULER_NO_TASK; } GNUNET_free_non_null (handle->my_hello); @@ -1857,7 +1842,7 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle th->notify_size = size + sizeof (struct OutboundMessage); th->priority = priority; th->notify_delay_task - = GNUNET_SCHEDULER_add_delayed (handle->sched, timeout, + = GNUNET_SCHEDULER_add_delayed (timeout, &peer_transmit_timeout, th); schedule_transmission (handle); return th; @@ -1902,8 +1887,7 @@ GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct } if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (n->h->sched, - th->notify_delay_task); + GNUNET_SCHEDULER_cancel (th->notify_delay_task); th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; } } diff --git a/src/transport/transport_api_address_lookup.c b/src/transport/transport_api_address_lookup.c index cb15f0565..022d5f03b 100644 --- a/src/transport/transport_api_address_lookup.c +++ b/src/transport/transport_api_address_lookup.c @@ -108,7 +108,6 @@ address_response_processor (void *cls, /** * Convert a binary address into a human readable address. * - * @param sched scheduler to use * @param cfg configuration to use * @param address address to convert (binary format) * @param addressLen number of bytes in address @@ -120,8 +119,7 @@ address_response_processor (void *cls, * @param aluc_cls closure for aluc */ void -GNUNET_TRANSPORT_address_lookup (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *address, size_t addressLen, int numeric, @@ -146,7 +144,7 @@ GNUNET_TRANSPORT_address_lookup (struct GNUNET_SCHEDULER_Handle *sched, aluc (aluc_cls, NULL); return; } - client = GNUNET_CLIENT_connect (sched, "transport", cfg); + client = GNUNET_CLIENT_connect ("transport", cfg); if (client == NULL) { aluc (aluc_cls, NULL); diff --git a/src/transport/transport_api_blacklist.c b/src/transport/transport_api_blacklist.c index 1025edef4..2315b515f 100644 --- a/src/transport/transport_api_blacklist.c +++ b/src/transport/transport_api_blacklist.c @@ -44,11 +44,6 @@ struct GNUNET_TRANSPORT_Blacklist */ struct GNUNET_CLIENT_Connection * client; - /** - * Scheduler to use. - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * Configuration to use. */ @@ -175,8 +170,7 @@ reconnect (struct GNUNET_TRANSPORT_Blacklist *br) { if (br->client != NULL) GNUNET_CLIENT_disconnect (br->client, GNUNET_NO); - br->client = GNUNET_CLIENT_connect (br->sched, - "transport", + br->client = GNUNET_CLIENT_connect ("transport", br->cfg); GNUNET_assert (br->client != NULL); br->th = GNUNET_CLIENT_notify_transmit_ready (br->client, @@ -249,27 +243,24 @@ reply (struct GNUNET_TRANSPORT_Blacklist *br) * only way to re-enable connections from peers that were previously * blacklisted. * - * @param sched scheduler to use * @param cfg configuration to use * @param cb callback to invoke to check if connections are allowed * @param cb_cls closure for cb * @return NULL on error, otherwise handle for cancellation */ struct GNUNET_TRANSPORT_Blacklist * -GNUNET_TRANSPORT_blacklist (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_TRANSPORT_BlacklistCallback cb, void *cb_cls) { struct GNUNET_CLIENT_Connection * client; struct GNUNET_TRANSPORT_Blacklist *ret; - client = GNUNET_CLIENT_connect (sched, "transport", cfg); + client = GNUNET_CLIENT_connect ("transport", cfg); if (NULL == client) return NULL; ret = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_Blacklist)); ret->client = client; - ret->sched = sched; ret->cfg = cfg; ret->th = GNUNET_CLIENT_notify_transmit_ready (client, sizeof (struct GNUNET_MessageHeader), diff --git a/src/util/client.c b/src/util/client.c index 13c4062a5..171e9e957 100644 --- a/src/util/client.c +++ b/src/util/client.c @@ -150,11 +150,6 @@ struct GNUNET_CLIENT_Connection */ struct GNUNET_CONNECTION_Handle *sock; - /** - * Our scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * Our configuration. * FIXME: why do we DUP the configuration? Avoid this! @@ -262,15 +257,13 @@ struct GNUNET_CLIENT_Connection /** * Try to connect to the service. * - * @param sched scheduler to use * @param service_name name of service to connect to * @param cfg configuration to use * @param attempt counter used to alternate between IP and UNIX domain sockets * @return NULL on error */ static struct GNUNET_CONNECTION_Handle * -do_connect (struct GNUNET_SCHEDULER_Handle *sched, - const char *service_name, +do_connect (const char *service_name, const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int attempt) { @@ -288,8 +281,7 @@ do_connect (struct GNUNET_SCHEDULER_Handle *sched, service_name, "UNIXPATH", &unixpath)) { - sock = GNUNET_CONNECTION_create_from_connect_to_unixpath (sched, - cfg, + sock = GNUNET_CONNECTION_create_from_connect_to_unixpath (cfg, unixpath); GNUNET_free (unixpath); if (sock != NULL) @@ -323,8 +315,7 @@ do_connect (struct GNUNET_SCHEDULER_Handle *sched, service_name); return NULL; } - sock = GNUNET_CONNECTION_create_from_connect (sched, - cfg, + sock = GNUNET_CONNECTION_create_from_connect (cfg, hostname, port); GNUNET_free (hostname); @@ -335,28 +326,24 @@ do_connect (struct GNUNET_SCHEDULER_Handle *sched, /** * Get a connection with a service. * - * @param sched scheduler to use * @param service_name name of the service * @param cfg configuration to use * @return NULL on error (service unknown to configuration) */ struct GNUNET_CLIENT_Connection * -GNUNET_CLIENT_connect (struct GNUNET_SCHEDULER_Handle *sched, - const char *service_name, +GNUNET_CLIENT_connect (const char *service_name, const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_CLIENT_Connection *ret; struct GNUNET_CONNECTION_Handle *sock; - sock = do_connect (sched, - service_name, + sock = do_connect (service_name, cfg, 0); if (sock == NULL) return NULL; ret = GNUNET_malloc (sizeof (struct GNUNET_CLIENT_Connection)); ret->attempts = 1; ret->sock = sock; - ret->sched = sched; ret->service_name = GNUNET_strdup (service_name); ret->cfg = GNUNET_CONFIGURATION_dup (cfg); ret->back_off = GNUNET_TIME_UNIT_MILLISECONDS; @@ -418,7 +405,7 @@ GNUNET_CLIENT_disconnect (struct GNUNET_CLIENT_Connection *sock, GNUNET_CLIENT_notify_transmit_ready_cancel (sock->th); if (sock->receive_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sock->sched, sock->receive_task); + GNUNET_SCHEDULER_cancel (sock->receive_task); sock->receive_task = GNUNET_SCHEDULER_NO_TASK; } GNUNET_array_grow (sock->received_buf, sock->received_size, 0); @@ -569,8 +556,7 @@ GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock, sock->receive_timeout = GNUNET_TIME_relative_to_absolute (timeout); if (GNUNET_YES == sock->msg_complete) { - sock->receive_task = GNUNET_SCHEDULER_add_after (sock->sched, - GNUNET_SCHEDULER_NO_TASK, + sock->receive_task = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, &receive_task, sock); } else @@ -588,11 +574,9 @@ GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock, * Report service unavailable. */ static void -service_test_error (struct GNUNET_SCHEDULER_Handle *s, - GNUNET_SCHEDULER_Task task, void *task_cls) +service_test_error (GNUNET_SCHEDULER_Task task, void *task_cls) { - GNUNET_SCHEDULER_add_continuation (s, - task, + GNUNET_SCHEDULER_add_continuation (task, task_cls, GNUNET_SCHEDULER_REASON_TIMEOUT); } @@ -617,14 +601,13 @@ confirm_handler (void *cls, const struct GNUNET_MessageHeader *msg) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received confirmation that service is running.\n"); #endif - GNUNET_SCHEDULER_add_continuation (conn->sched, - conn->test_cb, + GNUNET_SCHEDULER_add_continuation (conn->test_cb, conn->test_cb_cls, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } else { - service_test_error (conn->sched, conn->test_cb, conn->test_cb_cls); + service_test_error (conn->test_cb, conn->test_cb_cls); } GNUNET_CLIENT_disconnect (conn, GNUNET_NO); } @@ -642,7 +625,7 @@ write_test (void *cls, size_t size, void *buf) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Failure to transmit TEST request.\n")); #endif - service_test_error (conn->sched, conn->test_cb, conn->test_cb_cls); + service_test_error (conn->test_cb, conn->test_cb_cls); GNUNET_CLIENT_disconnect (conn, GNUNET_NO); return 0; /* client disconnected */ } @@ -664,7 +647,6 @@ write_test (void *cls, size_t size, void *buf) /** * Wait until the service is running. * - * @param sched scheduler to use * @param service name of the service to wait for * @param cfg configuration to use * @param timeout how long to wait at most in ms @@ -674,8 +656,7 @@ write_test (void *cls, size_t size, void *buf) * @param task_cls closure for task */ void -GNUNET_CLIENT_service_test (struct GNUNET_SCHEDULER_Handle *sched, - const char *service, +GNUNET_CLIENT_service_test (const char *service, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TIME_Relative timeout, GNUNET_SCHEDULER_Task task, void *task_cls) @@ -686,14 +667,14 @@ GNUNET_CLIENT_service_test (struct GNUNET_SCHEDULER_Handle *sched, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing if service `%s' is running.\n", service); #endif - conn = GNUNET_CLIENT_connect (sched, service, cfg); + conn = GNUNET_CLIENT_connect (service, cfg); if (conn == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Could not connect to service `%s', must not be running.\n"), service); - service_test_error (sched, task, task_cls); + service_test_error (task, task_cls); return; } conn->test_cb = task; @@ -709,7 +690,7 @@ GNUNET_CLIENT_service_test (struct GNUNET_SCHEDULER_Handle *sched, GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failure to transmit request to service `%s'\n"), service); - service_test_error (sched, task, task_cls); + service_test_error (task, task_cls); GNUNET_CLIENT_disconnect (conn, GNUNET_NO); return; } @@ -791,7 +772,7 @@ client_notify (void *cls, size_t size, void *buf) { delay = GNUNET_TIME_absolute_get_remaining (th->timeout); delay.rel_value /= 2; - if ( (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & GNUNET_SCHEDULER_get_reason (th->sock->sched))) || + if ( (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & GNUNET_SCHEDULER_get_reason ())) || (GNUNET_YES != th->auto_retry) || (0 == --th->attempts_left) || (delay.rel_value < 1) ) @@ -807,8 +788,7 @@ client_notify (void *cls, size_t size, void *buf) } /* auto-retry */ GNUNET_CONNECTION_destroy (th->sock->sock, GNUNET_NO); - th->sock->sock = do_connect (th->sock->sched, - th->sock->service_name, + th->sock->sock = do_connect (th->sock->service_name, th->sock->cfg, th->sock->attempts++); GNUNET_assert (NULL != th->sock->sock); @@ -824,8 +804,7 @@ client_notify (void *cls, size_t size, void *buf) MAX_ATTEMPTS - th->attempts_left, (unsigned long long) delay.rel_value); #endif - th->reconnect_task = GNUNET_SCHEDULER_add_delayed (th->sock->sched, - delay, + th->reconnect_task = GNUNET_SCHEDULER_add_delayed (delay, &client_delayed_retry, th); th->sock->th = th; @@ -904,7 +883,7 @@ GNUNET_CLIENT_notify_transmit_ready_cancel (struct if (th->reconnect_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_break (NULL == th->th); - GNUNET_SCHEDULER_cancel (th->sock->sched, th->reconnect_task); + GNUNET_SCHEDULER_cancel (th->reconnect_task); th->reconnect_task = GNUNET_SCHEDULER_NO_TASK; } else diff --git a/src/util/connection.c b/src/util/connection.c index 04d0c864d..a25dc0350 100644 --- a/src/util/connection.c +++ b/src/util/connection.c @@ -160,11 +160,6 @@ struct AddressProbe struct GNUNET_CONNECTION_Handle { - /** - * Scheduler that was used for the connect task. - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * Configuration to use. */ @@ -312,14 +307,11 @@ void GNUNET_CONNECTION_persist_(struct GNUNET_CONNECTION_Handle *sock) * socket should henceforth be no longer used directly. * GNUNET_socket_destroy will close it. * - * @param sched scheduler to use * @param osSocket existing socket to box * @return the boxed socket handle */ struct GNUNET_CONNECTION_Handle * -GNUNET_CONNECTION_create_from_existing (struct GNUNET_SCHEDULER_Handle - *sched, - struct GNUNET_NETWORK_Handle +GNUNET_CONNECTION_create_from_existing (struct GNUNET_NETWORK_Handle *osSocket) { struct GNUNET_CONNECTION_Handle *ret; @@ -327,7 +319,6 @@ GNUNET_CONNECTION_create_from_existing (struct GNUNET_SCHEDULER_Handle ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); ret->sock = osSocket; - ret->sched = sched; return ret; } @@ -336,16 +327,13 @@ GNUNET_CONNECTION_create_from_existing (struct GNUNET_SCHEDULER_Handle * Create a socket handle by accepting on a listen socket. This * function may block if the listen socket has no connection ready. * - * @param sched scheduler to use * @param access function to use to check if access is allowed * @param access_cls closure for access * @param lsock listen socket * @return the socket handle, NULL on error */ struct GNUNET_CONNECTION_Handle * -GNUNET_CONNECTION_create_from_accept (struct GNUNET_SCHEDULER_Handle - *sched, - GNUNET_CONNECTION_AccessCheck access, +GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access, void *access_cls, struct GNUNET_NETWORK_Handle *lsock) { @@ -416,7 +404,6 @@ GNUNET_CONNECTION_create_from_accept (struct GNUNET_SCHEDULER_Handle ret->addr = uaddr; ret->addrlen = addrlen; ret->sock = sock; - ret->sched = sched; #if DEBUG_CONNECTION GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Accepting connection from `%s': %p\n"), @@ -494,8 +481,7 @@ destroy_continuation (void *cls, #endif GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); sock->destroy_task - = GNUNET_SCHEDULER_add_after (sock->sched, - sock->write_task, + = GNUNET_SCHEDULER_add_after (sock->write_task, &destroy_continuation, sock); return; } @@ -517,8 +503,7 @@ destroy_continuation (void *cls, { GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); sock->destroy_task - = GNUNET_SCHEDULER_add_after (sock->sched, - sock->read_task, + = GNUNET_SCHEDULER_add_after (sock->read_task, &destroy_continuation, sock); return; } @@ -529,7 +514,7 @@ destroy_continuation (void *cls, while (NULL != (pos = sock->ap_head)) { GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock)); - GNUNET_SCHEDULER_cancel (sock->sched, pos->task); + GNUNET_SCHEDULER_cancel (pos->task); GNUNET_CONTAINER_DLL_remove (sock->ap_head, sock->ap_tail, pos); GNUNET_free (pos); } @@ -606,8 +591,7 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h) h); #endif h->ccs -= COCO_RECEIVE_AGAIN; - h->read_task = GNUNET_SCHEDULER_add_after (h->sched, - GNUNET_SCHEDULER_NO_TASK, + h->read_task = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, &receive_again, h); } if (0 != (h->ccs & COCO_TRANSMIT_READY)) @@ -618,12 +602,11 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h) h); #endif GNUNET_assert (h->nth.timeout_task != GNUNET_SCHEDULER_NO_TASK); - GNUNET_SCHEDULER_cancel (h->sched, h->nth.timeout_task); + GNUNET_SCHEDULER_cancel (h->nth.timeout_task); h->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK; h->ccs -= COCO_TRANSMIT_READY; GNUNET_assert (h->write_task == GNUNET_SCHEDULER_NO_TASK); - h->write_task = GNUNET_SCHEDULER_add_after (h->sched, - GNUNET_SCHEDULER_NO_TASK, + h->write_task = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, &transmit_ready, h); } if (0 != (h->ccs & COCO_DESTROY_CONTINUATION)) @@ -636,8 +619,7 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h) h->ccs -= COCO_DESTROY_CONTINUATION; GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->destroy_task); h->destroy_task - = GNUNET_SCHEDULER_add_now (h->sched, - &destroy_continuation, + = GNUNET_SCHEDULER_add_now (&destroy_continuation, h); } } @@ -665,8 +647,7 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *h) h); #endif h->ccs -= COCO_RECEIVE_AGAIN; - h->read_task = GNUNET_SCHEDULER_add_after (h->sched, - GNUNET_SCHEDULER_NO_TASK, + h->read_task = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, &receive_again, h); } if (0 != (h->ccs & COCO_TRANSMIT_READY)) @@ -677,13 +658,12 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *h) h); #endif GNUNET_assert (h->nth.timeout_task != GNUNET_SCHEDULER_NO_TASK); - GNUNET_SCHEDULER_cancel (h->sched, h->nth.timeout_task); + GNUNET_SCHEDULER_cancel (h->nth.timeout_task); h->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK; h->ccs -= COCO_TRANSMIT_READY; GNUNET_assert (h->write_task == GNUNET_SCHEDULER_NO_TASK); h->write_task = - GNUNET_SCHEDULER_add_write_net (h->sched, - GNUNET_TIME_absolute_get_remaining + GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining (h->nth.transmit_timeout), h->sock, &transmit_ready, h); } @@ -697,9 +677,8 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *h) h->ccs -= COCO_DESTROY_CONTINUATION; GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->destroy_task); h->destroy_task - = GNUNET_SCHEDULER_add_now (h->sched, - &destroy_continuation, - h); + = GNUNET_SCHEDULER_add_now (&destroy_continuation, + h); } } @@ -749,7 +728,7 @@ connect_probe_continuation (void *cls, while (NULL != (pos = h->ap_head)) { GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock)); - GNUNET_SCHEDULER_cancel (h->sched, pos->task); + GNUNET_SCHEDULER_cancel (pos->task); GNUNET_CONTAINER_DLL_remove (h->ap_head, h->ap_tail, pos); GNUNET_free (pos); } @@ -842,7 +821,7 @@ try_connect_using_address (void *cls, GNUNET_TIME_absolute_get_remaining (h->receive_timeout)); ap->task = - GNUNET_SCHEDULER_add_write_net (h->sched, delay, ap->sock, + GNUNET_SCHEDULER_add_write_net (delay, ap->sock, &connect_probe_continuation, ap); } @@ -852,15 +831,13 @@ try_connect_using_address (void *cls, * This function returns immediately, even if the connection has not * yet been established. This function only creates TCP connections. * - * @param sched scheduler to use * @param cfg configuration to use * @param hostname name of the host to connect to * @param port port to connect to * @return the socket handle */ struct GNUNET_CONNECTION_Handle * -GNUNET_CONNECTION_create_from_connect (struct GNUNET_SCHEDULER_Handle *sched, - const struct +GNUNET_CONNECTION_create_from_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *hostname, uint16_t port) { @@ -869,13 +846,11 @@ GNUNET_CONNECTION_create_from_connect (struct GNUNET_SCHEDULER_Handle *sched, GNUNET_assert (0 < strlen (hostname)); /* sanity check */ ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); ret->cfg = cfg; - ret->sched = sched; ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); ret->port = port; ret->hostname = GNUNET_strdup (hostname); - ret->dns_active = GNUNET_RESOLVER_ip_get (sched, - cfg, + ret->dns_active = GNUNET_RESOLVER_ip_get (cfg, ret->hostname, AF_UNSPEC, GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT, @@ -889,14 +864,12 @@ GNUNET_CONNECTION_create_from_connect (struct GNUNET_SCHEDULER_Handle *sched, * This function returns immediately, even if the connection has not * yet been established. This function only creates UNIX connections. * - * @param sched scheduler to use * @param cfg configuration to use * @param unixpath path to connect to * @return the socket handle, NULL on systems without UNIX support */ struct GNUNET_CONNECTION_Handle * -GNUNET_CONNECTION_create_from_connect_to_unixpath (struct GNUNET_SCHEDULER_Handle *sched, - const struct +GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *unixpath) { @@ -922,7 +895,6 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (struct GNUNET_SCHEDULER_Handl #endif ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); ret->cfg = cfg; - ret->sched = sched; ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); ret->port = 0; @@ -960,15 +932,13 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (struct GNUNET_SCHEDULER_Handl * This function returns immediately, even if the connection has not * yet been established. This function only creates TCP connections. * - * @param sched scheduler to use * @param af_family address family to use * @param serv_addr server address * @param addrlen length of server address * @return the socket handle */ struct GNUNET_CONNECTION_Handle * -GNUNET_CONNECTION_create_from_sockaddr (struct GNUNET_SCHEDULER_Handle - *sched, int af_family, +GNUNET_CONNECTION_create_from_sockaddr (int af_family, const struct sockaddr *serv_addr, socklen_t addrlen) { @@ -990,7 +960,7 @@ GNUNET_CONNECTION_create_from_sockaddr (struct GNUNET_SCHEDULER_Handle GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s)); return NULL; } - ret = GNUNET_CONNECTION_create_from_existing (sched, s); + ret = GNUNET_CONNECTION_create_from_existing (s); ret->addr = GNUNET_malloc (addrlen); memcpy (ret->addr, serv_addr, addrlen); ret->addrlen = addrlen; @@ -1041,8 +1011,7 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *sock, { if (sock->write_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sock->sched, - sock->write_task); + GNUNET_SCHEDULER_cancel (sock->write_task); sock->write_task = GNUNET_SCHEDULER_NO_TASK; sock->write_buffer_off = 0; } @@ -1052,11 +1021,10 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *sock, GNUNET_RESOLVER_request_cancel (sock->dns_active); sock->dns_active = NULL; } - GNUNET_assert (sock->sched != NULL); + GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); sock->destroy_task - = GNUNET_SCHEDULER_add_now (sock->sched, - &destroy_continuation, sock); + = GNUNET_SCHEDULER_add_now (&destroy_continuation, sock); } @@ -1113,8 +1081,7 @@ receive_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ignoring shutdown signal per configuration\n"); #endif - sh->read_task = GNUNET_SCHEDULER_add_read_net (tc->sched, - GNUNET_TIME_absolute_get_remaining + sh->read_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining (sh->receive_timeout), sh->sock, &receive_ready, sh); @@ -1212,8 +1179,7 @@ receive_again (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } GNUNET_assert (sh->sock != NULL); /* connect succeeded, wait for data! */ - sh->read_task = GNUNET_SCHEDULER_add_read_net (tc->sched, - GNUNET_TIME_absolute_get_remaining + sh->read_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining (sh->receive_timeout), sh->sock, &receive_ready, sh); @@ -1252,7 +1218,6 @@ GNUNET_CONNECTION_receive (struct GNUNET_CONNECTION_Handle *sock, if (sock->sock != NULL) { memset (&tc, 0, sizeof (tc)); - tc.sched = sock->sched; tc.reason = GNUNET_SCHEDULER_REASON_PREREQ_DONE; receive_again (sock, &tc); return; @@ -1293,8 +1258,7 @@ GNUNET_CONNECTION_receive_cancel (struct GNUNET_CONNECTION_Handle *sock) { if (sock->read_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_assert (sock == GNUNET_SCHEDULER_cancel (sock->sched, - sock->read_task)); + GNUNET_assert (sock == GNUNET_SCHEDULER_cancel (sock->read_task)); sock->read_task = GNUNET_SCHEDULER_NO_TASK; } else @@ -1421,8 +1385,7 @@ transmit_error (struct GNUNET_CONNECTION_Handle *sock) } if (sock->read_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (sock->sched, - sock->read_task); + GNUNET_SCHEDULER_cancel (sock->read_task); sock->read_task = GNUNET_SCHEDULER_NO_TASK; signal_timeout (sock); return; @@ -1567,8 +1530,7 @@ SCHEDULE_WRITE: #endif if (sock->write_task == GNUNET_SCHEDULER_NO_TASK) sock->write_task = - GNUNET_SCHEDULER_add_write_net (tc->sched, - GNUNET_TIME_absolute_get_remaining + GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining (sock->nth.transmit_timeout), sock->sock, &transmit_ready, sock); } @@ -1612,10 +1574,8 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle (sock->ap_head == NULL) && (sock->dns_active == NULL)) { if (sock->write_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (sock->sched, - sock->write_task); - sock->write_task = GNUNET_SCHEDULER_add_now (sock->sched, - &connect_error, sock); + GNUNET_SCHEDULER_cancel (sock->write_task); + sock->write_task = GNUNET_SCHEDULER_add_now (&connect_error, sock); return &sock->nth; } if (GNUNET_SCHEDULER_NO_TASK != sock->write_task) @@ -1626,8 +1586,7 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduling transmit_ready (%p).\n", sock); #endif - sock->write_task = GNUNET_SCHEDULER_add_write_net (sock->sched, - GNUNET_TIME_absolute_get_remaining + sock->write_task = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining (sock->nth. transmit_timeout), sock->sock, @@ -1642,8 +1601,7 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle sock); #endif sock->ccs |= COCO_TRANSMIT_READY; - sock->nth.timeout_task = GNUNET_SCHEDULER_add_delayed (sock->sched, - timeout, + sock->nth.timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, &transmit_timeout, sock); } @@ -1668,7 +1626,7 @@ GNUNET_CONNECTION_notify_transmit_ready_cancel (struct "notify_transmit_ready_cancel cancels timeout_task (%p)\n", h); #endif - GNUNET_SCHEDULER_cancel (h->sh->sched, h->timeout_task); + GNUNET_SCHEDULER_cancel (h->timeout_task); h->timeout_task = GNUNET_SCHEDULER_NO_TASK; h->sh->ccs -= COCO_TRANSMIT_READY; } @@ -1676,7 +1634,7 @@ GNUNET_CONNECTION_notify_transmit_ready_cancel (struct { if (h->sh->write_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (h->sh->sched, h->sh->write_task); + GNUNET_SCHEDULER_cancel (h->sh->write_task); h->sh->write_task = GNUNET_SCHEDULER_NO_TASK; } } diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c index ab6fc28cf..9e5af4ab5 100644 --- a/src/util/crypto_hash.c +++ b/src/util/crypto_hash.c @@ -82,11 +82,6 @@ struct GNUNET_CRYPTO_FileHashContext */ struct GNUNET_DISK_FileHandle *fh; - /** - * Our scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * Cummulated hash. */ @@ -166,8 +161,7 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; } fhc->task - = GNUNET_SCHEDULER_add_after (tc->sched, - GNUNET_SCHEDULER_NO_TASK, + = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, &file_hash_task, fhc); } @@ -175,7 +169,6 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /** * Compute the hash of an entire file. * - * @param sched scheduler to use * @param priority scheduling priority to use * @param filename name of file to hash * @param blocksize number of bytes to process in one task @@ -184,8 +177,7 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @return NULL on (immediate) errror */ struct GNUNET_CRYPTO_FileHashContext * -GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched, - enum GNUNET_SCHEDULER_Priority priority, +GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, const char *filename, size_t blocksize, GNUNET_CRYPTO_HashCompletedCallback callback, @@ -197,7 +189,6 @@ GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched, fhc = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_FileHashContext) + blocksize); fhc->callback = callback; fhc->callback_cls = callback_cls; - fhc->sched = sched; fhc->buffer = (unsigned char *) &fhc[1]; fhc->filename = GNUNET_strdup (filename); if (GPG_ERR_NO_ERROR != gcry_md_open (&fhc->md, GCRY_MD_SHA512, 0)) @@ -223,7 +214,7 @@ GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched, return NULL; } fhc->task - = GNUNET_SCHEDULER_add_with_priority (sched, priority, + = GNUNET_SCHEDULER_add_with_priority (priority, &file_hash_task, fhc); return fhc; } @@ -237,8 +228,7 @@ GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched, void GNUNET_CRYPTO_hash_file_cancel (struct GNUNET_CRYPTO_FileHashContext *fhc) { - GNUNET_SCHEDULER_cancel (fhc->sched, - fhc->task); + GNUNET_SCHEDULER_cancel (fhc->task); GNUNET_free (fhc->filename); GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fhc->fh)); GNUNET_free (fhc); diff --git a/src/util/disk.c b/src/util/disk.c index 265295922..307c4535b 100644 --- a/src/util/disk.c +++ b/src/util/disk.c @@ -810,10 +810,6 @@ GNUNET_DISK_directory_scan (const char *dirName, */ struct GNUNET_DISK_DirectoryIterator { - /** - * Our scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; /** * Function to call on directory entries. @@ -906,8 +902,7 @@ GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator GNUNET_DISK_directory_iterator_next (iter, GNUNET_YES); return GNUNET_NO; } - GNUNET_SCHEDULER_add_with_priority (iter->sched, - iter->priority, + GNUNET_SCHEDULER_add_with_priority (iter->priority, &directory_iterator_task, iter); return GNUNET_YES; } @@ -919,15 +914,13 @@ GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator * If a scheduler does not need to be used, GNUNET_DISK_directory_scan * may provide a simpler API. * - * @param sched scheduler to use * @param prio priority to use * @param dirName the name of the directory * @param callback the method to call for each file * @param callback_cls closure for callback */ void -GNUNET_DISK_directory_iterator_start (struct GNUNET_SCHEDULER_Handle *sched, - enum GNUNET_SCHEDULER_Priority prio, +GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio, const char *dirName, GNUNET_DISK_DirectoryIteratorCallback callback, void *callback_cls) @@ -935,7 +928,6 @@ GNUNET_DISK_directory_iterator_start (struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_DISK_DirectoryIterator *di; di = GNUNET_malloc (sizeof (struct GNUNET_DISK_DirectoryIterator)); - di->sched = sched; di->callback = callback; di->callback_cls = callback_cls; di->directory = OPENDIR (dirName); diff --git a/src/util/gnunet-resolver.c b/src/util/gnunet-resolver.c index 9686d3a06..18ce232f2 100644 --- a/src/util/gnunet-resolver.c +++ b/src/util/gnunet-resolver.c @@ -49,21 +49,19 @@ printer (void *cls, * Main function that will be run by the scheduler. * * @param cls closure - * @param sched the scheduler to use * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param cfg configuration */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { if (args[0] == NULL) return; - GNUNET_RESOLVER_ip_get (sched, cfg, + GNUNET_RESOLVER_ip_get (cfg, args[0], AF_UNSPEC, GET_TIMEOUT, diff --git a/src/util/gnunet-service-resolver.c b/src/util/gnunet-service-resolver.c index b0e2f0be4..68d2daae7 100644 --- a/src/util/gnunet-service-resolver.c +++ b/src/util/gnunet-service-resolver.c @@ -477,13 +477,11 @@ handle_get (void *cls, * Process resolver requests. * * @param cls closure - * @param sched scheduler to use * @param server the initialized server * @param cfg configuration to use */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg) { diff --git a/src/util/program.c b/src/util/program.c index 9a5ee8833..6f8467837 100644 --- a/src/util/program.c +++ b/src/util/program.c @@ -77,7 +77,7 @@ program_main (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct CommandContext *cc = cls; - cc->task (cc->task_cls, tc->sched, cc->args, cc->cfgfile, cc->cfg); + cc->task (cc->task_cls, cc->args, cc->cfgfile, cc->cfg); } diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c index f4832ed9c..7daaaf1cc 100644 --- a/src/util/resolver_api.c +++ b/src/util/resolver_api.c @@ -79,11 +79,6 @@ struct GNUNET_RESOLVER_RequestHandle */ struct GNUNET_CLIENT_Connection *client; - /** - * Our scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * Name of the host that we are resolving. */ @@ -401,7 +396,6 @@ loopback_resolution (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /** * Convert a string to one or more IP addresses. * - * @param sched scheduler to use * @param cfg configuration to use * @param hostname the hostname to resolve * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any" @@ -411,8 +405,7 @@ loopback_resolution (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @return handle that can be used to cancel the request, NULL on error */ struct GNUNET_RESOLVER_RequestHandle * -GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_RESOLVER_ip_get (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *hostname, int domain, struct GNUNET_TIME_Relative timeout, @@ -436,7 +429,6 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, return NULL; } rh = GNUNET_malloc (sizeof (struct GNUNET_RESOLVER_RequestHandle) + slen); - rh->sched = sched; rh->domain = domain; rh->addr_callback = callback; rh->cls = callback_cls; @@ -454,8 +446,7 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, &v6)) && ((domain == AF_INET6) || (domain == AF_UNSPEC)))) { - rh->task = GNUNET_SCHEDULER_add_now (sched, - &numeric_resolution, rh); + rh->task = GNUNET_SCHEDULER_add_now (&numeric_resolution, rh); return rh; } /* then, check if this is a loopback address */ @@ -463,12 +454,11 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, while (loopback[i] != NULL) if (0 == strcasecmp (loopback[i++], hostname)) { - rh->task = GNUNET_SCHEDULER_add_now (sched, - &loopback_resolution, rh); + rh->task = GNUNET_SCHEDULER_add_now (&loopback_resolution, rh); return rh; } - client = GNUNET_CLIENT_connect (sched, "resolver", cfg); + client = GNUNET_CLIENT_connect ("resolver", cfg); if (client == NULL) { GNUNET_free (rh); @@ -595,7 +585,6 @@ numeric_reverse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /** * Get an IP address as a string. * - * @param sched scheduler to use * @param cfg configuration to use * @param sa host address * @param salen length of host address @@ -606,8 +595,7 @@ numeric_reverse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @return handle that can be used to cancel the request */ struct GNUNET_RESOLVER_RequestHandle * -GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_RESOLVER_hostname_get (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct sockaddr *sa, socklen_t salen, int do_resolve, @@ -625,14 +613,12 @@ GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, rh->name_callback = callback; rh->cls = cls; rh->timeout = GNUNET_TIME_relative_to_absolute (timeout); - rh->sched = sched; rh->salen = salen; memcpy (&rh[1], sa, salen); if (GNUNET_NO == do_resolve) { - rh->task = GNUNET_SCHEDULER_add_now (sched, - &numeric_reverse, rh); + rh->task = GNUNET_SCHEDULER_add_now (&numeric_reverse, rh); return rh; } if (salen + sizeof (struct GNUNET_RESOLVER_GetMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) @@ -641,7 +627,7 @@ GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, GNUNET_free (rh); return NULL; } - client = GNUNET_CLIENT_connect (sched, "resolver", cfg); + client = GNUNET_CLIENT_connect ("resolver", cfg); if (client == NULL) { GNUNET_free (rh); @@ -710,7 +696,6 @@ GNUNET_RESOLVER_local_fqdn_get ( void ) /** * Looking our own hostname. * - * @param sched scheduler to use * @param cfg configuration to use * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any" * @param callback function to call with addresses @@ -719,8 +704,7 @@ GNUNET_RESOLVER_local_fqdn_get ( void ) * @return handle that can be used to cancel the request, NULL on error */ struct GNUNET_RESOLVER_RequestHandle * -GNUNET_RESOLVER_hostname_resolve (struct GNUNET_SCHEDULER_Handle *sched, - const struct GNUNET_CONFIGURATION_Handle +GNUNET_RESOLVER_hostname_resolve (const struct GNUNET_CONFIGURATION_Handle *cfg, int domain, struct GNUNET_TIME_Relative timeout, GNUNET_RESOLVER_AddressCallback callback, @@ -739,8 +723,7 @@ GNUNET_RESOLVER_hostname_resolve (struct GNUNET_SCHEDULER_Handle *sched, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Resolving our hostname `%s'\n"), hostname); #endif - return GNUNET_RESOLVER_ip_get (sched, - cfg, hostname, domain, timeout, callback, + return GNUNET_RESOLVER_ip_get (cfg, hostname, domain, timeout, callback, cls); } @@ -759,7 +742,7 @@ GNUNET_RESOLVER_request_cancel (struct GNUNET_RESOLVER_RequestHandle *h) if (h->client != NULL) GNUNET_CLIENT_disconnect (h->client, GNUNET_NO); if (h->task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (h->sched, h->task); + GNUNET_SCHEDULER_cancel (h->task); GNUNET_free (h); } diff --git a/src/util/scheduler.c b/src/util/scheduler.c index 9b8ab4b29..341400bba 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c @@ -163,84 +163,76 @@ struct Task /** - * Handle for the scheduling service. - */ -struct GNUNET_SCHEDULER_Handle -{ - - /** - * List of tasks waiting for an event. - */ - struct Task *pending; - - /** - * List of tasks waiting ONLY for a timeout event. - * Sorted by timeout (earliest first). Used so that - * we do not traverse the list of these tasks when - * building select sets (we just look at the head - * to determine the respective timeout ONCE). - */ - struct Task *pending_timeout; +* List of tasks waiting for an event. +*/ +struct Task *pending; - /** - * Last inserted task waiting ONLY for a timeout event. - * Used to (heuristically) speed up insertion. - */ - struct Task *pending_timeout_last; +/** +* List of tasks waiting ONLY for a timeout event. +* Sorted by timeout (earliest first). Used so that +* we do not traverse the list of these tasks when +* building select sets (we just look at the head +* to determine the respective timeout ONCE). +*/ +struct Task *pending_timeout; - /** - * ID of the task that is running right now. - */ - struct Task *active_task; +/** +* Last inserted task waiting ONLY for a timeout event. +* Used to (heuristically) speed up insertion. +*/ +struct Task *pending_timeout_last; - /** - * List of tasks ready to run right now, - * grouped by importance. - */ - struct Task *ready[GNUNET_SCHEDULER_PRIORITY_COUNT]; +/** +* ID of the task that is running right now. +*/ +struct Task *active_task; - /** - * Identity of the last task queued. Incremented for each task to - * generate a unique task ID (it is virtually impossible to start - * more than 2^64 tasks during the lifetime of a process). - */ - GNUNET_SCHEDULER_TaskIdentifier last_id; +/** +* List of tasks ready to run right now, +* grouped by importance. +*/ +struct Task *ready[GNUNET_SCHEDULER_PRIORITY_COUNT]; - /** - * Highest number so that all tasks with smaller identifiers - * have already completed. Also the lowest number of a task - * still waiting to be executed. - */ - GNUNET_SCHEDULER_TaskIdentifier lowest_pending_id; +/** +* Identity of the last task queued. Incremented for each task to +* generate a unique task ID (it is virtually impossible to start +* more than 2^64 tasks during the lifetime of a process). +*/ +GNUNET_SCHEDULER_TaskIdentifier last_id; - /** - * Number of tasks on the ready list. - */ - unsigned int ready_count; +/** +* Highest number so that all tasks with smaller identifiers +* have already completed. Also the lowest number of a task +* still waiting to be executed. +*/ +GNUNET_SCHEDULER_TaskIdentifier lowest_pending_id; - /** - * How many tasks have we run so far? - */ - unsigned long long tasks_run; +/** +* Number of tasks on the ready list. +*/ +unsigned int ready_count; - /** - * Priority of the task running right now. Only - * valid while a task is running. - */ - enum GNUNET_SCHEDULER_Priority current_priority; +/** +* How many tasks have we run so far? +*/ +unsigned long long tasks_run; - /** - * Priority of the highest task added in the current select - * iteration. - */ - enum GNUNET_SCHEDULER_Priority max_priority_added; +/** +* Priority of the task running right now. Only +* valid while a task is running. +*/ +enum GNUNET_SCHEDULER_Priority current_priority; - /** - * How 'nice' are we right now? - */ - int nice_level; +/** +* Priority of the highest task added in the current select +* iteration. +*/ +enum GNUNET_SCHEDULER_Priority max_priority_added; -}; +/** +* How 'nice' are we right now? +*/ +int nice_level; /** @@ -270,17 +262,16 @@ check_priority (enum GNUNET_SCHEDULER_Priority p) * @return GNUNET_YES if so, GNUNET_NO if not */ static int -is_pending (struct GNUNET_SCHEDULER_Handle *sched, - GNUNET_SCHEDULER_TaskIdentifier id) +is_pending (GNUNET_SCHEDULER_TaskIdentifier id) { struct Task *pos; enum GNUNET_SCHEDULER_Priority p; GNUNET_SCHEDULER_TaskIdentifier min; - if (id < sched->lowest_pending_id) + if (id < lowest_pending_id) return GNUNET_NO; min = -1; /* maximum value */ - pos = sched->pending; + pos = pending; while (pos != NULL) { if (pos->id == id) @@ -289,7 +280,7 @@ is_pending (struct GNUNET_SCHEDULER_Handle *sched, min = pos->id; pos = pos->next; } - pos = sched->pending_timeout; + pos = pending_timeout; while (pos != NULL) { if (pos->id == id) @@ -300,7 +291,7 @@ is_pending (struct GNUNET_SCHEDULER_Handle *sched, } for (p = 0; p < GNUNET_SCHEDULER_PRIORITY_COUNT; p++) { - pos = sched->ready[p]; + pos = ready[p]; while (pos != NULL) { if (pos->id == id) @@ -310,7 +301,7 @@ is_pending (struct GNUNET_SCHEDULER_Handle *sched, pos = pos->next; } } - sched->lowest_pending_id = min; + lowest_pending_id = min; return GNUNET_NO; } @@ -324,8 +315,7 @@ is_pending (struct GNUNET_SCHEDULER_Handle *sched, * @param timeout next timeout (updated) */ static void -update_sets (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_NETWORK_FDSet *rs, +update_sets (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws, struct GNUNET_TIME_Relative *timeout) { @@ -334,7 +324,7 @@ update_sets (struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_TIME_Relative to; now = GNUNET_TIME_absolute_get (); - pos = sched->pending_timeout; + pos = pending_timeout; if (pos != NULL) { to = GNUNET_TIME_absolute_get_difference (now, pos->timeout); @@ -343,11 +333,11 @@ update_sets (struct GNUNET_SCHEDULER_Handle *sched, if (pos->reason != 0) *timeout = GNUNET_TIME_UNIT_ZERO; } - pos = sched->pending; + pos = pending; while (pos != NULL) { if ((pos->prereq_id != GNUNET_SCHEDULER_NO_TASK) && - (GNUNET_YES == is_pending (sched, pos->prereq_id))) + (GNUNET_YES == is_pending (pos->prereq_id))) { pos = pos->next; continue; @@ -411,8 +401,7 @@ set_overlaps (const struct GNUNET_NETWORK_FDSet *ready, * @return GNUNET_YES if we can run it, GNUNET_NO if not. */ static int -is_ready (struct GNUNET_SCHEDULER_Handle *sched, - struct Task *task, +is_ready (struct Task *task, struct GNUNET_TIME_Absolute now, const struct GNUNET_NETWORK_FDSet *rs, const struct GNUNET_NETWORK_FDSet *ws) @@ -436,7 +425,7 @@ is_ready (struct GNUNET_SCHEDULER_Handle *sched, return GNUNET_NO; /* not ready */ if (task->prereq_id != GNUNET_SCHEDULER_NO_TASK) { - if (GNUNET_YES == is_pending (sched, task->prereq_id)) + if (GNUNET_YES == is_pending (task->prereq_id)) { task->reason = reason; return GNUNET_NO; /* prereq waiting */ @@ -455,15 +444,14 @@ is_ready (struct GNUNET_SCHEDULER_Handle *sched, * @param task task ready for execution */ static void -queue_ready_task (struct GNUNET_SCHEDULER_Handle *handle, - struct Task *task) +queue_ready_task (struct Task *task) { enum GNUNET_SCHEDULER_Priority p = task->priority; if (0 != (task->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) p = GNUNET_SCHEDULER_PRIORITY_SHUTDOWN; - task->next = handle->ready[check_priority (p)]; - handle->ready[check_priority (p)] = task; - handle->ready_count++; + task->next = ready[check_priority (p)]; + ready[check_priority (p)] = task; + ready_count++; } @@ -476,8 +464,7 @@ queue_ready_task (struct GNUNET_SCHEDULER_Handle *handle, * @param ws FDs ready for writing */ static void -check_ready (struct GNUNET_SCHEDULER_Handle *handle, - const struct GNUNET_NETWORK_FDSet *rs, +check_ready (const struct GNUNET_NETWORK_FDSet *rs, const struct GNUNET_NETWORK_FDSet *ws) { struct Task *pos; @@ -487,7 +474,7 @@ check_ready (struct GNUNET_SCHEDULER_Handle *handle, now = GNUNET_TIME_absolute_get (); prev = NULL; - pos = handle->pending_timeout; + pos = pending_timeout; while (pos != NULL) { next = pos->next; @@ -495,13 +482,13 @@ check_ready (struct GNUNET_SCHEDULER_Handle *handle, pos->reason |= GNUNET_SCHEDULER_REASON_TIMEOUT; if (0 == pos->reason) break; - handle->pending_timeout = next; - if (handle->pending_timeout_last == pos) - handle->pending_timeout_last = NULL; - queue_ready_task (handle, pos); + pending_timeout = next; + if (pending_timeout_last == pos) + pending_timeout_last = NULL; + queue_ready_task (pos); pos = next; } - pos = handle->pending; + pos = pending; while (pos != NULL) { #if DEBUG_TASKS @@ -510,13 +497,13 @@ check_ready (struct GNUNET_SCHEDULER_Handle *handle, pos->id, pos->callback_cls); #endif next = pos->next; - if (GNUNET_YES == is_ready (handle, pos, now, rs, ws)) + if (GNUNET_YES == is_ready (pos, now, rs, ws)) { if (prev == NULL) - handle->pending = next; + pending = next; else prev->next = next; - queue_ready_task (handle, pos); + queue_ready_task (pos); pos = next; continue; } @@ -536,12 +523,12 @@ check_ready (struct GNUNET_SCHEDULER_Handle *handle, * @param sched the scheduler */ void -GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched) +GNUNET_SCHEDULER_shutdown () { struct Task *pos; int i; - pos = sched->pending_timeout; + pos = pending_timeout; while (pos != NULL) { pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN; @@ -550,7 +537,7 @@ GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched) readiness-factors */ pos = pos->next; } - pos = sched->pending; + pos = pending; while (pos != NULL) { pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN; @@ -561,7 +548,7 @@ GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched) } for (i=0;iready[i]; + pos = ready[i]; while (pos != NULL) { pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN; @@ -605,37 +592,36 @@ destroy_task (struct Task *t) * @param ws FDs ready for writing */ static void -run_ready (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_NETWORK_FDSet *rs, +run_ready (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws) { enum GNUNET_SCHEDULER_Priority p; struct Task *pos; struct GNUNET_SCHEDULER_TaskContext tc; - sched->max_priority_added = GNUNET_SCHEDULER_PRIORITY_KEEP; + max_priority_added = GNUNET_SCHEDULER_PRIORITY_KEEP; do { - if (sched->ready_count == 0) + if (ready_count == 0) return; - GNUNET_assert (sched->ready[GNUNET_SCHEDULER_PRIORITY_KEEP] == NULL); + GNUNET_assert (ready[GNUNET_SCHEDULER_PRIORITY_KEEP] == NULL); /* yes, p>0 is correct, 0 is "KEEP" which should always be an empty queue (see assertion)! */ for (p = GNUNET_SCHEDULER_PRIORITY_COUNT - 1; p > 0; p--) { - pos = sched->ready[p]; + pos = ready[p]; if (pos != NULL) break; } GNUNET_assert (pos != NULL); /* ready_count wrong? */ - sched->ready[p] = pos->next; - sched->ready_count--; - if (sched->current_priority != pos->priority) + ready[p] = pos->next; + ready_count--; + if (current_priority != pos->priority) { - sched->current_priority = pos->priority; + current_priority = pos->priority; (void) GNUNET_OS_set_process_priority (GNUNET_OS_process_current (), pos->priority); } - sched->active_task = pos; + active_task = pos; #if PROFILE_DELAYS if (GNUNET_TIME_absolute_get_duration (pos->start_time).rel_value > DELAY_THRESHOLD.rel_value) @@ -646,7 +632,6 @@ run_ready (struct GNUNET_SCHEDULER_Handle *sched, (unsigned long long) GNUNET_TIME_absolute_get_duration (pos->start_time).rel_value); } #endif - tc.sched = sched; tc.reason = pos->reason; tc.read_ready = (pos->read_set == NULL) ? rs : pos->read_set; if ( (pos->read_fd != -1) && @@ -677,11 +662,11 @@ run_ready (struct GNUNET_SCHEDULER_Handle *sched, i, pos->backtrace_strings[i]); #endif - sched->active_task = NULL; + active_task = NULL; destroy_task (pos); - sched->tasks_run++; + tasks_run++; } - while ( (sched->pending == NULL) || (p >= sched->max_priority_added) ); + while ( (pending == NULL) || (p >= max_priority_added) ); } /** @@ -732,7 +717,6 @@ sighandler_shutdown () void GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls) { - struct GNUNET_SCHEDULER_Handle sched; struct GNUNET_NETWORK_FDSet *rs; struct GNUNET_NETWORK_FDSet *ws; struct GNUNET_TIME_Relative timeout; @@ -763,24 +747,22 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls) shc_quit = GNUNET_SIGNAL_handler_install (SIGQUIT, &sighandler_shutdown); shc_hup = GNUNET_SIGNAL_handler_install (SIGHUP, &sighandler_shutdown); #endif - memset (&sched, 0, sizeof (sched)); - sched.current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT; - GNUNET_SCHEDULER_add_continuation (&sched, - task, + current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT; + GNUNET_SCHEDULER_add_continuation (task, task_cls, GNUNET_SCHEDULER_REASON_STARTUP); last_tr = 0; busy_wait_warning = 0; - while ((sched.pending != NULL) || - (sched.pending_timeout != NULL) || - (sched.ready_count > 0)) + while ((pending != NULL) || + (pending_timeout != NULL) || + (ready_count > 0)) { GNUNET_NETWORK_fdset_zero (rs); GNUNET_NETWORK_fdset_zero (ws); timeout = GNUNET_TIME_UNIT_FOREVER_REL; - update_sets (&sched, rs, ws, &timeout); + update_sets (rs, ws, &timeout); GNUNET_NETWORK_fdset_handle_set (rs, pr); - if (sched.ready_count > 0) + if (ready_count > 0) { /* no blocking, more work already ready! */ timeout = GNUNET_TIME_UNIT_ZERO; @@ -810,22 +792,22 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls) _("Looks like we're busy waiting...\n")); sleep (1); /* mitigate */ } - check_ready (&sched, rs, ws); - run_ready (&sched, rs, ws); + check_ready (rs, ws); + run_ready (rs, ws); if (GNUNET_NETWORK_fdset_handle_isset (rs, pr)) { /* consume the signal */ GNUNET_DISK_file_read (pr, &c, sizeof (c)); /* mark all active tasks as ready due to shutdown */ - GNUNET_SCHEDULER_shutdown (&sched); + GNUNET_SCHEDULER_shutdown (); } - if (last_tr == sched.tasks_run) + if (last_tr == tasks_run) { busy_wait_warning++; } else { - last_tr = sched.tasks_run; + last_tr = tasks_run; busy_wait_warning = 0; } } @@ -852,9 +834,9 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls) * @return reason(s) why the current task is run */ enum GNUNET_SCHEDULER_Reason -GNUNET_SCHEDULER_get_reason (struct GNUNET_SCHEDULER_Handle *sched) +GNUNET_SCHEDULER_get_reason () { - return sched->active_task->reason; + return active_task->reason; } @@ -869,18 +851,17 @@ GNUNET_SCHEDULER_get_reason (struct GNUNET_SCHEDULER_Handle *sched) * @return number of tasks pending right now */ unsigned int -GNUNET_SCHEDULER_get_load (struct GNUNET_SCHEDULER_Handle *sched, - enum GNUNET_SCHEDULER_Priority p) +GNUNET_SCHEDULER_get_load (enum GNUNET_SCHEDULER_Priority p) { struct Task *pos; unsigned int ret; if (p == GNUNET_SCHEDULER_PRIORITY_COUNT) - return sched->ready_count; + return ready_count; if (p == GNUNET_SCHEDULER_PRIORITY_KEEP) - p = sched->current_priority; + p = current_priority; ret = 0; - pos = sched->ready[check_priority (p)]; + pos = ready[check_priority (p)]; while (pos != NULL) { pos = pos->next; @@ -899,8 +880,7 @@ GNUNET_SCHEDULER_get_load (struct GNUNET_SCHEDULER_Handle *sched, * @return original closure of the task */ void * -GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched, - GNUNET_SCHEDULER_TaskIdentifier task) +GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_TaskIdentifier task) { struct Task *t; struct Task *prev; @@ -910,7 +890,7 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched, to = 0; prev = NULL; - t = sched->pending; + t = pending; while (t != NULL) { if (t->id == task) @@ -922,7 +902,7 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched, { prev = NULL; to = 1; - t = sched->pending_timeout; + t = pending_timeout; while (t != NULL) { if (t->id == task) @@ -930,8 +910,8 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched, prev = t; t = t->next; } - if (sched->pending_timeout_last == t) - sched->pending_timeout_last = NULL; + if (pending_timeout_last == t) + pending_timeout_last = NULL; } p = 0; while (t == NULL) @@ -939,12 +919,12 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched, p++; GNUNET_assert (p < GNUNET_SCHEDULER_PRIORITY_COUNT); prev = NULL; - t = sched->ready[p]; + t = ready[p]; while (t != NULL) { if (t->id == task) { - sched->ready_count--; + ready_count--; break; } prev = t; @@ -957,16 +937,16 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched, { if (to == 0) { - sched->pending = t->next; + pending = t->next; } else { - sched->pending_timeout = t->next; + pending_timeout = t->next; } } else { - sched->ready[p] = t->next; + ready[p] = t->next; } } else @@ -994,8 +974,7 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched, * @param reason reason for task invocation */ void -GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched, - GNUNET_SCHEDULER_Task task, +GNUNET_SCHEDULER_add_continuation (GNUNET_SCHEDULER_Task task, void *task_cls, enum GNUNET_SCHEDULER_Reason reason) { @@ -1012,18 +991,18 @@ GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched, t->write_fd = -1; t->callback = task; t->callback_cls = task_cls; - t->id = ++sched->last_id; + t->id = ++last_id; #if PROFILE_DELAYS t->start_time = GNUNET_TIME_absolute_get (); #endif t->reason = reason; - t->priority = sched->current_priority; + t->priority = current_priority; #if DEBUG_TASKS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding continuation task: %llu / %p\n", t->id, t->callback_cls); #endif - queue_ready_task (sched, t); + queue_ready_task (t); } @@ -1046,12 +1025,10 @@ GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched, * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched, - GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, +GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, GNUNET_SCHEDULER_Task task, void *task_cls) { - return GNUNET_SCHEDULER_add_select (sched, - GNUNET_SCHEDULER_PRIORITY_KEEP, + return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, prerequisite_task, GNUNET_TIME_UNIT_ZERO, NULL, NULL, task, task_cls); @@ -1069,13 +1046,11 @@ GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched, * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -GNUNET_SCHEDULER_add_with_priority (struct GNUNET_SCHEDULER_Handle * sched, - enum GNUNET_SCHEDULER_Priority prio, +GNUNET_SCHEDULER_add_with_priority (enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_Task task, void *task_cls) { - return GNUNET_SCHEDULER_add_select (sched, - prio, + return GNUNET_SCHEDULER_add_select (prio, GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_ZERO, NULL, NULL, task, task_cls); @@ -1097,8 +1072,7 @@ GNUNET_SCHEDULER_add_with_priority (struct GNUNET_SCHEDULER_Handle * sched, * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched, - struct GNUNET_TIME_Relative delay, +GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_Task task, void *task_cls) { #if 1 @@ -1120,15 +1094,15 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched, #endif t->read_fd = -1; t->write_fd = -1; - t->id = ++sched->last_id; + t->id = ++last_id; #if PROFILE_DELAYS t->start_time = GNUNET_TIME_absolute_get (); #endif t->timeout = GNUNET_TIME_relative_to_absolute (delay); - t->priority = sched->current_priority; + t->priority = current_priority; /* try tail first (optimization in case we are appending to a long list of tasks with timeouts) */ - prev = sched->pending_timeout_last; + prev = pending_timeout_last; if (prev != NULL) { if (prev->timeout.abs_value > t->timeout.abs_value) @@ -1139,7 +1113,7 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched, if (prev == NULL) { /* heuristic failed, do traversal of timeout list */ - pos = sched->pending_timeout; + pos = pending_timeout; } while ( (pos != NULL) && ( (pos->timeout.abs_value <= t->timeout.abs_value) || @@ -1149,12 +1123,12 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched, pos = pos->next; } if (prev == NULL) - sched->pending_timeout = t; + pending_timeout = t; else prev->next = t; t->next = pos; /* hyper-optimization... */ - sched->pending_timeout_last = t; + pending_timeout_last = t; #if DEBUG_TASKS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -1194,12 +1168,10 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched, * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -GNUNET_SCHEDULER_add_now (struct GNUNET_SCHEDULER_Handle *sched, - GNUNET_SCHEDULER_Task task, - void *task_cls) +GNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_Task task, + void *task_cls) { - return GNUNET_SCHEDULER_add_select (sched, - GNUNET_SCHEDULER_PRIORITY_KEEP, + return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_ZERO, NULL, NULL, task, task_cls); @@ -1236,8 +1208,7 @@ GNUNET_SCHEDULER_add_now (struct GNUNET_SCHEDULER_Handle *sched, * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -add_without_sets (struct GNUNET_SCHEDULER_Handle * sched, - struct GNUNET_TIME_Relative delay, +add_without_sets (struct GNUNET_TIME_Relative delay, int rfd, int wfd, GNUNET_SCHEDULER_Task task, void *task_cls) @@ -1257,16 +1228,16 @@ add_without_sets (struct GNUNET_SCHEDULER_Handle * sched, #endif t->read_fd = rfd; t->write_fd = wfd; - t->id = ++sched->last_id; + t->id = ++last_id; #if PROFILE_DELAYS t->start_time = GNUNET_TIME_absolute_get (); #endif t->prereq_id = GNUNET_SCHEDULER_NO_TASK; t->timeout = GNUNET_TIME_relative_to_absolute (delay); - t->priority = check_priority (sched->current_priority); - t->next = sched->pending; - sched->pending = t; - sched->max_priority_added = GNUNET_MAX (sched->max_priority_added, + t->priority = check_priority (current_priority); + t->next = pending; + pending = t; + max_priority_added = GNUNET_MAX (max_priority_added, t->priority); #if DEBUG_TASKS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -1305,13 +1276,11 @@ add_without_sets (struct GNUNET_SCHEDULER_Handle * sched, * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle * sched, - struct GNUNET_TIME_Relative delay, +GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay, struct GNUNET_NETWORK_Handle * rfd, GNUNET_SCHEDULER_Task task, void *task_cls) { - return add_without_sets (sched, - delay, + return add_without_sets (delay, GNUNET_NETWORK_get_fd (rfd), -1, task, @@ -1337,13 +1306,11 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle * sched, * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle * sched, - struct GNUNET_TIME_Relative delay, +GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay, struct GNUNET_NETWORK_Handle * wfd, GNUNET_SCHEDULER_Task task, void *task_cls) { - return add_without_sets (sched, - delay, + return add_without_sets (delay, -1, GNUNET_NETWORK_get_fd (wfd), task, @@ -1369,8 +1336,7 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle * sched, * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle * sched, - struct GNUNET_TIME_Relative delay, +GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay, const struct GNUNET_DISK_FileHandle * rfd, GNUNET_SCHEDULER_Task task, void *task_cls) { @@ -1391,8 +1357,7 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle * sched, int fd; GNUNET_DISK_internal_file_handle_ (rfd, &fd, sizeof (int)); - return add_without_sets (sched, - delay, + return add_without_sets (delay, fd, -1, task, @@ -1420,8 +1385,7 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle * sched, * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle * sched, - struct GNUNET_TIME_Relative delay, +GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, const struct GNUNET_DISK_FileHandle * wfd, GNUNET_SCHEDULER_Task task, void *task_cls) { @@ -1442,8 +1406,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle * sched, int fd; GNUNET_DISK_internal_file_handle_ (wfd, &fd, sizeof (int)); - return add_without_sets (sched, - delay, + return add_without_sets (delay, -1, fd, task, @@ -1488,8 +1451,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle * sched, * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle * sched, - enum GNUNET_SCHEDULER_Priority prio, +GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, struct GNUNET_TIME_Relative delay, @@ -1522,7 +1484,7 @@ GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle * sched, t->write_set = GNUNET_NETWORK_fdset_create (); GNUNET_NETWORK_fdset_copy (t->write_set, ws); } - t->id = ++sched->last_id; + t->id = ++last_id; #if PROFILE_DELAYS t->start_time = GNUNET_TIME_absolute_get (); #endif @@ -1530,11 +1492,11 @@ GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle * sched, t->timeout = GNUNET_TIME_relative_to_absolute (delay); t->priority = check_priority ((prio == - GNUNET_SCHEDULER_PRIORITY_KEEP) ? sched->current_priority + GNUNET_SCHEDULER_PRIORITY_KEEP) ? current_priority : prio); - t->next = sched->pending; - sched->pending = t; - sched->max_priority_added = GNUNET_MAX (sched->max_priority_added, + t->next = pending; + pending = t; + max_priority_added = GNUNET_MAX (max_priority_added, t->priority); #if DEBUG_TASKS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, diff --git a/src/util/server.c b/src/util/server.c index 516885fed..f586e4204 100644 --- a/src/util/server.c +++ b/src/util/server.c @@ -79,11 +79,6 @@ struct NotifyList */ struct GNUNET_SERVER_Handle { - /** - * My scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * List of handlers for incoming messages. */ @@ -249,8 +244,7 @@ process_listen_socket (void *cls, if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) { /* ignore shutdown, someone else will take care of it! */ - server->listen_task = GNUNET_SCHEDULER_add_select (server->sched, - GNUNET_SCHEDULER_PRIORITY_HIGH, + server->listen_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH, GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, r, NULL, @@ -266,7 +260,7 @@ process_listen_socket (void *cls, (tc->read_ready, server->listen_sockets[i])) { sock = - GNUNET_CONNECTION_create_from_accept (tc->sched, server->access, + GNUNET_CONNECTION_create_from_accept (server->access, server->access_cls, server->listen_sockets[i]); if (sock != NULL) @@ -285,8 +279,7 @@ process_listen_socket (void *cls, i++; } /* listen for more! */ - server->listen_task = GNUNET_SCHEDULER_add_select (server->sched, - GNUNET_SCHEDULER_PRIORITY_HIGH, + server->listen_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH, GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, r, NULL, @@ -386,7 +379,6 @@ open_listen_socket (const struct sockaddr *serverAddr, socklen_t socklen) /** * Create a new server. * - * @param sched scheduler to use * @param access function for access control * @param access_cls closure for access * @param lsocks NULL-terminated array of listen sockets @@ -397,8 +389,7 @@ open_listen_socket (const struct sockaddr *serverAddr, socklen_t socklen) * (typically, "port" already in use) */ struct GNUNET_SERVER_Handle * -GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched, - GNUNET_CONNECTION_AccessCheck access, void *access_cls, +GNUNET_SERVER_create_with_sockets (GNUNET_CONNECTION_AccessCheck access, void *access_cls, struct GNUNET_NETWORK_Handle **lsocks, struct GNUNET_TIME_Relative idle_timeout, @@ -409,7 +400,6 @@ GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched, int i; ret = GNUNET_malloc (sizeof (struct GNUNET_SERVER_Handle)); - ret->sched = sched; ret->idle_timeout = idle_timeout; ret->listen_sockets = lsocks; ret->access = access; @@ -421,8 +411,7 @@ GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched, i = 0; while (NULL != ret->listen_sockets[i]) GNUNET_NETWORK_fdset_set (r, ret->listen_sockets[i++]); - ret->listen_task = GNUNET_SCHEDULER_add_select (sched, - GNUNET_SCHEDULER_PRIORITY_HIGH, + ret->listen_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH, GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, r, NULL, @@ -437,7 +426,6 @@ GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched, /** * Create a new server. * - * @param sched scheduler to use * @param access function for access control * @param access_cls closure for access * @param serverAddr address to listen on (including port), NULL terminated array @@ -449,8 +437,7 @@ GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched, * (typically, "port" already in use) */ struct GNUNET_SERVER_Handle * -GNUNET_SERVER_create (struct GNUNET_SCHEDULER_Handle *sched, - GNUNET_CONNECTION_AccessCheck access, +GNUNET_SERVER_create (GNUNET_CONNECTION_AccessCheck access, void *access_cls, struct sockaddr *const *serverAddr, const socklen_t * socklen, @@ -489,8 +476,7 @@ GNUNET_SERVER_create (struct GNUNET_SCHEDULER_Handle *sched, { lsocks = NULL; } - return GNUNET_SERVER_create_with_sockets (sched, - access, access_cls, + return GNUNET_SERVER_create_with_sockets (access, access_cls, lsocks, idle_timeout, require_found); @@ -514,7 +500,7 @@ GNUNET_SERVER_destroy (struct GNUNET_SERVER_Handle *s) #endif if (GNUNET_SCHEDULER_NO_TASK != s->listen_task) { - GNUNET_SCHEDULER_cancel (s->sched, s->listen_task); + GNUNET_SCHEDULER_cancel (s->listen_task); s->listen_task = GNUNET_SCHEDULER_NO_TASK; } if (s->listen_sockets != NULL) @@ -1023,8 +1009,7 @@ GNUNET_SERVER_client_disconnect (struct GNUNET_SERVER_Client *client) #endif if (client->restart_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (client->server->sched, - client->restart_task); + GNUNET_SCHEDULER_cancel (client->restart_task); client->restart_task = GNUNET_SCHEDULER_NO_TASK; } if (GNUNET_YES == client->receive_pending) @@ -1053,8 +1038,7 @@ GNUNET_SERVER_client_disconnect (struct GNUNET_SERVER_Client *client) prev->next = pos->next; if (client->restart_task != GNUNET_SCHEDULER_NO_TASK) { - GNUNET_SCHEDULER_cancel (server->sched, - client->restart_task); + GNUNET_SCHEDULER_cancel (client->restart_task); client->restart_task = GNUNET_SCHEDULER_NO_TASK; } n = server->disconnect_notify_list; @@ -1182,8 +1166,7 @@ GNUNET_SERVER_receive_done (struct GNUNET_SERVER_Client *client, int success) "GNUNET_SERVER_receive_done causes restart in reading from the socket\n"); #endif GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == client->restart_task); - client->restart_task = GNUNET_SCHEDULER_add_now (client->server->sched, - &restart_processing, + client->restart_task = GNUNET_SCHEDULER_add_now (&restart_processing, client); } diff --git a/src/util/service.c b/src/util/service.c index d18d4e9e3..3423b58cb 100644 --- a/src/util/service.c +++ b/src/util/service.c @@ -429,11 +429,6 @@ struct GNUNET_SERVICE_Context */ struct GNUNET_SERVER_Handle *server; - /** - * Scheduler for the server. - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * NULL-terminated array of addresses to bind to, NULL if we got pre-bound * listen sockets. @@ -1290,16 +1285,13 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct GNUNET_SERVICE_Context *sctx = cls; unsigned int i; - sctx->sched = tc->sched; if (sctx->lsocks != NULL) - sctx->server = GNUNET_SERVER_create_with_sockets (tc->sched, - &check_access, + sctx->server = GNUNET_SERVER_create_with_sockets (&check_access, sctx, sctx->lsocks, sctx->timeout, sctx->require_found); else - sctx->server = GNUNET_SERVER_create (tc->sched, - &check_access, + sctx->server = GNUNET_SERVER_create (&check_access, sctx, sctx->addrs, sctx->addrlens, @@ -1325,8 +1317,7 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { /* install a task that will kill the server process if the scheduler ever gets a shutdown signal */ - GNUNET_SCHEDULER_add_delayed (tc->sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, sctx->server); } sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers)); @@ -1354,7 +1345,7 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) i++; } } - sctx->task (sctx->task_cls, tc->sched, sctx->server, sctx->cfg); + sctx->task (sctx->task_cls, sctx->server, sctx->cfg); } @@ -1612,13 +1603,11 @@ shutdown: * initialized system. * * @param serviceName our service name - * @param sched scheduler to use * @param cfg configuration to use * @return NULL on error, service handle */ struct GNUNET_SERVICE_Context * GNUNET_SERVICE_start (const char *serviceName, - struct GNUNET_SCHEDULER_Handle *sched, const struct GNUNET_CONFIGURATION_Handle *cfg) { int i; @@ -1630,7 +1619,6 @@ GNUNET_SERVICE_start (const char *serviceName, sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL; sctx->serviceName = serviceName; sctx->cfg = cfg; - sctx->sched = sched; /* setup subsystems */ if (GNUNET_OK != setup_service (sctx)) @@ -1639,14 +1627,12 @@ GNUNET_SERVICE_start (const char *serviceName, return NULL; } if (sctx->lsocks != NULL) - sctx->server = GNUNET_SERVER_create_with_sockets (sched, - &check_access, + sctx->server = GNUNET_SERVER_create_with_sockets (&check_access, sctx, sctx->lsocks, sctx->timeout, sctx->require_found); else - sctx->server = GNUNET_SERVER_create (sched, - &check_access, + sctx->server = GNUNET_SERVER_create (&check_access, sctx, sctx->addrs, sctx->addrlens, diff --git a/src/util/test_client.c b/src/util/test_client.c index ead6751a4..3851744c2 100644 --- a/src/util/test_client.c +++ b/src/util/test_client.c @@ -150,8 +150,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #endif sa.sin_family = AF_INET; sa.sin_port = htons (PORT); - server = GNUNET_SERVER_create (tc->sched, - NULL, + server = GNUNET_SERVER_create (NULL, NULL, sap, slens, @@ -162,7 +161,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) handlers[0].callback_cls = cls; handlers[1].callback_cls = cls; GNUNET_SERVER_add_handlers (server, handlers); - client = GNUNET_CLIENT_connect (tc->sched, MYNAME, cfg); + client = GNUNET_CLIENT_connect (MYNAME, cfg); GNUNET_assert (client != NULL); GNUNET_assert (NULL != GNUNET_CLIENT_notify_transmit_ready (client, diff --git a/src/util/test_connection.c b/src/util/test_connection.c index 0cc02059d..71b37c8ac 100644 --- a/src/util/test_connection.c +++ b/src/util/test_connection.c @@ -118,8 +118,7 @@ run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test accepts connection\n"); #endif - asock = GNUNET_CONNECTION_create_from_accept (tc->sched, - NULL, NULL, ls); + asock = GNUNET_CONNECTION_create_from_accept (NULL, NULL, ls); GNUNET_assert (asock != NULL); GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); #if VERBOSE @@ -157,10 +156,9 @@ static void task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { ls = open_listen_socket (); - lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls); + lsock = GNUNET_CONNECTION_create_from_existing (ls); GNUNET_assert (lsock != NULL); - csock = GNUNET_CONNECTION_create_from_connect (tc->sched, - cfg, + csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); GNUNET_assert (csock != NULL); #if VERBOSE @@ -174,8 +172,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test prepares to accept\n"); #endif - GNUNET_SCHEDULER_add_read_net (tc->sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, ls, &run_accept, cls); } diff --git a/src/util/test_connection_addressing.c b/src/util/test_connection_addressing.c index 4c10bd074..f5328be92 100644 --- a/src/util/test_connection_addressing.c +++ b/src/util/test_connection_addressing.c @@ -115,8 +115,7 @@ run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct sockaddr_in *v4; struct sockaddr_in expect; - asock = GNUNET_CONNECTION_create_from_accept (tc->sched, - NULL, NULL, ls); + asock = GNUNET_CONNECTION_create_from_accept (NULL, NULL, ls); GNUNET_assert (asock != NULL); GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); GNUNET_assert (GNUNET_OK == @@ -153,7 +152,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct sockaddr_in v4; ls = open_listen_socket (); - lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls); + lsock = GNUNET_CONNECTION_create_from_existing (ls); GNUNET_assert (lsock != NULL); #if HAVE_SOCKADDR_IN_SIN_LEN @@ -162,8 +161,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) v4.sin_family = AF_INET; v4.sin_port = htons (PORT); v4.sin_addr.s_addr = htonl (INADDR_LOOPBACK); - csock = GNUNET_CONNECTION_create_from_sockaddr (tc->sched, - AF_INET, + csock = GNUNET_CONNECTION_create_from_sockaddr (AF_INET, (const struct sockaddr *) &v4, sizeof (v4)); GNUNET_assert (csock != NULL); @@ -173,8 +171,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_TIME_UNIT_SECONDS, &make_hello, NULL)); GNUNET_CONNECTION_destroy (csock, GNUNET_YES); - GNUNET_SCHEDULER_add_read_net (tc->sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, ls, &run_accept, cls); } diff --git a/src/util/test_connection_receive_cancel.c b/src/util/test_connection_receive_cancel.c index e4d7111d4..1e6720235 100644 --- a/src/util/test_connection_receive_cancel.c +++ b/src/util/test_connection_receive_cancel.c @@ -90,8 +90,7 @@ static void run_accept_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - asock = GNUNET_CONNECTION_create_from_accept (tc->sched, - NULL, NULL, ls); + asock = GNUNET_CONNECTION_create_from_accept (NULL, NULL, ls); GNUNET_assert (asock != NULL); GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); GNUNET_CONNECTION_destroy (lsock, GNUNET_YES); @@ -119,16 +118,14 @@ static void task_receive_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { ls = open_listen_socket (); - lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls); + lsock = GNUNET_CONNECTION_create_from_existing (ls); GNUNET_assert (lsock != NULL); - csock = GNUNET_CONNECTION_create_from_connect (tc->sched, cfg, + csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); GNUNET_assert (csock != NULL); - GNUNET_SCHEDULER_add_read_net (tc->sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, ls, &run_accept_cancel, cls); - GNUNET_SCHEDULER_add_delayed (tc->sched, - GNUNET_TIME_UNIT_SECONDS, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &receive_cancel_task, cls); } diff --git a/src/util/test_connection_timeout.c b/src/util/test_connection_timeout.c index 5291ad3c4..0e2190e41 100644 --- a/src/util/test_connection_timeout.c +++ b/src/util/test_connection_timeout.c @@ -107,9 +107,9 @@ task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { ls = open_listen_socket (); - lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls); + lsock = GNUNET_CONNECTION_create_from_existing (ls); GNUNET_assert (lsock != NULL); - csock = GNUNET_CONNECTION_create_from_connect (tc->sched, cfg, + csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); GNUNET_assert (csock != NULL); GNUNET_assert (NULL != diff --git a/src/util/test_connection_timeout_no_connect.c b/src/util/test_connection_timeout_no_connect.c index 468e965ca..3519f197b 100644 --- a/src/util/test_connection_timeout_no_connect.c +++ b/src/util/test_connection_timeout_no_connect.c @@ -53,7 +53,7 @@ handle_timeout (void *cls, size_t size, void *buf) static void task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - csock = GNUNET_CONNECTION_create_from_connect (tc->sched, cfg, + csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); GNUNET_assert (csock != NULL); GNUNET_assert (NULL != diff --git a/src/util/test_connection_transmit_cancel.c b/src/util/test_connection_transmit_cancel.c index d4456b00d..72e27243b 100644 --- a/src/util/test_connection_transmit_cancel.c +++ b/src/util/test_connection_transmit_cancel.c @@ -50,7 +50,7 @@ task_transmit_cancel (void *cls, struct GNUNET_CONNECTION_TransmitHandle *th; struct GNUNET_CONNECTION_Handle *csock; - csock = GNUNET_CONNECTION_create_from_connect (tc->sched, cfg, + csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); GNUNET_assert (csock != NULL); th = GNUNET_CONNECTION_notify_transmit_ready (csock, diff --git a/src/util/test_crypto_hash.c b/src/util/test_crypto_hash.c index 33f19c804..85de9fbbb 100644 --- a/src/util/test_crypto_hash.c +++ b/src/util/test_crypto_hash.c @@ -123,8 +123,7 @@ static void file_hasher (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_assert (NULL != - GNUNET_CRYPTO_hash_file (tc->sched, - GNUNET_SCHEDULER_PRIORITY_DEFAULT, + GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_DEFAULT, FILENAME, 1024, &finished_task, cls)); } diff --git a/src/util/test_disk.c b/src/util/test_disk.c index 9a5ea3a57..fb79e7cd8 100644 --- a/src/util/test_disk.c +++ b/src/util/test_disk.c @@ -169,8 +169,7 @@ iter_callback (void *cls, static void iter_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - GNUNET_DISK_directory_iterator_start (tc->sched, - GNUNET_SCHEDULER_PRIORITY_DEFAULT, + GNUNET_DISK_directory_iterator_start (GNUNET_SCHEDULER_PRIORITY_DEFAULT, "test", &iter_callback, cls); } diff --git a/src/util/test_os_start_process.c b/src/util/test_os_start_process.c index bce1c7151..f82860e83 100644 --- a/src/util/test_os_start_process.c +++ b/src/util/test_os_start_process.c @@ -78,8 +78,8 @@ read_call (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_break (0); ok = 1; - GNUNET_SCHEDULER_cancel(tc->sched, die_task); - GNUNET_SCHEDULER_add_now(tc->sched, &end_task, NULL); + GNUNET_SCHEDULER_cancel(die_task); + GNUNET_SCHEDULER_add_now(&end_task, NULL); return; } @@ -89,13 +89,12 @@ read_call (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #endif if (ok == 0) { - GNUNET_SCHEDULER_cancel(tc->sched, die_task); - GNUNET_SCHEDULER_add_now(tc->sched, &end_task, NULL); + GNUNET_SCHEDULER_cancel(die_task); + GNUNET_SCHEDULER_add_now(&end_task, NULL); return; } - GNUNET_SCHEDULER_add_read_file (tc->sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, stdout_read_handle, &read_call, stdout_read_handle); } @@ -145,10 +144,9 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) stdout_read_handle = GNUNET_DISK_pipe_handle(hello_pipe_stdout, GNUNET_DISK_PIPE_END_READ); - die_task = GNUNET_SCHEDULER_add_delayed(tc->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 1), &end_task, NULL); + die_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 1), &end_task, NULL); - GNUNET_SCHEDULER_add_read_file (tc->sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, stdout_read_handle, &read_call, (void *)stdout_read_handle); } diff --git a/src/util/test_program.c b/src/util/test_program.c index e7745abff..33a6b50ea 100644 --- a/src/util/test_program.c +++ b/src/util/test_program.c @@ -58,13 +58,11 @@ static struct GNUNET_GETOPT_CommandLineOption options4[] = { static void runner (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { int *ok = cls; GNUNET_assert (setme1 == 1); - GNUNET_assert (sched != NULL); GNUNET_assert (0 == strcmp (args[0], "extra")); GNUNET_assert (args[1] == NULL); GNUNET_assert (0 == strcmp (cfgfile, "test_program_data.conf")); diff --git a/src/util/test_resolver_api.c b/src/util/test_resolver_api.c index 734420e84..bf2f8f00f 100644 --- a/src/util/test_resolver_api.c +++ b/src/util/test_resolver_api.c @@ -219,7 +219,7 @@ check_rootserver_name(void *cls, const char *hostname) } static void -run(void *cls, struct GNUNET_SCHEDULER_Handle *sched, char * const *args, +run(void *cls, char * const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { int *ok = cls; @@ -232,13 +232,13 @@ run(void *cls, struct GNUNET_SCHEDULER_Handle *sched, char * const *args, memset(&sa, 0, sizeof(sa)); sa.sin_family = AF_INET; sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - GNUNET_RESOLVER_ip_get(sched, cfg, "localhost", AF_INET, timeout, &check_127, + GNUNET_RESOLVER_ip_get(cfg, "localhost", AF_INET, timeout, &check_127, cls); - GNUNET_RESOLVER_hostname_get(sched, cfg, (const struct sockaddr *) &sa, + GNUNET_RESOLVER_hostname_get(cfg, (const struct sockaddr *) &sa, sizeof(struct sockaddr), GNUNET_YES, timeout, &check_localhost, cls); - GNUNET_RESOLVER_hostname_get(sched, cfg, (const struct sockaddr *) &sa, + GNUNET_RESOLVER_hostname_get(cfg, (const struct sockaddr *) &sa, sizeof(struct sockaddr), GNUNET_NO, timeout, &check_localhost_num, cls); - GNUNET_RESOLVER_hostname_resolve(sched, cfg, AF_UNSPEC, timeout, + GNUNET_RESOLVER_hostname_resolve(cfg, AF_UNSPEC, timeout, &check_hostname, cls); @@ -297,7 +297,7 @@ run(void *cls, struct GNUNET_SCHEDULER_Handle *sched, char * const *args, #endif /* Resolve the same using GNUNET */ - GNUNET_RESOLVER_ip_get(sched, cfg, ROOTSERVER_NAME, AF_INET, timeout, + GNUNET_RESOLVER_ip_get(cfg, ROOTSERVER_NAME, AF_INET, timeout, &check_rootserver_ip, cls); /* @@ -350,7 +350,7 @@ run(void *cls, struct GNUNET_SCHEDULER_Handle *sched, char * const *args, #else sa.sin_addr.S_un.S_addr = inet_addr(ROOTSERVER_IP); #endif - GNUNET_RESOLVER_hostname_get(sched, cfg, (const struct sockaddr *) &sa, + GNUNET_RESOLVER_hostname_get(cfg, (const struct sockaddr *) &sa, sizeof(struct sockaddr), GNUNET_YES, timeout, &check_rootserver_name, cls); } diff --git a/src/util/test_scheduler.c b/src/util/test_scheduler.c index 0ac186588..f0c908d7d 100644 --- a/src/util/test_scheduler.c +++ b/src/util/test_scheduler.c @@ -34,8 +34,7 @@ task3 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { int *ok = cls; /* t4 should be ready (albeit with lower priority) */ - GNUNET_assert (1 == GNUNET_SCHEDULER_get_load (tc->sched, - GNUNET_SCHEDULER_PRIORITY_COUNT)); + GNUNET_assert (1 == GNUNET_SCHEDULER_get_load (GNUNET_SCHEDULER_PRIORITY_COUNT)); GNUNET_assert (3 == *ok); (*ok) = 4; } @@ -48,8 +47,7 @@ task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (2 == *ok); (*ok) = 3; /* t3 will go before t4: higher priority */ - GNUNET_SCHEDULER_add_with_priority (tc->sched, - GNUNET_SCHEDULER_PRIORITY_UI, + GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, &task3, cls); } @@ -101,10 +99,9 @@ taskRd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0])); GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1)); (*ok) = 8; - GNUNET_SCHEDULER_add_with_priority (tc->sched, - GNUNET_SCHEDULER_PRIORITY_IDLE, + GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, &taskLast, cls); - GNUNET_SCHEDULER_shutdown (tc->sched); + GNUNET_SCHEDULER_shutdown (); } @@ -118,11 +115,9 @@ task5 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (NULL != p); fds[0] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_READ); fds[1] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_WRITE); - GNUNET_SCHEDULER_add_read_file (tc->sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, fds[0], &taskRd, cls); - GNUNET_SCHEDULER_add_write_file (tc->sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, fds[1], &taskWrt, cls); } @@ -137,12 +132,11 @@ task1 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (1 == *ok); (*ok) = 2; /* t2 will go first -- prereq for all */ - t2 = GNUNET_SCHEDULER_add_after (tc->sched, - GNUNET_SCHEDULER_NO_TASK, &task2, cls); + t2 = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, &task2, cls); /* t4 will go after t2 ('add after') and after t3 (priority) */ - t4 = GNUNET_SCHEDULER_add_after (tc->sched, t2, &task4, cls); + t4 = GNUNET_SCHEDULER_add_after (t2, &task4, cls); /* t5 will go last (after p4) */ - GNUNET_SCHEDULER_add_after (tc->sched, t4, &task5, cls); + GNUNET_SCHEDULER_add_after (t4, &task5, cls); } @@ -168,9 +162,8 @@ taskShutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) int *ok = cls; GNUNET_assert (1 == *ok); *ok = 8; - GNUNET_SCHEDULER_add_delayed (tc->sched, - GNUNET_TIME_UNIT_FOREVER_REL, &taskLast, cls); - GNUNET_SCHEDULER_shutdown (tc->sched); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &taskLast, cls); + GNUNET_SCHEDULER_shutdown (); } @@ -195,8 +188,7 @@ taskSig (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) int *ok = cls; GNUNET_assert (1 == *ok); *ok = 8; - GNUNET_SCHEDULER_add_delayed (tc->sched, - GNUNET_TIME_UNIT_FOREVER_REL, &taskLast, cls); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &taskLast, cls); GNUNET_break (0 == PLIBC_KILL (getpid (), SIGTERM)); } @@ -223,9 +215,7 @@ taskCancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (1 == *ok); *ok = 0; - GNUNET_SCHEDULER_cancel (tc->sched, - GNUNET_SCHEDULER_add_after (tc->sched, - GNUNET_SCHEDULER_NO_TASK, + GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, &taskNeverRun, NULL)); } diff --git a/src/util/test_scheduler_delay.c b/src/util/test_scheduler_delay.c index 24d30be99..1f60ca9fd 100644 --- a/src/util/test_scheduler_delay.c +++ b/src/util/test_scheduler_delay.c @@ -65,8 +65,7 @@ test_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) fprintf (stderr, "\n"); return; } - GNUNET_SCHEDULER_add_delayed (tc->sched, - GNUNET_TIME_relative_multiply + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, i), &test_task, NULL); i += INCR; diff --git a/src/util/test_server.c b/src/util/test_server.c index 78e2d52bf..00d4352f8 100644 --- a/src/util/test_server.c +++ b/src/util/test_server.c @@ -45,8 +45,6 @@ static struct GNUNET_SERVER_Client *argclient; static struct GNUNET_CONFIGURATION_Handle *cfg; -static struct GNUNET_SCHEDULER_Handle *sched; - static int ok; @@ -70,8 +68,7 @@ recv_fin_cb (void *cls, GNUNET_assert (ok == 5); ok = 6; GNUNET_SERVER_receive_done (client, GNUNET_OK); - GNUNET_SCHEDULER_add_now (sched, - &finish_up, + GNUNET_SCHEDULER_add_now (&finish_up, NULL); } @@ -181,15 +178,13 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) slens[0] = sizeof (sa); sap[1] = NULL; slens[1] = 0; - sched = tc->sched; memset (&sa, 0, sizeof (sa)); #if HAVE_SOCKADDR_IN_SIN_LEN sa.sin_len = sizeof (sa); #endif sa.sin_family = AF_INET; sa.sin_port = htons (PORT); - server = GNUNET_SERVER_create (tc->sched, - NULL, + server = GNUNET_SERVER_create (NULL, NULL, sap, slens, @@ -201,8 +196,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_CONFIGURATION_set_value_number (cfg, "test-server", "PORT", PORT); GNUNET_CONFIGURATION_set_value_string (cfg, "test-server", "HOSTNAME", "localhost"); GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", "localhost"); - cc = GNUNET_CLIENT_connect (tc->sched, - "test-server", + cc = GNUNET_CLIENT_connect ("test-server", cfg); GNUNET_assert (cc != NULL); GNUNET_assert (NULL != diff --git a/src/util/test_server_disconnect.c b/src/util/test_server_disconnect.c index 2fef5642e..8ab8ef35b 100644 --- a/src/util/test_server_disconnect.c +++ b/src/util/test_server_disconnect.c @@ -42,8 +42,6 @@ static struct GNUNET_CLIENT_Connection *cc; static struct GNUNET_CONFIGURATION_Handle *cfg; -static struct GNUNET_SCHEDULER_Handle *sched; - static int ok; @@ -66,8 +64,7 @@ notify_disconnect (void *cls, struct GNUNET_SERVER_Client *clientarg) return; GNUNET_assert (ok == 4); ok = 5; - GNUNET_SCHEDULER_add_now (sched, - &finish_up, + GNUNET_SCHEDULER_add_now (&finish_up, NULL); } @@ -91,8 +88,7 @@ recv_cb (void *cls, GNUNET_assert (ok == 2); ok = 3; GNUNET_SERVER_client_keep (client); - GNUNET_SCHEDULER_add_now (sched, - &server_disconnect, client); + GNUNET_SCHEDULER_add_now (&server_disconnect, client); GNUNET_assert (sizeof (struct GNUNET_MessageHeader) == ntohs (message->size)); GNUNET_assert (MY_TYPE == ntohs (message->type)); @@ -134,15 +130,13 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) slens[0] = sizeof (sa); sap[1] = NULL; slens[1] = 0; - sched = tc->sched; memset (&sa, 0, sizeof (sa)); #if HAVE_SOCKADDR_IN_SIN_LEN sa.sin_len = sizeof (sa); #endif sa.sin_family = AF_INET; sa.sin_port = htons (PORT); - server = GNUNET_SERVER_create (tc->sched, - NULL, + server = GNUNET_SERVER_create (NULL, NULL, sap, slens, @@ -155,8 +149,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_CONFIGURATION_set_value_number (cfg, "test-server", "PORT", PORT); GNUNET_CONFIGURATION_set_value_string (cfg, "test-server", "HOSTNAME", "localhost"); GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", "localhost"); - cc = GNUNET_CLIENT_connect (tc->sched, - "test-server", + cc = GNUNET_CLIENT_connect ("test-server", cfg); GNUNET_assert (cc != NULL); GNUNET_assert (NULL != diff --git a/src/util/test_server_with_client.c b/src/util/test_server_with_client.c index 4157be250..5c36b7b03 100644 --- a/src/util/test_server_with_client.c +++ b/src/util/test_server_with_client.c @@ -41,8 +41,6 @@ static struct GNUNET_SERVER_Handle *server; static struct GNUNET_CLIENT_Connection *client; -static struct GNUNET_SCHEDULER_Handle *sched; - static struct GNUNET_CONFIGURATION_Handle *cfg; static int ok; @@ -86,8 +84,7 @@ recv_cb (void *cls, { case 2: ok++; - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_relative_multiply + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 50), &send_done, argclient); break; @@ -127,8 +124,7 @@ notify_disconnect (void *cls, struct GNUNET_SERVER_Client *client) return; GNUNET_assert (ok == 5); ok = 0; - GNUNET_SCHEDULER_add_now (sched, - &clean_up, NULL); + GNUNET_SCHEDULER_add_now (&clean_up, NULL); } @@ -167,15 +163,13 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) slens[0] = sizeof (sa); sap[1] = NULL; slens[1] = 0; - sched = tc->sched; memset (&sa, 0, sizeof (sa)); #if HAVE_SOCKADDR_IN_SIN_LEN sa.sin_len = sizeof (sa); #endif sa.sin_family = AF_INET; sa.sin_port = htons (PORT); - server = GNUNET_SERVER_create (tc->sched, - NULL, + server = GNUNET_SERVER_create (NULL, NULL, sap, slens, @@ -192,7 +186,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) "localhost"); GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", "localhost"); - client = GNUNET_CLIENT_connect (tc->sched, "test", cfg); + client = GNUNET_CLIENT_connect ("test", cfg); GNUNET_assert (client != NULL); GNUNET_CLIENT_notify_transmit_ready (client, 256, diff --git a/src/util/test_service.c b/src/util/test_service.c index 6c78a4eb9..9bd58352b 100644 --- a/src/util/test_service.c +++ b/src/util/test_service.c @@ -37,8 +37,6 @@ #define MY_TYPE 256 -static struct GNUNET_SCHEDULER_Handle *sched; - static struct GNUNET_SERVICE_Context *sctx; static int ok = 1; @@ -67,8 +65,7 @@ ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service confirmed running\n"); - sched = tc->sched; - client = GNUNET_CLIENT_connect (tc->sched, "test_service", cfg); + client = GNUNET_CLIENT_connect ("test_service", cfg); GNUNET_assert (client != NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client connecting, waiting to transmit\n"); @@ -94,9 +91,9 @@ recv_cb (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving client message...\n"); GNUNET_SERVER_receive_done (client, GNUNET_OK); if (sctx != NULL) - GNUNET_SCHEDULER_add_now (sched, &do_stop, NULL); + GNUNET_SCHEDULER_add_now (&do_stop, NULL); else - GNUNET_SCHEDULER_shutdown (sched); + GNUNET_SCHEDULER_shutdown (); ok = 0; } @@ -110,14 +107,12 @@ static struct GNUNET_SERVER_MessageHandler myhandlers[] = { static void runner (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service initializing\n"); GNUNET_SERVER_add_handlers (server, myhandlers); - GNUNET_CLIENT_service_test (sched, - "test_service", + GNUNET_CLIENT_service_test ("test_service", cfg, GNUNET_TIME_UNIT_SECONDS, &ready, (void *) cfg); } @@ -161,9 +156,8 @@ ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct GNUNET_CLIENT_Connection *client; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 ready\n"); - sched = tc->sched; GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); - client = GNUNET_CLIENT_connect (tc->sched, "test_service6", cfg); + client = GNUNET_CLIENT_connect ("test_service6", cfg); GNUNET_assert (client != NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 client connected\n"); GNUNET_CLIENT_notify_transmit_ready (client, @@ -174,14 +168,12 @@ ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void runner6 (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initializing v6 service\n"); GNUNET_SERVER_add_handlers (server, myhandlers); - GNUNET_CLIENT_service_test (sched, - "test_service6", + GNUNET_CLIENT_service_test ("test_service6", cfg, GNUNET_TIME_UNIT_SECONDS, &ready6, (void *) cfg); } @@ -220,7 +212,6 @@ check6 () static void start_stop_main (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -228,9 +219,9 @@ start_stop_main (void *cls, int *ret = cls; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting service using start method\n"); - sctx = GNUNET_SERVICE_start ("test_service", sched, cfg); + sctx = GNUNET_SERVICE_start ("test_service", cfg); GNUNET_assert (NULL != sctx); - runner (cls, sched, GNUNET_SERVICE_get_server (sctx), cfg); + runner (cls, GNUNET_SERVICE_get_server (sctx), cfg); *ret = 0; } diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c index d4ff33b9c..f6a20f8a6 100644 --- a/src/vpn/gnunet-daemon-vpn.c +++ b/src/vpn/gnunet-daemon-vpn.c @@ -21,7 +21,7 @@ /** * @file vpn/gnunet-daemon-vpn.c * @brief - * @author Philipp Tölke + * @author Philipp Toelke */ #include "platform.h" #include "gnunet_getopt_lib.h" @@ -43,11 +43,6 @@ */ static int ret; -/** - * The scheduler to use throughout the daemon - */ -static struct GNUNET_SCHEDULER_Handle *sched; - /** * The configuration to use */ @@ -222,7 +217,7 @@ start_helper_and_schedule(void *cls, restart_hijack = 1; GNUNET_CLIENT_notify_transmit_ready(dns_connection, sizeof(struct GNUNET_MessageHeader), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, NULL); - GNUNET_SCHEDULER_add_read_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, fh_from_helper, &helper_read, NULL); + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, fh_from_helper, &helper_read, NULL); } /** @@ -240,7 +235,7 @@ restart_helper(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) { GNUNET_DISK_pipe_close(helper_out); /* Restart the helper */ - GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_UNIT_SECONDS, start_helper_and_schedule, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, start_helper_and_schedule, NULL); } /** @@ -259,13 +254,13 @@ helper_read(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tsdkctx) { /* On read-error, restart the helper */ if (t<=0) { GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Read error for header from vpn-helper: %m\n"); - GNUNET_SCHEDULER_add_now(sched, restart_helper, cls); + GNUNET_SCHEDULER_add_now(restart_helper, cls); return; } /* FIXME */ GNUNET_SERVER_mst_receive(mst, NULL, buf, t, 0, 0); - GNUNET_SCHEDULER_add_read_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, fh_from_helper, &helper_read, NULL); + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, fh_from_helper, &helper_read, NULL); } /** @@ -343,8 +338,7 @@ helper_write(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tsdkctx) { /* if more packets are available, reschedule */ if (answer_proc_head != NULL) - GNUNET_SCHEDULER_add_write_file (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, fh_to_helper, &helper_write, NULL); @@ -429,7 +423,7 @@ message_token(void *cls, memcpy(pkt6_icmp, pkt6, ntohs(pkt6->shdr.size)); /* If this packet is an icmp-echo-request and a mapping exists, answer */ if (pkt6_icmp->icmp_hdr.type == 0x80 && address_mapping_exists(pkt6->ip6_hdr.sadr)) - GNUNET_SCHEDULER_add_now(sched, &send_icmp_response, pkt6_icmp); + GNUNET_SCHEDULER_add_now(&send_icmp_response, pkt6_icmp); break; } } @@ -477,7 +471,7 @@ connect_to_service_dns (void *cls, return; GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connecting to service-dns\n"); GNUNET_assert (dns_connection == NULL); - dns_connection = GNUNET_CLIENT_connect (sched, "dns", cfg); + dns_connection = GNUNET_CLIENT_connect ("dns", cfg); GNUNET_CLIENT_receive(dns_connection, &dns_answer_handler, NULL, GNUNET_TIME_UNIT_FOREVER_REL); /* If a packet is already in the list, schedule to send it */ @@ -565,7 +559,7 @@ process_answer(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tc) { GNUNET_CONTAINER_DLL_insert_after(answer_proc_head, answer_proc_tail, answer_proc_tail, list); - GNUNET_SCHEDULER_add_write_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, fh_to_helper, &helper_write, NULL); + GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, fh_to_helper, &helper_write, NULL); return; } @@ -581,8 +575,7 @@ dns_answer_handler(void* cls, const struct GNUNET_MessageHeader *msg) { { GNUNET_CLIENT_disconnect(dns_connection, GNUNET_NO); dns_connection = NULL; - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_SECONDS, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &connect_to_service_dns, NULL); return; @@ -594,8 +587,7 @@ dns_answer_handler(void* cls, const struct GNUNET_MessageHeader *msg) { GNUNET_break (0); GNUNET_CLIENT_disconnect(dns_connection, GNUNET_NO); dns_connection = NULL; - GNUNET_SCHEDULER_add_now (sched, - &connect_to_service_dns, + GNUNET_SCHEDULER_add_now (&connect_to_service_dns, NULL); return; } @@ -603,7 +595,7 @@ dns_answer_handler(void* cls, const struct GNUNET_MessageHeader *msg) { memcpy(pkt, msg, ntohs(msg->size)); - GNUNET_SCHEDULER_add_now(sched, process_answer, pkt); + GNUNET_SCHEDULER_add_now(process_answer, pkt); GNUNET_CLIENT_receive(dns_connection, &dns_answer_handler, NULL, GNUNET_TIME_UNIT_FOREVER_REL); } @@ -611,24 +603,21 @@ dns_answer_handler(void* cls, const struct GNUNET_MessageHeader *msg) { * Main function that will be run by the scheduler. * * @param cls closure - * @param sched the scheduler to use * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param cfg configuration */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched_, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg_) { - sched = sched_; mst = GNUNET_SERVER_mst_create(&message_token, NULL); cfg = cfg_; restart_hijack = 0; - GNUNET_SCHEDULER_add_now (sched, connect_to_service_dns, NULL); - GNUNET_SCHEDULER_add_now (sched, start_helper_and_schedule, NULL); - GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls); + GNUNET_SCHEDULER_add_now (connect_to_service_dns, NULL); + GNUNET_SCHEDULER_add_now (start_helper_and_schedule, NULL); + GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls); } /** diff --git a/src/vpn/gnunet-service-dns.c b/src/vpn/gnunet-service-dns.c index 7997112c4..f8b1209e9 100644 --- a/src/vpn/gnunet-service-dns.c +++ b/src/vpn/gnunet-service-dns.c @@ -39,10 +39,6 @@ #include "gnunet_crypto_lib.h" #include "gnunet_signatures.h" -/** - * The scheduler to use throughout the service - */ -static struct GNUNET_SCHEDULER_Handle *sched; /** * The UDP-Socket through which DNS-Resolves will be sent if they are not to be @@ -107,17 +103,17 @@ struct receive_dht_cls { * Hijack all outgoing DNS-Traffic but for traffic leaving "our" port. */ static void -hijack(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tc) { +hijack(unsigned short port) { char port_s[6]; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Hijacking, port is %d\n", dnsoutport); - snprintf(port_s, 6, "%d", dnsoutport); - GNUNET_OS_process_close (GNUNET_OS_start_process(NULL, - NULL, - "gnunet-helper-hijack-dns", - "gnunet-hijack-dns", - port_s, - NULL)); + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Hijacking, port is %d\n", port); + snprintf(port_s, 6, "%d", port); + GNUNET_OS_start_process(NULL, + NULL, + "gnunet-helper-hijack-dns", + "gnunet-hijack-dns", + port_s, + NULL); } /** @@ -166,81 +162,6 @@ send_answer(void* cls, size_t size, void* buf) { return len; } -static void -send_rev_query(void * cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - struct dns_pkt_parsed* pdns = (struct dns_pkt_parsed*) cls; - - unsigned short id = pdns->s.id; - - if (query_states[id].valid != GNUNET_YES) return; - query_states[id].valid = GNUNET_NO; - - GNUNET_assert(query_states[id].namelen == 74); - - size_t len = sizeof(struct answer_packet) - 1 \ - + sizeof(struct dns_static) \ - + 74 /* this is the length of a reverse ipv6-lookup */ \ - + sizeof(struct dns_query_line) \ - + 2 /* To hold the pointer (as defined in RFC1035) to the name */ \ - + sizeof(struct dns_record_line) - 1 \ - - 2 /* We do not know the lenght of the answer yet*/ \ - - 2 /* No idea why... */ ; - - struct answer_packet_list* answer = GNUNET_malloc(len + 2*sizeof(struct answer_packet_list*)); - memset(answer, 0, len + 2*sizeof(struct answer_packet_list*)); - - answer->pkt.hdr.type = htons(GNUNET_MESSAGE_TYPE_LOCAL_RESPONSE_DNS); - answer->pkt.hdr.size = htons(len); - answer->pkt.subtype = GNUNET_DNS_ANSWER_TYPE_REV; - - answer->pkt.from = query_states[id].remote_ip; - - answer->pkt.to = query_states[id].local_ip; - answer->pkt.dst_port = query_states[id].local_port; - - struct dns_pkt *dpkt = (struct dns_pkt*)answer->pkt.data; - - dpkt->s.id = id; - dpkt->s.aa = 1; - dpkt->s.qr = 1; - dpkt->s.ra = 1; - dpkt->s.qdcount = htons(1); - dpkt->s.ancount = htons(1); - - memcpy(dpkt->data, query_states[id].name, query_states[id].namelen); - GNUNET_free(query_states[id].name); - - struct dns_query_line* dque = (struct dns_query_line*)(dpkt->data+(query_states[id].namelen)); - dque->type = htons(12); /* PTR */ - dque->class = htons(1); /* IN */ - - char* anname = (char*)(dpkt->data+(query_states[id].namelen)+sizeof(struct dns_query_line)); - memcpy(anname, (char[]){0xc0, 0x0c}, 2); - - struct dns_record_line *drec_data = (struct dns_record_line*)(dpkt->data+(query_states[id].namelen)+sizeof(struct dns_query_line)+2); - drec_data->type = htons(12); /* AAAA */ - drec_data->class = htons(1); /* IN */ - drec_data->ttl = htonl(3600); /* FIXME: read from block */ - - /* Calculate at which offset in the packet the length of the name and the - * name, it is filled in by the daemon-vpn */ - answer->pkt.addroffset = htons((unsigned short)((unsigned long)(&drec_data->data_len)-(unsigned long)(&answer->pkt))); - - GNUNET_CONTAINER_DLL_insert_after(head, tail, tail, answer); - - GNUNET_SERVER_notify_transmit_ready(query_states[id].client, - len, - GNUNET_TIME_UNIT_FOREVER_REL, - &send_answer, - query_states[id].client); - - /* - * build - * complete dns-packet with empty name in the answer - * provide offsett of the name - */ -} - /** * Receive a block from the dht. */ @@ -315,6 +236,7 @@ receive_dht(void *cls, memcpy(dpkt->data, query_states[id].name, query_states[id].namelen); GNUNET_free(query_states[id].name); + struct dns_query_line* dque = (struct dns_query_line*)(dpkt->data+(query_states[id].namelen)); dque->type = htons(28); /* AAAA */ dque->class = htons(1); /* IN */ @@ -351,9 +273,7 @@ rehijack(void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { unhijack(dnsoutport); - GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_UNIT_SECONDS, hijack, NULL); - - GNUNET_SERVER_receive_done(client, GNUNET_OK); + hijack(dnsoutport); } /** @@ -376,7 +296,6 @@ receive_query(void *cls, query_states[dns->s.id].name = GNUNET_malloc(query_states[dns->s.id].namelen); memcpy(query_states[dns->s.id].name, dns->data, query_states[dns->s.id].namelen); - /* The query is for a .gnunet-address */ if (pdns->queries[0]->namelen > 9 && 0 == strncmp(pdns->queries[0]->name+(pdns->queries[0]->namelen - 9), ".gnunet.", 9)) { @@ -404,18 +323,6 @@ receive_query(void *cls, receive_dht, cls); - goto outfree; - } - - /* The query is for a PTR of a previosly resolved virtual IP */ - if (htons(pdns->queries[0]->qtype) == 12 && - pdns->queries[0]->namelen > 19 && - 0 == strncmp(pdns->queries[0]->name+(pdns->queries[0]->namelen - 19), ".4.3.2.1.ip6.arpa.", 19)) - { - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Reverse-Query for .gnunet!\n"); - - GNUNET_SCHEDULER_add_now(sched, send_rev_query, pdns); - goto out; } @@ -432,10 +339,9 @@ receive_query(void *cls, (struct sockaddr*) &dest, sizeof dest); -outfree: +out: free_parsed_dns_packet(pdns); pdns = NULL; -out: GNUNET_SERVER_receive_done(client, GNUNET_OK); } @@ -485,8 +391,7 @@ read_response (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { query_states[dns->s.id].client); } - GNUNET_SCHEDULER_add_read_net(sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_read_net(GNUNET_TIME_UNIT_FOREVER_REL, dnsout, &read_response, NULL); @@ -567,21 +472,18 @@ publish_name (void *cls, NULL, NULL); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_HOURS, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_HOURS, publish_name, NULL); } /** * @param cls closure - * @param sched scheduler to use * @param server the initialized server * @param cfg configuration to use */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched_, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg_) { @@ -593,14 +495,13 @@ run (void *cls, }; cfg = cfg_; - sched = sched_; unsigned int i; for (i = 0; i < 65536; i++) { query_states[i].valid = GNUNET_NO; } - dht = GNUNET_DHT_connect(sched, cfg, 1024); + dht = GNUNET_DHT_connect(cfg, 1024); struct sockaddr_in addr; @@ -626,13 +527,14 @@ run (void *cls, dnsoutport = htons(addr.sin_port); - GNUNET_SCHEDULER_add_now (sched, publish_name, NULL); + hijack(htons(addr.sin_port)); + + GNUNET_SCHEDULER_add_now (publish_name, NULL); - GNUNET_SCHEDULER_add_read_net(sched, GNUNET_TIME_UNIT_FOREVER_REL, dnsout, &read_response, NULL); + GNUNET_SCHEDULER_add_read_net(GNUNET_TIME_UNIT_FOREVER_REL, dnsout, &read_response, NULL); GNUNET_SERVER_add_handlers (server, handlers); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, cls); } -- cgit v1.2.3