From b272a833ee57cad630ecbcce1aab366777042dd9 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 19 Apr 2012 12:07:05 +0000 Subject: [PATCH] -fixing #2274 -- eliminating GNUNET_SCHEDULER_add_after --- src/dns/gnunet-service-dns.c | 2 - src/gns/gnunet-gns-fcfsd.c | 2 +- src/hostlist/hostlist-client.c | 2 +- src/hostlist/hostlist-server.c | 2 +- src/include/gnunet_scheduler_lib.h | 30 +------------ .../gnunet-service-transport_blacklist.c | 6 +-- .../gnunet-service-transport_clients.c | 4 +- src/transport/plugin_transport_http_client.c | 2 +- src/transport/plugin_transport_http_server.c | 4 +- src/transport/plugin_transport_udp.c | 8 ---- src/transport/plugin_transport_unix.c | 3 -- src/util/scheduler.c | 43 +++--------------- src/util/server.c | 3 -- src/util/test_scheduler.c | 44 ++++++------------- 14 files changed, 32 insertions(+), 123 deletions(-) diff --git a/src/dns/gnunet-service-dns.c b/src/dns/gnunet-service-dns.c index fbb27e4bc..1fc201ff9 100644 --- a/src/dns/gnunet-service-dns.c +++ b/src/dns/gnunet-service-dns.c @@ -734,7 +734,6 @@ get_request_socket (int af) if (NULL != rs->dnsout6) GNUNET_NETWORK_fdset_set (rset, rs->dnsout6); rs->read_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, REQUEST_TIMEOUT, rset, NULL, @@ -1100,7 +1099,6 @@ read_response (void *cls, if (NULL != rs->dnsout6) GNUNET_NETWORK_fdset_set (rset, rs->dnsout6); rs->read_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_absolute_get_remaining (rs->timeout), rset, NULL, diff --git a/src/gns/gnunet-gns-fcfsd.c b/src/gns/gnunet-gns-fcfsd.c index 8d6a58302..7e099df62 100644 --- a/src/gns/gnunet-gns-fcfsd.c +++ b/src/gns/gnunet-gns-fcfsd.c @@ -642,7 +642,7 @@ run_httpd () GNUNET_NETWORK_fdset_copy_native (wes, &es, max + 1); httpd_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH, - GNUNET_SCHEDULER_NO_TASK, tv, wrs, wws, + tv, wrs, wws, &do_httpd, NULL); GNUNET_NETWORK_fdset_destroy (wrs); GNUNET_NETWORK_fdset_destroy (wws); diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index 350a0baee..5d3f037b3 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c @@ -766,7 +766,7 @@ download_prepare () #endif ti_download = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, rtime, grs, gws, + rtime, grs, gws, &task_download, multi); GNUNET_NETWORK_fdset_destroy (gws); GNUNET_NETWORK_fdset_destroy (grs); diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c index e7bddbbf3..c38830ca0 100644 --- a/src/hostlist/hostlist-server.c +++ b/src/hostlist/hostlist-server.c @@ -512,7 +512,7 @@ prepare_daemon (struct MHD_Daemon *daemon_handle) GNUNET_NETWORK_fdset_copy_native (wes, &es, max + 1); ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH, - GNUNET_SCHEDULER_NO_TASK, tv, wrs, wws, + tv, wrs, wws, &run_daemon, daemon_handle); GNUNET_NETWORK_fdset_destroy (wrs); GNUNET_NETWORK_fdset_destroy (wws); diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h index e16ccc511..c0b33a400 100644 --- a/src/include/gnunet_scheduler_lib.h +++ b/src/include/gnunet_scheduler_lib.h @@ -308,26 +308,6 @@ GNUNET_SCHEDULER_add_continuation_with_priority (GNUNET_SCHEDULER_Task task, voi enum GNUNET_SCHEDULER_Priority priority); -/** - * Schedule a new task to be run after the specified prerequisite task - * has completed. It will be run with DEFAULT priority. - * - * * @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 - * on completion of other tasks (this will cause the task to run as - * soon as possible). - * @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_after (GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, - GNUNET_SCHEDULER_Task task, void *task_cls); - - /** * Schedule a new task to be run with a specified priority. * @@ -511,12 +491,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, * || shutdown-active) * * - * * @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 - * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency - * on completion of other tasks. + * @param prio how important is this task? * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever", * which means that the task will only be run after we receive SIGTERM * @param rs set of file descriptors we want to read (can be NULL) @@ -527,8 +502,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, * only valid until "task" is started! */ GNUNET_SCHEDULER_TaskIdentifier -GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, - GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, +GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, struct GNUNET_TIME_Relative delay, const struct GNUNET_NETWORK_FDSet *rs, const struct GNUNET_NETWORK_FDSet *ws, diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c index 10362681c..44a029474 100644 --- a/src/transport/gnunet-service-transport_blacklist.c +++ b/src/transport/gnunet-service-transport_blacklist.c @@ -113,7 +113,7 @@ struct GST_BlacklistCheck * Current transmission request handle for this client, or NULL if no * request is pending. */ - struct GNUNET_CONNECTION_TransmitHandle *th; + struct GNUNET_SERVER_TransmitHandle *th; /** * Our current position in the blacklisters list. @@ -191,7 +191,7 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client) bc->bl_pos = bl->next; if (bc->th != NULL) { - GNUNET_CONNECTION_notify_transmit_ready_cancel (bc->th); + GNUNET_SERVER_notify_transmit_ready_cancel (bc->th); bc->th = NULL; } if (bc->task == GNUNET_SCHEDULER_NO_TASK) @@ -813,7 +813,7 @@ GST_blacklist_test_cancel (struct GST_BlacklistCheck *bc) } if (NULL != bc->th) { - GNUNET_CONNECTION_notify_transmit_ready_cancel (bc->th); + GNUNET_SERVER_notify_transmit_ready_cancel (bc->th); bc->th = NULL; } GNUNET_free (bc); diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 227f4f093..f430ef91a 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c @@ -102,7 +102,7 @@ struct TransportClient /** * Current transmit request handle. */ - struct GNUNET_CONNECTION_TransmitHandle *th; + struct GNUNET_SERVER_TransmitHandle *th; /** * Length of the list of messages pending for this client. @@ -417,7 +417,7 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client) GNUNET_CONTAINER_DLL_remove (clients_head, clients_tail, tc); if (tc->th != NULL) { - GNUNET_CONNECTION_notify_transmit_ready_cancel (tc->th); + GNUNET_SERVER_notify_transmit_ready_cancel (tc->th); tc->th = NULL; } GNUNET_break (0 == tc->message_count); diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index 4679e451b..b079c1732 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c @@ -133,7 +133,7 @@ client_schedule (struct Plugin *plugin, int now) plugin->client_perform_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, timeout, grs, gws, + timeout, grs, gws, &client_run, plugin); GNUNET_NETWORK_fdset_destroy (gws); GNUNET_NETWORK_fdset_destroy (grs); diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index 634f51c27..499fd06c8 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c @@ -988,7 +988,7 @@ server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle, #endif ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, tv, wrs, wws, + tv, wrs, wws, &server_v4_run, plugin); } if (daemon_handle == plugin->server_v6) @@ -1004,7 +1004,7 @@ server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle, #endif ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, tv, wrs, wws, + tv, wrs, wws, &server_v6_run, plugin); } GNUNET_NETWORK_fdset_destroy (wrs); diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 5ea2ba8da..818c61fb3 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -936,7 +936,6 @@ enqueue_fragment (void *cls, const struct GNUNET_MessageHeader *msg) plugin->select_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs_v4, plugin->ws_v4, @@ -954,7 +953,6 @@ enqueue_fragment (void *cls, const struct GNUNET_MessageHeader *msg) plugin->select_task_v6 = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs_v6, plugin->ws_v6, @@ -1096,7 +1094,6 @@ udp_plugin_send (void *cls, plugin->select_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs_v4, plugin->ws_v4, @@ -1114,7 +1111,6 @@ udp_plugin_send (void *cls, plugin->select_task_v6 = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs_v6, plugin->ws_v6, @@ -1847,7 +1843,6 @@ udp_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (plugin->select_task); plugin->select_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs_v4, (plugin->ipv4_queue_head != NULL) ? plugin->ws_v4 : NULL, @@ -1895,7 +1890,6 @@ udp_plugin_select_v6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (plugin->select_task_v6 != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (plugin->select_task_v6); plugin->select_task_v6 = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs_v6, (plugin->ipv6_queue_head != NULL) ? plugin->ws_v6 : NULL, @@ -2034,7 +2028,6 @@ setup_sockets (struct Plugin *plugin, struct sockaddr_in6 *serverAddrv6, struct plugin->select_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs_v4, NULL, @@ -2055,7 +2048,6 @@ setup_sockets (struct Plugin *plugin, struct sockaddr_in6 *serverAddrv6, struct plugin->select_task_v6 = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs_v6, NULL, diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index b7239ee9a..bd8a2db5b 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c @@ -644,7 +644,6 @@ unix_plugin_send (void *cls, plugin->select_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, plugin->ws, @@ -835,7 +834,6 @@ unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_SCHEDULER_cancel (plugin->select_task); plugin->select_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, (plugin->msg_head != NULL) ? plugin->ws : NULL, @@ -906,7 +904,6 @@ unix_transport_server_start (void *cls) plugin->select_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, NULL, diff --git a/src/util/scheduler.c b/src/util/scheduler.c index c54672f5f..8d3106032 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c @@ -1106,31 +1106,6 @@ GNUNET_SCHEDULER_add_continuation (GNUNET_SCHEDULER_Task task, void *task_cls, } -/** - * Schedule a new task to be run after the specified prerequisite task - * has completed. It will be run with the DEFAULT priority. - * - * @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 - * on completion of other tasks (this will cause the task to run as - * soon as possible). - * @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_after (GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, - GNUNET_SCHEDULER_Task task, void *task_cls) -{ - return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - prerequisite_task, GNUNET_TIME_UNIT_ZERO, - NULL, NULL, task, task_cls); -} - - /** * Schedule a new task to be run with a specified priority. * @@ -1144,7 +1119,7 @@ GNUNET_SCHEDULER_TaskIdentifier GNUNET_SCHEDULER_add_with_priority (enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_Task task, void *task_cls) { - return GNUNET_SCHEDULER_add_select (prio, GNUNET_SCHEDULER_NO_TASK, + return GNUNET_SCHEDULER_add_select (prio, GNUNET_TIME_UNIT_ZERO, NULL, NULL, task, task_cls); } @@ -1299,7 +1274,6 @@ GNUNET_SCHEDULER_add_now_with_lifeness (int lifeness, ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_ZERO, NULL, NULL, task, task_cls); GNUNET_assert (pending->id == ret); @@ -1450,7 +1424,7 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay, GNUNET_NETWORK_fdset_set (rs, rfd); ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, delay, rs, NULL, + delay, rs, NULL, task, task_cls); GNUNET_NETWORK_fdset_destroy (rs); return ret; @@ -1493,7 +1467,7 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay, GNUNET_NETWORK_fdset_set (ws, wfd); ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, delay, NULL, ws, + delay, NULL, ws, task, task_cls); GNUNET_NETWORK_fdset_destroy (ws); return ret; @@ -1536,7 +1510,7 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay, GNUNET_NETWORK_fdset_handle_set (rs, rfd); ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, delay, rs, NULL, + delay, rs, NULL, task, task_cls); GNUNET_NETWORK_fdset_destroy (rs); return ret; @@ -1581,7 +1555,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, GNUNET_NETWORK_fdset_handle_set (ws, wfd); ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, delay, NULL, ws, + delay, NULL, ws, task, task_cls); GNUNET_NETWORK_fdset_destroy (ws); return ret; @@ -1617,11 +1591,6 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, * * * @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 - * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency - * on completion of other tasks. * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever", * which means that the task will only be run after we receive SIGTERM * @param rs set of file descriptors we want to read (can be NULL) @@ -1633,7 +1602,6 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, */ GNUNET_SCHEDULER_TaskIdentifier GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, - GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, struct GNUNET_TIME_Relative delay, const struct GNUNET_NETWORK_FDSet *rs, const struct GNUNET_NETWORK_FDSet *ws, @@ -1671,7 +1639,6 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, #if PROFILE_DELAYS t->start_time = GNUNET_TIME_absolute_get (); #endif - t->prereq_id = prerequisite_task; t->timeout = GNUNET_TIME_relative_to_absolute (delay); t->priority = check_priority ((prio == diff --git a/src/util/server.c b/src/util/server.c index ede31b558..fc96db802 100644 --- a/src/util/server.c +++ b/src/util/server.c @@ -324,7 +324,6 @@ process_listen_socket (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* ignore shutdown, someone else will take care of it! */ server->listen_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH, - GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, r, NULL, &process_listen_socket, server); GNUNET_NETWORK_fdset_destroy (r); @@ -354,7 +353,6 @@ process_listen_socket (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* listen for more! */ server->listen_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH, - GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, r, NULL, &process_listen_socket, server); GNUNET_NETWORK_fdset_destroy (r); @@ -498,7 +496,6 @@ GNUNET_SERVER_create_with_sockets (GNUNET_CONNECTION_AccessCheck access, GNUNET_NETWORK_fdset_set (r, ret->listen_sockets[i++]); ret->listen_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH, - GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, r, NULL, &process_listen_socket, ret); GNUNET_NETWORK_fdset_destroy (r); diff --git a/src/util/test_scheduler.c b/src/util/test_scheduler.c index 01982ee8b..9832ade6f 100644 --- a/src/util/test_scheduler.c +++ b/src/util/test_scheduler.c @@ -30,37 +30,25 @@ #define VERBOSE GNUNET_NO static void -task3 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { int *ok = cls; - /* t4 should be ready (albeit with lower priority) */ + /* t3 should be ready (albeit with lower priority) */ GNUNET_assert (1 == GNUNET_SCHEDULER_get_load (GNUNET_SCHEDULER_PRIORITY_COUNT)); - GNUNET_assert (3 == *ok); - (*ok) = 4; -} - - -static void -task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) -{ - int *ok = cls; - GNUNET_assert (2 == *ok); (*ok) = 3; - /* t3 will go before t4: higher priority */ - GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, &task3, - cls); } + static void -task4 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +task3 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { int *ok = cls; - GNUNET_assert (4 == *ok); - (*ok) = 5; + GNUNET_assert (3 == *ok); + (*ok) = 4; } struct GNUNET_DISK_PipeHandle *p; @@ -113,11 +101,11 @@ taskRd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -task5 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +task4 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { int *ok = cls; - GNUNET_assert (5 == *ok); + GNUNET_assert (4 == *ok); (*ok) = 6; p = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_NO, GNUNET_NO); GNUNET_assert (NULL != p); @@ -134,17 +122,13 @@ static void task1 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { int *ok = cls; - GNUNET_SCHEDULER_TaskIdentifier t2; - GNUNET_SCHEDULER_TaskIdentifier t4; GNUNET_assert (1 == *ok); (*ok) = 2; - /* t2 will go first -- prereq for all */ - 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 (t2, &task4, cls); - /* t5 will go last (after p4) */ - GNUNET_SCHEDULER_add_after (t4, &task5, cls); + GNUNET_SCHEDULER_add_now (&task3, cls); + GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, &task2, + cls); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &task4, cls); } @@ -225,8 +209,8 @@ taskCancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (1 == *ok); *ok = 0; - GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_add_after - (GNUNET_SCHEDULER_NO_TASK, &taskNeverRun, NULL)); + GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_add_now + (&taskNeverRun, NULL)); } -- 2.25.1