aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-11-04 14:10:32 +0000
committerChristian Grothoff <christian@grothoff.org>2009-11-04 14:10:32 +0000
commitcf45b8dff29c366d51aa2e6ea6a64b99b514b9c9 (patch)
tree5cb37c041743daff5af528dbbe24f5c563ce702e /src
parentb91546a3de767292e6472c6b1927480adba43d88 (diff)
downloadgnunet-cf45b8dff29c366d51aa2e6ea6a64b99b514b9c9.tar.gz
gnunet-cf45b8dff29c366d51aa2e6ea6a64b99b514b9c9.zip
bugfixes and redesigning scheduler API
Diffstat (limited to 'src')
-rw-r--r--src/arm/gnunet-arm.c3
-rw-r--r--src/arm/gnunet-service-arm.c16
-rw-r--r--src/core/core_api.c13
-rw-r--r--src/core/gnunet-service-core.c27
-rw-r--r--src/core/test_core_api.c7
-rw-r--r--src/core/test_core_api_start_only.c1
-rw-r--r--src/datastore/gnunet-service-datastore.c23
-rw-r--r--src/datastore/perf_datastore_api.c16
-rw-r--r--src/datastore/perf_plugin_datastore.c11
-rw-r--r--src/datastore/plugin_datastore_sqlite.c1
-rw-r--r--src/datastore/test_datastore_api.c9
-rw-r--r--src/datastore/test_datastore_api_management.c5
-rw-r--r--src/fs/fs_download.c3
-rw-r--r--src/fs/fs_list_indexed.c5
-rw-r--r--src/fs/fs_publish.c53
-rw-r--r--src/fs/fs_search.c3
-rw-r--r--src/fs/fs_tree.c2
-rw-r--r--src/fs/fs_unindex.c1
-rw-r--r--src/fs/gnunet-service-fs.c47
-rw-r--r--src/fs/test_fs_download.c6
-rw-r--r--src/fs/test_fs_list_indexed.c3
-rw-r--r--src/fs/test_fs_publish.c3
-rw-r--r--src/fs/test_fs_search.c4
-rw-r--r--src/fs/test_fs_unindex.c4
-rw-r--r--src/hostlist/gnunet-daemon-hostlist.c3
-rw-r--r--src/hostlist/hostlist-client.c4
-rw-r--r--src/hostlist/hostlist-server.c4
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist.c1
-rw-r--r--src/include/gnunet_crypto_lib.h2
-rw-r--r--src/include/gnunet_scheduler_lib.h229
-rw-r--r--src/include/gnunet_service_lib.h17
-rw-r--r--src/nat/nat.c8
-rw-r--r--src/nat/test_nat.c4
-rw-r--r--src/peerinfo/gnunet-service-peerinfo.c49
-rw-r--r--src/peerinfo/test_peerinfo_api.c1
-rw-r--r--src/statistics/gnunet-service-statistics.c44
-rw-r--r--src/template/gnunet-service-template.c34
-rw-r--r--src/testing/testing.c26
-rw-r--r--src/topology/gnunet-daemon-topology.c9
-rw-r--r--src/topology/test_gnunet_service_topology.c2
-rw-r--r--src/transport/gnunet-service-transport.c33
-rw-r--r--src/transport/plugin_transport_tcp.c3
-rw-r--r--src/transport/test_plugin_transport.c4
-rw-r--r--src/transport/transport_api.c32
-rw-r--r--src/util/client.c13
-rw-r--r--src/util/connection.c37
-rw-r--r--src/util/crypto_hash.c15
-rw-r--r--src/util/disk.c8
-rw-r--r--src/util/gnunet-service-resolver.c2
-rw-r--r--src/util/resolver_api.c9
-rw-r--r--src/util/scheduler.c555
-rw-r--r--src/util/server.c4
-rw-r--r--src/util/service.c31
-rw-r--r--src/util/test_connection.c3
-rw-r--r--src/util/test_connection_addressing.c3
-rw-r--r--src/util/test_connection_receive_cancel.c6
-rw-r--r--src/util/test_crypto_hash.c2
-rw-r--r--src/util/test_scheduler.c105
-rw-r--r--src/util/test_scheduler_delay.c3
-rw-r--r--src/util/test_server.c3
-rw-r--r--src/util/test_server_disconnect.c6
-rw-r--r--src/util/test_server_with_client.c3
-rw-r--r--src/util/test_service.c32
63 files changed, 593 insertions, 1022 deletions
diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c
index 09a1305a5..d0748f173 100644
--- a/src/arm/gnunet-arm.c
+++ b/src/arm/gnunet-arm.c
@@ -123,7 +123,6 @@ confirm_cb (void *cls, int success)
123 break; 123 break;
124 } 124 }
125 GNUNET_SCHEDULER_add_continuation (sched, 125 GNUNET_SCHEDULER_add_continuation (sched,
126 GNUNET_NO,
127 &cps_loop, 126 &cps_loop,
128 NULL, 127 NULL,
129 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 128 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -147,7 +146,6 @@ confirm_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
147 else 146 else
148 fprintf (stdout, _("Service `%s' is not running.\n"), service); 147 fprintf (stdout, _("Service `%s' is not running.\n"), service);
149 GNUNET_SCHEDULER_add_continuation (sched, 148 GNUNET_SCHEDULER_add_continuation (sched,
150 GNUNET_NO,
151 &cps_loop, 149 &cps_loop,
152 NULL, 150 NULL,
153 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 151 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -181,7 +179,6 @@ run (void *cls,
181 return; 179 return;
182 } 180 }
183 GNUNET_SCHEDULER_add_continuation (sched, 181 GNUNET_SCHEDULER_add_continuation (sched,
184 GNUNET_NO,
185 &cps_loop, 182 &cps_loop,
186 NULL, 183 NULL,
187 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 184 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c
index ebb9c337e..bfb3896bf 100644
--- a/src/arm/gnunet-service-arm.c
+++ b/src/arm/gnunet-service-arm.c
@@ -516,9 +516,6 @@ stop_service (struct GNUNET_SERVER_Client *client,
516 pos->kill_continuation_cls = client; 516 pos->kill_continuation_cls = client;
517 GNUNET_SERVER_client_keep (client); 517 GNUNET_SERVER_client_keep (client);
518 GNUNET_SCHEDULER_add_delayed (sched, 518 GNUNET_SCHEDULER_add_delayed (sched,
519 GNUNET_YES,
520 GNUNET_SCHEDULER_PRIORITY_IDLE,
521 GNUNET_SCHEDULER_NO_TASK,
522 MAINT_FAST_FREQUENCY, &maint, NULL); 519 MAINT_FAST_FREQUENCY, &maint, NULL);
523 } 520 }
524 else 521 else
@@ -641,9 +638,6 @@ maint (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
641 } 638 }
642 if (cls == NULL) 639 if (cls == NULL)
643 GNUNET_SCHEDULER_add_delayed (tc->sched, 640 GNUNET_SCHEDULER_add_delayed (tc->sched,
644 GNUNET_YES,
645 GNUNET_SCHEDULER_PRIORITY_IDLE,
646 GNUNET_SCHEDULER_NO_TASK,
647 MAINT_FREQUENCY, &maint, NULL); 641 MAINT_FREQUENCY, &maint, NULL);
648 642
649 /* check for services that died (WAITPID) */ 643 /* check for services that died (WAITPID) */
@@ -800,11 +794,9 @@ run (void *cls,
800 GNUNET_SERVER_add_handlers (server, handlers); 794 GNUNET_SERVER_add_handlers (server, handlers);
801 795
802 /* manage services */ 796 /* manage services */
803 GNUNET_SCHEDULER_add_delayed (sched, 797 GNUNET_SCHEDULER_add_with_priority (sched,
804 GNUNET_YES, 798 GNUNET_SCHEDULER_PRIORITY_IDLE,
805 GNUNET_SCHEDULER_PRIORITY_IDLE, 799 &maint, NULL);
806 GNUNET_SCHEDULER_NO_TASK,
807 MAINT_FREQUENCY, &maint, NULL);
808} 800}
809 801
810 802
@@ -820,7 +812,7 @@ main (int argc, char *const *argv)
820{ 812{
821 return (GNUNET_OK == 813 return (GNUNET_OK ==
822 GNUNET_SERVICE_run (argc, 814 GNUNET_SERVICE_run (argc,
823 argv, "arm", &run, NULL, NULL, NULL)) ? 0 : 1; 815 argv, "arm", &run, NULL)) ? 0 : 1;
824} 816}
825 817
826/* end of gnunet-service-arm.c */ 818/* end of gnunet-service-arm.c */
diff --git a/src/core/core_api.c b/src/core/core_api.c
index 1a74eb7d0..91055dd03 100644
--- a/src/core/core_api.c
+++ b/src/core/core_api.c
@@ -320,9 +320,6 @@ request_start (void *cls, size_t size, void *buf)
320 } 320 }
321 /* create new timeout task (in case core takes too long to respond!) */ 321 /* create new timeout task (in case core takes too long to respond!) */
322 th->timeout_task = GNUNET_SCHEDULER_add_delayed (h->sched, 322 th->timeout_task = GNUNET_SCHEDULER_add_delayed (h->sched,
323 GNUNET_NO,
324 GNUNET_SCHEDULER_PRIORITY_KEEP,
325 GNUNET_SCHEDULER_NO_TASK,
326 GNUNET_TIME_absolute_get_remaining 323 GNUNET_TIME_absolute_get_remaining
327 (th->timeout), 324 (th->timeout),
328 &timeout_request, th); 325 &timeout_request, th);
@@ -748,9 +745,7 @@ transmit_start (void *cls, size_t size, void *buf)
748 h->startup_timeout = 745 h->startup_timeout =
749 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); 746 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES);
750 h->reconnect_task = 747 h->reconnect_task =
751 GNUNET_SCHEDULER_add_delayed (h->sched, GNUNET_NO, 748 GNUNET_SCHEDULER_add_delayed (h->sched,
752 GNUNET_SCHEDULER_PRIORITY_IDLE,
753 GNUNET_SCHEDULER_NO_TASK,
754 delay, &reconnect_task, h); 749 delay, &reconnect_task, h);
755 return 0; 750 return 0;
756 } 751 }
@@ -990,9 +985,6 @@ GNUNET_CORE_peer_configure (struct GNUNET_CORE_Handle *handle,
990 th->info_cls = info_cls; 985 th->info_cls = info_cls;
991 th->timeout = GNUNET_TIME_relative_to_absolute (timeout); 986 th->timeout = GNUNET_TIME_relative_to_absolute (timeout);
992 th->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->sched, 987 th->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->sched,
993 GNUNET_NO,
994 GNUNET_SCHEDULER_PRIORITY_KEEP,
995 GNUNET_SCHEDULER_NO_TASK,
996 timeout, 988 timeout,
997 &timeout_request, th); 989 &timeout_request, th);
998 th->msize = sizeof (struct RequestConfigureMessage); 990 th->msize = sizeof (struct RequestConfigureMessage);
@@ -1112,9 +1104,6 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle,
1112 th->peer = *target; 1104 th->peer = *target;
1113 th->timeout = GNUNET_TIME_relative_to_absolute (maxdelay); 1105 th->timeout = GNUNET_TIME_relative_to_absolute (maxdelay);
1114 th->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->sched, 1106 th->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->sched,
1115 GNUNET_NO,
1116 GNUNET_SCHEDULER_PRIORITY_KEEP,
1117 GNUNET_SCHEDULER_NO_TASK,
1118 maxdelay, 1107 maxdelay,
1119 &timeout_request, th); 1108 &timeout_request, th);
1120 th->priority = priority; 1109 th->priority = priority;
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c
index 1d272b873..839eb2727 100644
--- a/src/core/gnunet-service-core.c
+++ b/src/core/gnunet-service-core.c
@@ -1703,9 +1703,6 @@ process_plaintext_neighbour_queue (struct Neighbour *n)
1703 /* no messages selected for sending, try again later... */ 1703 /* no messages selected for sending, try again later... */
1704 n->retry_plaintext_task = 1704 n->retry_plaintext_task =
1705 GNUNET_SCHEDULER_add_delayed (sched, 1705 GNUNET_SCHEDULER_add_delayed (sched,
1706 GNUNET_NO,
1707 GNUNET_SCHEDULER_PRIORITY_IDLE,
1708 GNUNET_SCHEDULER_NO_TASK,
1709 retry_time, 1706 retry_time,
1710 &retry_plaintext_processing, n); 1707 &retry_plaintext_processing, n);
1711 return; 1708 return;
@@ -2154,9 +2151,6 @@ send_key (struct Neighbour *n)
2154 if (n->status != PEER_STATE_KEY_CONFIRMED) 2151 if (n->status != PEER_STATE_KEY_CONFIRMED)
2155 n->retry_set_key_task 2152 n->retry_set_key_task
2156 = GNUNET_SCHEDULER_add_delayed (sched, 2153 = GNUNET_SCHEDULER_add_delayed (sched,
2157 GNUNET_NO,
2158 GNUNET_SCHEDULER_PRIORITY_KEEP,
2159 GNUNET_SCHEDULER_NO_TASK,
2160 n->set_key_retry_frequency, 2154 n->set_key_retry_frequency,
2161 &set_key_retry_task, n); 2155 &set_key_retry_task, n);
2162} 2156}
@@ -2894,9 +2888,6 @@ schedule_quota_update (struct Neighbour *n)
2894 GNUNET_SCHEDULER_NO_TASK); 2888 GNUNET_SCHEDULER_NO_TASK);
2895 n->quota_update_task 2889 n->quota_update_task
2896 = GNUNET_SCHEDULER_add_delayed (sched, 2890 = GNUNET_SCHEDULER_add_delayed (sched,
2897 GNUNET_NO,
2898 GNUNET_SCHEDULER_PRIORITY_IDLE,
2899 GNUNET_SCHEDULER_NO_TASK,
2900 QUOTA_UPDATE_FREQUENCY, 2891 QUOTA_UPDATE_FREQUENCY,
2901 &neighbour_quota_update, 2892 &neighbour_quota_update,
2902 n); 2893 n);
@@ -3114,6 +3105,8 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3114 } 3105 }
3115 while (NULL != (c = clients)) 3106 while (NULL != (c = clients))
3116 handle_client_disconnect (NULL, c->client_handle); 3107 handle_client_disconnect (NULL, c->client_handle);
3108 if (my_private_key != NULL)
3109 GNUNET_CRYPTO_rsa_key_free (my_private_key);
3117} 3110}
3118 3111
3119 3112
@@ -3198,9 +3191,6 @@ run (void *cls,
3198 &handle_transport_notify_disconnect); 3191 &handle_transport_notify_disconnect);
3199 GNUNET_assert (NULL != transport); 3192 GNUNET_assert (NULL != transport);
3200 GNUNET_SCHEDULER_add_delayed (sched, 3193 GNUNET_SCHEDULER_add_delayed (sched,
3201 GNUNET_YES,
3202 GNUNET_SCHEDULER_PRIORITY_IDLE,
3203 GNUNET_SCHEDULER_NO_TASK,
3204 GNUNET_TIME_UNIT_FOREVER_REL, 3194 GNUNET_TIME_UNIT_FOREVER_REL,
3205 &cleaning_task, NULL); 3195 &cleaning_task, NULL);
3206 /* process client requests */ 3196 /* process client requests */
@@ -3210,17 +3200,6 @@ run (void *cls,
3210} 3200}
3211 3201
3212 3202
3213/**
3214 * Function called during shutdown. Clean up our state.
3215 */
3216static void
3217cleanup (void *cls,
3218 const struct GNUNET_CONFIGURATION_Handle *cfg)
3219{
3220 if (my_private_key != NULL)
3221 GNUNET_CRYPTO_rsa_key_free (my_private_key);
3222}
3223
3224 3203
3225/** 3204/**
3226 * The main function for the transport service. 3205 * The main function for the transport service.
@@ -3235,7 +3214,7 @@ main (int argc, char *const *argv)
3235 return (GNUNET_OK == 3214 return (GNUNET_OK ==
3236 GNUNET_SERVICE_run (argc, 3215 GNUNET_SERVICE_run (argc,
3237 argv, 3216 argv,
3238 "core", &run, NULL, &cleanup, NULL)) ? 0 : 1; 3217 "core", &run, NULL)) ? 0 : 1;
3239} 3218}
3240 3219
3241/* end of gnunet-service-core.c */ 3220/* end of gnunet-service-core.c */
diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c
index 89aa34f5b..ebd4e8e99 100644
--- a/src/core/test_core_api.c
+++ b/src/core/test_core_api.c
@@ -172,9 +172,6 @@ process_mtype (void *cls,
172 OKPP; 172 OKPP;
173 GNUNET_SCHEDULER_cancel (sched, err_task); 173 GNUNET_SCHEDULER_cancel (sched, err_task);
174 GNUNET_SCHEDULER_add_delayed (sched, 174 GNUNET_SCHEDULER_add_delayed (sched,
175 GNUNET_NO,
176 GNUNET_SCHEDULER_PRIORITY_KEEP,
177 GNUNET_SCHEDULER_NO_TASK,
178 GNUNET_TIME_UNIT_ZERO, &terminate_task, NULL); 175 GNUNET_TIME_UNIT_ZERO, &terminate_task, NULL);
179 return GNUNET_OK; 176 return GNUNET_OK;
180} 177}
@@ -201,9 +198,6 @@ transmit_ready (void *cls, size_t size, void *buf)
201 m->size = htons (sizeof (struct GNUNET_MessageHeader)); 198 m->size = htons (sizeof (struct GNUNET_MessageHeader));
202 err_task = 199 err_task =
203 GNUNET_SCHEDULER_add_delayed (sched, 200 GNUNET_SCHEDULER_add_delayed (sched,
204 GNUNET_NO,
205 GNUNET_SCHEDULER_PRIORITY_KEEP,
206 GNUNET_SCHEDULER_NO_TASK,
207 GNUNET_TIME_UNIT_MINUTES, &terminate_task_error, NULL); 201 GNUNET_TIME_UNIT_MINUTES, &terminate_task_error, NULL);
208 202
209 return sizeof (struct GNUNET_MessageHeader); 203 return sizeof (struct GNUNET_MessageHeader);
@@ -300,7 +294,6 @@ setup_peer (struct PeerContext *p, const char *cfgname)
300 "-L", "DEBUG", 294 "-L", "DEBUG",
301#endif 295#endif
302 "-c", cfgname, NULL); 296 "-c", cfgname, NULL);
303 sleep (1); /* allow ARM to start */
304#endif 297#endif
305 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 298 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
306 GNUNET_ARM_start_services (p->cfg, sched, "core", NULL); 299 GNUNET_ARM_start_services (p->cfg, sched, "core", NULL);
diff --git a/src/core/test_core_api_start_only.c b/src/core/test_core_api_start_only.c
index ce2668b89..5ca750664 100644
--- a/src/core/test_core_api_start_only.c
+++ b/src/core/test_core_api_start_only.c
@@ -166,7 +166,6 @@ setup_peer (struct PeerContext *p, const char *cfgname)
166 "-L", "DEBUG", 166 "-L", "DEBUG",
167#endif 167#endif
168 "-c", cfgname, NULL); 168 "-c", cfgname, NULL);
169 sleep (1); /* allow ARM to start */
170#endif 169#endif
171 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 170 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
172 GNUNET_ARM_start_services (p->cfg, sched, "core", NULL); 171 GNUNET_ARM_start_services (p->cfg, sched, "core", NULL);
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index 3a22f9bda..27b1cd58e 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -260,9 +260,6 @@ expired_processor (void *cls,
260 { 260 {
261 expired_kill_task 261 expired_kill_task
262 = GNUNET_SCHEDULER_add_delayed (sched, 262 = GNUNET_SCHEDULER_add_delayed (sched,
263 GNUNET_NO,
264 GNUNET_SCHEDULER_PRIORITY_IDLE,
265 GNUNET_SCHEDULER_NO_TASK,
266 MAX_EXPIRE_DELAY, 263 MAX_EXPIRE_DELAY,
267 &delete_expired, 264 &delete_expired,
268 NULL); 265 NULL);
@@ -1209,7 +1206,7 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1209 GNUNET_CONTAINER_bloomfilter_free (filter); 1206 GNUNET_CONTAINER_bloomfilter_free (filter);
1210 filter = NULL; 1207 filter = NULL;
1211 } 1208 }
1212 // GNUNET_ARM_stop_services (cfg, tc->sched, "statistics", NULL); 1209 GNUNET_ARM_stop_services (cfg, tc->sched, "statistics", NULL);
1213} 1210}
1214 1211
1215 1212
@@ -1307,28 +1304,22 @@ run (void *cls,
1307 _("Failed to initialize bloomfilter.\n")); 1304 _("Failed to initialize bloomfilter.\n"));
1308 return; 1305 return;
1309 } 1306 }
1310// GNUNET_ARM_start_services (cfg, sched, "statistics", NULL); 1307 GNUNET_ARM_start_services (cfg, sched, "statistics", NULL);
1311 plugin = load_plugin (); 1308 plugin = load_plugin ();
1312 if (NULL == plugin) 1309 if (NULL == plugin)
1313 { 1310 {
1314 GNUNET_CONTAINER_bloomfilter_free (filter); 1311 GNUNET_CONTAINER_bloomfilter_free (filter);
1315 filter = NULL; 1312 filter = NULL;
1316// GNUNET_ARM_stop_services (cfg, sched, "statistics", NULL); 1313 GNUNET_ARM_stop_services (cfg, sched, "statistics", NULL);
1317 return; 1314 return;
1318 } 1315 }
1319 GNUNET_SERVER_disconnect_notify (server, &cleanup_reservations, NULL); 1316 GNUNET_SERVER_disconnect_notify (server, &cleanup_reservations, NULL);
1320 GNUNET_SERVER_add_handlers (server, handlers); 1317 GNUNET_SERVER_add_handlers (server, handlers);
1321 expired_kill_task 1318 expired_kill_task
1322 = GNUNET_SCHEDULER_add_delayed (sched, 1319 = GNUNET_SCHEDULER_add_with_priority (sched,
1323 GNUNET_NO, 1320 GNUNET_SCHEDULER_PRIORITY_IDLE,
1324 GNUNET_SCHEDULER_PRIORITY_IDLE, 1321 &delete_expired, NULL);
1325 GNUNET_SCHEDULER_NO_TASK,
1326 GNUNET_TIME_UNIT_ZERO,
1327 &delete_expired, NULL);
1328 GNUNET_SCHEDULER_add_delayed (sched, 1322 GNUNET_SCHEDULER_add_delayed (sched,
1329 GNUNET_YES,
1330 GNUNET_SCHEDULER_PRIORITY_IDLE,
1331 GNUNET_SCHEDULER_NO_TASK,
1332 GNUNET_TIME_UNIT_FOREVER_REL, 1323 GNUNET_TIME_UNIT_FOREVER_REL,
1333 &cleaning_task, NULL); 1324 &cleaning_task, NULL);
1334 1325
@@ -1350,7 +1341,7 @@ main (int argc, char *const *argv)
1350 ret = (GNUNET_OK == 1341 ret = (GNUNET_OK ==
1351 GNUNET_SERVICE_run (argc, 1342 GNUNET_SERVICE_run (argc,
1352 argv, 1343 argv,
1353 "datastore", &run, NULL, NULL, NULL)) ? 0 : 1; 1344 "datastore", &run, NULL)) ? 0 : 1;
1354 return ret; 1345 return ret;
1355} 1346}
1356 1347
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c
index 2344dafe8..34adf0c7d 100644
--- a/src/datastore/perf_datastore_api.c
+++ b/src/datastore/perf_datastore_api.c
@@ -140,7 +140,6 @@ check_success (void *cls,
140 crc->phase = RP_CUT; 140 crc->phase = RP_CUT;
141 } 141 }
142 GNUNET_SCHEDULER_add_continuation (crc->sched, 142 GNUNET_SCHEDULER_add_continuation (crc->sched,
143 GNUNET_NO,
144 &run_continuation, 143 &run_continuation,
145 crc, 144 crc,
146 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 145 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -167,7 +166,6 @@ remove_next(void *cls,
167#endif 166#endif
168 GNUNET_assert (GNUNET_OK == success); 167 GNUNET_assert (GNUNET_OK == success);
169 GNUNET_SCHEDULER_add_continuation (crc->sched, 168 GNUNET_SCHEDULER_add_continuation (crc->sched,
170 GNUNET_NO,
171 &run_continuation, 169 &run_continuation,
172 crc, 170 crc,
173 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 171 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -214,18 +212,15 @@ delete_value (void *cls,
214 { 212 {
215 crc->phase = RP_REPORT; 213 crc->phase = RP_REPORT;
216 GNUNET_SCHEDULER_add_continuation (crc->sched, 214 GNUNET_SCHEDULER_add_continuation (crc->sched,
217 GNUNET_NO,
218 &run_continuation, 215 &run_continuation,
219 crc, 216 crc,
220 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 217 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
221 return; 218 return;
222 } 219 }
223 GNUNET_SCHEDULER_add_after (crc->sched, 220 GNUNET_SCHEDULER_add_with_priority (crc->sched,
224 GNUNET_NO, 221 GNUNET_SCHEDULER_PRIORITY_HIGH,
225 GNUNET_SCHEDULER_PRIORITY_HIGH, 222 &do_delete,
226 GNUNET_SCHEDULER_NO_TASK, 223 crc);
227 &do_delete,
228 crc);
229 return; 224 return;
230 } 225 }
231 stored_ops++; 226 stored_ops++;
@@ -303,7 +298,6 @@ run_continuation (void *cls,
303 crc->phase = RP_PUT; 298 crc->phase = RP_PUT;
304 crc->j = 0; 299 crc->j = 0;
305 GNUNET_SCHEDULER_add_continuation (crc->sched, 300 GNUNET_SCHEDULER_add_continuation (crc->sched,
306 GNUNET_NO,
307 &run_continuation, 301 &run_continuation,
308 crc, 302 crc,
309 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 303 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -335,7 +329,6 @@ run (void *cls,
335 crc->cfg = cfg; 329 crc->cfg = cfg;
336 crc->phase = RP_PUT; 330 crc->phase = RP_PUT;
337 GNUNET_SCHEDULER_add_continuation (crc->sched, 331 GNUNET_SCHEDULER_add_continuation (crc->sched,
338 GNUNET_NO,
339 &run_continuation, 332 &run_continuation,
340 crc, 333 crc,
341 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 334 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -364,7 +357,6 @@ check ()
364 "-L", "DEBUG", 357 "-L", "DEBUG",
365#endif 358#endif
366 "-c", "test_datastore_api_data.conf", NULL); 359 "-c", "test_datastore_api_data.conf", NULL);
367 sleep (1);
368 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 360 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
369 argv, "perf-datastore-api", "nohelp", 361 argv, "perf-datastore-api", "nohelp",
370 options, &run, NULL); 362 options, &run, NULL);
diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c
index b7bc9db31..a23569875 100644
--- a/src/datastore/perf_plugin_datastore.c
+++ b/src/datastore/perf_plugin_datastore.c
@@ -168,8 +168,6 @@ iterateDummy (void *cls,
168 crc->phase = RP_PUT; 168 crc->phase = RP_PUT;
169 } 169 }
170 GNUNET_SCHEDULER_add_after (crc->sched, 170 GNUNET_SCHEDULER_add_after (crc->sched,
171 GNUNET_NO,
172 GNUNET_SCHEDULER_PRIORITY_KEEP,
173 GNUNET_SCHEDULER_NO_TASK, 171 GNUNET_SCHEDULER_NO_TASK,
174 &test, crc); 172 &test, crc);
175 return GNUNET_OK; 173 return GNUNET_OK;
@@ -254,8 +252,6 @@ test (void *cls,
254 crc->i++; 252 crc->i++;
255 crc->phase = RP_LP_GET; 253 crc->phase = RP_LP_GET;
256 GNUNET_SCHEDULER_add_after (crc->sched, 254 GNUNET_SCHEDULER_add_after (crc->sched,
257 GNUNET_NO,
258 GNUNET_SCHEDULER_PRIORITY_KEEP,
259 GNUNET_SCHEDULER_NO_TASK, 255 GNUNET_SCHEDULER_NO_TASK,
260 &test, crc); 256 &test, crc);
261 break; 257 break;
@@ -301,11 +297,8 @@ test (void *cls,
301 break; 297 break;
302 case RP_DONE: 298 case RP_DONE:
303 crc->api->drop (crc->api->cls); 299 crc->api->drop (crc->api->cls);
304 GNUNET_SCHEDULER_add_delayed (crc->sched, 300 GNUNET_SCHEDULER_add_with_priority (crc->sched,
305 GNUNET_YES,
306 GNUNET_SCHEDULER_PRIORITY_IDLE, 301 GNUNET_SCHEDULER_PRIORITY_IDLE,
307 GNUNET_SCHEDULER_NO_TASK,
308 GNUNET_TIME_UNIT_ZERO,
309 &cleaning_task, crc); 302 &cleaning_task, crc);
310 break; 303 break;
311 } 304 }
@@ -364,8 +357,6 @@ run (void *cls,
364 crc->cfg = c; 357 crc->cfg = c;
365 crc->phase = RP_PUT; 358 crc->phase = RP_PUT;
366 GNUNET_SCHEDULER_add_after (s, 359 GNUNET_SCHEDULER_add_after (s,
367 GNUNET_YES,
368 GNUNET_SCHEDULER_PRIORITY_KEEP,
369 GNUNET_SCHEDULER_NO_TASK, 360 GNUNET_SCHEDULER_NO_TASK,
370 &test, crc); 361 &test, crc);
371} 362}
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c
index e673bafa4..1607ba5e0 100644
--- a/src/datastore/plugin_datastore_sqlite.c
+++ b/src/datastore/plugin_datastore_sqlite.c
@@ -663,7 +663,6 @@ sqlite_next_request (void *next_cls,
663 if (GNUNET_YES == end_it) 663 if (GNUNET_YES == end_it)
664 nc->end_it = GNUNET_YES; 664 nc->end_it = GNUNET_YES;
665 GNUNET_SCHEDULER_add_continuation (nc->plugin->env->sched, 665 GNUNET_SCHEDULER_add_continuation (nc->plugin->env->sched,
666 GNUNET_NO,
667 &sqlite_next_request_cont, 666 &sqlite_next_request_cont,
668 nc, 667 nc,
669 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 668 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c
index 605cb042d..5d4443cbe 100644
--- a/src/datastore/test_datastore_api.c
+++ b/src/datastore/test_datastore_api.c
@@ -145,7 +145,6 @@ check_success (void *cls,
145 GNUNET_free_non_null (crc->data); 145 GNUNET_free_non_null (crc->data);
146 crc->data = NULL; 146 crc->data = NULL;
147 GNUNET_SCHEDULER_add_continuation (crc->sched, 147 GNUNET_SCHEDULER_add_continuation (crc->sched,
148 GNUNET_NO,
149 &run_continuation, 148 &run_continuation,
150 crc, 149 crc,
151 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 150 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -164,7 +163,6 @@ get_reserved (void *cls,
164 GNUNET_assert (0 < success); 163 GNUNET_assert (0 < success);
165 crc->rid = success; 164 crc->rid = success;
166 GNUNET_SCHEDULER_add_continuation (crc->sched, 165 GNUNET_SCHEDULER_add_continuation (crc->sched,
167 GNUNET_NO,
168 &run_continuation, 166 &run_continuation,
169 crc, 167 crc,
170 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 168 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -193,7 +191,6 @@ check_value (void *cls,
193 crc->i = ITERATIONS; 191 crc->i = ITERATIONS;
194 } 192 }
195 GNUNET_SCHEDULER_add_continuation (crc->sched, 193 GNUNET_SCHEDULER_add_continuation (crc->sched,
196 GNUNET_NO,
197 &run_continuation, 194 &run_continuation,
198 crc, 195 crc,
199 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 196 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -226,7 +223,6 @@ delete_value (void *cls,
226 { 223 {
227 crc->phase = RP_DO_DEL; 224 crc->phase = RP_DO_DEL;
228 GNUNET_SCHEDULER_add_continuation (crc->sched, 225 GNUNET_SCHEDULER_add_continuation (crc->sched,
229 GNUNET_NO,
230 &run_continuation, 226 &run_continuation,
231 crc, 227 crc,
232 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 228 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -259,7 +255,6 @@ check_nothing (void *cls,
259 crc->phase = RP_RESERVE; 255 crc->phase = RP_RESERVE;
260 } 256 }
261 GNUNET_SCHEDULER_add_continuation (crc->sched, 257 GNUNET_SCHEDULER_add_continuation (crc->sched,
262 GNUNET_NO,
263 &run_continuation, 258 &run_continuation,
264 crc, 259 crc,
265 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 260 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -284,7 +279,6 @@ check_multiple (void *cls,
284 GNUNET_assert (crc->phase == RP_GET_MULTIPLE_DONE); 279 GNUNET_assert (crc->phase == RP_GET_MULTIPLE_DONE);
285 crc->phase = RP_UPDATE; 280 crc->phase = RP_UPDATE;
286 GNUNET_SCHEDULER_add_continuation (crc->sched, 281 GNUNET_SCHEDULER_add_continuation (crc->sched,
287 GNUNET_NO,
288 &run_continuation, 282 &run_continuation,
289 crc, 283 crc,
290 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 284 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -315,7 +309,6 @@ check_update (void *cls,
315 GNUNET_assert (crc->phase == RP_UPDATE_DONE); 309 GNUNET_assert (crc->phase == RP_UPDATE_DONE);
316 crc->phase = RP_DONE; 310 crc->phase = RP_DONE;
317 GNUNET_SCHEDULER_add_continuation (crc->sched, 311 GNUNET_SCHEDULER_add_continuation (crc->sched,
318 GNUNET_NO,
319 &run_continuation, 312 &run_continuation,
320 crc, 313 crc,
321 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 314 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -542,7 +535,6 @@ run (void *cls,
542 now = GNUNET_TIME_absolute_get (); 535 now = GNUNET_TIME_absolute_get ();
543 datastore = GNUNET_DATASTORE_connect (cfg, sched); 536 datastore = GNUNET_DATASTORE_connect (cfg, sched);
544 GNUNET_SCHEDULER_add_continuation (crc->sched, 537 GNUNET_SCHEDULER_add_continuation (crc->sched,
545 GNUNET_NO,
546 &run_continuation, 538 &run_continuation,
547 crc, 539 crc,
548 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 540 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -572,7 +564,6 @@ check ()
572 "-L", "DEBUG", 564 "-L", "DEBUG",
573#endif 565#endif
574 "-c", "test_datastore_api_data.conf", NULL); 566 "-c", "test_datastore_api_data.conf", NULL);
575 sleep (1);
576 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 567 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
577 argv, "test-datastore-api", "nohelp", 568 argv, "test-datastore-api", "nohelp",
578 options, &run, NULL); 569 options, &run, NULL);
diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c
index 48daebb1d..cad789a6f 100644
--- a/src/datastore/test_datastore_api_management.c
+++ b/src/datastore/test_datastore_api_management.c
@@ -133,7 +133,6 @@ check_success (void *cls,
133 GNUNET_free_non_null (crc->data); 133 GNUNET_free_non_null (crc->data);
134 crc->data = NULL; 134 crc->data = NULL;
135 GNUNET_SCHEDULER_add_continuation (crc->sched, 135 GNUNET_SCHEDULER_add_continuation (crc->sched,
136 GNUNET_NO,
137 &run_continuation, 136 &run_continuation,
138 crc, 137 crc,
139 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 138 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -171,7 +170,6 @@ check_value (void *cls,
171 if (0 == crc->i) 170 if (0 == crc->i)
172 crc->phase = RP_DONE; 171 crc->phase = RP_DONE;
173 GNUNET_SCHEDULER_add_continuation (crc->sched, 172 GNUNET_SCHEDULER_add_continuation (crc->sched,
174 GNUNET_NO,
175 &run_continuation, 173 &run_continuation,
176 crc, 174 crc,
177 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 175 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -206,7 +204,6 @@ check_nothing (void *cls,
206 if (0 == --crc->i) 204 if (0 == --crc->i)
207 crc->phase = RP_DONE; 205 crc->phase = RP_DONE;
208 GNUNET_SCHEDULER_add_continuation (crc->sched, 206 GNUNET_SCHEDULER_add_continuation (crc->sched,
209 GNUNET_NO,
210 &run_continuation, 207 &run_continuation,
211 crc, 208 crc,
212 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 209 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -310,7 +307,6 @@ run (void *cls,
310 now = GNUNET_TIME_absolute_get (); 307 now = GNUNET_TIME_absolute_get ();
311 datastore = GNUNET_DATASTORE_connect (cfg, sched); 308 datastore = GNUNET_DATASTORE_connect (cfg, sched);
312 GNUNET_SCHEDULER_add_continuation (crc->sched, 309 GNUNET_SCHEDULER_add_continuation (crc->sched,
313 GNUNET_NO,
314 &run_continuation, 310 &run_continuation,
315 crc, 311 crc,
316 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 312 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -340,7 +336,6 @@ check ()
340 "-L", "DEBUG", 336 "-L", "DEBUG",
341#endif 337#endif
342 "-c", "test_datastore_api_data.conf", NULL); 338 "-c", "test_datastore_api_data.conf", NULL);
343 sleep (1);
344 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 339 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
345 argv, "test-datastore-api", "nohelp", 340 argv, "test-datastore-api", "nohelp",
346 options, &run, NULL); 341 options, &run, NULL);
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c
index e92eb85c1..4b3d96082 100644
--- a/src/fs/fs_download.c
+++ b/src/fs/fs_download.c
@@ -718,9 +718,6 @@ try_reconnect (struct GNUNET_FS_DownloadContext *dc)
718 } 718 }
719 dc->task 719 dc->task
720 = GNUNET_SCHEDULER_add_delayed (dc->h->sched, 720 = GNUNET_SCHEDULER_add_delayed (dc->h->sched,
721 GNUNET_NO,
722 GNUNET_SCHEDULER_PRIORITY_IDLE,
723 GNUNET_SCHEDULER_NO_TASK,
724 GNUNET_TIME_UNIT_SECONDS, 721 GNUNET_TIME_UNIT_SECONDS,
725 &do_reconnect, 722 &do_reconnect,
726 dc); 723 dc);
diff --git a/src/fs/fs_list_indexed.c b/src/fs/fs_list_indexed.c
index 9ef205ca0..d182f9aa4 100644
--- a/src/fs/fs_list_indexed.c
+++ b/src/fs/fs_list_indexed.c
@@ -91,7 +91,6 @@ handle_index_info (void *cls,
91 "GET_INDEXED", 91 "GET_INDEXED",
92 "fs"); 92 "fs");
93 GNUNET_SCHEDULER_add_continuation (gic->h->sched, 93 GNUNET_SCHEDULER_add_continuation (gic->h->sched,
94 GNUNET_NO,
95 gic->cont, 94 gic->cont,
96 gic->cont_cls, 95 gic->cont_cls,
97 GNUNET_SCHEDULER_REASON_TIMEOUT); 96 GNUNET_SCHEDULER_REASON_TIMEOUT);
@@ -103,7 +102,6 @@ handle_index_info (void *cls,
103 { 102 {
104 /* normal end-of-list */ 103 /* normal end-of-list */
105 GNUNET_SCHEDULER_add_continuation (gic->h->sched, 104 GNUNET_SCHEDULER_add_continuation (gic->h->sched,
106 GNUNET_NO,
107 gic->cont, 105 gic->cont,
108 gic->cont_cls, 106 gic->cont_cls,
109 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 107 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -124,7 +122,6 @@ handle_index_info (void *cls,
124 "GET_INDEXED", 122 "GET_INDEXED",
125 "fs"); 123 "fs");
126 GNUNET_SCHEDULER_add_continuation (gic->h->sched, 124 GNUNET_SCHEDULER_add_continuation (gic->h->sched,
127 GNUNET_NO,
128 gic->cont, 125 gic->cont,
129 gic->cont_cls, 126 gic->cont_cls,
130 GNUNET_SCHEDULER_REASON_TIMEOUT); 127 GNUNET_SCHEDULER_REASON_TIMEOUT);
@@ -138,7 +135,6 @@ handle_index_info (void *cls,
138 &iim->file_id)) 135 &iim->file_id))
139 { 136 {
140 GNUNET_SCHEDULER_add_continuation (gic->h->sched, 137 GNUNET_SCHEDULER_add_continuation (gic->h->sched,
141 GNUNET_NO,
142 gic->cont, 138 gic->cont,
143 gic->cont_cls, 139 gic->cont_cls,
144 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 140 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -185,7 +181,6 @@ GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h,
185 _("Failed to not connect to `%s' service.\n"), 181 _("Failed to not connect to `%s' service.\n"),
186 "fs"); 182 "fs");
187 GNUNET_SCHEDULER_add_continuation (h->sched, 183 GNUNET_SCHEDULER_add_continuation (h->sched,
188 GNUNET_NO,
189 cont, 184 cont,
190 cont_cls, 185 cont_cls,
191 GNUNET_SCHEDULER_REASON_TIMEOUT); 186 GNUNET_SCHEDULER_REASON_TIMEOUT);
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c
index 721951970..bef03a45e 100644
--- a/src/fs/fs_publish.c
+++ b/src/fs/fs_publish.c
@@ -185,13 +185,10 @@ ds_put_cont (void *cls,
185 GNUNET_FS_file_information_sync (pcc->p); 185 GNUNET_FS_file_information_sync (pcc->p);
186 if (NULL != pcc->cont) 186 if (NULL != pcc->cont)
187 pcc->sc->upload_task 187 pcc->sc->upload_task
188 = GNUNET_SCHEDULER_add_delayed (pcc->sc->h->sched, 188 = GNUNET_SCHEDULER_add_with_priority (pcc->sc->h->sched,
189 GNUNET_NO, 189 GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
190 GNUNET_SCHEDULER_PRIORITY_BACKGROUND, 190 pcc->cont,
191 GNUNET_SCHEDULER_NO_TASK, 191 pcc->cont_cls);
192 GNUNET_TIME_UNIT_ZERO,
193 pcc->cont,
194 pcc->cont_cls);
195 GNUNET_free (pcc); 192 GNUNET_free (pcc);
196} 193}
197 194
@@ -325,13 +322,10 @@ publish_kblocks_cont (void *cls,
325 { 322 {
326 signal_publish_error (p, sc, emsg); 323 signal_publish_error (p, sc, emsg);
327 sc->upload_task 324 sc->upload_task
328 = GNUNET_SCHEDULER_add_delayed (sc->h->sched, 325 = GNUNET_SCHEDULER_add_with_priority (sc->h->sched,
329 GNUNET_NO, 326 GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
330 GNUNET_SCHEDULER_PRIORITY_BACKGROUND, 327 &do_upload,
331 GNUNET_SCHEDULER_NO_TASK, 328 sc);
332 GNUNET_TIME_UNIT_ZERO,
333 &do_upload,
334 sc);
335 return; 329 return;
336 } 330 }
337 GNUNET_FS_file_information_sync (p); 331 GNUNET_FS_file_information_sync (p);
@@ -343,13 +337,10 @@ publish_kblocks_cont (void *cls,
343 else 337 else
344 sc->fi_pos = p->dir; 338 sc->fi_pos = p->dir;
345 sc->upload_task 339 sc->upload_task
346 = GNUNET_SCHEDULER_add_delayed (sc->h->sched, 340 = GNUNET_SCHEDULER_add_with_priority (sc->h->sched,
347 GNUNET_NO, 341 GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
348 GNUNET_SCHEDULER_PRIORITY_BACKGROUND, 342 &do_upload,
349 GNUNET_SCHEDULER_NO_TASK, 343 sc);
350 GNUNET_TIME_UNIT_ZERO,
351 &do_upload,
352 sc);
353} 344}
354 345
355 346
@@ -446,11 +437,8 @@ encode_cont (void *cls,
446 } 437 }
447 /* continue with main */ 438 /* continue with main */
448 sc->upload_task 439 sc->upload_task
449 = GNUNET_SCHEDULER_add_delayed (sc->h->sched, 440 = GNUNET_SCHEDULER_add_with_priority (sc->h->sched,
450 GNUNET_NO, 441 GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
451 GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
452 GNUNET_SCHEDULER_NO_TASK,
453 GNUNET_TIME_UNIT_ZERO,
454 &do_upload, 442 &do_upload,
455 sc); 443 sc);
456} 444}
@@ -486,11 +474,8 @@ block_proc (void *cls,
486 if (NULL == sc->dsh) 474 if (NULL == sc->dsh)
487 { 475 {
488 sc->upload_task 476 sc->upload_task
489 = GNUNET_SCHEDULER_add_delayed (sc->h->sched, 477 = GNUNET_SCHEDULER_add_with_priority (sc->h->sched,
490 GNUNET_NO,
491 GNUNET_SCHEDULER_PRIORITY_BACKGROUND, 478 GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
492 GNUNET_SCHEDULER_NO_TASK,
493 GNUNET_TIME_UNIT_ZERO,
494 &do_upload, 479 &do_upload,
495 sc); 480 sc);
496 return; 481 return;
@@ -910,7 +895,6 @@ do_upload (void *cls,
910 else 895 else
911 GNUNET_CRYPTO_hash_file (sc->h->sched, 896 GNUNET_CRYPTO_hash_file (sc->h->sched,
912 GNUNET_SCHEDULER_PRIORITY_IDLE, 897 GNUNET_SCHEDULER_PRIORITY_IDLE,
913 GNUNET_NO,
914 p->data.file.filename, 898 p->data.file.filename,
915 HASHING_BLOCKSIZE, 899 HASHING_BLOCKSIZE,
916 &hash_for_index_cb, 900 &hash_for_index_cb,
@@ -1018,11 +1002,8 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h,
1018 // and reserve as first task (then trigger 1002 // and reserve as first task (then trigger
1019 // "do_upload" from that continuation)! 1003 // "do_upload" from that continuation)!
1020 ret->upload_task 1004 ret->upload_task
1021 = GNUNET_SCHEDULER_add_delayed (h->sched, 1005 = GNUNET_SCHEDULER_add_with_priority (h->sched,
1022 GNUNET_NO,
1023 GNUNET_SCHEDULER_PRIORITY_BACKGROUND, 1006 GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
1024 GNUNET_SCHEDULER_NO_TASK,
1025 GNUNET_TIME_UNIT_ZERO,
1026 &do_upload, 1007 &do_upload,
1027 ret); 1008 ret);
1028 return ret; 1009 return ret;
@@ -1217,7 +1198,6 @@ kb_put_cont (void *cls,
1217 return; 1198 return;
1218 } 1199 }
1219 GNUNET_SCHEDULER_add_continuation (pkc->h->sched, 1200 GNUNET_SCHEDULER_add_continuation (pkc->h->sched,
1220 GNUNET_NO,
1221 &publish_ksk_cont, 1201 &publish_ksk_cont,
1222 pkc, 1202 pkc,
1223 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 1203 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -1383,7 +1363,6 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
1383 pkc->cpy->purpose.purpose = htonl(GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK); 1363 pkc->cpy->purpose.purpose = htonl(GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK);
1384 pkc->ksk_uri = GNUNET_FS_uri_dup (ksk_uri); 1364 pkc->ksk_uri = GNUNET_FS_uri_dup (ksk_uri);
1385 GNUNET_SCHEDULER_add_continuation (h->sched, 1365 GNUNET_SCHEDULER_add_continuation (h->sched,
1386 GNUNET_NO,
1387 &publish_ksk_cont, 1366 &publish_ksk_cont,
1388 pkc, 1367 pkc,
1389 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 1368 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c
index 8b986ec7c..5d03046e2 100644
--- a/src/fs/fs_search.c
+++ b/src/fs/fs_search.c
@@ -720,9 +720,6 @@ try_reconnect (struct GNUNET_FS_SearchContext *sc)
720 } 720 }
721 sc->task 721 sc->task
722 = GNUNET_SCHEDULER_add_delayed (sc->h->sched, 722 = GNUNET_SCHEDULER_add_delayed (sc->h->sched,
723 GNUNET_NO,
724 GNUNET_SCHEDULER_PRIORITY_IDLE,
725 GNUNET_SCHEDULER_NO_TASK,
726 GNUNET_TIME_UNIT_SECONDS, 723 GNUNET_TIME_UNIT_SECONDS,
727 &do_reconnect, 724 &do_reconnect,
728 sc); 725 sc);
diff --git a/src/fs/fs_tree.c b/src/fs/fs_tree.c
index 83da423f3..4d15d78f3 100644
--- a/src/fs/fs_tree.c
+++ b/src/fs/fs_tree.c
@@ -287,7 +287,6 @@ void GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder * te)
287 &te->emsg)) 287 &te->emsg))
288 { 288 {
289 GNUNET_SCHEDULER_add_continuation (te->h->sched, 289 GNUNET_SCHEDULER_add_continuation (te->h->sched,
290 GNUNET_NO,
291 te->cont, 290 te->cont,
292 te->cls, 291 te->cls,
293 GNUNET_SCHEDULER_REASON_TIMEOUT); 292 GNUNET_SCHEDULER_REASON_TIMEOUT);
@@ -309,7 +308,6 @@ void GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder * te)
309 te->uri->data.chk.chk = te->chk_tree[0]; 308 te->uri->data.chk.chk = te->chk_tree[0];
310 te->uri->data.chk.file_length = GNUNET_htonll (te->size); 309 te->uri->data.chk.file_length = GNUNET_htonll (te->size);
311 GNUNET_SCHEDULER_add_continuation (te->h->sched, 310 GNUNET_SCHEDULER_add_continuation (te->h->sched,
312 GNUNET_NO,
313 te->cont, 311 te->cont,
314 te->cls, 312 te->cls,
315 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 313 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c
index 0c3738753..243209b0e 100644
--- a/src/fs/fs_unindex.c
+++ b/src/fs/fs_unindex.c
@@ -420,7 +420,6 @@ GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h,
420 &pi); 420 &pi);
421 GNUNET_CRYPTO_hash_file (h->sched, 421 GNUNET_CRYPTO_hash_file (h->sched,
422 GNUNET_SCHEDULER_PRIORITY_IDLE, 422 GNUNET_SCHEDULER_PRIORITY_IDLE,
423 GNUNET_NO,
424 filename, 423 filename,
425 HASHING_BLOCKSIZE, 424 HASHING_BLOCKSIZE,
426 &process_hash, 425 &process_hash,
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index 5148c4675..ca6b9b426 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -1075,7 +1075,6 @@ handle_index_start (void *cls,
1075 /* slow validation, need to hash full file (again) */ 1075 /* slow validation, need to hash full file (again) */
1076 GNUNET_CRYPTO_hash_file (sched, 1076 GNUNET_CRYPTO_hash_file (sched,
1077 GNUNET_SCHEDULER_PRIORITY_IDLE, 1077 GNUNET_SCHEDULER_PRIORITY_IDLE,
1078 GNUNET_NO,
1079 fn, 1078 fn,
1080 HASHING_BLOCKSIZE, 1079 HASHING_BLOCKSIZE,
1081 &hash_for_index_val, 1080 &hash_for_index_val,
@@ -1287,9 +1286,6 @@ queue_ds_request (struct GNUNET_TIME_Relative deadline,
1287 if (deadline.value == GNUNET_TIME_UNIT_FOREVER_REL.value) 1286 if (deadline.value == GNUNET_TIME_UNIT_FOREVER_REL.value)
1288 return e; 1287 return e;
1289 e->task = GNUNET_SCHEDULER_add_delayed (sched, 1288 e->task = GNUNET_SCHEDULER_add_delayed (sched,
1290 GNUNET_NO,
1291 GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
1292 GNUNET_SCHEDULER_NO_TASK,
1293 deadline, 1289 deadline,
1294 &timeout_ds_request, 1290 &timeout_ds_request,
1295 e); 1291 e);
@@ -1718,13 +1714,10 @@ transmit_request_cb (void *cls,
1718 if (NULL == buf) 1714 if (NULL == buf)
1719 { 1715 {
1720 /* timeout, try another peer immediately again */ 1716 /* timeout, try another peer immediately again */
1721 pr->task = GNUNET_SCHEDULER_add_delayed (sched, 1717 pr->task = GNUNET_SCHEDULER_add_with_priority (sched,
1722 GNUNET_NO, 1718 GNUNET_SCHEDULER_PRIORITY_IDLE,
1723 GNUNET_SCHEDULER_PRIORITY_IDLE, 1719 &forward_request_task,
1724 GNUNET_SCHEDULER_NO_TASK, 1720 pr);
1725 GNUNET_TIME_UNIT_ZERO,
1726 &forward_request_task,
1727 pr);
1728 return 0; 1721 return 0;
1729 } 1722 }
1730 /* (2) build query message */ 1723 /* (2) build query message */
@@ -1751,9 +1744,6 @@ transmit_request_cb (void *cls,
1751 1744
1752 /* (3) schedule job to do it again (or another peer, etc.) */ 1745 /* (3) schedule job to do it again (or another peer, etc.) */
1753 pr->task = GNUNET_SCHEDULER_add_delayed (sched, 1746 pr->task = GNUNET_SCHEDULER_add_delayed (sched,
1754 GNUNET_NO,
1755 GNUNET_SCHEDULER_PRIORITY_IDLE,
1756 GNUNET_SCHEDULER_NO_TASK,
1757 get_processing_delay (), // FIXME! 1747 get_processing_delay (), // FIXME!
1758 &forward_request_task, 1748 &forward_request_task,
1759 pr); 1749 pr);
@@ -1797,9 +1787,6 @@ target_reservation_cb (void *cls,
1797 { 1787 {
1798 /* try again later; FIXME: we may need to un-reserve "amount"? */ 1788 /* try again later; FIXME: we may need to un-reserve "amount"? */
1799 pr->task = GNUNET_SCHEDULER_add_delayed (sched, 1789 pr->task = GNUNET_SCHEDULER_add_delayed (sched,
1800 GNUNET_NO,
1801 GNUNET_SCHEDULER_PRIORITY_IDLE,
1802 GNUNET_SCHEDULER_NO_TASK,
1803 get_processing_delay (), // FIXME: longer? 1790 get_processing_delay (), // FIXME: longer?
1804 &forward_request_task, 1791 &forward_request_task,
1805 pr); 1792 pr);
@@ -1821,9 +1808,6 @@ target_reservation_cb (void *cls,
1821 { 1808 {
1822 /* try again later */ 1809 /* try again later */
1823 pr->task = GNUNET_SCHEDULER_add_delayed (sched, 1810 pr->task = GNUNET_SCHEDULER_add_delayed (sched,
1824 GNUNET_NO,
1825 GNUNET_SCHEDULER_PRIORITY_IDLE,
1826 GNUNET_SCHEDULER_NO_TASK,
1827 get_processing_delay (), // FIXME: longer? 1811 get_processing_delay (), // FIXME: longer?
1828 &forward_request_task, 1812 &forward_request_task,
1829 pr); 1813 pr);
@@ -1854,9 +1838,6 @@ forward_request_task (void *cls,
1854 { 1838 {
1855 /* we're busy transmitting a result, wait a bit */ 1839 /* we're busy transmitting a result, wait a bit */
1856 pr->task = GNUNET_SCHEDULER_add_delayed (sched, 1840 pr->task = GNUNET_SCHEDULER_add_delayed (sched,
1857 GNUNET_NO,
1858 GNUNET_SCHEDULER_PRIORITY_IDLE,
1859 GNUNET_SCHEDULER_NO_TASK,
1860 get_processing_delay (), 1841 get_processing_delay (),
1861 &forward_request_task, 1842 &forward_request_task,
1862 pr); 1843 pr);
@@ -1872,9 +1853,6 @@ forward_request_task (void *cls,
1872 { 1853 {
1873 /* no possible target found, wait some time */ 1854 /* no possible target found, wait some time */
1874 pr->task = GNUNET_SCHEDULER_add_delayed (sched, 1855 pr->task = GNUNET_SCHEDULER_add_delayed (sched,
1875 GNUNET_NO,
1876 GNUNET_SCHEDULER_PRIORITY_IDLE,
1877 GNUNET_SCHEDULER_NO_TASK,
1878 get_processing_delay (), // FIXME: exponential back-off? or at least wait longer... 1856 get_processing_delay (), // FIXME: exponential back-off? or at least wait longer...
1879 &forward_request_task, 1857 &forward_request_task,
1880 pr); 1858 pr);
@@ -1998,9 +1976,6 @@ process_local_get_result (void *cls,
1998 pr, 1976 pr,
1999 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 1977 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
2000 pr->task = GNUNET_SCHEDULER_add_delayed (sched, 1978 pr->task = GNUNET_SCHEDULER_add_delayed (sched,
2001 GNUNET_NO,
2002 GNUNET_SCHEDULER_PRIORITY_IDLE,
2003 GNUNET_SCHEDULER_NO_TASK,
2004 get_processing_delay (), 1979 get_processing_delay (),
2005 &forward_request_task, 1980 &forward_request_task,
2006 pr); 1981 pr);
@@ -2132,7 +2107,6 @@ transmit_local_get_ready (void *cls,
2132 2107
2133 GNUNET_assert (GNUNET_OK == ok); 2108 GNUNET_assert (GNUNET_OK == ok);
2134 GNUNET_SCHEDULER_add_continuation (sched, 2109 GNUNET_SCHEDULER_add_continuation (sched,
2135 GNUNET_NO,
2136 &transmit_local_get, 2110 &transmit_local_get,
2137 lgc, 2111 lgc,
2138 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 2112 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -2514,9 +2488,6 @@ forward_get_request (void *cls,
2514 destroy_pending_request (eer); 2488 destroy_pending_request (eer);
2515 } 2489 }
2516 pr->task = GNUNET_SCHEDULER_add_delayed (sched, 2490 pr->task = GNUNET_SCHEDULER_add_delayed (sched,
2517 GNUNET_NO,
2518 GNUNET_SCHEDULER_PRIORITY_IDLE,
2519 GNUNET_SCHEDULER_NO_TASK,
2520 get_processing_delay (), 2491 get_processing_delay (),
2521 &forward_request_task, 2492 &forward_request_task,
2522 pr); 2493 pr);
@@ -2617,7 +2588,6 @@ process_p2p_get_result (void *cls,
2617 (pgc->type == GNUNET_DATASTORE_BLOCKTYPE_SKBLOCK) ) ) 2588 (pgc->type == GNUNET_DATASTORE_BLOCKTYPE_SKBLOCK) ) )
2618 { 2589 {
2619 GNUNET_SCHEDULER_add_continuation (sched, 2590 GNUNET_SCHEDULER_add_continuation (sched,
2620 GNUNET_NO,
2621 &forward_get_request, 2591 &forward_get_request,
2622 pgc, 2592 pgc,
2623 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 2593 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -2942,7 +2912,6 @@ handle_p2p_get (void *cls,
2942 pgc); 2912 pgc);
2943 else 2913 else
2944 GNUNET_SCHEDULER_add_continuation (sched, 2914 GNUNET_SCHEDULER_add_continuation (sched,
2945 GNUNET_NO,
2946 &forward_get_request, 2915 &forward_get_request,
2947 pgc, 2916 pgc,
2948 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 2917 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -3338,9 +3307,6 @@ core_start_cb (void *cls,
3338 if (server == NULL) 3307 if (server == NULL)
3339 { 3308 {
3340 GNUNET_SCHEDULER_add_delayed (sched, 3309 GNUNET_SCHEDULER_add_delayed (sched,
3341 GNUNET_NO,
3342 GNUNET_SCHEDULER_PRIORITY_HIGH,
3343 GNUNET_SCHEDULER_NO_TASK,
3344 GNUNET_TIME_UNIT_SECONDS, 3310 GNUNET_TIME_UNIT_SECONDS,
3345 &core_connect_task, 3311 &core_connect_task,
3346 NULL); 3312 NULL);
@@ -3412,9 +3378,6 @@ run (void *cls,
3412 GNUNET_SERVER_add_handlers (server, handlers); 3378 GNUNET_SERVER_add_handlers (server, handlers);
3413 core_connect_task (NULL, NULL); 3379 core_connect_task (NULL, NULL);
3414 GNUNET_SCHEDULER_add_delayed (sched, 3380 GNUNET_SCHEDULER_add_delayed (sched,
3415 GNUNET_YES,
3416 GNUNET_SCHEDULER_PRIORITY_IDLE,
3417 GNUNET_SCHEDULER_NO_TASK,
3418 GNUNET_TIME_UNIT_FOREVER_REL, 3381 GNUNET_TIME_UNIT_FOREVER_REL,
3419 &shutdown_task, 3382 &shutdown_task,
3420 NULL); 3383 NULL);
@@ -3434,7 +3397,7 @@ main (int argc, char *const *argv)
3434 return (GNUNET_OK == 3397 return (GNUNET_OK ==
3435 GNUNET_SERVICE_run (argc, 3398 GNUNET_SERVICE_run (argc,
3436 argv, 3399 argv,
3437 "fs", &run, NULL, NULL, NULL)) ? 0 : 1; 3400 "fs", &run, NULL)) ? 0 : 1;
3438} 3401}
3439 3402
3440/* end of gnunet-service-fs.c */ 3403/* end of gnunet-service-fs.c */
diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c
index 04cd3e5d8..4e73ef182 100644
--- a/src/fs/test_fs_download.c
+++ b/src/fs/test_fs_download.c
@@ -29,7 +29,7 @@
29#include "gnunet_arm_service.h" 29#include "gnunet_arm_service.h"
30#include "gnunet_fs_service.h" 30#include "gnunet_fs_service.h"
31 31
32#define VERBOSE GNUNET_NO 32#define VERBOSE GNUNET_YES
33 33
34#define START_ARM GNUNET_YES 34#define START_ARM GNUNET_YES
35 35
@@ -133,7 +133,6 @@ progress_cb (void *cls,
133 printf ("Download complete, %llu kbps.\n", 133 printf ("Download complete, %llu kbps.\n",
134 (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024)); 134 (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024));
135 GNUNET_SCHEDULER_add_continuation (sched, 135 GNUNET_SCHEDULER_add_continuation (sched,
136 GNUNET_NO,
137 &abort_download_task, 136 &abort_download_task,
138 NULL, 137 NULL,
139 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 138 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -154,7 +153,6 @@ progress_cb (void *cls,
154 event->value.publish.specifics.error.message); 153 event->value.publish.specifics.error.message);
155 GNUNET_break (0); 154 GNUNET_break (0);
156 GNUNET_SCHEDULER_add_continuation (sched, 155 GNUNET_SCHEDULER_add_continuation (sched,
157 GNUNET_NO,
158 &abort_publish_task, 156 &abort_publish_task,
159 NULL, 157 NULL,
160 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 158 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -164,7 +162,6 @@ progress_cb (void *cls,
164 "Error downloading file: %s\n", 162 "Error downloading file: %s\n",
165 event->value.download.specifics.error.message); 163 event->value.download.specifics.error.message);
166 GNUNET_SCHEDULER_add_continuation (sched, 164 GNUNET_SCHEDULER_add_continuation (sched,
167 GNUNET_NO,
168 &abort_download_task, 165 &abort_download_task,
169 NULL, 166 NULL,
170 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 167 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -196,7 +193,6 @@ progress_cb (void *cls,
196 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: 193 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
197 GNUNET_assert (download == event->value.download.dc); 194 GNUNET_assert (download == event->value.download.dc);
198 GNUNET_SCHEDULER_add_continuation (sched, 195 GNUNET_SCHEDULER_add_continuation (sched,
199 GNUNET_NO,
200 &abort_publish_task, 196 &abort_publish_task,
201 NULL, 197 NULL,
202 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 198 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
diff --git a/src/fs/test_fs_list_indexed.c b/src/fs/test_fs_list_indexed.c
index 868c9d71a..f9225e3ce 100644
--- a/src/fs/test_fs_list_indexed.c
+++ b/src/fs/test_fs_list_indexed.c
@@ -97,7 +97,6 @@ list_indexed_task (void *cls,
97{ 97{
98 98
99 GNUNET_SCHEDULER_add_continuation (sched, 99 GNUNET_SCHEDULER_add_continuation (sched,
100 GNUNET_NO,
101 &abort_publish_task, 100 &abort_publish_task,
102 NULL, 101 NULL,
103 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 102 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -120,7 +119,6 @@ progress_cb (void *cls,
120 if (0 == strcmp ("list_indexed-context-dir", 119 if (0 == strcmp ("list_indexed-context-dir",
121 event->value.publish.cctx)) 120 event->value.publish.cctx))
122 GNUNET_SCHEDULER_add_continuation (sched, 121 GNUNET_SCHEDULER_add_continuation (sched,
123 GNUNET_NO,
124 &list_indexed_task, 122 &list_indexed_task,
125 NULL, 123 NULL,
126 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 124 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -146,7 +144,6 @@ progress_cb (void *cls,
146 if (0 == strcmp ("list_indexed-context-dir", 144 if (0 == strcmp ("list_indexed-context-dir",
147 event->value.publish.cctx)) 145 event->value.publish.cctx))
148 GNUNET_SCHEDULER_add_continuation (sched, 146 GNUNET_SCHEDULER_add_continuation (sched,
149 GNUNET_NO,
150 &abort_publish_task, 147 &abort_publish_task,
151 NULL, 148 NULL,
152 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 149 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
diff --git a/src/fs/test_fs_publish.c b/src/fs/test_fs_publish.c
index 1b79b941d..a7bcd48d9 100644
--- a/src/fs/test_fs_publish.c
+++ b/src/fs/test_fs_publish.c
@@ -106,7 +106,6 @@ progress_cb (void *cls,
106 if (0 == strcmp ("list_indexed-context-dir", 106 if (0 == strcmp ("list_indexed-context-dir",
107 event->value.publish.cctx)) 107 event->value.publish.cctx))
108 GNUNET_SCHEDULER_add_continuation (sched, 108 GNUNET_SCHEDULER_add_continuation (sched,
109 GNUNET_NO,
110 &abort_publish_task, 109 &abort_publish_task,
111 NULL, 110 NULL,
112 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 111 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -131,7 +130,6 @@ progress_cb (void *cls,
131 if (0 == strcmp ("list_indexed-context-dir", 130 if (0 == strcmp ("list_indexed-context-dir",
132 event->value.publish.cctx)) 131 event->value.publish.cctx))
133 GNUNET_SCHEDULER_add_continuation (sched, 132 GNUNET_SCHEDULER_add_continuation (sched,
134 GNUNET_NO,
135 &abort_publish_task, 133 &abort_publish_task,
136 NULL, 134 NULL,
137 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 135 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -171,7 +169,6 @@ progress_cb (void *cls,
171 { 169 {
172 GNUNET_assert (publish == event->value.publish.sc); 170 GNUNET_assert (publish == event->value.publish.sc);
173 GNUNET_SCHEDULER_add_continuation (sched, 171 GNUNET_SCHEDULER_add_continuation (sched,
174 GNUNET_NO,
175 &abort_publish_task, 172 &abort_publish_task,
176 NULL, 173 NULL,
177 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 174 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
diff --git a/src/fs/test_fs_search.c b/src/fs/test_fs_search.c
index d1b5f77aa..e0961c4a7 100644
--- a/src/fs/test_fs_search.c
+++ b/src/fs/test_fs_search.c
@@ -124,7 +124,6 @@ progress_cb (void *cls,
124 printf ("Search complete.\n"); 124 printf ("Search complete.\n");
125#endif 125#endif
126 GNUNET_SCHEDULER_add_continuation (sched, 126 GNUNET_SCHEDULER_add_continuation (sched,
127 GNUNET_NO,
128 &abort_search_task, 127 &abort_search_task,
129 NULL, 128 NULL,
130 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 129 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -135,7 +134,6 @@ progress_cb (void *cls,
135 event->value.publish.specifics.error.message); 134 event->value.publish.specifics.error.message);
136 GNUNET_break (0); 135 GNUNET_break (0);
137 GNUNET_SCHEDULER_add_continuation (sched, 136 GNUNET_SCHEDULER_add_continuation (sched,
138 GNUNET_NO,
139 &abort_publish_task, 137 &abort_publish_task,
140 NULL, 138 NULL,
141 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 139 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -145,7 +143,6 @@ progress_cb (void *cls,
145 "Error searching file: %s\n", 143 "Error searching file: %s\n",
146 event->value.search.specifics.error.message); 144 event->value.search.specifics.error.message);
147 GNUNET_SCHEDULER_add_continuation (sched, 145 GNUNET_SCHEDULER_add_continuation (sched,
148 GNUNET_NO,
149 &abort_search_task, 146 &abort_search_task,
150 NULL, 147 NULL,
151 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 148 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -174,7 +171,6 @@ progress_cb (void *cls,
174 case GNUNET_FS_STATUS_SEARCH_STOPPED: 171 case GNUNET_FS_STATUS_SEARCH_STOPPED:
175 GNUNET_assert (search == event->value.search.sc); 172 GNUNET_assert (search == event->value.search.sc);
176 GNUNET_SCHEDULER_add_continuation (sched, 173 GNUNET_SCHEDULER_add_continuation (sched,
177 GNUNET_NO,
178 &abort_publish_task, 174 &abort_publish_task,
179 NULL, 175 NULL,
180 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 176 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
diff --git a/src/fs/test_fs_unindex.c b/src/fs/test_fs_unindex.c
index eb10c1db9..af9db7400 100644
--- a/src/fs/test_fs_unindex.c
+++ b/src/fs/test_fs_unindex.c
@@ -121,7 +121,6 @@ progress_cb (void *cls,
121 printf ("Unindex complete, %llu kbps.\n", 121 printf ("Unindex complete, %llu kbps.\n",
122 (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024)); 122 (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024));
123 GNUNET_SCHEDULER_add_continuation (sched, 123 GNUNET_SCHEDULER_add_continuation (sched,
124 GNUNET_NO,
125 &abort_unindex_task, 124 &abort_unindex_task,
126 NULL, 125 NULL,
127 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 126 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -142,7 +141,6 @@ progress_cb (void *cls,
142 event->value.publish.specifics.error.message); 141 event->value.publish.specifics.error.message);
143 GNUNET_break (0); 142 GNUNET_break (0);
144 GNUNET_SCHEDULER_add_continuation (sched, 143 GNUNET_SCHEDULER_add_continuation (sched,
145 GNUNET_NO,
146 &abort_publish_task, 144 &abort_publish_task,
147 NULL, 145 NULL,
148 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 146 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -152,7 +150,6 @@ progress_cb (void *cls,
152 "Error unindexing file: %s\n", 150 "Error unindexing file: %s\n",
153 event->value.unindex.specifics.error.message); 151 event->value.unindex.specifics.error.message);
154 GNUNET_SCHEDULER_add_continuation (sched, 152 GNUNET_SCHEDULER_add_continuation (sched,
155 GNUNET_NO,
156 &abort_unindex_task, 153 &abort_unindex_task,
157 NULL, 154 NULL,
158 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 155 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -181,7 +178,6 @@ progress_cb (void *cls,
181 case GNUNET_FS_STATUS_UNINDEX_STOPPED: 178 case GNUNET_FS_STATUS_UNINDEX_STOPPED:
182 GNUNET_assert (unindex == event->value.unindex.uc); 179 GNUNET_assert (unindex == event->value.unindex.uc);
183 GNUNET_SCHEDULER_add_continuation (sched, 180 GNUNET_SCHEDULER_add_continuation (sched,
184 GNUNET_NO,
185 &abort_publish_task, 181 &abort_publish_task,
186 NULL, 182 NULL,
187 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 183 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c
index 5aa4e70ea..78584cac9 100644
--- a/src/hostlist/gnunet-daemon-hostlist.c
+++ b/src/hostlist/gnunet-daemon-hostlist.c
@@ -177,9 +177,6 @@ run (void *cls,
177 NULL, GNUNET_NO, 177 NULL, GNUNET_NO,
178 handlers); 178 handlers);
179 GNUNET_SCHEDULER_add_delayed (sched, 179 GNUNET_SCHEDULER_add_delayed (sched,
180 GNUNET_YES,
181 GNUNET_SCHEDULER_PRIORITY_IDLE,
182 GNUNET_SCHEDULER_NO_TASK,
183 GNUNET_TIME_UNIT_FOREVER_REL, 180 GNUNET_TIME_UNIT_FOREVER_REL,
184 &cleaning_task, NULL); 181 &cleaning_task, NULL);
185} 182}
diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c
index e0ff1f5a2..8ef5c9895 100644
--- a/src/hostlist/hostlist-client.c
+++ b/src/hostlist/hostlist-client.c
@@ -404,7 +404,6 @@ run_multi ()
404 GNUNET_NETWORK_fdset_copy_native (gws, &ws, max); 404 GNUNET_NETWORK_fdset_copy_native (gws, &ws, max);
405 current_task 405 current_task
406 = GNUNET_SCHEDULER_add_select (sched, 406 = GNUNET_SCHEDULER_add_select (sched,
407 GNUNET_NO,
408 GNUNET_SCHEDULER_PRIORITY_DEFAULT, 407 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
409 GNUNET_SCHEDULER_NO_TASK, 408 GNUNET_SCHEDULER_NO_TASK,
410 GNUNET_TIME_UNIT_MINUTES, 409 GNUNET_TIME_UNIT_MINUTES,
@@ -549,9 +548,6 @@ schedule_hostlist_task ()
549 hostlist_delay.value, 548 hostlist_delay.value,
550 GNUNET_YES); 549 GNUNET_YES);
551 current_task = GNUNET_SCHEDULER_add_delayed (sched, 550 current_task = GNUNET_SCHEDULER_add_delayed (sched,
552 GNUNET_NO,
553 GNUNET_SCHEDULER_PRIORITY_IDLE,
554 GNUNET_SCHEDULER_NO_TASK,
555 delay, 551 delay,
556 &check_task, 552 &check_task,
557 NULL); 553 NULL);
diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c
index 03e3c5d69..38e144a9d 100644
--- a/src/hostlist/hostlist-server.c
+++ b/src/hostlist/hostlist-server.c
@@ -92,9 +92,6 @@ finish_response (struct HostSet *results)
92 GNUNET_free (results); 92 GNUNET_free (results);
93 /* schedule next update of the response */ 93 /* schedule next update of the response */
94 GNUNET_SCHEDULER_add_delayed (sched, 94 GNUNET_SCHEDULER_add_delayed (sched,
95 GNUNET_NO,
96 GNUNET_SCHEDULER_PRIORITY_IDLE,
97 GNUNET_SCHEDULER_NO_TASK,
98 RESPONSE_UPDATE_FREQUENCY, 95 RESPONSE_UPDATE_FREQUENCY,
99 &update_response, 96 &update_response,
100 NULL); 97 NULL);
@@ -252,7 +249,6 @@ prepare_daemon ()
252 GNUNET_NETWORK_fdset_copy_native (wes, &es, max); 249 GNUNET_NETWORK_fdset_copy_native (wes, &es, max);
253 hostlist_task 250 hostlist_task
254 = GNUNET_SCHEDULER_add_select (sched, 251 = GNUNET_SCHEDULER_add_select (sched,
255 GNUNET_NO,
256 GNUNET_SCHEDULER_PRIORITY_HIGH, 252 GNUNET_SCHEDULER_PRIORITY_HIGH,
257 GNUNET_SCHEDULER_NO_TASK, 253 GNUNET_SCHEDULER_NO_TASK,
258 tv, 254 tv,
diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c
index d71340377..ca7a2369a 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist.c
@@ -95,7 +95,6 @@ setup_peer (struct PeerContext *p, const char *cfgname)
95 "-L", "DEBUG", 95 "-L", "DEBUG",
96#endif 96#endif
97 "-c", cfgname, NULL); 97 "-c", cfgname, NULL);
98 sleep (1); /* allow ARM to start */
99#endif 98#endif
100 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 99 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
101 GNUNET_ARM_start_services (p->cfg, sched, "core", NULL); 100 GNUNET_ARM_start_services (p->cfg, sched, "core", NULL);
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 76d28ad57..1dc9cb1aa 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -370,7 +370,6 @@ typedef void (*GNUNET_CRYPTO_HashCompletedCallback) (void *cls,
370 * 370 *
371 * @param sched scheduler to use 371 * @param sched scheduler to use
372 * @param priority scheduling priority to use 372 * @param priority scheduling priority to use
373 * @param run_on_shutdown should we complete even on shutdown?
374 * @param filename name of file to hash 373 * @param filename name of file to hash
375 * @param blocksize number of bytes to process in one task 374 * @param blocksize number of bytes to process in one task
376 * @param callback function to call upon completion 375 * @param callback function to call upon completion
@@ -378,7 +377,6 @@ typedef void (*GNUNET_CRYPTO_HashCompletedCallback) (void *cls,
378 */ 377 */
379void GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched, 378void GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched,
380 enum GNUNET_SCHEDULER_Priority priority, 379 enum GNUNET_SCHEDULER_Priority priority,
381 int run_on_shutdown,
382 const char *filename, 380 const char *filename,
383 size_t blocksize, 381 size_t blocksize,
384 GNUNET_CRYPTO_HashCompletedCallback callback, 382 GNUNET_CRYPTO_HashCompletedCallback callback,
diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h
index 621e57fcf..760a674d5 100644
--- a/src/include/gnunet_scheduler_lib.h
+++ b/src/include/gnunet_scheduler_lib.h
@@ -197,21 +197,30 @@ typedef void (*GNUNET_SCHEDULER_Task) (void *cls,
197 197
198 198
199/** 199/**
200 * Initialize and run scheduler. This function will return when 200 * Initialize and run scheduler. This function will return when all
201 * either a shutdown was initiated (via signal) and all tasks marked 201 * tasks have completed. On systems with signals, receiving a SIGTERM
202 * to "run_on_shutdown" have been completed or when all tasks in 202 * (and other similar signals) will cause "GNUNET_SCHEDULER_shutdown"
203 * general have been completed. 203 * to be run after the active task is complete. As a result, SIGTERM
204 * causes all active tasks to be scheduled with reason
205 * "GNUNET_SCHEDULER_REASON_SHUTDOWN". (However, tasks added
206 * afterwards will execute normally!). Note that any particular
207 * signal will only shut down one scheduler; applications should
208 * always only create a single scheduler.
204 * 209 *
205 * @param task task to run immediately 210 * @param task task to run first (and immediately)
206 * @param cls closure of task 211 * @param task_cls closure of task
207 */ 212 */
208void GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *cls); 213void GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls);
209 214
210 215
211/** 216/**
212 * Request the shutdown of a scheduler. This function can be used to 217 * Request the shutdown of a scheduler. Marks all currently
213 * stop a scheduler, for example from within the signal 218 * pending tasks as ready because of shutdown. This will
214 * handler for signals causing shutdowns. 219 * cause all tasks to run (as soon as possible, respecting
220 * priorities and prerequisite tasks). Note that tasks
221 * scheduled AFTER this call may still be delayed arbitrarily.
222 *
223 * @param sched the scheduler
215 */ 224 */
216void GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched); 225void GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched);
217 226
@@ -256,68 +265,70 @@ void *GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched,
256 */ 265 */
257void 266void
258GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched, 267GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched,
259 int run_on_shutdown,
260 GNUNET_SCHEDULER_Task main, 268 GNUNET_SCHEDULER_Task main,
261 void *cls, 269 void *cls,
262 enum GNUNET_SCHEDULER_Reason reason); 270 enum GNUNET_SCHEDULER_Reason reason);
263 271
264 272
265/** 273/**
266 * Schedule a new task to be run after the specified 274 * Schedule a new task to be run after the specified prerequisite task
267 * prerequisite task has completed. 275 * has completed. It will be run with the priority of the calling
276 * task.
268 * 277 *
269 * @param sched scheduler to use 278 * @param sched scheduler to use
270 * @param run_on_shutdown run on shutdown?
271 * @param prio how important is this task?
272 * @param prerequisite_task run this task after the task with the given 279 * @param prerequisite_task run this task after the task with the given
273 * task identifier completes (and any of our other 280 * task identifier completes (and any of our other
274 * conditions, such as delay, read or write-readyness 281 * conditions, such as delay, read or write-readyness
275 * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency 282 * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency
276 * on completion of other tasks. 283 * on completion of other tasks (this will cause the task to run as
277 * @param main main function of the task 284 * soon as possible).
278 * @param cls closure of task 285 * @param task main function of the task
286 * @param task_cls closure of task
279 * @return unique task identifier for the job 287 * @return unique task identifier for the job
280 * only valid until "main" is started! 288 * only valid until "task" is started!
281 */ 289 */
282GNUNET_SCHEDULER_TaskIdentifier 290GNUNET_SCHEDULER_TaskIdentifier
283GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched, 291GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched,
284 int run_on_shutdown,
285 enum GNUNET_SCHEDULER_Priority prio,
286 GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, 292 GNUNET_SCHEDULER_TaskIdentifier prerequisite_task,
287 GNUNET_SCHEDULER_Task main, void *cls); 293 GNUNET_SCHEDULER_Task task,
294 void *task_cls);
295
296
297/**
298 * Schedule a new task to be run with a specified priority.
299 *
300 * @param sched scheduler to use
301 * @param prio how important is the new task?
302 * @param task main function of the task
303 * @param task_cls closure of task
304 * @return unique task identifier for the job
305 * only valid until "task" is started!
306 */
307GNUNET_SCHEDULER_TaskIdentifier
308GNUNET_SCHEDULER_add_with_priority (struct GNUNET_SCHEDULER_Handle *sched,
309 enum GNUNET_SCHEDULER_Priority prio,
310 GNUNET_SCHEDULER_Task task,
311 void *task_cls);
288 312
289 313
290/** 314/**
291 * Schedule a new task to be run with a specified delay. The task 315 * Schedule a new task to be run with a specified delay. The task
292 * will be scheduled for execution once the delay has expired and the 316 * will be scheduled for execution once the delay has expired. It
293 * prerequisite task has completed. 317 * will be run with the priority of the calling task.
294 * 318 *
295 * @param sched scheduler to use 319 * @param sched scheduler to use
296 * @param run_on_shutdown run on shutdown? You can use this 320 * @param delay when should this operation time out? Use
297 * argument to run a function only during shutdown 321 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
298 * by setting delay to -1. Set this 322 * @param task main function of the task
299 * argument to GNUNET_NO to skip this task if 323 * @param task_cls closure of task
300 * the user requested process termination.
301 * @param prio how important is this task?
302 * @param prerequisite_task run this task after the task with the given
303 * task identifier completes (and any of our other
304 * conditions, such as delay, read or write-readyness
305 * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency
306 * on completion of other tasks.
307 * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever"
308 * @param main main function of the task
309 * @param cls closure of task
310 * @return unique task identifier for the job 324 * @return unique task identifier for the job
311 * only valid until "main" is started! 325 * only valid until "task" is started!
312 */ 326 */
313GNUNET_SCHEDULER_TaskIdentifier 327GNUNET_SCHEDULER_TaskIdentifier
314GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle *sched, 328GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle *sched,
315 int run_on_shutdown,
316 enum GNUNET_SCHEDULER_Priority prio,
317 GNUNET_SCHEDULER_TaskIdentifier
318 prerequisite_task,
319 struct GNUNET_TIME_Relative delay, 329 struct GNUNET_TIME_Relative delay,
320 GNUNET_SCHEDULER_Task main, void *cls); 330 GNUNET_SCHEDULER_Task task,
331 void *task_cls);
321 332
322 333
323/** 334/**
@@ -325,32 +336,24 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle *sched,
325 * specified file descriptor is ready for reading. The delay can be 336 * specified file descriptor is ready for reading. The delay can be
326 * used as a timeout on the socket being ready. The task will be 337 * used as a timeout on the socket being ready. The task will be
327 * scheduled for execution once either the delay has expired or the 338 * scheduled for execution once either the delay has expired or the
328 * socket operation is ready. 339 * socket operation is ready. It will be run with the priority of
340 * the calling task.
329 * 341 *
330 * @param sched scheduler to use 342 * @param sched scheduler to use
331 * @param run_on_shutdown run on shutdown? Set this 343 * @param delay when should this operation time out? Use
332 * argument to GNUNET_NO to skip this task if 344 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
333 * the user requested process termination.
334 * @param prio how important is this task?
335 * @param prerequisite_task run this task after the task with the given
336 * task identifier completes (and any of our other
337 * conditions, such as delay, read or write-readyness
338 * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency
339 * on completion of other tasks.
340 * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever"
341 * @param rfd read file-descriptor 345 * @param rfd read file-descriptor
342 * @param main main function of the task 346 * @param task main function of the task
343 * @param cls closure of task 347 * @param task_cls closure of task
344 * @return unique task identifier for the job 348 * @return unique task identifier for the job
345 * only valid until "main" is started! 349 * only valid until "task" is started!
346 */ 350 */
347GNUNET_SCHEDULER_TaskIdentifier 351GNUNET_SCHEDULER_TaskIdentifier
348GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle *sched, 352GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle *sched,
349 int run_on_shutdown, 353 struct GNUNET_TIME_Relative delay,
350 enum GNUNET_SCHEDULER_Priority prio, 354 struct GNUNET_NETWORK_Handle *rfd,
351 GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, 355 GNUNET_SCHEDULER_Task task,
352 struct GNUNET_TIME_Relative delay, 356 void *task_cls);
353 struct GNUNET_NETWORK_Handle *rfd, GNUNET_SCHEDULER_Task main, void *cls);
354 357
355 358
356/** 359/**
@@ -358,32 +361,24 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle *sched,
358 * specified file descriptor is ready for writing. The delay can be 361 * specified file descriptor is ready for writing. The delay can be
359 * used as a timeout on the socket being ready. The task will be 362 * used as a timeout on the socket being ready. The task will be
360 * scheduled for execution once either the delay has expired or the 363 * scheduled for execution once either the delay has expired or the
361 * socket operation is ready. 364 * socket operation is ready. It will be run with the priority of
365 * the calling task.
362 * 366 *
363 * @param sched scheduler to use 367 * @param sched scheduler to use
364 * @param run_on_shutdown run on shutdown? Set this 368 * @param delay when should this operation time out? Use
365 * argument to GNUNET_NO to skip this task if 369 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
366 * the user requested process termination.
367 * @param prio how important is this task?
368 * @param prerequisite_task run this task after the task with the given
369 * task identifier completes (and any of our other
370 * conditions, such as delay, read or write-readyness
371 * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency
372 * on completion of other tasks.
373 * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever"
374 * @param wfd write file-descriptor 370 * @param wfd write file-descriptor
375 * @param main main function of the task 371 * @param task main function of the task
376 * @param cls closure of task 372 * @param task_cls closure of task
377 * @return unique task identifier for the job 373 * @return unique task identifier for the job
378 * only valid until "main" is started! 374 * only valid until "task" is started!
379 */ 375 */
380GNUNET_SCHEDULER_TaskIdentifier 376GNUNET_SCHEDULER_TaskIdentifier
381GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle *sched, 377GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle *sched,
382 int run_on_shutdown, 378 struct GNUNET_TIME_Relative delay,
383 enum GNUNET_SCHEDULER_Priority prio, 379 struct GNUNET_NETWORK_Handle *wfd,
384 GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, 380 GNUNET_SCHEDULER_Task task,
385 struct GNUNET_TIME_Relative delay, 381 void *task_cls);
386 struct GNUNET_NETWORK_Handle *wfd, GNUNET_SCHEDULER_Task main, void *cls);
387 382
388 383
389/** 384/**
@@ -391,33 +386,24 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle *sched,
391 * specified file descriptor is ready for reading. The delay can be 386 * specified file descriptor is ready for reading. The delay can be
392 * used as a timeout on the socket being ready. The task will be 387 * used as a timeout on the socket being ready. The task will be
393 * scheduled for execution once either the delay has expired or the 388 * scheduled for execution once either the delay has expired or the
394 * socket operation is ready. 389 * socket operation is ready. It will be run with the priority of
390 * the calling task.
395 * 391 *
396 * @param sched scheduler to use 392 * @param sched scheduler to use
397 * @param run_on_shutdown run on shutdown? Set this 393 * @param delay when should this operation time out? Use
398 * argument to GNUNET_NO to skip this task if 394 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
399 * the user requested process termination.
400 * @param prio how important is this task?
401 * @param prerequisite_task run this task after the task with the given
402 * task identifier completes (and any of our other
403 * conditions, such as delay, read or write-readyness
404 * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency
405 * on completion of other tasks.
406 * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever"
407 * @param rfd read file-descriptor 395 * @param rfd read file-descriptor
408 * @param main main function of the task 396 * @param task main function of the task
409 * @param cls closure of task 397 * @param task_cls closure of task
410 * @return unique task identifier for the job 398 * @return unique task identifier for the job
411 * only valid until "main" is started! 399 * only valid until "task" is started!
412 */ 400 */
413GNUNET_SCHEDULER_TaskIdentifier 401GNUNET_SCHEDULER_TaskIdentifier
414GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle *sched, 402GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle *sched,
415 int run_on_shutdown,
416 enum GNUNET_SCHEDULER_Priority prio,
417 GNUNET_SCHEDULER_TaskIdentifier prerequisite_task,
418 struct GNUNET_TIME_Relative delay, 403 struct GNUNET_TIME_Relative delay,
419 const struct GNUNET_DISK_FileHandle *rfd, 404 const struct GNUNET_DISK_FileHandle *rfd,
420 GNUNET_SCHEDULER_Task main, void *cls); 405 GNUNET_SCHEDULER_Task task,
406 void *task_cls);
421 407
422 408
423/** 409/**
@@ -425,33 +411,24 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle *sched,
425 * specified file descriptor is ready for writing. The delay can be 411 * specified file descriptor is ready for writing. The delay can be
426 * used as a timeout on the socket being ready. The task will be 412 * used as a timeout on the socket being ready. The task will be
427 * scheduled for execution once either the delay has expired or the 413 * scheduled for execution once either the delay has expired or the
428 * socket operation is ready. 414 * socket operation is ready. It will be run with the priority of
415 * the calling task.
429 * 416 *
430 * @param sched scheduler to use 417 * @param sched scheduler to use
431 * @param run_on_shutdown run on shutdown? Set this 418 * @param delay when should this operation time out? Use
432 * argument to GNUNET_NO to skip this task if 419 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
433 * the user requested process termination.
434 * @param prio how important is this task?
435 * @param prerequisite_task run this task after the task with the given
436 * task identifier completes (and any of our other
437 * conditions, such as delay, read or write-readyness
438 * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency
439 * on completion of other tasks.
440 * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever"
441 * @param wfd write file-descriptor 420 * @param wfd write file-descriptor
442 * @param main main function of the task 421 * @param task main function of the task
443 * @param cls closure of task 422 * @param task_cls closure of task
444 * @return unique task identifier for the job 423 * @return unique task identifier for the job
445 * only valid until "main" is started! 424 * only valid until "task" is started!
446 */ 425 */
447GNUNET_SCHEDULER_TaskIdentifier 426GNUNET_SCHEDULER_TaskIdentifier
448GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle *sched, 427GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle *sched,
449 int run_on_shutdown,
450 enum GNUNET_SCHEDULER_Priority prio,
451 GNUNET_SCHEDULER_TaskIdentifier prerequisite_task,
452 struct GNUNET_TIME_Relative delay, 428 struct GNUNET_TIME_Relative delay,
453 const struct GNUNET_DISK_FileHandle *wfd, 429 const struct GNUNET_DISK_FileHandle *wfd,
454 GNUNET_SCHEDULER_Task main, void *cls); 430 GNUNET_SCHEDULER_Task task,
431 void *task_cls);
455 432
456 433
457/** 434/**
@@ -472,33 +449,31 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle *sched,
472 * </code> 449 * </code>
473 * 450 *
474 * @param sched scheduler to use 451 * @param sched scheduler to use
475 * @param run_on_shutdown run on shutdown? Set this
476 * argument to GNUNET_NO to skip this task if
477 * the user requested process termination.
478 * @param prio how important is this task? 452 * @param prio how important is this task?
479 * @param prerequisite_task run this task after the task with the given 453 * @param prerequisite_task run this task after the task with the given
480 * task identifier completes (and any of our other 454 * task identifier completes (and any of our other
481 * conditions, such as delay, read or write-readyness 455 * conditions, such as delay, read or write-readyness
482 * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency 456 * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency
483 * on completion of other tasks. 457 * on completion of other tasks.
484 * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever" 458 * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever",
459 * which means that the task will only be run after we receive SIGTERM
485 * @param rs set of file descriptors we want to read (can be NULL) 460 * @param rs set of file descriptors we want to read (can be NULL)
486 * @param ws set of file descriptors we want to write (can be NULL) 461 * @param ws set of file descriptors we want to write (can be NULL)
487 * @param main main function of the task 462 * @param task main function of the task
488 * @param cls closure of task 463 * @param task_cls closure of task
489 * @return unique task identifier for the job 464 * @return unique task identifier for the job
490 * only valid until "main" is started! 465 * only valid until "task" is started!
491 */ 466 */
492GNUNET_SCHEDULER_TaskIdentifier 467GNUNET_SCHEDULER_TaskIdentifier
493GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle *sched, 468GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle *sched,
494 int run_on_shutdown,
495 enum GNUNET_SCHEDULER_Priority prio, 469 enum GNUNET_SCHEDULER_Priority prio,
496 GNUNET_SCHEDULER_TaskIdentifier 470 GNUNET_SCHEDULER_TaskIdentifier
497 prerequisite_task, 471 prerequisite_task,
498 struct GNUNET_TIME_Relative delay, 472 struct GNUNET_TIME_Relative delay,
499 const struct GNUNET_NETWORK_FDSet * rs, 473 const struct GNUNET_NETWORK_FDSet * rs,
500 const struct GNUNET_NETWORK_FDSet * ws, 474 const struct GNUNET_NETWORK_FDSet * ws,
501 GNUNET_SCHEDULER_Task main, void *cls); 475 GNUNET_SCHEDULER_Task task,
476 void *task_cls);
502 477
503#if 0 /* keep Emacsens' auto-indent happy */ 478#if 0 /* keep Emacsens' auto-indent happy */
504{ 479{
diff --git a/src/include/gnunet_service_lib.h b/src/include/gnunet_service_lib.h
index 0c69d297c..82089954e 100644
--- a/src/include/gnunet_service_lib.h
+++ b/src/include/gnunet_service_lib.h
@@ -55,18 +55,6 @@ typedef void (*GNUNET_SERVICE_Main) (void *cls,
55 55
56 56
57/** 57/**
58 * Function called when the service shuts
59 * down to run service-specific teardown code.
60 *
61 * @param cls closure
62 * @param cfg configuration to use
63 */
64typedef void (*GNUNET_SERVICE_Term) (void *cls,
65 const struct GNUNET_CONFIGURATION_Handle *
66 cfg);
67
68
69/**
70 * Run a standard GNUnet service startup sequence (initialize loggers 58 * Run a standard GNUnet service startup sequence (initialize loggers
71 * and configuration, parse options). 59 * and configuration, parse options).
72 * 60 *
@@ -75,8 +63,6 @@ typedef void (*GNUNET_SERVICE_Term) (void *cls,
75 * @param serviceName our service name 63 * @param serviceName our service name
76 * @param task main task of the service 64 * @param task main task of the service
77 * @param task_cls closure for task 65 * @param task_cls closure for task
78 * @param term termination task of the service
79 * @param term_cls closure for term
80 * @return GNUNET_SYSERR on error, GNUNET_OK 66 * @return GNUNET_SYSERR on error, GNUNET_OK
81 * if we shutdown nicely 67 * if we shutdown nicely
82 */ 68 */
@@ -84,8 +70,7 @@ int GNUNET_SERVICE_run (int argc,
84 char *const *argv, 70 char *const *argv,
85 const char *serviceName, 71 const char *serviceName,
86 GNUNET_SERVICE_Main task, 72 GNUNET_SERVICE_Main task,
87 void *task_cls, 73 void *task_cls);
88 GNUNET_SERVICE_Term term, void *term_cls);
89 74
90 75
91struct GNUNET_SERVICE_Context; 76struct GNUNET_SERVICE_Context;
diff --git a/src/nat/nat.c b/src/nat/nat.c
index 2a93d31a7..151c526d4 100644
--- a/src/nat/nat.c
+++ b/src/nat/nat.c
@@ -285,9 +285,7 @@ nat_pulse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
285 notify_change (nat, ext_addr_natpmp, port_mapped); 285 notify_change (nat, ext_addr_natpmp, port_mapped);
286 } 286 }
287 287
288 nat->pulse_timer = GNUNET_SCHEDULER_add_delayed (nat->sched, GNUNET_NO, 288 nat->pulse_timer = GNUNET_SCHEDULER_add_delayed (nat->sched,
289 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
290 GNUNET_SCHEDULER_NO_TASK,
291 GNUNET_TIME_UNIT_SECONDS, 289 GNUNET_TIME_UNIT_SECONDS,
292 &nat_pulse, nat); 290 &nat_pulse, nat);
293} 291}
@@ -335,9 +333,7 @@ GNUNET_NAT_register (struct GNUNET_SCHEDULER_Handle *sched,
335 nat->natpmp = GNUNET_NAT_NATPMP_init (nat->local_addr, addrlen, nat->public_port); 333 nat->natpmp = GNUNET_NAT_NATPMP_init (nat->local_addr, addrlen, nat->public_port);
336 nat->upnp = GNUNET_NAT_UPNP_init (nat->local_addr, addrlen, nat->public_port); 334 nat->upnp = GNUNET_NAT_UPNP_init (nat->local_addr, addrlen, nat->public_port);
337 335
338 nat->pulse_timer = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, 336 nat->pulse_timer = GNUNET_SCHEDULER_add_delayed (sched,
339 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
340 GNUNET_SCHEDULER_NO_TASK,
341 GNUNET_TIME_UNIT_SECONDS, 337 GNUNET_TIME_UNIT_SECONDS,
342 &nat_pulse, nat); 338 &nat_pulse, nat);
343 339
diff --git a/src/nat/test_nat.c b/src/nat/test_nat.c
index 2ff168c56..dc5112c36 100644
--- a/src/nat/test_nat.c
+++ b/src/nat/test_nat.c
@@ -125,9 +125,7 @@ run (void *cls,
125 nat = GNUNET_NAT_register (sched, addr, data.addrlen, addr_callback, NULL); 125 nat = GNUNET_NAT_register (sched, addr, data.addrlen, addr_callback, NULL);
126 GNUNET_free (addr); 126 GNUNET_free (addr);
127 127
128 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, 128 GNUNET_SCHEDULER_add_delayed (sched,
129 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
130 GNUNET_SCHEDULER_NO_TASK,
131 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, TIMEOUT), 129 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, TIMEOUT),
132 stop, nat); 130 stop, nat);
133} 131}
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c
index 11e311c22..f5a60470e 100644
--- a/src/peerinfo/gnunet-service-peerinfo.c
+++ b/src/peerinfo/gnunet-service-peerinfo.c
@@ -342,6 +342,8 @@ cron_scan_directory_data_hosts (void *cls,
342 static unsigned int retries; 342 static unsigned int retries;
343 unsigned int count; 343 unsigned int count;
344 344
345 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
346 return;
345 count = 0; 347 count = 0;
346 GNUNET_DISK_directory_create (networkIdDirectory); 348 GNUNET_DISK_directory_create (networkIdDirectory);
347 GNUNET_DISK_directory_scan (networkIdDirectory, 349 GNUNET_DISK_directory_scan (networkIdDirectory,
@@ -351,9 +353,6 @@ cron_scan_directory_data_hosts (void *cls,
351 GNUNET_ERROR_TYPE_BULK, 353 GNUNET_ERROR_TYPE_BULK,
352 _("Still no peers found in `%s'!\n"), networkIdDirectory); 354 _("Still no peers found in `%s'!\n"), networkIdDirectory);
353 GNUNET_SCHEDULER_add_delayed (tc->sched, 355 GNUNET_SCHEDULER_add_delayed (tc->sched,
354 GNUNET_NO,
355 GNUNET_SCHEDULER_PRIORITY_KEEP,
356 GNUNET_SCHEDULER_NO_TASK,
357 DATA_HOST_FREQ, 356 DATA_HOST_FREQ,
358 &cron_scan_directory_data_hosts, NULL); 357 &cron_scan_directory_data_hosts, NULL);
359} 358}
@@ -501,12 +500,10 @@ cron_flush_trust (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
501 flush_trust (pos); 500 flush_trust (pos);
502 pos = pos->next; 501 pos = pos->next;
503 } 502 }
504 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 503 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
505 GNUNET_SCHEDULER_add_delayed (tc->sched, 504 return;
506 GNUNET_YES, 505 GNUNET_SCHEDULER_add_delayed (tc->sched,
507 GNUNET_SCHEDULER_PRIORITY_KEEP, 506 TRUST_FLUSH_FREQ, &cron_flush_trust, NULL);
508 GNUNET_SCHEDULER_NO_TASK,
509 TRUST_FLUSH_FREQ, &cron_flush_trust, NULL);
510} 507}
511 508
512 509
@@ -558,14 +555,13 @@ cron_clean_data_hosts (void *cls,
558{ 555{
559 struct GNUNET_TIME_Absolute now; 556 struct GNUNET_TIME_Absolute now;
560 557
558 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
559 return;
561 now = GNUNET_TIME_absolute_get (); 560 now = GNUNET_TIME_absolute_get ();
562 GNUNET_DISK_directory_scan (networkIdDirectory, 561 GNUNET_DISK_directory_scan (networkIdDirectory,
563 &discard_hosts_helper, &now); 562 &discard_hosts_helper, &now);
564 563
565 GNUNET_SCHEDULER_add_delayed (tc->sched, 564 GNUNET_SCHEDULER_add_delayed (tc->sched,
566 GNUNET_NO,
567 GNUNET_SCHEDULER_PRIORITY_KEEP,
568 GNUNET_SCHEDULER_NO_TASK,
569 DATA_HOST_CLEAN_FREQ, 565 DATA_HOST_CLEAN_FREQ,
570 &cron_clean_data_hosts, NULL); 566 &cron_clean_data_hosts, NULL);
571} 567}
@@ -660,6 +656,7 @@ static struct GNUNET_SERVER_MessageHandler handlers[] = {
660}; 656};
661 657
662 658
659
663/** 660/**
664 * Process statistics requests. 661 * Process statistics requests.
665 * 662 *
@@ -686,23 +683,15 @@ run (void *cls,
686 &trustDirectory)); 683 &trustDirectory));
687 GNUNET_DISK_directory_create (networkIdDirectory); 684 GNUNET_DISK_directory_create (networkIdDirectory);
688 GNUNET_DISK_directory_create (trustDirectory); 685 GNUNET_DISK_directory_create (trustDirectory);
689 GNUNET_SCHEDULER_add_delayed (sched, 686 GNUNET_SCHEDULER_add_with_priority (sched,
690 GNUNET_NO, 687 GNUNET_SCHEDULER_PRIORITY_IDLE,
691 GNUNET_SCHEDULER_PRIORITY_IDLE, 688 &cron_scan_directory_data_hosts, NULL);
692 GNUNET_SCHEDULER_NO_TASK, 689 GNUNET_SCHEDULER_add_with_priority (sched,
693 GNUNET_TIME_UNIT_MILLISECONDS, 690 GNUNET_SCHEDULER_PRIORITY_HIGH,
694 &cron_scan_directory_data_hosts, NULL); 691 &cron_flush_trust, NULL);
695 GNUNET_SCHEDULER_add_delayed (sched, 692 GNUNET_SCHEDULER_add_with_priority (sched,
696 GNUNET_YES, 693 GNUNET_SCHEDULER_PRIORITY_IDLE,
697 GNUNET_SCHEDULER_PRIORITY_HIGH, 694 &cron_clean_data_hosts, NULL);
698 GNUNET_SCHEDULER_NO_TASK,
699 TRUST_FLUSH_FREQ, &cron_flush_trust, NULL);
700 GNUNET_SCHEDULER_add_delayed (sched,
701 GNUNET_NO,
702 GNUNET_SCHEDULER_PRIORITY_IDLE,
703 GNUNET_SCHEDULER_NO_TASK,
704 DATA_HOST_CLEAN_FREQ,
705 &cron_clean_data_hosts, NULL);
706 GNUNET_SERVER_add_handlers (server, handlers); 695 GNUNET_SERVER_add_handlers (server, handlers);
707} 696}
708 697
@@ -722,7 +711,7 @@ main (int argc, char *const *argv)
722 ret = (GNUNET_OK == 711 ret = (GNUNET_OK ==
723 GNUNET_SERVICE_run (argc, 712 GNUNET_SERVICE_run (argc,
724 argv, 713 argv,
725 "peerinfo", &run, NULL, NULL, NULL)) ? 0 : 1; 714 "peerinfo", &run, NULL)) ? 0 : 1;
726 GNUNET_free_non_null (networkIdDirectory); 715 GNUNET_free_non_null (networkIdDirectory);
727 GNUNET_free_non_null (trustDirectory); 716 GNUNET_free_non_null (trustDirectory);
728 return ret; 717 return ret;
diff --git a/src/peerinfo/test_peerinfo_api.c b/src/peerinfo/test_peerinfo_api.c
index 2bae851bc..a375ca40e 100644
--- a/src/peerinfo/test_peerinfo_api.c
+++ b/src/peerinfo/test_peerinfo_api.c
@@ -149,7 +149,6 @@ check ()
149 "-L", "DEBUG", 149 "-L", "DEBUG",
150#endif 150#endif
151 "-c", "test_peerinfo_api_data.conf", NULL); 151 "-c", "test_peerinfo_api_data.conf", NULL);
152 sleep (1);
153 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 152 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
154 argv, "test-peerinfo-api", "nohelp", 153 argv, "test-peerinfo-api", "nohelp",
155 options, &run, &ok); 154 options, &run, &ok);
diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c
index 3221fe2ae..8de9a8047 100644
--- a/src/statistics/gnunet-service-statistics.c
+++ b/src/statistics/gnunet-service-statistics.c
@@ -83,6 +83,11 @@ struct StatsEntry
83}; 83};
84 84
85/** 85/**
86 * Our configuration.
87 */
88static const struct GNUNET_CONFIGURATION_Handle *cfg;
89
90/**
86 * Linked list of our active statistics. 91 * Linked list of our active statistics.
87 */ 92 */
88static struct StatsEntry *start; 93static struct StatsEntry *start;
@@ -96,10 +101,11 @@ static uint32_t uidgen;
96 * Load persistent values from disk. Disk format is 101 * Load persistent values from disk. Disk format is
97 * exactly the same format that we also use for 102 * exactly the same format that we also use for
98 * setting the values over the network. 103 * setting the values over the network.
104 *
105 * @param server handle to the server context
99 */ 106 */
100static void 107static void
101load (struct GNUNET_SERVER_Handle *server, 108load (struct GNUNET_SERVER_Handle *server)
102 const struct GNUNET_CONFIGURATION_Handle *cfg)
103{ 109{
104 char *fn; 110 char *fn;
105 struct GNUNET_DISK_FileHandle *fh; 111 struct GNUNET_DISK_FileHandle *fh;
@@ -153,16 +159,11 @@ load (struct GNUNET_SERVER_Handle *server,
153 GNUNET_free (fn); 159 GNUNET_free (fn);
154} 160}
155 161
156
157/** 162/**
158 * Write persistent statistics to disk. 163 * Write persistent statistics to disk.
159 *
160 * @param cls closure
161 * @param cfg configuration to use
162 */ 164 */
163static void 165static void
164save (void *cls, 166save ()
165 const struct GNUNET_CONFIGURATION_Handle *cfg)
166{ 167{
167 struct StatsEntry *pos; 168 struct StatsEntry *pos;
168 char *fn; 169 char *fn;
@@ -435,21 +436,40 @@ static struct GNUNET_SERVER_MessageHandler handlers[] = {
435 436
436 437
437/** 438/**
439 * Task run during shutdown.
440 *
441 * @param cls unused
442 * @param tc unused
443 */
444static void
445shutdown_task (void *cls,
446 const struct GNUNET_SCHEDULER_TaskContext *tc)
447{
448 save ();
449}
450
451
452/**
438 * Process statistics requests. 453 * Process statistics requests.
439 * 454 *
440 * @param cls closure 455 * @param cls closure
441 * @param sched scheduler to use 456 * @param sched scheduler to use
442 * @param server the initialized server 457 * @param server the initialized server
443 * @param cfg configuration to use 458 * @param c configuration to use
444 */ 459 */
445static void 460static void
446run (void *cls, 461run (void *cls,
447 struct GNUNET_SCHEDULER_Handle *sched, 462 struct GNUNET_SCHEDULER_Handle *sched,
448 struct GNUNET_SERVER_Handle *server, 463 struct GNUNET_SERVER_Handle *server,
449 const struct GNUNET_CONFIGURATION_Handle *cfg) 464 const struct GNUNET_CONFIGURATION_Handle *c)
450{ 465{
466 cfg = c;
451 GNUNET_SERVER_add_handlers (server, handlers); 467 GNUNET_SERVER_add_handlers (server, handlers);
452 load (server, cfg); 468 load (server);
469 GNUNET_SCHEDULER_add_delayed (sched,
470 GNUNET_TIME_UNIT_FOREVER_REL,
471 &shutdown_task,
472 NULL);
453} 473}
454 474
455 475
@@ -466,7 +486,7 @@ main (int argc, char *const *argv)
466 return (GNUNET_OK == 486 return (GNUNET_OK ==
467 GNUNET_SERVICE_run (argc, 487 GNUNET_SERVICE_run (argc,
468 argv, 488 argv,
469 "statistics", &run, NULL, &save, NULL)) ? 0 : 1; 489 "statistics", &run, NULL)) ? 0 : 1;
470} 490}
471 491
472/* end of gnunet-service-statistics.c */ 492/* end of gnunet-service-statistics.c */
diff --git a/src/template/gnunet-service-template.c b/src/template/gnunet-service-template.c
index 3ab7d3dcc..15ba94b7d 100644
--- a/src/template/gnunet-service-template.c
+++ b/src/template/gnunet-service-template.c
@@ -27,19 +27,6 @@
27#include "gnunet_getopt_lib.h" 27#include "gnunet_getopt_lib.h"
28#include "gnunet_service_lib.h" 28#include "gnunet_service_lib.h"
29 29
30/**
31 * Do cleanup here.
32 *
33 * @param cls closure
34 * @param cfg configuration to use
35 */
36static void
37finish (void *cls,
38 const struct GNUNET_CONFIGURATION_Handle *cfg)
39{
40 /* FIXME */
41}
42
43 30
44/** 31/**
45 * List of handlers for the messages understood by this 32 * List of handlers for the messages understood by this
@@ -50,6 +37,21 @@ static struct GNUNET_SERVER_MessageHandler handlers[] = {
50 {NULL, NULL, 0, 0} 37 {NULL, NULL, 0, 0}
51}; 38};
52 39
40
41/**
42 * Task run during shutdown.
43 *
44 * @param cls unused
45 * @param tc unused
46 */
47static void
48cleanup_task (void *cls,
49 const struct GNUNET_SCHEDULER_TaskContext *tc)
50{
51 /* FIXME: do clean up here */
52}
53
54
53/** 55/**
54 * Process template requests. 56 * Process template requests.
55 * 57 *
@@ -66,6 +68,10 @@ run (void *cls,
66{ 68{
67 /* FIXME: do setup here */ 69 /* FIXME: do setup here */
68 GNUNET_SERVER_add_handlers (server, handlers); 70 GNUNET_SERVER_add_handlers (server, handlers);
71 GNUNET_SCHEDULER_add_delayed (sched,
72 GNUNET_TIME_UNIT_FOREVER_REL,
73 &cleanup_task,
74 NULL);
69} 75}
70 76
71 77
@@ -82,7 +88,7 @@ main (int argc, char *const *argv)
82 return (GNUNET_OK == 88 return (GNUNET_OK ==
83 GNUNET_SERVICE_run (argc, 89 GNUNET_SERVICE_run (argc,
84 argv, 90 argv,
85 "template", &run, NULL, &finish, NULL)) ? 0 : 1; 91 "template", &run, NULL)) ? 0 : 1;
86} 92}
87 93
88/* end of gnunet-service-template.c */ 94/* end of gnunet-service-template.c */
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 2bd14095f..e34e7a9ac 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -306,9 +306,6 @@ start_fsm (void *cls,
306 /* wait some more */ 306 /* wait some more */
307 d->task 307 d->task
308 = GNUNET_SCHEDULER_add_delayed (d->sched, 308 = GNUNET_SCHEDULER_add_delayed (d->sched,
309 GNUNET_NO,
310 GNUNET_SCHEDULER_PRIORITY_KEEP,
311 GNUNET_SCHEDULER_NO_TASK,
312 GNUNET_CONSTANTS_EXEC_WAIT, 309 GNUNET_CONSTANTS_EXEC_WAIT,
313 &start_fsm, 310 &start_fsm,
314 d); 311 d);
@@ -392,9 +389,6 @@ start_fsm (void *cls,
392 d->wait_runs = 0; 389 d->wait_runs = 0;
393 d->task 390 d->task
394 = GNUNET_SCHEDULER_add_delayed (d->sched, 391 = GNUNET_SCHEDULER_add_delayed (d->sched,
395 GNUNET_NO,
396 GNUNET_SCHEDULER_PRIORITY_KEEP,
397 GNUNET_SCHEDULER_NO_TASK,
398 GNUNET_CONSTANTS_EXEC_WAIT, 392 GNUNET_CONSTANTS_EXEC_WAIT,
399 &start_fsm, 393 &start_fsm,
400 d); 394 d);
@@ -423,9 +417,6 @@ start_fsm (void *cls,
423 /* wait some more */ 417 /* wait some more */
424 d->task 418 d->task
425 = GNUNET_SCHEDULER_add_delayed (d->sched, 419 = GNUNET_SCHEDULER_add_delayed (d->sched,
426 GNUNET_NO,
427 GNUNET_SCHEDULER_PRIORITY_KEEP,
428 GNUNET_SCHEDULER_NO_TASK,
429 GNUNET_CONSTANTS_EXEC_WAIT, 420 GNUNET_CONSTANTS_EXEC_WAIT,
430 &start_fsm, 421 &start_fsm,
431 d); 422 d);
@@ -474,9 +465,6 @@ start_fsm (void *cls,
474 /* wait some more */ 465 /* wait some more */
475 d->task 466 d->task
476 = GNUNET_SCHEDULER_add_delayed (d->sched, 467 = GNUNET_SCHEDULER_add_delayed (d->sched,
477 GNUNET_NO,
478 GNUNET_SCHEDULER_PRIORITY_KEEP,
479 GNUNET_SCHEDULER_NO_TASK,
480 GNUNET_CONSTANTS_EXEC_WAIT, 468 GNUNET_CONSTANTS_EXEC_WAIT,
481 &start_fsm, 469 &start_fsm,
482 d); 470 d);
@@ -528,9 +516,6 @@ start_fsm (void *cls,
528 /* wait some more */ 516 /* wait some more */
529 d->task 517 d->task
530 = GNUNET_SCHEDULER_add_delayed (d->sched, 518 = GNUNET_SCHEDULER_add_delayed (d->sched,
531 GNUNET_NO,
532 GNUNET_SCHEDULER_PRIORITY_KEEP,
533 GNUNET_SCHEDULER_NO_TASK,
534 GNUNET_CONSTANTS_EXEC_WAIT, 519 GNUNET_CONSTANTS_EXEC_WAIT,
535 &start_fsm, 520 &start_fsm,
536 d); 521 d);
@@ -675,9 +660,6 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched,
675 } 660 }
676 ret->task 661 ret->task
677 = GNUNET_SCHEDULER_add_delayed (sched, 662 = GNUNET_SCHEDULER_add_delayed (sched,
678 GNUNET_YES,
679 GNUNET_SCHEDULER_PRIORITY_KEEP,
680 GNUNET_SCHEDULER_NO_TASK,
681 GNUNET_CONSTANTS_EXEC_WAIT, 663 GNUNET_CONSTANTS_EXEC_WAIT,
682 &start_fsm, 664 &start_fsm,
683 ret); 665 ret);
@@ -689,7 +671,6 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched,
689#endif 671#endif
690 ret->phase = SP_COPIED; 672 ret->phase = SP_COPIED;
691 GNUNET_SCHEDULER_add_continuation (sched, 673 GNUNET_SCHEDULER_add_continuation (sched,
692 GNUNET_NO,
693 &start_fsm, 674 &start_fsm,
694 ret, 675 ret,
695 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 676 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -781,9 +762,6 @@ void GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
781 d->dead_cb_cls = cb_cls; 762 d->dead_cb_cls = cb_cls;
782 d->task 763 d->task
783 = GNUNET_SCHEDULER_add_delayed (d->sched, 764 = GNUNET_SCHEDULER_add_delayed (d->sched,
784 GNUNET_YES,
785 GNUNET_SCHEDULER_PRIORITY_KEEP,
786 GNUNET_SCHEDULER_NO_TASK,
787 GNUNET_CONSTANTS_EXEC_WAIT, 765 GNUNET_CONSTANTS_EXEC_WAIT,
788 &start_fsm, 766 &start_fsm,
789 d); 767 d);
@@ -879,9 +857,6 @@ void GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d,
879 d->update_cb_cls = cb_cls; 857 d->update_cb_cls = cb_cls;
880 d->task 858 d->task
881 = GNUNET_SCHEDULER_add_delayed (d->sched, 859 = GNUNET_SCHEDULER_add_delayed (d->sched,
882 GNUNET_NO,
883 GNUNET_SCHEDULER_PRIORITY_KEEP,
884 GNUNET_SCHEDULER_NO_TASK,
885 GNUNET_CONSTANTS_EXEC_WAIT, 860 GNUNET_CONSTANTS_EXEC_WAIT,
886 &start_fsm, 861 &start_fsm,
887 d); 862 d);
@@ -986,7 +961,6 @@ transmit_ready (void *cls, size_t size, void *buf)
986 GNUNET_TRANSPORT_disconnect (ctx->d2th); 961 GNUNET_TRANSPORT_disconnect (ctx->d2th);
987 ctx->d2th = NULL; 962 ctx->d2th = NULL;
988 GNUNET_SCHEDULER_add_continuation (ctx->d1->sched, 963 GNUNET_SCHEDULER_add_continuation (ctx->d1->sched,
989 GNUNET_NO,
990 &notify_connect_result, 964 &notify_connect_result,
991 ctx, 965 ctx,
992 (buf == NULL) ? 966 (buf == NULL) ?
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c
index b156ddfaf..cdf3da809 100644
--- a/src/topology/gnunet-daemon-topology.c
+++ b/src/topology/gnunet-daemon-topology.c
@@ -523,9 +523,6 @@ schedule_peer_search ()
523 (unsigned long long) delay.value); 523 (unsigned long long) delay.value);
524#endif 524#endif
525 GNUNET_SCHEDULER_add_delayed (sched, 525 GNUNET_SCHEDULER_add_delayed (sched,
526 GNUNET_NO,
527 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
528 GNUNET_SCHEDULER_NO_TASK,
529 delay, 526 delay,
530 &find_more_peers, 527 &find_more_peers,
531 NULL); 528 NULL);
@@ -823,9 +820,6 @@ core_init (void *cls,
823#endif 820#endif
824 if (autoconnect) 821 if (autoconnect)
825 GNUNET_SCHEDULER_add_delayed (sched, 822 GNUNET_SCHEDULER_add_delayed (sched,
826 GNUNET_NO,
827 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
828 GNUNET_SCHEDULER_NO_TASK,
829 GNUNET_TIME_UNIT_SECONDS /* give core time to tell us about existing connections */, 823 GNUNET_TIME_UNIT_SECONDS /* give core time to tell us about existing connections */,
830 &find_more_peers, 824 &find_more_peers,
831 NULL); 825 NULL);
@@ -1227,9 +1221,6 @@ run (void *cls,
1227 handlers); 1221 handlers);
1228 1222
1229 GNUNET_SCHEDULER_add_delayed (sched, 1223 GNUNET_SCHEDULER_add_delayed (sched,
1230 GNUNET_YES,
1231 GNUNET_SCHEDULER_PRIORITY_IDLE,
1232 GNUNET_SCHEDULER_NO_TASK,
1233 GNUNET_TIME_UNIT_FOREVER_REL, 1224 GNUNET_TIME_UNIT_FOREVER_REL,
1234 &cleaning_task, NULL); 1225 &cleaning_task, NULL);
1235} 1226}
diff --git a/src/topology/test_gnunet_service_topology.c b/src/topology/test_gnunet_service_topology.c
index b2790c0c9..2536f5454 100644
--- a/src/topology/test_gnunet_service_topology.c
+++ b/src/topology/test_gnunet_service_topology.c
@@ -26,7 +26,7 @@
26 26
27#define VERBOSE GNUNET_YES 27#define VERBOSE GNUNET_YES
28 28
29#define NUM_PEERS 10 29#define NUM_PEERS 4
30 30
31/** 31/**
32 * How long until we give up on connecting the peers? 32 * How long until we give up on connecting the peers?
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 0dc3f859d..efe53e021 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -710,9 +710,9 @@ transmit_to_client_callback (void *cls, size_t size, void *buf)
710 GNUNET_free (q); 710 GNUNET_free (q);
711 client->message_count--; 711 client->message_count--;
712 } 712 }
713 GNUNET_assert (tsize > 0);
714 if (NULL != q) 713 if (NULL != q)
715 { 714 {
715 GNUNET_assert (msize >= sizeof (struct GNUNET_MessageHeader));
716 th = GNUNET_SERVER_notify_transmit_ready (client->client, 716 th = GNUNET_SERVER_notify_transmit_ready (client->client,
717 msize, 717 msize,
718 GNUNET_TIME_UNIT_FOREVER_REL, 718 GNUNET_TIME_UNIT_FOREVER_REL,
@@ -753,6 +753,7 @@ transmit_to_client (struct TransportClient *client,
753 } 753 }
754 client->message_count++; 754 client->message_count++;
755 msize = ntohs (msg->size); 755 msize = ntohs (msg->size);
756 GNUNET_assert (msize >= sizeof (struct GNUNET_MessageHeader));
756 q = GNUNET_malloc (sizeof (struct ClientMessageQueueEntry) + msize); 757 q = GNUNET_malloc (sizeof (struct ClientMessageQueueEntry) + msize);
757 memcpy (&q[1], msg, msize); 758 memcpy (&q[1], msg, msize);
758 /* append to message queue */ 759 /* append to message queue */
@@ -1217,9 +1218,6 @@ update_addresses (struct TransportPlugin *plugin, int fresh)
1217 if (min_remaining.value < GNUNET_TIME_UNIT_FOREVER_REL.value) 1218 if (min_remaining.value < GNUNET_TIME_UNIT_FOREVER_REL.value)
1218 plugin->address_update_task 1219 plugin->address_update_task
1219 = GNUNET_SCHEDULER_add_delayed (plugin->env.sched, 1220 = GNUNET_SCHEDULER_add_delayed (plugin->env.sched,
1220 GNUNET_NO,
1221 GNUNET_SCHEDULER_PRIORITY_IDLE,
1222 GNUNET_SCHEDULER_NO_TASK,
1223 min_remaining, 1221 min_remaining,
1224 &expire_address_task, plugin); 1222 &expire_address_task, plugin);
1225 1223
@@ -1527,9 +1525,6 @@ cleanup_validation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1527 pos = pos->next; 1525 pos = pos->next;
1528 } 1526 }
1529 GNUNET_SCHEDULER_add_delayed (sched, 1527 GNUNET_SCHEDULER_add_delayed (sched,
1530 GNUNET_NO,
1531 GNUNET_SCHEDULER_PRIORITY_IDLE,
1532 GNUNET_SCHEDULER_NO_TASK,
1533 GNUNET_TIME_absolute_get_remaining (first), 1528 GNUNET_TIME_absolute_get_remaining (first),
1534 &cleanup_validation, NULL); 1529 &cleanup_validation, NULL);
1535 } 1530 }
@@ -1631,12 +1626,9 @@ plugin_env_notify_validation (void *cls,
1631 GNUNET_i2s (peer)); 1626 GNUNET_i2s (peer));
1632#endif 1627#endif
1633 pos->timeout.value = 0; 1628 pos->timeout.value = 0;
1634 GNUNET_SCHEDULER_add_delayed (sched, 1629 GNUNET_SCHEDULER_add_with_priority (sched,
1635 GNUNET_NO, 1630 GNUNET_SCHEDULER_PRIORITY_IDLE,
1636 GNUNET_SCHEDULER_PRIORITY_IDLE, 1631 &cleanup_validation, NULL);
1637 GNUNET_SCHEDULER_NO_TASK,
1638 GNUNET_TIME_UNIT_ZERO,
1639 &cleanup_validation, NULL);
1640 } 1632 }
1641 else 1633 else
1642 { 1634 {
@@ -1798,9 +1790,6 @@ check_hello_validated (void *cls,
1798 va = va->next; 1790 va = va->next;
1799 } 1791 }
1800 GNUNET_SCHEDULER_add_delayed (sched, 1792 GNUNET_SCHEDULER_add_delayed (sched,
1801 GNUNET_NO,
1802 GNUNET_SCHEDULER_PRIORITY_IDLE,
1803 GNUNET_SCHEDULER_NO_TASK,
1804 GNUNET_TIME_absolute_get_remaining (chvc->e->timeout), 1793 GNUNET_TIME_absolute_get_remaining (chvc->e->timeout),
1805 &cleanup_validation, NULL); 1794 &cleanup_validation, NULL);
1806 GNUNET_free (chvc); 1795 GNUNET_free (chvc);
@@ -2047,9 +2036,6 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer)
2047 n->quota_in = (GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT + 59999) / (60 * 1000); 2036 n->quota_in = (GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT + 59999) / (60 * 1000);
2048 add_plugins (n); 2037 add_plugins (n);
2049 n->timeout_task = GNUNET_SCHEDULER_add_delayed (sched, 2038 n->timeout_task = GNUNET_SCHEDULER_add_delayed (sched,
2050 GNUNET_NO,
2051 GNUNET_SCHEDULER_PRIORITY_IDLE,
2052 GNUNET_SCHEDULER_NO_TASK,
2053 GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2039 GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
2054 &neighbour_timeout_task, n); 2040 &neighbour_timeout_task, n);
2055 transmit_to_peer (NULL, 0, 2041 transmit_to_peer (NULL, 0,
@@ -2161,9 +2147,7 @@ plugin_env_receive (void *cls,
2161 n->peer_timeout = 2147 n->peer_timeout =
2162 GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 2148 GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
2163 n->timeout_task = 2149 n->timeout_task =
2164 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, 2150 GNUNET_SCHEDULER_add_delayed (sched,
2165 GNUNET_SCHEDULER_PRIORITY_IDLE,
2166 GNUNET_SCHEDULER_NO_TASK,
2167 GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2151 GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
2168 &neighbour_timeout_task, n); 2152 &neighbour_timeout_task, n);
2169 update_quota (n); 2153 update_quota (n);
@@ -2698,9 +2682,6 @@ run (void *cls,
2698 GNUNET_free (plugs); 2682 GNUNET_free (plugs);
2699 } 2683 }
2700 GNUNET_SCHEDULER_add_delayed (sched, 2684 GNUNET_SCHEDULER_add_delayed (sched,
2701 GNUNET_YES,
2702 GNUNET_SCHEDULER_PRIORITY_IDLE,
2703 GNUNET_SCHEDULER_NO_TASK,
2704 GNUNET_TIME_UNIT_FOREVER_REL, 2685 GNUNET_TIME_UNIT_FOREVER_REL,
2705 &unload_plugins, NULL); 2686 &unload_plugins, NULL);
2706 if (no_transports) 2687 if (no_transports)
@@ -2728,7 +2709,7 @@ main (int argc, char *const *argv)
2728 GNUNET_SERVICE_run (argc, 2709 GNUNET_SERVICE_run (argc,
2729 argv, 2710 argv,
2730 "transport", 2711 "transport",
2731 &run, NULL, NULL, NULL)) ? 0 : 1; 2712 &run, NULL)) ? 0 : 1;
2732} 2713}
2733 2714
2734/* end of gnunet-service-transport.c */ 2715/* end of gnunet-service-transport.c */
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index eeb333a53..a391b1b42 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -1898,9 +1898,6 @@ handle_tcp_data (void *cls,
1898 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1898 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1899 else 1899 else
1900 GNUNET_SCHEDULER_add_delayed (session->plugin->env->sched, 1900 GNUNET_SCHEDULER_add_delayed (session->plugin->env->sched,
1901 GNUNET_NO,
1902 GNUNET_SCHEDULER_PRIORITY_HIGH,
1903 GNUNET_SCHEDULER_NO_TASK,
1904 delay, &delayed_done, session); 1901 delay, &delayed_done, session);
1905} 1902}
1906 1903
diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c
index ec1b6b76c..856cadeaf 100644
--- a/src/transport/test_plugin_transport.c
+++ b/src/transport/test_plugin_transport.c
@@ -179,7 +179,6 @@ validation_notification (void *cls,
179 here will end the process. */ 179 here will end the process. */
180 ok = 0; /* if the last test succeeded, report success */ 180 ok = 0; /* if the last test succeeded, report success */
181 GNUNET_SCHEDULER_add_continuation (sched, 181 GNUNET_SCHEDULER_add_continuation (sched,
182 GNUNET_NO,
183 &unload_task, 182 &unload_task,
184 (void*) cfg, 183 (void*) cfg,
185 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 184 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -236,9 +235,6 @@ test_validation ()
236 /* add job to catch failure (timeout) */ 235 /* add job to catch failure (timeout) */
237 validation_timeout_task = 236 validation_timeout_task =
238 GNUNET_SCHEDULER_add_delayed (sched, 237 GNUNET_SCHEDULER_add_delayed (sched,
239 GNUNET_NO,
240 GNUNET_SCHEDULER_PRIORITY_KEEP,
241 GNUNET_SCHEDULER_NO_TASK,
242 TIMEOUT, 238 TIMEOUT,
243 &validation_failed, 239 &validation_failed,
244 NULL); 240 NULL);
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c
index 122950a74..c98194da0 100644
--- a/src/transport/transport_api.c
+++ b/src/transport/transport_api.c
@@ -625,9 +625,6 @@ schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h,
625 th->notify_size = size; 625 th->notify_size = size;
626 th->notify_delay_task 626 th->notify_delay_task
627 = GNUNET_SCHEDULER_add_delayed (h->sched, 627 = GNUNET_SCHEDULER_add_delayed (h->sched,
628 GNUNET_NO,
629 GNUNET_SCHEDULER_PRIORITY_KEEP,
630 GNUNET_SCHEDULER_NO_TASK,
631 timeout, 628 timeout,
632 &peer_transmit_timeout, th); 629 &peer_transmit_timeout, th);
633 if (at_head) 630 if (at_head)
@@ -704,7 +701,6 @@ send_set_quota (void *cls, size_t size, void *buf)
704 if (buf == NULL) 701 if (buf == NULL)
705 { 702 {
706 GNUNET_SCHEDULER_add_continuation (sqc->handle->sched, 703 GNUNET_SCHEDULER_add_continuation (sqc->handle->sched,
707 GNUNET_NO,
708 sqc->cont, 704 sqc->cont,
709 sqc->cont_cls, 705 sqc->cont_cls,
710 GNUNET_SCHEDULER_REASON_TIMEOUT); 706 GNUNET_SCHEDULER_REASON_TIMEOUT);
@@ -724,7 +720,6 @@ send_set_quota (void *cls, size_t size, void *buf)
724 memcpy (&msg->peer, &sqc->target, sizeof (struct GNUNET_PeerIdentity)); 720 memcpy (&msg->peer, &sqc->target, sizeof (struct GNUNET_PeerIdentity));
725 if (sqc->cont != NULL) 721 if (sqc->cont != NULL)
726 GNUNET_SCHEDULER_add_continuation (sqc->handle->sched, 722 GNUNET_SCHEDULER_add_continuation (sqc->handle->sched,
727 GNUNET_NO,
728 sqc->cont, 723 sqc->cont,
729 sqc->cont_cls, 724 sqc->cont_cls,
730 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 725 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -802,9 +797,6 @@ hello_wait_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
802 GNUNET_TIME_absolute_get_remaining (hwl->timeout).value); 797 GNUNET_TIME_absolute_get_remaining (hwl->timeout).value);
803#endif 798#endif
804 hwl->task = GNUNET_SCHEDULER_add_delayed (hwl->handle->sched, 799 hwl->task = GNUNET_SCHEDULER_add_delayed (hwl->handle->sched,
805 GNUNET_YES,
806 GNUNET_SCHEDULER_PRIORITY_KEEP,
807 GNUNET_SCHEDULER_NO_TASK,
808 GNUNET_TIME_absolute_get_remaining (hwl->timeout), 800 GNUNET_TIME_absolute_get_remaining (hwl->timeout),
809 &hello_wait_timeout, hwl); 801 &hello_wait_timeout, hwl);
810 return; 802 return;
@@ -862,9 +854,6 @@ GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
862 hwl->rec_cls = rec_cls; 854 hwl->rec_cls = rec_cls;
863 hwl->timeout = GNUNET_TIME_relative_to_absolute (timeout); 855 hwl->timeout = GNUNET_TIME_relative_to_absolute (timeout);
864 hwl->task = GNUNET_SCHEDULER_add_delayed (handle->sched, 856 hwl->task = GNUNET_SCHEDULER_add_delayed (handle->sched,
865 GNUNET_YES,
866 GNUNET_SCHEDULER_PRIORITY_KEEP,
867 GNUNET_SCHEDULER_NO_TASK,
868 timeout, 857 timeout,
869 &hello_wait_timeout, hwl); 858 &hello_wait_timeout, hwl);
870 return; 859 return;
@@ -1018,9 +1007,6 @@ request_connect (void *cls, size_t size, void *buf)
1018 memcpy (&tcm->peer, &th->target, sizeof (struct GNUNET_PeerIdentity)); 1007 memcpy (&tcm->peer, &th->target, sizeof (struct GNUNET_PeerIdentity));
1019 th->notify_delay_task 1008 th->notify_delay_task
1020 = GNUNET_SCHEDULER_add_delayed (h->sched, 1009 = GNUNET_SCHEDULER_add_delayed (h->sched,
1021 GNUNET_NO,
1022 GNUNET_SCHEDULER_PRIORITY_KEEP,
1023 GNUNET_SCHEDULER_NO_TASK,
1024 GNUNET_TIME_absolute_get_remaining 1010 GNUNET_TIME_absolute_get_remaining
1025 (th->timeout), 1011 (th->timeout),
1026 &peer_transmit_timeout, th); 1012 &peer_transmit_timeout, th);
@@ -1128,9 +1114,6 @@ remove_neighbour (struct GNUNET_TRANSPORT_Handle *h,
1128 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == th->notify_delay_task); 1114 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == th->notify_delay_task);
1129 th->notify_delay_task 1115 th->notify_delay_task
1130 = GNUNET_SCHEDULER_add_delayed (h->sched, 1116 = GNUNET_SCHEDULER_add_delayed (h->sched,
1131 GNUNET_NO,
1132 GNUNET_SCHEDULER_PRIORITY_KEEP,
1133 GNUNET_SCHEDULER_NO_TASK,
1134 CONNECT_RETRY_TIMEOUT, 1117 CONNECT_RETRY_TIMEOUT,
1135 &try_connect_task, 1118 &try_connect_task,
1136 th); 1119 th);
@@ -1214,9 +1197,6 @@ schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h)
1214 GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK); 1197 GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK);
1215 h->reconnect_task 1198 h->reconnect_task
1216 = GNUNET_SCHEDULER_add_delayed (h->sched, 1199 = GNUNET_SCHEDULER_add_delayed (h->sched,
1217 GNUNET_NO,
1218 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1219 GNUNET_SCHEDULER_NO_TASK,
1220 h->reconnect_delay, &reconnect, h); 1200 h->reconnect_delay, &reconnect, h);
1221 h->reconnect_delay = GNUNET_TIME_UNIT_SECONDS; 1201 h->reconnect_delay = GNUNET_TIME_UNIT_SECONDS;
1222} 1202}
@@ -1318,9 +1298,6 @@ schedule_request (struct GNUNET_TRANSPORT_TransmitHandle *th)
1318#endif 1298#endif
1319 th->notify_delay_task 1299 th->notify_delay_task
1320 = GNUNET_SCHEDULER_add_delayed (h->sched, 1300 = GNUNET_SCHEDULER_add_delayed (h->sched,
1321 GNUNET_NO,
1322 GNUNET_SCHEDULER_PRIORITY_KEEP,
1323 GNUNET_SCHEDULER_NO_TASK,
1324 duration, &transmit_ready, th); 1301 duration, &transmit_ready, th);
1325 return; 1302 return;
1326 } 1303 }
@@ -1340,9 +1317,6 @@ schedule_request (struct GNUNET_TRANSPORT_TransmitHandle *th)
1340#endif 1317#endif
1341 th->notify_delay_task 1318 th->notify_delay_task
1342 = GNUNET_SCHEDULER_add_delayed (h->sched, 1319 = GNUNET_SCHEDULER_add_delayed (h->sched,
1343 GNUNET_NO,
1344 GNUNET_SCHEDULER_PRIORITY_KEEP,
1345 GNUNET_SCHEDULER_NO_TASK,
1346 GNUNET_TIME_absolute_get_remaining 1320 GNUNET_TIME_absolute_get_remaining
1347 (th->timeout), &peer_transmit_timeout, th); 1321 (th->timeout), &peer_transmit_timeout, th);
1348 return; 1322 return;
@@ -1593,9 +1567,6 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
1593 GNUNET_assert (th->notify_delay_task == GNUNET_SCHEDULER_NO_TASK); 1567 GNUNET_assert (th->notify_delay_task == GNUNET_SCHEDULER_NO_TASK);
1594 th->notify_delay_task 1568 th->notify_delay_task
1595 = GNUNET_SCHEDULER_add_delayed (h->sched, 1569 = GNUNET_SCHEDULER_add_delayed (h->sched,
1596 GNUNET_NO,
1597 GNUNET_SCHEDULER_PRIORITY_KEEP,
1598 GNUNET_SCHEDULER_NO_TASK,
1599 GNUNET_TIME_absolute_get_remaining(th->timeout), 1570 GNUNET_TIME_absolute_get_remaining(th->timeout),
1600 &peer_transmit_timeout, 1571 &peer_transmit_timeout,
1601 th); 1572 th);
@@ -1937,9 +1908,6 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle
1937#endif 1908#endif
1938 th->notify_delay_task 1909 th->notify_delay_task
1939 = GNUNET_SCHEDULER_add_delayed (handle->sched, 1910 = GNUNET_SCHEDULER_add_delayed (handle->sched,
1940 GNUNET_NO,
1941 GNUNET_SCHEDULER_PRIORITY_KEEP,
1942 GNUNET_SCHEDULER_NO_TASK,
1943 timeout, &peer_transmit_timeout, th); 1911 timeout, &peer_transmit_timeout, th);
1944 return th; 1912 return th;
1945 } 1913 }
diff --git a/src/util/client.c b/src/util/client.c
index 60aa6f101..05f579b9f 100644
--- a/src/util/client.c
+++ b/src/util/client.c
@@ -308,8 +308,6 @@ GNUNET_CLIENT_disconnect (struct GNUNET_CLIENT_Connection *sock)
308 sock->in_receive = GNUNET_SYSERR; 308 sock->in_receive = GNUNET_SYSERR;
309 else 309 else
310 GNUNET_SCHEDULER_add_after (sock->sched, 310 GNUNET_SCHEDULER_add_after (sock->sched,
311 GNUNET_YES,
312 GNUNET_SCHEDULER_PRIORITY_KEEP,
313 GNUNET_SCHEDULER_NO_TASK, 311 GNUNET_SCHEDULER_NO_TASK,
314 &finish_cleanup, sock); 312 &finish_cleanup, sock);
315} 313}
@@ -353,8 +351,6 @@ receive_helper (void *cls,
353 GNUNET_assert (conn->msg_complete == GNUNET_NO); 351 GNUNET_assert (conn->msg_complete == GNUNET_NO);
354 if (GNUNET_SYSERR == conn->in_receive) 352 if (GNUNET_SYSERR == conn->in_receive)
355 GNUNET_SCHEDULER_add_after (conn->sched, 353 GNUNET_SCHEDULER_add_after (conn->sched,
356 GNUNET_YES,
357 GNUNET_SCHEDULER_PRIORITY_KEEP,
358 GNUNET_SCHEDULER_NO_TASK, 354 GNUNET_SCHEDULER_NO_TASK,
359 &finish_cleanup, conn); 355 &finish_cleanup, conn);
360 conn->in_receive = GNUNET_NO; 356 conn->in_receive = GNUNET_NO;
@@ -412,8 +408,6 @@ receive_task (void *scls, const struct GNUNET_SCHEDULER_TaskContext *tc)
412 408
413 if (GNUNET_SYSERR == sock->in_receive) 409 if (GNUNET_SYSERR == sock->in_receive)
414 GNUNET_SCHEDULER_add_after (sock->sched, 410 GNUNET_SCHEDULER_add_after (sock->sched,
415 GNUNET_YES,
416 GNUNET_SCHEDULER_PRIORITY_KEEP,
417 GNUNET_SCHEDULER_NO_TASK, 411 GNUNET_SCHEDULER_NO_TASK,
418 &finish_cleanup, sock); 412 &finish_cleanup, sock);
419 sock->in_receive = GNUNET_NO; 413 sock->in_receive = GNUNET_NO;
@@ -457,8 +451,6 @@ GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock,
457 sock->in_receive = GNUNET_YES; 451 sock->in_receive = GNUNET_YES;
458 if (GNUNET_YES == sock->msg_complete) 452 if (GNUNET_YES == sock->msg_complete)
459 GNUNET_SCHEDULER_add_after (sock->sched, 453 GNUNET_SCHEDULER_add_after (sock->sched,
460 GNUNET_YES,
461 GNUNET_SCHEDULER_PRIORITY_KEEP,
462 GNUNET_SCHEDULER_NO_TASK, 454 GNUNET_SCHEDULER_NO_TASK,
463 &receive_task, sock); 455 &receive_task, sock);
464 else 456 else
@@ -522,7 +514,6 @@ service_test_error (struct GNUNET_SCHEDULER_Handle *s,
522 GNUNET_SCHEDULER_Task task, void *task_cls) 514 GNUNET_SCHEDULER_Task task, void *task_cls)
523{ 515{
524 GNUNET_SCHEDULER_add_continuation (s, 516 GNUNET_SCHEDULER_add_continuation (s,
525 GNUNET_YES,
526 task, 517 task,
527 task_cls, 518 task_cls,
528 GNUNET_SCHEDULER_REASON_TIMEOUT); 519 GNUNET_SCHEDULER_REASON_TIMEOUT);
@@ -549,7 +540,6 @@ confirm_handler (void *cls, const struct GNUNET_MessageHeader *msg)
549 "Received confirmation that service is running.\n"); 540 "Received confirmation that service is running.\n");
550#endif 541#endif
551 GNUNET_SCHEDULER_add_continuation (conn->sched, 542 GNUNET_SCHEDULER_add_continuation (conn->sched,
552 GNUNET_YES,
553 conn->test_cb, 543 conn->test_cb,
554 conn->test_cb_cls, 544 conn->test_cb_cls,
555 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 545 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -719,9 +709,6 @@ client_notify (void *cls, size_t size, void *buf)
719 GNUNET_assert (NULL != th->sock->sock); 709 GNUNET_assert (NULL != th->sock->sock);
720 delay = GNUNET_TIME_relative_min (delay, GNUNET_TIME_UNIT_SECONDS); 710 delay = GNUNET_TIME_relative_min (delay, GNUNET_TIME_UNIT_SECONDS);
721 th->task = GNUNET_SCHEDULER_add_delayed (th->sock->sched, 711 th->task = GNUNET_SCHEDULER_add_delayed (th->sock->sched,
722 GNUNET_NO,
723 GNUNET_SCHEDULER_PRIORITY_KEEP,
724 GNUNET_SCHEDULER_NO_TASK,
725 delay, 712 delay,
726 &client_delayed_retry, th); 713 &client_delayed_retry, th);
727 th->sock->th = th; 714 th->sock->th = th;
diff --git a/src/util/connection.c b/src/util/connection.c
index 066b81bbe..9bf2aa975 100644
--- a/src/util/connection.c
+++ b/src/util/connection.c
@@ -476,8 +476,6 @@ destroy_continuation (void *cls,
476 "Destroy waits for write_task to be done (%p)\n", sock); 476 "Destroy waits for write_task to be done (%p)\n", sock);
477#endif 477#endif
478 GNUNET_SCHEDULER_add_after (sock->sched, 478 GNUNET_SCHEDULER_add_after (sock->sched,
479 GNUNET_YES,
480 GNUNET_SCHEDULER_PRIORITY_KEEP,
481 sock->write_task, 479 sock->write_task,
482 &destroy_continuation, sock); 480 &destroy_continuation, sock);
483 return; 481 return;
@@ -498,8 +496,6 @@ destroy_continuation (void *cls,
498 if (sock->read_task != GNUNET_SCHEDULER_NO_TASK) 496 if (sock->read_task != GNUNET_SCHEDULER_NO_TASK)
499 { 497 {
500 GNUNET_SCHEDULER_add_after (sock->sched, 498 GNUNET_SCHEDULER_add_after (sock->sched,
501 GNUNET_YES,
502 GNUNET_SCHEDULER_PRIORITY_KEEP,
503 sock->read_task, 499 sock->read_task,
504 &destroy_continuation, sock); 500 &destroy_continuation, sock);
505 return; 501 return;
@@ -569,8 +565,6 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h)
569#endif 565#endif
570 h->ccs -= COCO_RECEIVE_AGAIN; 566 h->ccs -= COCO_RECEIVE_AGAIN;
571 h->read_task = GNUNET_SCHEDULER_add_after (h->sched, 567 h->read_task = GNUNET_SCHEDULER_add_after (h->sched,
572 GNUNET_NO,
573 GNUNET_SCHEDULER_PRIORITY_KEEP,
574 GNUNET_SCHEDULER_NO_TASK, 568 GNUNET_SCHEDULER_NO_TASK,
575 &receive_again, h); 569 &receive_again, h);
576 } 570 }
@@ -586,8 +580,6 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h)
586 h->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK; 580 h->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK;
587 h->ccs -= COCO_TRANSMIT_READY; 581 h->ccs -= COCO_TRANSMIT_READY;
588 h->write_task = GNUNET_SCHEDULER_add_after (h->sched, 582 h->write_task = GNUNET_SCHEDULER_add_after (h->sched,
589 GNUNET_NO,
590 GNUNET_SCHEDULER_PRIORITY_KEEP,
591 GNUNET_SCHEDULER_NO_TASK, 583 GNUNET_SCHEDULER_NO_TASK,
592 &transmit_ready, h); 584 &transmit_ready, h);
593 } 585 }
@@ -600,7 +592,6 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h)
600#endif 592#endif
601 h->ccs -= COCO_DESTROY_CONTINUATION; 593 h->ccs -= COCO_DESTROY_CONTINUATION;
602 GNUNET_SCHEDULER_add_continuation (h->sched, 594 GNUNET_SCHEDULER_add_continuation (h->sched,
603 GNUNET_NO,
604 &destroy_continuation, 595 &destroy_continuation,
605 h, GNUNET_SCHEDULER_REASON_TIMEOUT); 596 h, GNUNET_SCHEDULER_REASON_TIMEOUT);
606 } 597 }
@@ -630,8 +621,6 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *h)
630#endif 621#endif
631 h->ccs -= COCO_RECEIVE_AGAIN; 622 h->ccs -= COCO_RECEIVE_AGAIN;
632 h->read_task = GNUNET_SCHEDULER_add_after (h->sched, 623 h->read_task = GNUNET_SCHEDULER_add_after (h->sched,
633 GNUNET_NO,
634 GNUNET_SCHEDULER_PRIORITY_KEEP,
635 GNUNET_SCHEDULER_NO_TASK, 624 GNUNET_SCHEDULER_NO_TASK,
636 &receive_again, h); 625 &receive_again, h);
637 } 626 }
@@ -648,9 +637,6 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *h)
648 h->ccs -= COCO_TRANSMIT_READY; 637 h->ccs -= COCO_TRANSMIT_READY;
649 h->write_task = 638 h->write_task =
650 GNUNET_SCHEDULER_add_write_net (h->sched, 639 GNUNET_SCHEDULER_add_write_net (h->sched,
651 GNUNET_NO,
652 GNUNET_SCHEDULER_PRIORITY_KEEP,
653 GNUNET_SCHEDULER_NO_TASK,
654 GNUNET_TIME_absolute_get_remaining 640 GNUNET_TIME_absolute_get_remaining
655 (h->nth.transmit_timeout), h->sock, 641 (h->nth.transmit_timeout), h->sock,
656 &transmit_ready, h); 642 &transmit_ready, h);
@@ -664,7 +650,6 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *h)
664#endif 650#endif
665 h->ccs -= COCO_DESTROY_CONTINUATION; 651 h->ccs -= COCO_DESTROY_CONTINUATION;
666 GNUNET_SCHEDULER_add_continuation (h->sched, 652 GNUNET_SCHEDULER_add_continuation (h->sched,
667 GNUNET_NO,
668 &destroy_continuation, 653 &destroy_continuation,
669 h, 654 h,
670 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 655 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -808,9 +793,8 @@ try_connect_using_address (void *cls,
808 GNUNET_TIME_absolute_get_remaining (h-> 793 GNUNET_TIME_absolute_get_remaining (h->
809 receive_timeout)); 794 receive_timeout));
810 ap->task = 795 ap->task =
811 GNUNET_SCHEDULER_add_write_net (h->sched, GNUNET_NO, 796 GNUNET_SCHEDULER_add_write_net (h->sched,
812 GNUNET_SCHEDULER_PRIORITY_KEEP, 797 delay, ap->sock,
813 GNUNET_SCHEDULER_NO_TASK, delay, ap->sock,
814 &connect_probe_continuation, ap); 798 &connect_probe_continuation, ap);
815} 799}
816 800
@@ -956,8 +940,6 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *sock)
956 } 940 }
957 GNUNET_assert (sock->sched != NULL); 941 GNUNET_assert (sock->sched != NULL);
958 GNUNET_SCHEDULER_add_after (sock->sched, 942 GNUNET_SCHEDULER_add_after (sock->sched,
959 GNUNET_YES,
960 GNUNET_SCHEDULER_PRIORITY_KEEP,
961 GNUNET_SCHEDULER_NO_TASK, 943 GNUNET_SCHEDULER_NO_TASK,
962 &destroy_continuation, sock); 944 &destroy_continuation, sock);
963} 945}
@@ -1101,9 +1083,6 @@ receive_again (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1101 GNUNET_assert (sh->sock != NULL); 1083 GNUNET_assert (sh->sock != NULL);
1102 /* connect succeeded, wait for data! */ 1084 /* connect succeeded, wait for data! */
1103 sh->read_task = GNUNET_SCHEDULER_add_read_net (tc->sched, 1085 sh->read_task = GNUNET_SCHEDULER_add_read_net (tc->sched,
1104 GNUNET_YES,
1105 GNUNET_SCHEDULER_PRIORITY_KEEP,
1106 GNUNET_SCHEDULER_NO_TASK,
1107 GNUNET_TIME_absolute_get_remaining 1086 GNUNET_TIME_absolute_get_remaining
1108 (sh->receive_timeout), 1087 (sh->receive_timeout),
1109 sh->sock, 1088 sh->sock,
@@ -1406,9 +1385,6 @@ SCHEDULE_WRITE:
1406 if (sock->write_task == GNUNET_SCHEDULER_NO_TASK) 1385 if (sock->write_task == GNUNET_SCHEDULER_NO_TASK)
1407 sock->write_task = 1386 sock->write_task =
1408 GNUNET_SCHEDULER_add_write_net (tc->sched, 1387 GNUNET_SCHEDULER_add_write_net (tc->sched,
1409 GNUNET_NO,
1410 GNUNET_SCHEDULER_PRIORITY_KEEP,
1411 GNUNET_SCHEDULER_NO_TASK,
1412 GNUNET_TIME_absolute_get_remaining 1388 GNUNET_TIME_absolute_get_remaining
1413 (sock->nth.transmit_timeout), 1389 (sock->nth.transmit_timeout),
1414 sock->sock, &transmit_ready, sock); 1390 sock->sock, &transmit_ready, sock);
@@ -1453,9 +1429,6 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle
1453 (sock->ap_head == NULL) && (sock->dns_active == NULL)) 1429 (sock->ap_head == NULL) && (sock->dns_active == NULL))
1454 { 1430 {
1455 sock->write_task = GNUNET_SCHEDULER_add_delayed (sock->sched, 1431 sock->write_task = GNUNET_SCHEDULER_add_delayed (sock->sched,
1456 GNUNET_NO,
1457 GNUNET_SCHEDULER_PRIORITY_KEEP,
1458 GNUNET_SCHEDULER_NO_TASK,
1459 GNUNET_TIME_UNIT_ZERO, 1432 GNUNET_TIME_UNIT_ZERO,
1460 &connect_error, sock); 1433 &connect_error, sock);
1461 return &sock->nth; 1434 return &sock->nth;
@@ -1469,9 +1442,6 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle
1469 "Scheduling transmit_ready (%p).\n", sock); 1442 "Scheduling transmit_ready (%p).\n", sock);
1470#endif 1443#endif
1471 sock->write_task = GNUNET_SCHEDULER_add_write_net (sock->sched, 1444 sock->write_task = GNUNET_SCHEDULER_add_write_net (sock->sched,
1472 GNUNET_NO,
1473 GNUNET_SCHEDULER_PRIORITY_KEEP,
1474 GNUNET_SCHEDULER_NO_TASK,
1475 GNUNET_TIME_absolute_get_remaining 1445 GNUNET_TIME_absolute_get_remaining
1476 (sock->nth. 1446 (sock->nth.
1477 transmit_timeout), 1447 transmit_timeout),
@@ -1488,9 +1458,6 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle
1488#endif 1458#endif
1489 sock->ccs |= COCO_TRANSMIT_READY; 1459 sock->ccs |= COCO_TRANSMIT_READY;
1490 sock->nth.timeout_task = GNUNET_SCHEDULER_add_delayed (sock->sched, 1460 sock->nth.timeout_task = GNUNET_SCHEDULER_add_delayed (sock->sched,
1491 GNUNET_NO,
1492 GNUNET_SCHEDULER_PRIORITY_KEEP,
1493 GNUNET_SCHEDULER_NO_TASK,
1494 timeout, 1461 timeout,
1495 &transmit_timeout, 1462 &transmit_timeout,
1496 sock); 1463 sock);
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c
index 3f5869489..dcee545f7 100644
--- a/src/util/crypto_hash.c
+++ b/src/util/crypto_hash.c
@@ -416,11 +416,6 @@ struct FileHashContext
416 uint64_t offset; 416 uint64_t offset;
417 417
418 /** 418 /**
419 * Run on shutdown?
420 */
421 int run_on_shutdown;
422
423 /**
424 * File descriptor. 419 * File descriptor.
425 */ 420 */
426 struct GNUNET_DISK_FileHandle *fh; 421 struct GNUNET_DISK_FileHandle *fh;
@@ -476,8 +471,6 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
476 return; 471 return;
477 } 472 }
478 GNUNET_SCHEDULER_add_after (tc->sched, 473 GNUNET_SCHEDULER_add_after (tc->sched,
479 fhc->run_on_shutdown,
480 GNUNET_SCHEDULER_PRIORITY_KEEP,
481 GNUNET_SCHEDULER_NO_TASK, &file_hash_task, fhc); 474 GNUNET_SCHEDULER_NO_TASK, &file_hash_task, fhc);
482} 475}
483 476
@@ -487,7 +480,6 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
487 * 480 *
488 * @param sched scheduler to use 481 * @param sched scheduler to use
489 * @param priority scheduling priority to use 482 * @param priority scheduling priority to use
490 * @param run_on_shutdown should we complete even on shutdown?
491 * @param filename name of file to hash 483 * @param filename name of file to hash
492 * @param blocksize number of bytes to process in one task 484 * @param blocksize number of bytes to process in one task
493 * @param callback function to call upon completion 485 * @param callback function to call upon completion
@@ -496,7 +488,6 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
496void 488void
497GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched, 489GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched,
498 enum GNUNET_SCHEDULER_Priority priority, 490 enum GNUNET_SCHEDULER_Priority priority,
499 int run_on_shutdown,
500 const char *filename, 491 const char *filename,
501 size_t blocksize, 492 size_t blocksize,
502 GNUNET_CRYPTO_HashCompletedCallback callback, 493 GNUNET_CRYPTO_HashCompletedCallback callback,
@@ -518,7 +509,6 @@ GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched,
518 file_hash_finish (fhc, NULL); 509 file_hash_finish (fhc, NULL);
519 return; 510 return;
520 } 511 }
521 fhc->run_on_shutdown = run_on_shutdown;
522 fhc->fh = GNUNET_DISK_file_open (filename, 512 fhc->fh = GNUNET_DISK_file_open (filename,
523 GNUNET_DISK_OPEN_READ, 513 GNUNET_DISK_OPEN_READ,
524 GNUNET_DISK_PERM_NONE); 514 GNUNET_DISK_PERM_NONE);
@@ -527,10 +517,7 @@ GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched,
527 file_hash_finish (fhc, NULL); 517 file_hash_finish (fhc, NULL);
528 return; 518 return;
529 } 519 }
530 GNUNET_SCHEDULER_add_after (sched, 520 GNUNET_SCHEDULER_add_with_priority (sched, priority, &file_hash_task, fhc);
531 run_on_shutdown,
532 priority,
533 GNUNET_SCHEDULER_NO_TASK, &file_hash_task, fhc);
534} 521}
535 522
536 523
diff --git a/src/util/disk.c b/src/util/disk.c
index 9f93a1ee2..3b3cb9e65 100644
--- a/src/util/disk.c
+++ b/src/util/disk.c
@@ -856,11 +856,9 @@ GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator
856 GNUNET_DISK_directory_iterator_next (iter, GNUNET_YES); 856 GNUNET_DISK_directory_iterator_next (iter, GNUNET_YES);
857 return GNUNET_NO; 857 return GNUNET_NO;
858 } 858 }
859 GNUNET_SCHEDULER_add_after (iter->sched, 859 GNUNET_SCHEDULER_add_with_priority (iter->sched,
860 GNUNET_YES, 860 iter->priority,
861 iter->priority, 861 &directory_iterator_task, iter);
862 GNUNET_SCHEDULER_NO_TASK,
863 &directory_iterator_task, iter);
864 return GNUNET_YES; 862 return GNUNET_YES;
865} 863}
866 864
diff --git a/src/util/gnunet-service-resolver.c b/src/util/gnunet-service-resolver.c
index f8dd2e166..4dcabface 100644
--- a/src/util/gnunet-service-resolver.c
+++ b/src/util/gnunet-service-resolver.c
@@ -516,7 +516,7 @@ main (int argc, char *const *argv)
516 ret = (GNUNET_OK == 516 ret = (GNUNET_OK ==
517 GNUNET_SERVICE_run (argc, 517 GNUNET_SERVICE_run (argc,
518 argv, 518 argv,
519 "resolver", &run, NULL, NULL, NULL)) ? 0 : 1; 519 "resolver", &run, NULL)) ? 0 : 1;
520 520
521 while (head != NULL) 521 while (head != NULL)
522 { 522 {
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c
index 69d143bc1..812cdc84e 100644
--- a/src/util/resolver_api.c
+++ b/src/util/resolver_api.c
@@ -442,9 +442,6 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched,
442 ((domain == AF_INET6) || (domain == AF_UNSPEC)))) 442 ((domain == AF_INET6) || (domain == AF_UNSPEC))))
443 { 443 {
444 rh->task = GNUNET_SCHEDULER_add_delayed (sched, 444 rh->task = GNUNET_SCHEDULER_add_delayed (sched,
445 GNUNET_NO,
446 GNUNET_SCHEDULER_PRIORITY_KEEP,
447 GNUNET_SCHEDULER_NO_TASK,
448 GNUNET_TIME_UNIT_ZERO, 445 GNUNET_TIME_UNIT_ZERO,
449 &numeric_resolution, rh); 446 &numeric_resolution, rh);
450 return rh; 447 return rh;
@@ -455,9 +452,6 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched,
455 if (0 == strcasecmp (loopback[i++], hostname)) 452 if (0 == strcasecmp (loopback[i++], hostname))
456 { 453 {
457 rh->task = GNUNET_SCHEDULER_add_delayed (sched, 454 rh->task = GNUNET_SCHEDULER_add_delayed (sched,
458 GNUNET_NO,
459 GNUNET_SCHEDULER_PRIORITY_KEEP,
460 GNUNET_SCHEDULER_NO_TASK,
461 GNUNET_TIME_UNIT_ZERO, 455 GNUNET_TIME_UNIT_ZERO,
462 &loopback_resolution, rh); 456 &loopback_resolution, rh);
463 return rh; 457 return rh;
@@ -623,9 +617,6 @@ GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched,
623 if (GNUNET_NO == do_resolve) 617 if (GNUNET_NO == do_resolve)
624 { 618 {
625 rh->task = GNUNET_SCHEDULER_add_delayed (sched, 619 rh->task = GNUNET_SCHEDULER_add_delayed (sched,
626 GNUNET_NO,
627 GNUNET_SCHEDULER_PRIORITY_KEEP,
628 GNUNET_SCHEDULER_NO_TASK,
629 GNUNET_TIME_UNIT_ZERO, 620 GNUNET_TIME_UNIT_ZERO,
630 &numeric_reverse, rh); 621 &numeric_reverse, rh);
631 return rh; 622 return rh;
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index 2bb356eb6..16f65b457 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -95,11 +95,6 @@ struct Task
95 */ 95 */
96 enum GNUNET_SCHEDULER_Priority priority; 96 enum GNUNET_SCHEDULER_Priority priority;
97 97
98 /**
99 * Should this task be run on shutdown?
100 */
101 int run_on_shutdown;
102
103}; 98};
104 99
105 100
@@ -135,12 +130,6 @@ struct GNUNET_SCHEDULER_Handle
135 GNUNET_SCHEDULER_TaskIdentifier lowest_pending_id; 130 GNUNET_SCHEDULER_TaskIdentifier lowest_pending_id;
136 131
137 /** 132 /**
138 * GNUNET_NO if we are running normally,
139 * GNUNET_YES if we are in shutdown mode.
140 */
141 int shutdown;
142
143 /**
144 * Number of tasks on the ready list. 133 * Number of tasks on the ready list.
145 */ 134 */
146 unsigned int ready_count; 135 unsigned int ready_count;
@@ -260,6 +249,8 @@ update_sets (struct GNUNET_SCHEDULER_Handle *sched,
260 GNUNET_NETWORK_fdset_add (rs, pos->read_set); 249 GNUNET_NETWORK_fdset_add (rs, pos->read_set);
261 if (pos->write_set != NULL) 250 if (pos->write_set != NULL)
262 GNUNET_NETWORK_fdset_add (ws, pos->write_set); 251 GNUNET_NETWORK_fdset_add (ws, pos->write_set);
252 if (pos->reason != 0)
253 *timeout = GNUNET_TIME_UNIT_ZERO;
263 pos = pos->next; 254 pos = pos->next;
264 } 255 }
265} 256}
@@ -309,12 +300,7 @@ is_ready (struct GNUNET_SCHEDULER_Handle *sched,
309 const struct GNUNET_NETWORK_FDSet *rs, 300 const struct GNUNET_NETWORK_FDSet *rs,
310 const struct GNUNET_NETWORK_FDSet *ws) 301 const struct GNUNET_NETWORK_FDSet *ws)
311{ 302{
312 if ((GNUNET_NO == task->run_on_shutdown) && (GNUNET_YES == sched->shutdown)) 303 if (now.value >= task->timeout.value)
313 return GNUNET_NO;
314 if ((GNUNET_YES == task->run_on_shutdown) &&
315 (GNUNET_YES == sched->shutdown))
316 task->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN;
317 if (now.value >= task->timeout.value)
318 task->reason |= GNUNET_SCHEDULER_REASON_TIMEOUT; 304 task->reason |= GNUNET_SCHEDULER_REASON_TIMEOUT;
319 if ((0 == (task->reason & GNUNET_SCHEDULER_REASON_READ_READY)) && 305 if ((0 == (task->reason & GNUNET_SCHEDULER_REASON_READ_READY)) &&
320 (rs != NULL) && (set_overlaps (rs, task->read_set))) 306 (rs != NULL) && (set_overlaps (rs, task->read_set)))
@@ -395,6 +381,32 @@ check_ready (struct GNUNET_SCHEDULER_Handle *handle,
395 381
396 382
397/** 383/**
384 * Request the shutdown of a scheduler. Marks all currently
385 * pending tasks as ready because of shutdown. This will
386 * cause all tasks to run (as soon as possible, respecting
387 * priorities and prerequisite tasks). Note that tasks
388 * scheduled AFTER this call may still be delayed arbitrarily.
389 *
390 * @param sched the scheduler
391 */
392void
393GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched)
394{
395 struct Task *pos;
396
397 pos = sched->pending;
398 while (pos != NULL)
399 {
400 pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN;
401 /* we don't move the task into the ready queue yet; check_ready
402 will do that later, possibly adding additional
403 readyness-factors */
404 pos = pos->next;
405 }
406}
407
408
409/**
398 * Destroy a task (release associated resources) 410 * Destroy a task (release associated resources)
399 * 411 *
400 * @param t task to destroy 412 * @param t task to destroy
@@ -415,7 +427,7 @@ destroy_task (struct Task *t)
415 * empty. Keep running tasks until we are either no longer running 427 * empty. Keep running tasks until we are either no longer running
416 * "URGENT" tasks or until we have at least one "pending" task (which 428 * "URGENT" tasks or until we have at least one "pending" task (which
417 * may become ready, hence we should select on it). Naturally, if 429 * may become ready, hence we should select on it). Naturally, if
418 * there are no more ready tasks, we also return. 430 * there are no more ready tasks, we also return.
419 * 431 *
420 * @param sched the scheduler 432 * @param sched the scheduler
421 */ 433 */
@@ -459,7 +471,7 @@ run_ready (struct GNUNET_SCHEDULER_Handle *sched)
459 while ((sched->pending == NULL) || (p == GNUNET_SCHEDULER_PRIORITY_URGENT)); 471 while ((sched->pending == NULL) || (p == GNUNET_SCHEDULER_PRIORITY_URGENT));
460} 472}
461 473
462 474#ifndef MINGW
463/** 475/**
464 * Pipe used to communicate shutdown via signal. 476 * Pipe used to communicate shutdown via signal.
465 */ 477 */
@@ -478,19 +490,25 @@ sighandler_shutdown ()
478 (sigpipe, GNUNET_DISK_PIPE_END_WRITE), &c, 490 (sigpipe, GNUNET_DISK_PIPE_END_WRITE), &c,
479 sizeof (c)); 491 sizeof (c));
480} 492}
493#endif
481 494
482 495
483/** 496/**
484 * Initialize a scheduler using this thread. This function will 497 * Initialize and run scheduler. This function will return when all
485 * return when either a shutdown was initiated (via signal) and all 498 * tasks have completed. On systems with signals, receiving a SIGTERM
486 * tasks marked to "run_on_shutdown" have been completed or when all 499 * (and other similar signals) will cause "GNUNET_SCHEDULER_shutdown"
487 * tasks in general have been completed. 500 * to be run after the active task is complete. As a result, SIGTERM
501 * causes all active tasks to be scheduled with reason
502 * "GNUNET_SCHEDULER_REASON_SHUTDOWN". (However, tasks added
503 * afterwards will execute normally!). Note that any particular signal
504 * will only shut down one scheduler; applications should always only
505 * create a single scheduler.
488 * 506 *
489 * @param task task to run immediately 507 * @param task task to run immediately
490 * @param cls closure of task 508 * @param task_cls closure of task
491 */ 509 */
492void 510void
493GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *cls) 511GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls)
494{ 512{
495 struct GNUNET_SCHEDULER_Handle sched; 513 struct GNUNET_SCHEDULER_Handle sched;
496 struct GNUNET_NETWORK_FDSet *rs; 514 struct GNUNET_NETWORK_FDSet *rs;
@@ -501,12 +519,12 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *cls)
501 struct GNUNET_SIGNAL_Context *shc_term; 519 struct GNUNET_SIGNAL_Context *shc_term;
502 struct GNUNET_SIGNAL_Context *shc_quit; 520 struct GNUNET_SIGNAL_Context *shc_quit;
503 struct GNUNET_SIGNAL_Context *shc_hup; 521 struct GNUNET_SIGNAL_Context *shc_hup;
504 struct Task *tpos;
505 unsigned long long last_tr; 522 unsigned long long last_tr;
506 unsigned int busy_wait_warning; 523 unsigned int busy_wait_warning;
507#ifndef MINGW 524#ifndef MINGW
508 const struct GNUNET_DISK_FileHandle *pr; 525 const struct GNUNET_DISK_FileHandle *pr;
509#endif 526#endif
527 char c;
510 528
511 rs = GNUNET_NETWORK_fdset_create (); 529 rs = GNUNET_NETWORK_fdset_create ();
512 ws = GNUNET_NETWORK_fdset_create (); 530 ws = GNUNET_NETWORK_fdset_create ();
@@ -516,38 +534,40 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *cls)
516 GNUNET_assert (sigpipe != NULL); 534 GNUNET_assert (sigpipe != NULL);
517 pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ); 535 pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ);
518 GNUNET_assert (pr != NULL); 536 GNUNET_assert (pr != NULL);
519 shc_int = GNUNET_SIGNAL_handler_install (SIGINT, &sighandler_shutdown); 537 shc_int = GNUNET_SIGNAL_handler_install (SIGINT, &sighandler_shutdown);
520 shc_term = GNUNET_SIGNAL_handler_install (SIGTERM, &sighandler_shutdown); 538 shc_term = GNUNET_SIGNAL_handler_install (SIGTERM, &sighandler_shutdown);
521 shc_quit = GNUNET_SIGNAL_handler_install (SIGQUIT, &sighandler_shutdown); 539 shc_quit = GNUNET_SIGNAL_handler_install (SIGQUIT, &sighandler_shutdown);
522 shc_hup = GNUNET_SIGNAL_handler_install (SIGHUP, &sighandler_shutdown); 540 shc_hup = GNUNET_SIGNAL_handler_install (SIGHUP, &sighandler_shutdown);
523#endif 541#endif
524 memset (&sched, 0, sizeof (sched)); 542 memset (&sched, 0, sizeof (sched));
525 sched.current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT; 543 sched.current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT;
526 GNUNET_SCHEDULER_add_continuation (&sched, 544 GNUNET_SCHEDULER_add_continuation (&sched,
527 GNUNET_YES,
528 task, 545 task,
529 cls, GNUNET_SCHEDULER_REASON_STARTUP); 546 task_cls,
547 GNUNET_SCHEDULER_REASON_STARTUP);
530 last_tr = 0; 548 last_tr = 0;
531 busy_wait_warning = 0; 549 busy_wait_warning = 0;
532 while ((GNUNET_NO == sched.shutdown) && 550 while ( (sched.pending != NULL) || (sched.ready_count > 0) )
533 ((sched.pending != NULL) || (sched.ready_count > 0)))
534 { 551 {
535 GNUNET_NETWORK_fdset_zero (rs); 552 GNUNET_NETWORK_fdset_zero (rs);
536 GNUNET_NETWORK_fdset_zero (ws); 553 GNUNET_NETWORK_fdset_zero (ws);
537 timeout = GNUNET_TIME_relative_get_forever (); 554 timeout = GNUNET_TIME_UNIT_FOREVER_REL;
538 update_sets (&sched, rs, ws, &timeout); 555 update_sets (&sched, rs, ws, &timeout);
539#ifndef MINGW
540 GNUNET_NETWORK_fdset_handle_set (rs, pr); 556 GNUNET_NETWORK_fdset_handle_set (rs, pr);
541#endif
542 if (sched.ready_count > 0) 557 if (sched.ready_count > 0)
543 { 558 {
544 /* no blocking, more work already ready! */ 559 /* no blocking, more work already ready! */
545 timeout = GNUNET_TIME_relative_get_zero (); 560 timeout = GNUNET_TIME_UNIT_ZERO;
546 } 561 }
547 ret = GNUNET_NETWORK_socket_select (rs, ws, NULL, timeout); 562 ret = GNUNET_NETWORK_socket_select (rs, ws, NULL, timeout);
548#ifndef MINGW 563#ifndef MINGW
549 if (GNUNET_NETWORK_fdset_handle_isset (rs, pr)) 564 if (GNUNET_NETWORK_fdset_handle_isset (rs, pr))
550 break; 565 {
566 /* consume the signal */
567 GNUNET_DISK_file_read (pr, &c, sizeof(c));
568 /* mark all active tasks as ready due to shutdown */
569 GNUNET_SCHEDULER_shutdown (&sched);
570 }
551#endif 571#endif
552 if (last_tr == sched.tasks_run) 572 if (last_tr == sched.tasks_run)
553 { 573 {
@@ -574,7 +594,6 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *cls)
574 check_ready (&sched, rs, ws); 594 check_ready (&sched, rs, ws);
575 run_ready (&sched); 595 run_ready (&sched);
576 } 596 }
577 sched.shutdown = GNUNET_YES;
578#ifndef MINGW 597#ifndef MINGW
579 GNUNET_SIGNAL_handler_uninstall (shc_int); 598 GNUNET_SIGNAL_handler_uninstall (shc_int);
580 GNUNET_SIGNAL_handler_uninstall (shc_term); 599 GNUNET_SIGNAL_handler_uninstall (shc_term);
@@ -583,36 +602,11 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *cls)
583 GNUNET_DISK_pipe_close (sigpipe); 602 GNUNET_DISK_pipe_close (sigpipe);
584 sigpipe = NULL; 603 sigpipe = NULL;
585#endif 604#endif
586 do
587 {
588 run_ready (&sched);
589 check_ready (&sched, NULL, NULL);
590 }
591 while (sched.ready_count > 0);
592 while (NULL != (tpos = sched.pending))
593 {
594 sched.pending = tpos->next;
595 GNUNET_free (tpos);
596 }
597 GNUNET_NETWORK_fdset_destroy (rs); 605 GNUNET_NETWORK_fdset_destroy (rs);
598 GNUNET_NETWORK_fdset_destroy (ws); 606 GNUNET_NETWORK_fdset_destroy (ws);
599} 607}
600 608
601 609
602/**
603 * Request the shutdown of a scheduler. This function can be used to
604 * stop a scheduling thread when created with the
605 * "GNUNET_SCHEDULER_init_thread" function or from within the signal
606 * handler for signals causing shutdowns.
607 *
608 * @param sched the scheduler
609 */
610void
611GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched)
612{
613 sched->shutdown = GNUNET_YES;
614}
615
616 610
617/** 611/**
618 * Get information about the current load of this scheduler. Use this 612 * Get information about the current load of this scheduler. Use this
@@ -715,102 +709,113 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched,
715 * and the reason code can be specified. 709 * and the reason code can be specified.
716 * 710 *
717 * @param sched scheduler to use 711 * @param sched scheduler to use
718 * @param run_on_shutdown should this task be run if we are shutting down? 712 * @param task main function of the task
719 * @param main main function of the task 713 * @param task_cls closure for 'main'
720 * @param cls closure for 'main'
721 * @param reason reason for task invocation 714 * @param reason reason for task invocation
722 */ 715 */
723void 716void
724GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched, 717GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched,
725 int run_on_shutdown, 718 GNUNET_SCHEDULER_Task task,
726 GNUNET_SCHEDULER_Task main, 719 void *task_cls,
727 void *cls,
728 enum GNUNET_SCHEDULER_Reason reason) 720 enum GNUNET_SCHEDULER_Reason reason)
729{ 721{
730 struct Task *task; 722 struct Task *t;
731 723
732 task = GNUNET_malloc (sizeof (struct Task)); 724 t = GNUNET_malloc (sizeof (struct Task));
733 task->callback = main; 725 t->callback = task;
734 task->callback_cls = cls; 726 t->callback_cls = task_cls;
735 task->id = ++sched->last_id; 727 t->id = ++sched->last_id;
736 task->reason = reason; 728 t->reason = reason;
737 task->priority = sched->current_priority; 729 t->priority = sched->current_priority;
738 task->run_on_shutdown = run_on_shutdown;
739#if DEBUG_TASKS 730#if DEBUG_TASKS
740 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 731 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
741 "Adding continuation task: %llu / %p\n", 732 "Adding continuation task: %llu / %p\n",
742 task->id, task->callback_cls); 733 t->id, t->callback_cls);
743#endif 734#endif
744 queue_ready_task (sched, task); 735 queue_ready_task (sched, t);
745} 736}
746 737
747 738
739
748/** 740/**
749 * Schedule a new task to be run after the specified 741 * Schedule a new task to be run after the specified prerequisite task
750 * prerequisite task has completed. 742 * has completed. It will be run with the priority of the calling
743 * task.
751 * 744 *
752 * @param sched scheduler to use 745 * @param sched scheduler to use
753 * @param run_on_shutdown run on shutdown?
754 * @param prio how important is this task?
755 * @param prerequisite_task run this task after the task with the given 746 * @param prerequisite_task run this task after the task with the given
756 * task identifier completes (and any of our other 747 * task identifier completes (and any of our other
757 * conditions, such as delay, read or write-readyness 748 * conditions, such as delay, read or write-readyness
758 * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency 749 * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency
759 * on completion of other tasks. 750 * on completion of other tasks (this will cause the task to run as
760 * @param main main function of the task 751 * soon as possible).
761 * @param cls closure for 'main' 752 * @param task main function of the task
753 * @param task_cls closure of task
762 * @return unique task identifier for the job 754 * @return unique task identifier for the job
763 * only valid until "main" is started! 755 * only valid until "task" is started!
764 */ 756 */
765GNUNET_SCHEDULER_TaskIdentifier 757GNUNET_SCHEDULER_TaskIdentifier
766GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched, 758GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched,
767 int run_on_shutdown,
768 enum GNUNET_SCHEDULER_Priority prio,
769 GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, 759 GNUNET_SCHEDULER_TaskIdentifier prerequisite_task,
770 GNUNET_SCHEDULER_Task main, void *cls) 760 GNUNET_SCHEDULER_Task task,
761 void *task_cls)
771{ 762{
772 return GNUNET_SCHEDULER_add_select (sched, run_on_shutdown, prio, 763 return GNUNET_SCHEDULER_add_select (sched,
764 GNUNET_SCHEDULER_PRIORITY_KEEP,
773 prerequisite_task, 765 prerequisite_task,
774 GNUNET_TIME_UNIT_ZERO, 766 GNUNET_TIME_UNIT_ZERO,
775 NULL, NULL, main, cls); 767 NULL, NULL, task, task_cls);
776} 768}
777 769
778 770
779/** 771/**
772 * Schedule a new task to be run with a specified priority.
773 *
774 * @param sched scheduler to use
775 * @param prio how important is the new task?
776 * @param task main function of the task
777 * @param task_cls closure of task
778 * @return unique task identifier for the job
779 * only valid until "task" is started!
780 */
781GNUNET_SCHEDULER_TaskIdentifier
782GNUNET_SCHEDULER_add_with_priority (struct GNUNET_SCHEDULER_Handle *sched,
783 enum GNUNET_SCHEDULER_Priority prio,
784 GNUNET_SCHEDULER_Task task,
785 void *task_cls)
786{
787 return GNUNET_SCHEDULER_add_select (sched,
788 prio,
789 GNUNET_SCHEDULER_NO_TASK,
790 GNUNET_TIME_UNIT_ZERO,
791 NULL, NULL, task, task_cls);
792}
793
794
795
796/**
780 * Schedule a new task to be run with a specified delay. The task 797 * Schedule a new task to be run with a specified delay. The task
781 * will be scheduled for execution once the delay has expired and the 798 * will be scheduled for execution once the delay has expired. It
782 * prerequisite task has completed. 799 * will be run with the priority of the calling task.
783 * 800 *
784 * @param sched scheduler to use 801 * @param sched scheduler to use
785 * @param run_on_shutdown run on shutdown? You can use this 802 * @param delay when should this operation time out? Use
786 * argument to run a function only during shutdown 803 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
787 * by setting delay to -1. Set this 804 * @param task main function of the task
788 * argument to GNUNET_NO to skip this task if 805 * @param task_cls closure of task
789 * the user requested process termination.
790 * @param prio how important is this task?
791 * @param prerequisite_task run this task after the task with the given
792 * task identifier completes (and any of our other
793 * conditions, such as delay, read or write-readyness
794 * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency
795 * on completion of other tasks.
796 * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever"
797 * @param main main function of the task
798 * @param cls closure of task
799 * @return unique task identifier for the job 806 * @return unique task identifier for the job
800 * only valid until "main" is started! 807 * only valid until "task" is started!
801 */ 808 */
802GNUNET_SCHEDULER_TaskIdentifier 809GNUNET_SCHEDULER_TaskIdentifier
803GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched, 810GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle *sched,
804 int run_on_shutdown,
805 enum GNUNET_SCHEDULER_Priority prio,
806 GNUNET_SCHEDULER_TaskIdentifier
807 prerequisite_task,
808 struct GNUNET_TIME_Relative delay, 811 struct GNUNET_TIME_Relative delay,
809 GNUNET_SCHEDULER_Task main, void *cls) 812 GNUNET_SCHEDULER_Task task,
813 void *task_cls)
810{ 814{
811 return GNUNET_SCHEDULER_add_select (sched, run_on_shutdown, prio, 815 return GNUNET_SCHEDULER_add_select (sched,
812 prerequisite_task, delay, 816 GNUNET_SCHEDULER_PRIORITY_KEEP,
813 NULL, NULL, main, cls); 817 GNUNET_SCHEDULER_NO_TASK, delay,
818 NULL, NULL, task, task_cls);
814} 819}
815 820
816 821
@@ -819,34 +824,24 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched,
819 * specified file descriptor is ready for reading. The delay can be 824 * specified file descriptor is ready for reading. The delay can be
820 * used as a timeout on the socket being ready. The task will be 825 * used as a timeout on the socket being ready. The task will be
821 * scheduled for execution once either the delay has expired or the 826 * scheduled for execution once either the delay has expired or the
822 * socket operation is ready. 827 * socket operation is ready. It will be run with the priority of
828 * the calling task.
823 * 829 *
824 * @param sched scheduler to use 830 * @param sched scheduler to use
825 * @param run_on_shutdown run on shutdown? Set this 831 * @param delay when should this operation time out? Use
826 * argument to GNUNET_NO to skip this task if 832 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
827 * the user requested process termination.
828 * @param prio how important is this task?
829 * @param prerequisite_task run this task after the task with the given
830 * task identifier completes (and any of our other
831 * conditions, such as delay, read or write-readyness
832 * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency
833 * on completion of other tasks.
834 * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever"
835 * @param rfd read file-descriptor 833 * @param rfd read file-descriptor
836 * @param main main function of the task 834 * @param task main function of the task
837 * @param cls closure of task 835 * @param task_cls closure of task
838 * @return unique task identifier for the job 836 * @return unique task identifier for the job
839 * only valid until "main" is started! 837 * only valid until "task" is started!
840 */ 838 */
841GNUNET_SCHEDULER_TaskIdentifier 839GNUNET_SCHEDULER_TaskIdentifier
842GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle * sched, 840GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle *sched,
843 int run_on_shutdown, 841 struct GNUNET_TIME_Relative delay,
844 enum GNUNET_SCHEDULER_Priority prio, 842 struct GNUNET_NETWORK_Handle *rfd,
845 GNUNET_SCHEDULER_TaskIdentifier 843 GNUNET_SCHEDULER_Task task,
846 prerequisite_task, 844 void *task_cls)
847 struct GNUNET_TIME_Relative delay,
848 struct GNUNET_NETWORK_Handle * rfd,
849 GNUNET_SCHEDULER_Task main, void *cls)
850{ 845{
851 struct GNUNET_NETWORK_FDSet *rs; 846 struct GNUNET_NETWORK_FDSet *rs;
852 GNUNET_SCHEDULER_TaskIdentifier ret; 847 GNUNET_SCHEDULER_TaskIdentifier ret;
@@ -854,9 +849,11 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle * sched,
854 GNUNET_assert (rfd != NULL); 849 GNUNET_assert (rfd != NULL);
855 rs = GNUNET_NETWORK_fdset_create (); 850 rs = GNUNET_NETWORK_fdset_create ();
856 GNUNET_NETWORK_fdset_set (rs, rfd); 851 GNUNET_NETWORK_fdset_set (rs, rfd);
857 ret = GNUNET_SCHEDULER_add_select (sched, run_on_shutdown, prio, 852 ret = GNUNET_SCHEDULER_add_select (sched,
858 prerequisite_task, delay, 853 GNUNET_SCHEDULER_PRIORITY_KEEP,
859 rs, NULL, main, cls); 854 GNUNET_SCHEDULER_NO_TASK,
855 delay,
856 rs, NULL, task, task_cls);
860 GNUNET_NETWORK_fdset_destroy (rs); 857 GNUNET_NETWORK_fdset_destroy (rs);
861 return ret; 858 return ret;
862} 859}
@@ -867,34 +864,24 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle * sched,
867 * specified file descriptor is ready for writing. The delay can be 864 * specified file descriptor is ready for writing. The delay can be
868 * used as a timeout on the socket being ready. The task will be 865 * used as a timeout on the socket being ready. The task will be
869 * scheduled for execution once either the delay has expired or the 866 * scheduled for execution once either the delay has expired or the
870 * socket operation is ready. 867 * socket operation is ready. It will be run with the priority of
868 * the calling task.
871 * 869 *
872 * @param sched scheduler to use 870 * @param sched scheduler to use
873 * @param run_on_shutdown run on shutdown? Set this 871 * @param delay when should this operation time out? Use
874 * argument to GNUNET_NO to skip this task if 872 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
875 * the user requested process termination.
876 * @param prio how important is this task?
877 * @param prerequisite_task run this task after the task with the given
878 * task identifier completes (and any of our other
879 * conditions, such as delay, read or write-readyness
880 * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency
881 * on completion of other tasks.
882 * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever"
883 * @param wfd write file-descriptor 873 * @param wfd write file-descriptor
884 * @param main main function of the task 874 * @param task main function of the task
885 * @param cls closure of task 875 * @param task_cls closure of task
886 * @return unique task identifier for the job 876 * @return unique task identifier for the job
887 * only valid until "main" is started! 877 * only valid until "task" is started!
888 */ 878 */
889GNUNET_SCHEDULER_TaskIdentifier 879GNUNET_SCHEDULER_TaskIdentifier
890GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle * sched, 880GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle *sched,
891 int run_on_shutdown, 881 struct GNUNET_TIME_Relative delay,
892 enum GNUNET_SCHEDULER_Priority prio, 882 struct GNUNET_NETWORK_Handle *wfd,
893 GNUNET_SCHEDULER_TaskIdentifier 883 GNUNET_SCHEDULER_Task task,
894 prerequisite_task, 884 void *task_cls)
895 struct GNUNET_TIME_Relative delay,
896 struct GNUNET_NETWORK_Handle * wfd,
897 GNUNET_SCHEDULER_Task main, void *cls)
898{ 885{
899 struct GNUNET_NETWORK_FDSet *ws; 886 struct GNUNET_NETWORK_FDSet *ws;
900 GNUNET_SCHEDULER_TaskIdentifier ret; 887 GNUNET_SCHEDULER_TaskIdentifier ret;
@@ -902,14 +889,95 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle * sched,
902 GNUNET_assert (wfd != NULL); 889 GNUNET_assert (wfd != NULL);
903 ws = GNUNET_NETWORK_fdset_create (); 890 ws = GNUNET_NETWORK_fdset_create ();
904 GNUNET_NETWORK_fdset_set (ws, wfd); 891 GNUNET_NETWORK_fdset_set (ws, wfd);
905 ret = GNUNET_SCHEDULER_add_select (sched, run_on_shutdown, prio, 892 ret = GNUNET_SCHEDULER_add_select (sched,
906 prerequisite_task, delay, 893 GNUNET_SCHEDULER_PRIORITY_KEEP,
907 NULL, ws, main, cls); 894 GNUNET_SCHEDULER_NO_TASK, delay,
895 NULL, ws, task, task_cls);
896 GNUNET_NETWORK_fdset_destroy (ws);
897 return ret;
898}
899
900
901/**
902 * Schedule a new task to be run with a specified delay or when the
903 * specified file descriptor is ready for reading. The delay can be
904 * used as a timeout on the socket being ready. The task will be
905 * scheduled for execution once either the delay has expired or the
906 * socket operation is ready. It will be run with the priority of
907 * the calling task.
908 *
909 * @param sched scheduler to use
910 * @param delay when should this operation time out? Use
911 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
912 * @param rfd read file-descriptor
913 * @param task main function of the task
914 * @param task_cls closure of task
915 * @return unique task identifier for the job
916 * only valid until "task" is started!
917 */
918GNUNET_SCHEDULER_TaskIdentifier
919GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle *sched,
920 struct GNUNET_TIME_Relative delay,
921 const struct GNUNET_DISK_FileHandle *rfd,
922 GNUNET_SCHEDULER_Task task,
923 void *task_cls)
924{
925 struct GNUNET_NETWORK_FDSet *rs;
926 GNUNET_SCHEDULER_TaskIdentifier ret;
927
928 GNUNET_assert (rfd != NULL);
929 rs = GNUNET_NETWORK_fdset_create ();
930 GNUNET_NETWORK_fdset_handle_set (rs, rfd);
931 ret = GNUNET_SCHEDULER_add_select (sched,
932 GNUNET_SCHEDULER_PRIORITY_KEEP,
933 GNUNET_SCHEDULER_NO_TASK, delay,
934 rs, NULL, task, task_cls);
935 GNUNET_NETWORK_fdset_destroy (rs);
936 return ret;
937}
938
939
940/**
941 * Schedule a new task to be run with a specified delay or when the
942 * specified file descriptor is ready for writing. The delay can be
943 * used as a timeout on the socket being ready. The task will be
944 * scheduled for execution once either the delay has expired or the
945 * socket operation is ready. It will be run with the priority of
946 * the calling task.
947 *
948 * @param sched scheduler to use
949 * @param delay when should this operation time out? Use
950 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
951 * @param wfd write file-descriptor
952 * @param task main function of the task
953 * @param task_cls closure of task
954 * @return unique task identifier for the job
955 * only valid until "task" is started!
956 */
957GNUNET_SCHEDULER_TaskIdentifier
958GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle *sched,
959 struct GNUNET_TIME_Relative delay,
960 const struct GNUNET_DISK_FileHandle *wfd,
961 GNUNET_SCHEDULER_Task task,
962 void *task_cls)
963{
964 struct GNUNET_NETWORK_FDSet *ws;
965 GNUNET_SCHEDULER_TaskIdentifier ret;
966
967 GNUNET_assert (wfd != NULL);
968 ws = GNUNET_NETWORK_fdset_create ();
969 GNUNET_NETWORK_fdset_handle_set (ws, wfd);
970 ret = GNUNET_SCHEDULER_add_select (sched,
971 GNUNET_SCHEDULER_PRIORITY_KEEP,
972 GNUNET_SCHEDULER_NO_TASK,
973 delay,
974 NULL, ws, task, task_cls);
908 GNUNET_NETWORK_fdset_destroy (ws); 975 GNUNET_NETWORK_fdset_destroy (ws);
909 return ret; 976 return ret;
910} 977}
911 978
912 979
980
913/** 981/**
914 * Schedule a new task to be run with a specified delay or when any of 982 * Schedule a new task to be run with a specified delay or when any of
915 * the specified file descriptor sets is ready. The delay can be used 983 * the specified file descriptor sets is ready. The delay can be used
@@ -928,160 +996,61 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle * sched,
928 * </code> 996 * </code>
929 * 997 *
930 * @param sched scheduler to use 998 * @param sched scheduler to use
931 * @param run_on_shutdown run on shutdown? Set this
932 * argument to GNUNET_NO to skip this task if
933 * the user requested process termination.
934 * @param prio how important is this task? 999 * @param prio how important is this task?
935 * @param prerequisite_task run this task after the task with the given 1000 * @param prerequisite_task run this task after the task with the given
936 * task identifier completes (and any of our other 1001 * task identifier completes (and any of our other
937 * conditions, such as delay, read or write-readyness 1002 * conditions, such as delay, read or write-readyness
938 * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency 1003 * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency
939 * on completion of other tasks. 1004 * on completion of other tasks.
940 * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever" 1005 * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever",
1006 * which means that the task will only be run after we receive SIGTERM
941 * @param rs set of file descriptors we want to read (can be NULL) 1007 * @param rs set of file descriptors we want to read (can be NULL)
942 * @param ws set of file descriptors we want to write (can be NULL) 1008 * @param ws set of file descriptors we want to write (can be NULL)
943 * @param main main function of the task 1009 * @param task main function of the task
944 * @param cls closure of task 1010 * @param task_cls closure of task
945 * @return unique task identifier for the job 1011 * @return unique task identifier for the job
946 * only valid until "main" is started! 1012 * only valid until "task" is started!
947 */ 1013 */
948GNUNET_SCHEDULER_TaskIdentifier 1014GNUNET_SCHEDULER_TaskIdentifier
949GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle * sched, 1015GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle *sched,
950 int run_on_shutdown,
951 enum GNUNET_SCHEDULER_Priority prio, 1016 enum GNUNET_SCHEDULER_Priority prio,
952 GNUNET_SCHEDULER_TaskIdentifier 1017 GNUNET_SCHEDULER_TaskIdentifier
953 prerequisite_task, 1018 prerequisite_task,
954 struct GNUNET_TIME_Relative delay, 1019 struct GNUNET_TIME_Relative delay,
955 const struct GNUNET_NETWORK_FDSet * rs, 1020 const struct GNUNET_NETWORK_FDSet * rs,
956 const struct GNUNET_NETWORK_FDSet * ws, 1021 const struct GNUNET_NETWORK_FDSet * ws,
957 GNUNET_SCHEDULER_Task main, void *cls) 1022 GNUNET_SCHEDULER_Task task,
1023 void *task_cls)
958{ 1024{
959 struct Task *task; 1025 struct Task *t;
960 1026
961 task = GNUNET_malloc (sizeof (struct Task)); 1027 t = GNUNET_malloc (sizeof (struct Task));
962 task->callback = main; 1028 t->callback = task;
963 task->callback_cls = cls; 1029 t->callback_cls = task_cls;
964 if (rs != NULL) 1030 if (rs != NULL)
965 { 1031 {
966 task->read_set = GNUNET_NETWORK_fdset_create (); 1032 t->read_set = GNUNET_NETWORK_fdset_create ();
967 GNUNET_NETWORK_fdset_copy (task->read_set, rs); 1033 GNUNET_NETWORK_fdset_copy (t->read_set, rs);
968 } 1034 }
969 if (ws != NULL) 1035 if (ws != NULL)
970 { 1036 {
971 task->write_set = GNUNET_NETWORK_fdset_create (); 1037 t->write_set = GNUNET_NETWORK_fdset_create ();
972 GNUNET_NETWORK_fdset_copy (task->write_set, ws); 1038 GNUNET_NETWORK_fdset_copy (t->write_set, ws);
973 } 1039 }
974 task->id = ++sched->last_id; 1040 t->id = ++sched->last_id;
975 task->prereq_id = prerequisite_task; 1041 t->prereq_id = prerequisite_task;
976 task->timeout = GNUNET_TIME_relative_to_absolute (delay); 1042 t->timeout = GNUNET_TIME_relative_to_absolute (delay);
977 task->priority = 1043 t->priority =
978 check_priority ((prio == 1044 check_priority ((prio ==
979 GNUNET_SCHEDULER_PRIORITY_KEEP) ? sched->current_priority 1045 GNUNET_SCHEDULER_PRIORITY_KEEP) ? sched->current_priority
980 : prio); 1046 : prio);
981 task->run_on_shutdown = run_on_shutdown; 1047 t->next = sched->pending;
982 task->next = sched->pending; 1048 sched->pending = t;
983 sched->pending = task;
984#if DEBUG_TASKS 1049#if DEBUG_TASKS
985 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1050 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
986 "Adding task: %llu / %p\n", task->id, task->callback_cls); 1051 "Adding task: %llu / %p\n", t->id, t->callback_cls);
987#endif 1052#endif
988 return task->id; 1053 return t->id;
989} 1054}
990 1055
991/**
992 * Schedule a new task to be run with a specified delay or when the
993 * specified file descriptor is ready for reading. The delay can be
994 * used as a timeout on the socket being ready. The task will be
995 * scheduled for execution once either the delay has expired or the
996 * socket operation is ready.
997 *
998 * @param sched scheduler to use
999 * @param run_on_shutdown run on shutdown? Set this
1000 * argument to GNUNET_NO to skip this task if
1001 * the user requested process termination.
1002 * @param prio how important is this task?
1003 * @param prerequisite_task run this task after the task with the given
1004 * task identifier completes (and any of our other
1005 * conditions, such as delay, read or write-readyness
1006 * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency
1007 * on completion of other tasks.
1008 * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever"
1009 * @param rfd read file-descriptor
1010 * @param main main function of the task
1011 * @param cls closure of task
1012 * @return unique task identifier for the job
1013 * only valid until "main" is started!
1014 */
1015GNUNET_SCHEDULER_TaskIdentifier
1016GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle * sched,
1017 int run_on_shutdown,
1018 enum GNUNET_SCHEDULER_Priority prio,
1019 GNUNET_SCHEDULER_TaskIdentifier
1020 prerequisite_task,
1021 struct GNUNET_TIME_Relative delay,
1022 const struct GNUNET_DISK_FileHandle * rfd,
1023 GNUNET_SCHEDULER_Task main, void *cls)
1024{
1025 struct GNUNET_NETWORK_FDSet *rs;
1026 GNUNET_SCHEDULER_TaskIdentifier ret;
1027
1028 GNUNET_assert (rfd != NULL);
1029 rs = GNUNET_NETWORK_fdset_create ();
1030 GNUNET_NETWORK_fdset_handle_set (rs, rfd);
1031 ret = GNUNET_SCHEDULER_add_select (sched, run_on_shutdown, prio,
1032 prerequisite_task, delay,
1033 rs, NULL, main, cls);
1034 GNUNET_NETWORK_fdset_destroy (rs);
1035 return ret;
1036}
1037
1038
1039/**
1040 * Schedule a new task to be run with a specified delay or when the
1041 * specified file descriptor is ready for writing. The delay can be
1042 * used as a timeout on the socket being ready. The task will be
1043 * scheduled for execution once either the delay has expired or the
1044 * socket operation is ready.
1045 *
1046 * @param sched scheduler to use
1047 * @param run_on_shutdown run on shutdown? Set this
1048 * argument to GNUNET_NO to skip this task if
1049 * the user requested process termination.
1050 * @param prio how important is this task?
1051 * @param prerequisite_task run this task after the task with the given
1052 * task identifier completes (and any of our other
1053 * conditions, such as delay, read or write-readyness
1054 * are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency
1055 * on completion of other tasks.
1056 * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever"
1057 * @param wfd write file-descriptor
1058 * @param main main function of the task
1059 * @param cls closure of task
1060 * @return unique task identifier for the job
1061 * only valid until "main" is started!
1062 */
1063GNUNET_SCHEDULER_TaskIdentifier
1064GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle * sched,
1065 int run_on_shutdown,
1066 enum GNUNET_SCHEDULER_Priority prio,
1067 GNUNET_SCHEDULER_TaskIdentifier
1068 prerequisite_task,
1069 struct GNUNET_TIME_Relative delay,
1070 const struct GNUNET_DISK_FileHandle * wfd,
1071 GNUNET_SCHEDULER_Task main, void *cls)
1072{
1073 struct GNUNET_NETWORK_FDSet *ws;
1074 GNUNET_SCHEDULER_TaskIdentifier ret;
1075
1076 GNUNET_assert (wfd != NULL);
1077 ws = GNUNET_NETWORK_fdset_create ();
1078 GNUNET_NETWORK_fdset_handle_set (ws, wfd);
1079 ret = GNUNET_SCHEDULER_add_select (sched, run_on_shutdown, prio,
1080 prerequisite_task, delay,
1081 NULL, ws, main, cls);
1082 GNUNET_NETWORK_fdset_destroy (ws);
1083 return ret;
1084}
1085
1086
1087/* end of scheduler.c */ 1056/* end of scheduler.c */
diff --git a/src/util/server.c b/src/util/server.c
index 42fa8c46c..ff9c8c192 100644
--- a/src/util/server.c
+++ b/src/util/server.c
@@ -349,7 +349,6 @@ process_listen_socket (void *cls,
349 GNUNET_NETWORK_fdset_set (r, server->listen_socket); 349 GNUNET_NETWORK_fdset_set (r, server->listen_socket);
350 GNUNET_NETWORK_fdset_handle_set (r, shutpipe); 350 GNUNET_NETWORK_fdset_handle_set (r, shutpipe);
351 GNUNET_SCHEDULER_add_select (server->sched, 351 GNUNET_SCHEDULER_add_select (server->sched,
352 GNUNET_YES,
353 GNUNET_SCHEDULER_PRIORITY_HIGH, 352 GNUNET_SCHEDULER_PRIORITY_HIGH,
354 GNUNET_SCHEDULER_NO_TASK, 353 GNUNET_SCHEDULER_NO_TASK,
355 GNUNET_TIME_UNIT_FOREVER_REL, 354 GNUNET_TIME_UNIT_FOREVER_REL,
@@ -475,7 +474,7 @@ GNUNET_SERVER_create (struct GNUNET_SCHEDULER_Handle *sched,
475 GNUNET_NETWORK_fdset_handle_set (r, 474 GNUNET_NETWORK_fdset_handle_set (r,
476 GNUNET_DISK_pipe_handle (ret->shutpipe, 475 GNUNET_DISK_pipe_handle (ret->shutpipe,
477 GNUNET_DISK_PIPE_END_READ)); 476 GNUNET_DISK_PIPE_END_READ));
478 GNUNET_SCHEDULER_add_select (sched, GNUNET_YES, 477 GNUNET_SCHEDULER_add_select (sched,
479 GNUNET_SCHEDULER_PRIORITY_HIGH, 478 GNUNET_SCHEDULER_PRIORITY_HIGH,
480 GNUNET_SCHEDULER_NO_TASK, 479 GNUNET_SCHEDULER_NO_TASK,
481 GNUNET_TIME_UNIT_FOREVER_REL, r, NULL, 480 GNUNET_TIME_UNIT_FOREVER_REL, r, NULL,
@@ -1167,7 +1166,6 @@ GNUNET_SERVER_receive_done (struct GNUNET_SERVER_Client *client, int success)
1167 if (GNUNET_YES != client->shutdown_now) 1166 if (GNUNET_YES != client->shutdown_now)
1168 { 1167 {
1169 GNUNET_SCHEDULER_add_continuation (client->server->sched, 1168 GNUNET_SCHEDULER_add_continuation (client->server->sched,
1170 GNUNET_NO,
1171 &restart_processing, 1169 &restart_processing,
1172 client, 1170 client,
1173 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 1171 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
diff --git a/src/util/service.c b/src/util/service.c
index 0a33809be..173c0f566 100644
--- a/src/util/service.c
+++ b/src/util/service.c
@@ -1068,6 +1068,22 @@ write_pid_file (struct GNUNET_SERVICE_Context *sctx, pid_t pid)
1068 1068
1069 1069
1070/** 1070/**
1071 * Task run during shutdown.
1072 *
1073 * @param cls unused
1074 * @param tc unused
1075 */
1076static void
1077shutdown_task (void *cls,
1078 const struct GNUNET_SCHEDULER_TaskContext *tc)
1079{
1080 struct GNUNET_SERVER_Handle *server = cls;
1081
1082 GNUNET_SERVER_destroy (server);
1083}
1084
1085
1086/**
1071 * Initial task for the service. 1087 * Initial task for the service.
1072 */ 1088 */
1073static void 1089static void
@@ -1092,6 +1108,10 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1092 sctx->ret = GNUNET_SYSERR; 1108 sctx->ret = GNUNET_SYSERR;
1093 return; 1109 return;
1094 } 1110 }
1111 GNUNET_SCHEDULER_add_delayed (tc->sched,
1112 GNUNET_TIME_UNIT_FOREVER_REL,
1113 &shutdown_task,
1114 sctx->server);
1095 sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers)); 1115 sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers));
1096 memcpy (sctx->my_handlers, defhandlers, sizeof (defhandlers)); 1116 memcpy (sctx->my_handlers, defhandlers, sizeof (defhandlers));
1097 i = 0; 1117 i = 0;
@@ -1249,6 +1269,7 @@ pid_file_delete (struct GNUNET_SERVICE_Context *sctx)
1249 GNUNET_free (pif); 1269 GNUNET_free (pif);
1250} 1270}
1251 1271
1272
1252/** 1273/**
1253 * Run a standard GNUnet service startup sequence (initialize loggers 1274 * Run a standard GNUnet service startup sequence (initialize loggers
1254 * and configuration, parse options). 1275 * and configuration, parse options).
@@ -1258,8 +1279,6 @@ pid_file_delete (struct GNUNET_SERVICE_Context *sctx)
1258 * @param serviceName our service name 1279 * @param serviceName our service name
1259 * @param task main task of the service 1280 * @param task main task of the service
1260 * @param task_cls closure for task 1281 * @param task_cls closure for task
1261 * @param term termination task of the service
1262 * @param term_cls closure for term
1263 * @return GNUNET_SYSERR on error, GNUNET_OK 1282 * @return GNUNET_SYSERR on error, GNUNET_OK
1264 * if we shutdown nicely 1283 * if we shutdown nicely
1265 */ 1284 */
@@ -1268,7 +1287,7 @@ GNUNET_SERVICE_run (int argc,
1268 char *const *argv, 1287 char *const *argv,
1269 const char *serviceName, 1288 const char *serviceName,
1270 GNUNET_SERVICE_Main task, 1289 GNUNET_SERVICE_Main task,
1271 void *task_cls, GNUNET_SERVICE_Term term, void *term_cls) 1290 void *task_cls)
1272{ 1291{
1273 char *cfg_fn; 1292 char *cfg_fn;
1274 char *loglev; 1293 char *loglev;
@@ -1347,12 +1366,8 @@ GNUNET_SERVICE_run (int argc,
1347 } 1366 }
1348 1367
1349 /* shutdown */ 1368 /* shutdown */
1350 if (term != NULL)
1351 term (term_cls, sctx.cfg);
1352 if ((do_daemonize == 1) && (sctx.server != NULL)) 1369 if ((do_daemonize == 1) && (sctx.server != NULL))
1353 pid_file_delete (&sctx); 1370 pid_file_delete (&sctx);
1354 if (sctx.server != NULL)
1355 GNUNET_SERVER_destroy (sctx.server);
1356 GNUNET_free_non_null (sctx.my_handlers); 1371 GNUNET_free_non_null (sctx.my_handlers);
1357 GNUNET_CONFIGURATION_destroy (cfg); 1372 GNUNET_CONFIGURATION_destroy (cfg);
1358 GNUNET_free_non_null (sctx.addr); 1373 GNUNET_free_non_null (sctx.addr);
@@ -1413,8 +1428,6 @@ GNUNET_SERVICE_start (const char *serviceName,
1413 while ((sctx->my_handlers[i].callback != NULL)) 1428 while ((sctx->my_handlers[i].callback != NULL))
1414 sctx->my_handlers[i++].callback_cls = sctx; 1429 sctx->my_handlers[i++].callback_cls = sctx;
1415 GNUNET_SERVER_add_handlers (sctx->server, sctx->my_handlers); 1430 GNUNET_SERVER_add_handlers (sctx->server, sctx->my_handlers);
1416
1417
1418 return sctx; 1431 return sctx;
1419} 1432}
1420 1433
diff --git a/src/util/test_connection.c b/src/util/test_connection.c
index 0f4c46b3b..07b5e843d 100644
--- a/src/util/test_connection.c
+++ b/src/util/test_connection.c
@@ -175,9 +175,6 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
175 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test prepares to accept\n"); 175 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test prepares to accept\n");
176#endif 176#endif
177 GNUNET_SCHEDULER_add_read_net (tc->sched, 177 GNUNET_SCHEDULER_add_read_net (tc->sched,
178 GNUNET_NO,
179 GNUNET_SCHEDULER_PRIORITY_HIGH,
180 GNUNET_SCHEDULER_NO_TASK,
181 GNUNET_TIME_UNIT_FOREVER_REL, 178 GNUNET_TIME_UNIT_FOREVER_REL,
182 ls, &run_accept, cls); 179 ls, &run_accept, cls);
183} 180}
diff --git a/src/util/test_connection_addressing.c b/src/util/test_connection_addressing.c
index 1b85dfac6..d6ac309f7 100644
--- a/src/util/test_connection_addressing.c
+++ b/src/util/test_connection_addressing.c
@@ -169,9 +169,6 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
169 &make_hello, NULL)); 169 &make_hello, NULL));
170 GNUNET_CONNECTION_destroy (csock); 170 GNUNET_CONNECTION_destroy (csock);
171 GNUNET_SCHEDULER_add_read_net (tc->sched, 171 GNUNET_SCHEDULER_add_read_net (tc->sched,
172 GNUNET_NO,
173 GNUNET_SCHEDULER_PRIORITY_HIGH,
174 GNUNET_SCHEDULER_NO_TASK,
175 GNUNET_TIME_UNIT_FOREVER_REL, 172 GNUNET_TIME_UNIT_FOREVER_REL,
176 ls, &run_accept, cls); 173 ls, &run_accept, cls);
177} 174}
diff --git a/src/util/test_connection_receive_cancel.c b/src/util/test_connection_receive_cancel.c
index 5856e27ed..b90191384 100644
--- a/src/util/test_connection_receive_cancel.c
+++ b/src/util/test_connection_receive_cancel.c
@@ -124,15 +124,9 @@ task_receive_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
124 "localhost", PORT, 1024); 124 "localhost", PORT, 1024);
125 GNUNET_assert (csock != NULL); 125 GNUNET_assert (csock != NULL);
126 GNUNET_SCHEDULER_add_read_net (tc->sched, 126 GNUNET_SCHEDULER_add_read_net (tc->sched,
127 GNUNET_NO,
128 GNUNET_SCHEDULER_PRIORITY_HIGH,
129 GNUNET_SCHEDULER_NO_TASK,
130 GNUNET_TIME_UNIT_FOREVER_REL, 127 GNUNET_TIME_UNIT_FOREVER_REL,
131 ls, &run_accept_cancel, cls); 128 ls, &run_accept_cancel, cls);
132 GNUNET_SCHEDULER_add_delayed (tc->sched, 129 GNUNET_SCHEDULER_add_delayed (tc->sched,
133 GNUNET_NO,
134 GNUNET_SCHEDULER_PRIORITY_KEEP,
135 GNUNET_SCHEDULER_NO_TASK,
136 GNUNET_TIME_UNIT_SECONDS, 130 GNUNET_TIME_UNIT_SECONDS,
137 &receive_cancel_task, cls); 131 &receive_cancel_task, cls);
138} 132}
diff --git a/src/util/test_crypto_hash.c b/src/util/test_crypto_hash.c
index 97ef4ec88..b650355c0 100644
--- a/src/util/test_crypto_hash.c
+++ b/src/util/test_crypto_hash.c
@@ -124,7 +124,7 @@ file_hasher (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
124{ 124{
125 GNUNET_CRYPTO_hash_file (tc->sched, 125 GNUNET_CRYPTO_hash_file (tc->sched,
126 GNUNET_SCHEDULER_PRIORITY_DEFAULT, 126 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
127 GNUNET_NO, FILENAME, 1024, &finished_task, cls); 127 FILENAME, 1024, &finished_task, cls);
128} 128}
129 129
130 130
diff --git a/src/util/test_scheduler.c b/src/util/test_scheduler.c
index 98dce6f97..3021dce19 100644
--- a/src/util/test_scheduler.c
+++ b/src/util/test_scheduler.c
@@ -30,14 +30,6 @@
30#define VERBOSE GNUNET_NO 30#define VERBOSE GNUNET_NO
31 31
32static void 32static void
33task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
34{
35 int *ok = cls;
36 GNUNET_assert (2 == *ok);
37 (*ok) = 3;
38}
39
40static void
41task3 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 33task3 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
42{ 34{
43 int *ok = cls; 35 int *ok = cls;
@@ -48,6 +40,19 @@ task3 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
48 (*ok) = 4; 40 (*ok) = 4;
49} 41}
50 42
43
44static void
45task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
46{
47 int *ok = cls;
48 GNUNET_assert (2 == *ok);
49 (*ok) = 3;
50 /* t3 will go before t4: higher priority */
51 GNUNET_SCHEDULER_add_with_priority (tc->sched,
52 GNUNET_SCHEDULER_PRIORITY_UI,
53 &task3, cls);
54}
55
51static void 56static void
52task4 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 57task4 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
53{ 58{
@@ -96,14 +101,9 @@ taskRd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
96 GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0])); 101 GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0]));
97 GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1)); 102 GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1));
98 (*ok) = 8; 103 (*ok) = 8;
99 GNUNET_SCHEDULER_add_after (tc->sched, 104 GNUNET_SCHEDULER_add_with_priority (tc->sched,
100 GNUNET_NO, 105 GNUNET_SCHEDULER_PRIORITY_IDLE,
101 GNUNET_SCHEDULER_PRIORITY_UI, 106 &taskLast, cls);
102 0, &taskNeverRun, NULL);
103 GNUNET_SCHEDULER_add_after (tc->sched,
104 GNUNET_YES,
105 GNUNET_SCHEDULER_PRIORITY_IDLE,
106 0, &taskLast, cls);
107 GNUNET_SCHEDULER_shutdown (tc->sched); 107 GNUNET_SCHEDULER_shutdown (tc->sched);
108} 108}
109 109
@@ -119,15 +119,9 @@ task5 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
119 fds[0] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_READ); 119 fds[0] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_READ);
120 fds[1] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_WRITE); 120 fds[1] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_WRITE);
121 GNUNET_SCHEDULER_add_read_file (tc->sched, 121 GNUNET_SCHEDULER_add_read_file (tc->sched,
122 GNUNET_NO,
123 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
124 GNUNET_SCHEDULER_NO_TASK,
125 GNUNET_TIME_UNIT_FOREVER_REL, 122 GNUNET_TIME_UNIT_FOREVER_REL,
126 fds[0], &taskRd, cls); 123 fds[0], &taskRd, cls);
127 GNUNET_SCHEDULER_add_write_file (tc->sched, 124 GNUNET_SCHEDULER_add_write_file (tc->sched,
128 GNUNET_NO,
129 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
130 GNUNET_SCHEDULER_NO_TASK,
131 GNUNET_TIME_UNIT_FOREVER_REL, 125 GNUNET_TIME_UNIT_FOREVER_REL,
132 fds[1], &taskWrt, cls); 126 fds[1], &taskWrt, cls);
133} 127}
@@ -144,24 +138,13 @@ task1 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
144 (*ok) = 2; 138 (*ok) = 2;
145 /* t2 will go first -- prereq for all */ 139 /* t2 will go first -- prereq for all */
146 t2 = GNUNET_SCHEDULER_add_after (tc->sched, 140 t2 = GNUNET_SCHEDULER_add_after (tc->sched,
147 GNUNET_NO,
148 GNUNET_SCHEDULER_PRIORITY_IDLE,
149 GNUNET_SCHEDULER_NO_TASK, &task2, cls); 141 GNUNET_SCHEDULER_NO_TASK, &task2, cls);
150 /* t3 will go before t4: higher priority */ 142 /* t4 will go after t2 ('add after') and after t3 (priority) */
151 t4 = GNUNET_SCHEDULER_add_after (tc->sched, 143 t4 = GNUNET_SCHEDULER_add_after (tc->sched,
152 GNUNET_NO,
153 GNUNET_SCHEDULER_PRIORITY_IDLE,
154 t2, &task4, cls); 144 t2, &task4, cls);
155 GNUNET_SCHEDULER_add_delayed (tc->sched, 145 /* t5 will go last (after p4) */
156 GNUNET_NO,
157 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
158 t2,
159 GNUNET_TIME_relative_get_zero (),
160 &task3, cls);
161 /* t4 will go first: lower prio, but prereq! */
162 GNUNET_SCHEDULER_add_after (tc->sched, 146 GNUNET_SCHEDULER_add_after (tc->sched,
163 GNUNET_NO, 147 t4, &task5, cls);
164 GNUNET_SCHEDULER_PRIORITY_UI, t4, &task5, cls);
165} 148}
166 149
167 150
@@ -182,20 +165,47 @@ check ()
182 165
183 166
184static void 167static void
168taskShutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
169{
170 int *ok = cls;
171 GNUNET_assert (1 == *ok);
172 *ok = 8;
173 GNUNET_SCHEDULER_add_delayed (tc->sched,
174 GNUNET_TIME_UNIT_FOREVER_REL,
175 &taskLast, cls);
176 GNUNET_SCHEDULER_shutdown (tc->sched);
177}
178
179
180/**
181 * Main method, starts scheduler with task1,
182 * checks that "ok" is correct at the end.
183 */
184static int
185checkShutdown ()
186{
187 int ok;
188
189 ok = 1;
190 GNUNET_SCHEDULER_run (&taskShutdown, &ok);
191 return ok;
192}
193
194
195static void
185taskSig (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 196taskSig (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
186{ 197{
187 int *ok = cls; 198 int *ok = cls;
188 GNUNET_assert (1 == *ok); 199 GNUNET_assert (1 == *ok);
189 *ok = 8; 200 *ok = 8;
190 GNUNET_SCHEDULER_add_after (tc->sched, 201 GNUNET_SCHEDULER_add_delayed (tc->sched,
191 GNUNET_NO, 202 GNUNET_TIME_UNIT_FOREVER_REL,
192 GNUNET_SCHEDULER_PRIORITY_UI, 203 &taskLast, cls);
193 0, &taskNeverRun, NULL); 204#ifndef MINGW
194 GNUNET_SCHEDULER_add_after (tc->sched,
195 GNUNET_YES,
196 GNUNET_SCHEDULER_PRIORITY_UI,
197 0, &taskLast, cls);
198 GNUNET_break (0 == PLIBC_KILL (getpid (), SIGTERM)); 205 GNUNET_break (0 == PLIBC_KILL (getpid (), SIGTERM));
206#else
207 GNUNET_SCHEDULER_shutdown (tc->sched);
208#endif
199} 209}
200 210
201 211
@@ -214,8 +224,6 @@ checkSignal ()
214} 224}
215 225
216 226
217
218
219static void 227static void
220taskCancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 228taskCancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
221{ 229{
@@ -225,9 +233,7 @@ taskCancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
225 *ok = 0; 233 *ok = 0;
226 GNUNET_SCHEDULER_cancel (tc->sched, 234 GNUNET_SCHEDULER_cancel (tc->sched,
227 GNUNET_SCHEDULER_add_after (tc->sched, 235 GNUNET_SCHEDULER_add_after (tc->sched,
228 GNUNET_NO, 236 GNUNET_SCHEDULER_NO_TASK,
229 GNUNET_SCHEDULER_PRIORITY_UI,
230 0,
231 &taskNeverRun, NULL)); 237 &taskNeverRun, NULL));
232} 238}
233 239
@@ -256,6 +262,7 @@ main (int argc, char *argv[])
256 GNUNET_log_setup ("test_scheduler", "WARNING", NULL); 262 GNUNET_log_setup ("test_scheduler", "WARNING", NULL);
257 ret += check (); 263 ret += check ();
258 ret += checkSignal (); 264 ret += checkSignal ();
265 ret += checkShutdown ();
259 ret += checkCancel (); 266 ret += checkCancel ();
260 GNUNET_DISK_pipe_close (p); 267 GNUNET_DISK_pipe_close (p);
261 268
diff --git a/src/util/test_scheduler_delay.c b/src/util/test_scheduler_delay.c
index f5477fd4c..d1d61c3e4 100644
--- a/src/util/test_scheduler_delay.c
+++ b/src/util/test_scheduler_delay.c
@@ -66,9 +66,6 @@ test_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
66 return; 66 return;
67 } 67 }
68 GNUNET_SCHEDULER_add_delayed (tc->sched, 68 GNUNET_SCHEDULER_add_delayed (tc->sched,
69 GNUNET_NO,
70 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
71 GNUNET_SCHEDULER_NO_TASK,
72 GNUNET_TIME_relative_multiply 69 GNUNET_TIME_relative_multiply
73 (GNUNET_TIME_UNIT_MILLISECONDS, i), 70 (GNUNET_TIME_UNIT_MILLISECONDS, i),
74 &test_task, NULL); 71 &test_task, NULL);
diff --git a/src/util/test_server.c b/src/util/test_server.c
index ae5609de0..95206c0f1 100644
--- a/src/util/test_server.c
+++ b/src/util/test_server.c
@@ -100,9 +100,6 @@ my_receive (void *cls,
100 stctx->cb = receiver; 100 stctx->cb = receiver;
101 stctx->cb_cls = receiver_cls; 101 stctx->cb_cls = receiver_cls;
102 ret = GNUNET_SCHEDULER_add_delayed (sched, 102 ret = GNUNET_SCHEDULER_add_delayed (sched,
103 GNUNET_NO,
104 GNUNET_SCHEDULER_PRIORITY_KEEP,
105 GNUNET_SCHEDULER_NO_TASK,
106 timeout, &signal_timeout, stctx); 103 timeout, &signal_timeout, stctx);
107 break; 104 break;
108 default: 105 default:
diff --git a/src/util/test_server_disconnect.c b/src/util/test_server_disconnect.c
index c5ce5e736..30fc34b08 100644
--- a/src/util/test_server_disconnect.c
+++ b/src/util/test_server_disconnect.c
@@ -95,9 +95,6 @@ recv_cb (void *cls,
95 case 2: 95 case 2:
96 ok++; 96 ok++;
97 GNUNET_SCHEDULER_add_delayed (sched, 97 GNUNET_SCHEDULER_add_delayed (sched,
98 GNUNET_YES,
99 GNUNET_SCHEDULER_PRIORITY_KEEP,
100 GNUNET_SCHEDULER_NO_TASK,
101 GNUNET_TIME_relative_multiply 98 GNUNET_TIME_relative_multiply
102 (GNUNET_TIME_UNIT_MILLISECONDS, 50), 99 (GNUNET_TIME_UNIT_MILLISECONDS, 50),
103 &send_done, argclient); 100 &send_done, argclient);
@@ -105,9 +102,6 @@ recv_cb (void *cls,
105 case 4: 102 case 4:
106 ok++; 103 ok++;
107 GNUNET_SCHEDULER_add_delayed (sched, 104 GNUNET_SCHEDULER_add_delayed (sched,
108 GNUNET_YES,
109 GNUNET_SCHEDULER_PRIORITY_KEEP,
110 GNUNET_SCHEDULER_NO_TASK,
111 GNUNET_TIME_relative_multiply 105 GNUNET_TIME_relative_multiply
112 (GNUNET_TIME_UNIT_MILLISECONDS, 50), 106 (GNUNET_TIME_UNIT_MILLISECONDS, 50),
113 &server_disconnect, argclient); 107 &server_disconnect, argclient);
diff --git a/src/util/test_server_with_client.c b/src/util/test_server_with_client.c
index 508c505b1..860ed3837 100644
--- a/src/util/test_server_with_client.c
+++ b/src/util/test_server_with_client.c
@@ -87,9 +87,6 @@ recv_cb (void *cls,
87 case 2: 87 case 2:
88 ok++; 88 ok++;
89 GNUNET_SCHEDULER_add_delayed (sched, 89 GNUNET_SCHEDULER_add_delayed (sched,
90 GNUNET_YES,
91 GNUNET_SCHEDULER_PRIORITY_KEEP,
92 GNUNET_SCHEDULER_NO_TASK,
93 GNUNET_TIME_relative_multiply 90 GNUNET_TIME_relative_multiply
94 (GNUNET_TIME_UNIT_MILLISECONDS, 50), 91 (GNUNET_TIME_UNIT_MILLISECONDS, 50),
95 &send_done, argclient); 92 &send_done, argclient);
diff --git a/src/util/test_service.c b/src/util/test_service.c
index 93cafb4d2..fa35da6e9 100644
--- a/src/util/test_service.c
+++ b/src/util/test_service.c
@@ -30,6 +30,7 @@
30#include "gnunet_scheduler_lib.h" 30#include "gnunet_scheduler_lib.h"
31#include "gnunet_time_lib.h" 31#include "gnunet_time_lib.h"
32 32
33
33#define VERBOSE GNUNET_NO 34#define VERBOSE GNUNET_NO
34 35
35#define PORT 12435 36#define PORT 12435
@@ -40,6 +41,9 @@ static struct GNUNET_SCHEDULER_Handle *sched;
40 41
41static struct GNUNET_SERVICE_Context *sctx; 42static struct GNUNET_SERVICE_Context *sctx;
42 43
44static int ok = 1;
45
46
43static void 47static void
44end_it (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 48end_it (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
45{ 49{
@@ -47,8 +51,11 @@ end_it (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
47 51
48 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down service\n"); 52 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down service\n");
49 GNUNET_CLIENT_service_shutdown (client); 53 GNUNET_CLIENT_service_shutdown (client);
50 if (sctx != NULL) 54 if (sctx != NULL)
51 GNUNET_SERVICE_stop (sctx); 55 GNUNET_SERVICE_stop (sctx);
56 else
57 GNUNET_SCHEDULER_shutdown (sched);
58 ok = 0;
52} 59}
53 60
54 61
@@ -63,7 +70,6 @@ build_msg (void *cls, size_t size, void *buf)
63 msg->type = htons (MY_TYPE); 70 msg->type = htons (MY_TYPE);
64 msg->size = htons (sizeof (struct GNUNET_MessageHeader)); 71 msg->size = htons (sizeof (struct GNUNET_MessageHeader));
65 GNUNET_SCHEDULER_add_continuation (sched, 72 GNUNET_SCHEDULER_add_continuation (sched,
66 GNUNET_YES,
67 &end_it, 73 &end_it,
68 client, 74 client,
69 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 75 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -103,6 +109,9 @@ static struct GNUNET_SERVER_MessageHandler myhandlers[] = {
103 {NULL, NULL, 0, 0} 109 {NULL, NULL, 0, 0}
104}; 110};
105 111
112
113
114
106static void 115static void
107runner (void *cls, 116runner (void *cls,
108 struct GNUNET_SCHEDULER_Handle *sched, 117 struct GNUNET_SCHEDULER_Handle *sched,
@@ -117,12 +126,6 @@ runner (void *cls,
117 (void *) cfg); 126 (void *) cfg);
118} 127}
119 128
120static void
121term (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
122{
123 int *ok = cls;
124 *ok = 0;
125}
126 129
127/** 130/**
128 * Main method, starts scheduler with task1, 131 * Main method, starts scheduler with task1,
@@ -131,7 +134,7 @@ term (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
131static int 134static int
132check () 135check ()
133{ 136{
134 int ok = 1; 137 ok = 1;
135 char *const argv[] = { 138 char *const argv[] = {
136 "test_service", 139 "test_service",
137 "-c", 140 "-c",
@@ -149,12 +152,12 @@ check ()
149 GNUNET_SERVICE_run (5, 152 GNUNET_SERVICE_run (5,
150 argv, 153 argv,
151 "test_service", 154 "test_service",
152 &runner, &ok, &term, &ok)); 155 &runner, &ok));
153 GNUNET_assert (0 == ok); 156 GNUNET_assert (0 == ok);
154 return ok; 157 return ok;
155} 158}
156 159
157static void 160static void
158ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 161ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
159{ 162{
160 const struct GNUNET_CONFIGURATION_Handle *cfg = cls; 163 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
@@ -193,7 +196,6 @@ runner6 (void *cls,
193static int 196static int
194check6 () 197check6 ()
195{ 198{
196 int ok = 1;
197 char *const argv[] = { 199 char *const argv[] = {
198 "test_service6", 200 "test_service6",
199 "-c", 201 "-c",
@@ -211,7 +213,7 @@ check6 ()
211 GNUNET_SERVICE_run (5, 213 GNUNET_SERVICE_run (5,
212 argv, 214 argv,
213 "test_service6", 215 "test_service6",
214 &runner6, &ok, &term, &ok)); 216 &runner6, &ok));
215 GNUNET_assert (0 == ok); 217 GNUNET_assert (0 == ok);
216 return ok; 218 return ok;
217} 219}
@@ -224,7 +226,7 @@ check6 ()
224static int 226static int
225check6d () 227check6d ()
226{ 228{
227 int ok = 1; 229 ok = 1;
228 char *const argv[] = { 230 char *const argv[] = {
229 "test_service6", 231 "test_service6",
230 "-c", 232 "-c",
@@ -243,7 +245,7 @@ check6d ()
243 GNUNET_SERVICE_run (6, 245 GNUNET_SERVICE_run (6,
244 argv, 246 argv,
245 "test_service6", 247 "test_service6",
246 &runner6, &ok, &term, &ok)); 248 &runner6, &ok));
247 GNUNET_break (0 == ok); 249 GNUNET_break (0 == ok);
248 return ok; 250 return ok;
249} 251}