aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/arm/arm_api.c61
-rw-r--r--src/arm/gnunet-arm.c25
-rw-r--r--src/arm/gnunet-service-arm.c36
-rw-r--r--src/arm/gnunet-service-arm.h3
-rw-r--r--src/arm/gnunet-service-arm_interceptor.c75
-rw-r--r--src/arm/mockup-service.c6
-rw-r--r--src/arm/test_arm_api.c9
-rw-r--r--src/arm/test_exponential_backoff.c37
-rw-r--r--src/arm/test_gnunet_service_manager.c10
-rw-r--r--src/core/core_api.c30
-rw-r--r--src/core/core_api_iterate_peers.c6
-rw-r--r--src/core/core_api_peer_get_info.c6
-rw-r--r--src/core/core_api_peer_request.c17
-rw-r--r--src/core/gnunet-service-core.c94
-rw-r--r--src/core/test_core_api.c18
-rw-r--r--src/core/test_core_api_reliability.c32
-rw-r--r--src/core/test_core_api_start_only.c9
-rw-r--r--src/core/test_core_quota_compliance.c37
-rw-r--r--src/datacache/datacache.c8
-rw-r--r--src/datacache/perf_datacache.c4
-rw-r--r--src/datacache/plugin_datacache.h4
-rw-r--r--src/datacache/test_datacache.c4
-rw-r--r--src/datacache/test_datacache_quota.c4
-rw-r--r--src/datastore/datastore_api.c35
-rw-r--r--src/datastore/gnunet-service-datastore.c25
-rw-r--r--src/datastore/perf_datastore_api.c23
-rw-r--r--src/datastore/perf_plugin_datastore.c21
-rw-r--r--src/datastore/plugin_datastore.h4
-rw-r--r--src/datastore/plugin_datastore_mysql.c6
-rw-r--r--src/datastore/plugin_datastore_postgres.c6
-rw-r--r--src/datastore/plugin_datastore_sqlite.c6
-rw-r--r--src/datastore/test_datastore_api.c31
-rw-r--r--src/datastore/test_datastore_api_management.c17
-rw-r--r--src/dht/dht_api.c26
-rw-r--r--src/dht/gnunet-dht-driver.c220
-rw-r--r--src/dht/gnunet-dht-get-peer.c16
-rw-r--r--src/dht/gnunet-dht-get.c14
-rw-r--r--src/dht/gnunet-dht-put.c11
-rw-r--r--src/dht/gnunet-service-dht.c88
-rw-r--r--src/dht/test_dht_api.c53
-rw-r--r--src/dht/test_dht_multipeer.c96
-rw-r--r--src/dht/test_dht_twopeer.c81
-rw-r--r--src/dht/test_dht_twopeer_put_get.c58
-rw-r--r--src/dht/test_dhtlog.c1
-rw-r--r--src/dv/dv.h3
-rw-r--r--src/dv/dv_api.c13
-rw-r--r--src/dv/gnunet-service-dv.c56
-rw-r--r--src/dv/plugin_transport_dv.c2
-rw-r--r--src/dv/test_transport_api_dv.c103
-rw-r--r--src/fs/fs.c34
-rw-r--r--src/fs/fs.h5
-rw-r--r--src/fs/fs_download.c12
-rw-r--r--src/fs/fs_list_indexed.c18
-rw-r--r--src/fs/fs_namespace.c16
-rw-r--r--src/fs/fs_publish.c46
-rw-r--r--src/fs/fs_search.c52
-rw-r--r--src/fs/fs_test_lib.c87
-rw-r--r--src/fs/fs_test_lib.h20
-rw-r--r--src/fs/fs_tree.c6
-rw-r--r--src/fs/fs_unindex.c9
-rw-r--r--src/fs/gnunet-directory.c2
-rw-r--r--src/fs/gnunet-download.c18
-rw-r--r--src/fs/gnunet-pseudonym.c5
-rw-r--r--src/fs/gnunet-publish.c23
-rw-r--r--src/fs/gnunet-search.c16
-rw-r--r--src/fs/gnunet-service-fs.c92
-rw-r--r--src/fs/gnunet-service-fs_indexing.c17
-rw-r--r--src/fs/gnunet-service-fs_indexing.h4
-rw-r--r--src/fs/gnunet-unindex.c18
-rw-r--r--src/fs/perf_gnunet_service_fs_p2p.c36
-rw-r--r--src/fs/test_fs_download.c27
-rw-r--r--src/fs/test_fs_download_indexed.c27
-rw-r--r--src/fs/test_fs_download_persistence.c30
-rw-r--r--src/fs/test_fs_file_information.c3
-rw-r--r--src/fs/test_fs_list_indexed.c16
-rw-r--r--src/fs/test_fs_namespace.c19
-rw-r--r--src/fs/test_fs_namespace_list_updateable.c7
-rw-r--r--src/fs/test_fs_publish.c13
-rw-r--r--src/fs/test_fs_publish_persistence.c19
-rw-r--r--src/fs/test_fs_search.c19
-rw-r--r--src/fs/test_fs_search_persistence.c25
-rw-r--r--src/fs/test_fs_start_stop.c7
-rw-r--r--src/fs/test_fs_test_lib.c28
-rw-r--r--src/fs/test_fs_unindex.c19
-rw-r--r--src/fs/test_fs_unindex_persistence.c25
-rw-r--r--src/fs/test_gnunet_service_fs_migration.c31
-rw-r--r--src/fs/test_gnunet_service_fs_p2p.c25
-rw-r--r--src/hostlist/gnunet-daemon-hostlist.c15
-rw-r--r--src/hostlist/hostlist-client.c52
-rw-r--r--src/hostlist/hostlist-client.h2
-rw-r--r--src/hostlist/hostlist-server.c19
-rw-r--r--src/hostlist/hostlist-server.h1
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist.c23
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist_learning.c40
-rw-r--r--src/include/gnunet_arm_service.h2
-rw-r--r--src/include/gnunet_client_lib.h10
-rw-r--r--src/include/gnunet_connection_lib.h23
-rw-r--r--src/include/gnunet_core_service.h16
-rw-r--r--src/include/gnunet_crypto_lib.h4
-rw-r--r--src/include/gnunet_datacache_lib.h4
-rw-r--r--src/include/gnunet_datastore_service.h6
-rw-r--r--src/include/gnunet_dht_service.h4
-rw-r--r--src/include/gnunet_disk_lib.h5
-rw-r--r--src/include/gnunet_fs_service.h4
-rw-r--r--src/include/gnunet_nat_lib.h4
-rw-r--r--src/include/gnunet_peerinfo_service.h6
-rw-r--r--src/include/gnunet_program_lib.h2
-rw-r--r--src/include/gnunet_resolver_service.h12
-rw-r--r--src/include/gnunet_scheduler_lib.h93
-rw-r--r--src/include/gnunet_server_lib.h10
-rw-r--r--src/include/gnunet_service_lib.h6
-rw-r--r--src/include/gnunet_statistics_service.h4
-rw-r--r--src/include/gnunet_testing_lib.h13
-rw-r--r--src/include/gnunet_transport_service.h14
-rw-r--r--src/include/gnunet_upnp_service.h4
-rw-r--r--src/monkey/gnunet-monkey.c2
-rw-r--r--src/nat/nat.c23
-rw-r--r--src/nat/natpmp.c5
-rw-r--r--src/nat/natpmp.h5
-rw-r--r--src/nat/test_nat.c6
-rw-r--r--src/nat/upnp-commands.c28
-rw-r--r--src/nat/upnp-commands.h20
-rw-r--r--src/nat/upnp-discover.c40
-rw-r--r--src/nat/upnp-discover.h4
-rw-r--r--src/nat/upnp.c16
-rw-r--r--src/nat/upnp.h5
-rw-r--r--src/peerinfo-tool/gnunet-peerinfo.c10
-rw-r--r--src/peerinfo/gnunet-service-peerinfo.c19
-rw-r--r--src/peerinfo/peerinfo_api.c35
-rw-r--r--src/peerinfo/peerinfo_api_notify.c17
-rwxr-xr-xsrc/peerinfo/perf_peerinfo_api.c6
-rw-r--r--src/peerinfo/test_peerinfo_api.c6
-rw-r--r--src/statistics/gnunet-service-statistics.c5
-rw-r--r--src/statistics/gnunet-statistics.c6
-rw-r--r--src/statistics/statistics_api.c19
-rw-r--r--src/statistics/test_statistics_api.c6
-rw-r--r--src/statistics/test_statistics_api_loop.c3
-rw-r--r--src/template/gnunet-service-template.c5
-rw-r--r--src/template/gnunet-template.c2
-rw-r--r--src/testing/test_testing.c3
-rw-r--r--src/testing/test_testing_connect.c10
-rw-r--r--src/testing/test_testing_group.c6
-rw-r--r--src/testing/test_testing_group_remote.c7
-rw-r--r--src/testing/test_testing_topology.c86
-rw-r--r--src/testing/test_testing_topology_blacklist.c54
-rw-r--r--src/testing/test_testing_topology_churn.c22
-rw-r--r--src/testing/testing.c102
-rw-r--r--src/testing/testing_group.c51
-rw-r--r--src/topology/gnunet-daemon-topology.c61
-rw-r--r--src/topology/test_gnunet_daemon_topology.c9
-rw-r--r--src/transport/gnunet-service-transport.c90
-rw-r--r--src/transport/plugin_transport.h5
-rw-r--r--src/transport/plugin_transport_http.c41
-rw-r--r--src/transport/plugin_transport_tcp.c37
-rw-r--r--src/transport/plugin_transport_udp.c42
-rw-r--r--src/transport/plugin_transport_wlan.c14
-rw-r--r--src/transport/test_plugin_transport.c12
-rw-r--r--src/transport/test_plugin_transport_http.c22
-rw-r--r--src/transport/test_plugin_transport_https.c22
-rw-r--r--src/transport/test_plugin_transport_udp.c9
-rw-r--r--src/transport/test_quota_compliance.c41
-rw-r--r--src/transport/test_transport_api.c16
-rw-r--r--src/transport/test_transport_api_reliability.c28
-rw-r--r--src/transport/transport_api.c52
-rw-r--r--src/transport/transport_api_address_lookup.c6
-rw-r--r--src/transport/transport_api_blacklist.c15
-rw-r--r--src/util/client.c61
-rw-r--r--src/util/connection.c112
-rw-r--r--src/util/crypto_hash.c18
-rw-r--r--src/util/disk.c12
-rw-r--r--src/util/gnunet-resolver.c4
-rw-r--r--src/util/gnunet-service-resolver.c2
-rw-r--r--src/util/program.c2
-rw-r--r--src/util/resolver_api.c37
-rw-r--r--src/util/scheduler.c374
-rw-r--r--src/util/server.c39
-rw-r--r--src/util/service.c26
-rw-r--r--src/util/test_client.c5
-rw-r--r--src/util/test_connection.c11
-rw-r--r--src/util/test_connection_addressing.c11
-rw-r--r--src/util/test_connection_receive_cancel.c13
-rw-r--r--src/util/test_connection_timeout.c4
-rw-r--r--src/util/test_connection_timeout_no_connect.c2
-rw-r--r--src/util/test_connection_transmit_cancel.c2
-rw-r--r--src/util/test_crypto_hash.c3
-rw-r--r--src/util/test_disk.c3
-rw-r--r--src/util/test_os_start_process.c16
-rw-r--r--src/util/test_program.c2
-rw-r--r--src/util/test_resolver_api.c14
-rw-r--r--src/util/test_scheduler.c36
-rw-r--r--src/util/test_scheduler_delay.c3
-rw-r--r--src/util/test_server.c12
-rw-r--r--src/util/test_server_disconnect.c15
-rw-r--r--src/util/test_server_with_client.c14
-rw-r--r--src/util/test_service.c25
-rw-r--r--src/vpn/gnunet-daemon-vpn.c41
-rw-r--r--src/vpn/gnunet-service-dns.c138
197 files changed, 1664 insertions, 3373 deletions
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c
index e404f8d27..f935c590f 100644
--- a/src/arm/arm_api.c
+++ b/src/arm/arm_api.c
@@ -49,11 +49,6 @@ struct GNUNET_ARM_Handle
49 */ 49 */
50 struct GNUNET_CONFIGURATION_Handle *cfg; 50 struct GNUNET_CONFIGURATION_Handle *cfg;
51 51
52 /**
53 * Scheduler to use.
54 */
55 struct GNUNET_SCHEDULER_Handle *sched;
56
57}; 52};
58 53
59 54
@@ -63,11 +58,6 @@ struct GNUNET_ARM_Handle
63struct ShutdownContext 58struct ShutdownContext
64{ 59{
65 /** 60 /**
66 * Scheduler to be used to call continuation
67 */
68 struct GNUNET_SCHEDULER_Handle *sched;
69
70 /**
71 * Connection to the service that is being shutdown. 61 * Connection to the service that is being shutdown.
72 */ 62 */
73 struct GNUNET_CLIENT_Connection *sock; 63 struct GNUNET_CLIENT_Connection *sock;
@@ -80,7 +70,7 @@ struct ShutdownContext
80 /** 70 /**
81 * Task set up to cancel the shutdown request on timeout. 71 * Task set up to cancel the shutdown request on timeout.
82 */ 72 */
83 GNUNET_SCHEDULER_TaskIdentifier timeout_task; 73 GNUNET_SCHEDULER_TaskIdentifier cancel_task;
84 74
85 /** 75 /**
86 * Task to call once shutdown complete 76 * Task to call once shutdown complete
@@ -99,7 +89,6 @@ struct ShutdownContext
99 89
100}; 90};
101 91
102
103/** 92/**
104 * Handler receiving response to service shutdown requests. 93 * Handler receiving response to service shutdown requests.
105 * First call with NULL: service misbehaving, or something. 94 * First call with NULL: service misbehaving, or something.
@@ -112,8 +101,7 @@ struct ShutdownContext
112 * @param msg NULL, indicating socket closure. 101 * @param msg NULL, indicating socket closure.
113 */ 102 */
114static void 103static void
115service_shutdown_handler (void *cls, 104service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg)
116 const struct GNUNET_MessageHeader *msg)
117{ 105{
118 struct ShutdownContext *shutdown_ctx = cls; 106 struct ShutdownContext *shutdown_ctx = cls;
119 107
@@ -124,7 +112,7 @@ service_shutdown_handler (void *cls,
124 "Service handle shutdown before ACK!\n"); 112 "Service handle shutdown before ACK!\n");
125 if (shutdown_ctx->cont != NULL) 113 if (shutdown_ctx->cont != NULL)
126 shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_SYSERR); 114 shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_SYSERR);
127 GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->timeout_task); 115 GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task);
128 GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); 116 GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO);
129 GNUNET_free(shutdown_ctx); 117 GNUNET_free(shutdown_ctx);
130 } 118 }
@@ -137,7 +125,7 @@ service_shutdown_handler (void *cls,
137 if (shutdown_ctx->cont != NULL) 125 if (shutdown_ctx->cont != NULL)
138 shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_NO); 126 shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_NO);
139 127
140 GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->timeout_task); 128 GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task);
141 GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); 129 GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO);
142 GNUNET_free(shutdown_ctx); 130 GNUNET_free(shutdown_ctx);
143 } 131 }
@@ -165,7 +153,7 @@ service_shutdown_handler (void *cls,
165 if (shutdown_ctx->cont != NULL) 153 if (shutdown_ctx->cont != NULL)
166 shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_YES); 154 shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_YES);
167 155
168 GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->timeout_task); 156 GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task);
169 GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); 157 GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO);
170 GNUNET_free(shutdown_ctx); 158 GNUNET_free(shutdown_ctx);
171 break; 159 break;
@@ -173,21 +161,17 @@ service_shutdown_handler (void *cls,
173 } 161 }
174} 162}
175 163
176
177/** 164/**
178 * Shutting down took too long, cancel receive and return error. 165 * Shutting down took too long, cancel receive and return error.
179 * 166 *
180 * @param cls closure 167 * @param cls closure
181 * @param tc context information (why was this task triggered now) 168 * @param tc context information (why was this task triggered now)
182 */ 169 */
183static void 170void service_shutdown_cancel (void *cls,
184service_shutdown_timeout (void *cls, 171 const struct GNUNET_SCHEDULER_TaskContext * tc)
185 const struct GNUNET_SCHEDULER_TaskContext * tc)
186{ 172{
187 struct ShutdownContext *shutdown_ctx = cls; 173 struct ShutdownContext *shutdown_ctx = cls;
188 174 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "service_shutdown_cancel called!\n");
189 GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
190 _("Timeout during attempt to shutdown service. Hoping it is simply down already.\n"));
191 shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_SYSERR); 175 shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_SYSERR);
192 GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); 176 GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO);
193 GNUNET_free(shutdown_ctx); 177 GNUNET_free(shutdown_ctx);
@@ -222,10 +206,9 @@ write_shutdown (void *cls, size_t size, void *buf)
222 GNUNET_CLIENT_receive (shutdown_ctx->sock, 206 GNUNET_CLIENT_receive (shutdown_ctx->sock,
223 &service_shutdown_handler, shutdown_ctx, 207 &service_shutdown_handler, shutdown_ctx,
224 GNUNET_TIME_UNIT_FOREVER_REL); 208 GNUNET_TIME_UNIT_FOREVER_REL);
225 shutdown_ctx->timeout_task = GNUNET_SCHEDULER_add_delayed (shutdown_ctx->sched, 209 shutdown_ctx->cancel_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining(shutdown_ctx->timeout),
226 GNUNET_TIME_absolute_get_remaining(shutdown_ctx->timeout), 210 &service_shutdown_cancel,
227 &service_shutdown_timeout, 211 shutdown_ctx);
228 shutdown_ctx);
229 msg = (struct GNUNET_MessageHeader *) buf; 212 msg = (struct GNUNET_MessageHeader *) buf;
230 msg->type = htons (GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN); 213 msg->type = htons (GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN);
231 msg->size = htons (sizeof (struct GNUNET_MessageHeader)); 214 msg->size = htons (sizeof (struct GNUNET_MessageHeader));
@@ -240,7 +223,6 @@ write_shutdown (void *cls, size_t size, void *buf)
240 * be used by the caller after this call 223 * be used by the caller after this call
241 * (calling this function frees "sock" after a while). 224 * (calling this function frees "sock" after a while).
242 * 225 *
243 * @param sched the scheduler to use for calling shutdown continuation
244 * @param sock the socket connected to the service 226 * @param sock the socket connected to the service
245 * @param timeout how long to wait before giving up on transmission 227 * @param timeout how long to wait before giving up on transmission
246 * @param cont continuation to call once the service is really down 228 * @param cont continuation to call once the service is really down
@@ -248,16 +230,13 @@ write_shutdown (void *cls, size_t size, void *buf)
248 * 230 *
249 */ 231 */
250static void 232static void
251arm_service_shutdown (struct GNUNET_SCHEDULER_Handle *sched, 233arm_service_shutdown (struct GNUNET_CLIENT_Connection *sock,
252 struct GNUNET_CLIENT_Connection *sock,
253 struct GNUNET_TIME_Relative timeout, 234 struct GNUNET_TIME_Relative timeout,
254 GNUNET_CLIENT_ShutdownTask cont, 235 GNUNET_CLIENT_ShutdownTask cont,
255 void *cont_cls) 236 void *cont_cls)
256{ 237{
257 struct ShutdownContext *shutdown_ctx; 238 struct ShutdownContext *shutdown_ctx;
258
259 shutdown_ctx = GNUNET_malloc(sizeof(struct ShutdownContext)); 239 shutdown_ctx = GNUNET_malloc(sizeof(struct ShutdownContext));
260 shutdown_ctx->sched = sched;
261 shutdown_ctx->cont = cont; 240 shutdown_ctx->cont = cont;
262 shutdown_ctx->cont_cls = cont_cls; 241 shutdown_ctx->cont_cls = cont_cls;
263 shutdown_ctx->sock = sock; 242 shutdown_ctx->sock = sock;
@@ -278,20 +257,17 @@ arm_service_shutdown (struct GNUNET_SCHEDULER_Handle *sched,
278 * @param cfg configuration to use (needed to contact ARM; 257 * @param cfg configuration to use (needed to contact ARM;
279 * the ARM service may internally use a different 258 * the ARM service may internally use a different
280 * configuration to determine how to start the service). 259 * configuration to determine how to start the service).
281 * @param sched scheduler to use
282 * @param service service that *this* process is implementing/providing, can be NULL 260 * @param service service that *this* process is implementing/providing, can be NULL
283 * @return context to use for further ARM operations, NULL on error 261 * @return context to use for further ARM operations, NULL on error
284 */ 262 */
285struct GNUNET_ARM_Handle * 263struct GNUNET_ARM_Handle *
286GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 264GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
287 struct GNUNET_SCHEDULER_Handle *sched,
288 const char *service) 265 const char *service)
289{ 266{
290 struct GNUNET_ARM_Handle *ret; 267 struct GNUNET_ARM_Handle *ret;
291 268
292 ret = GNUNET_malloc (sizeof (struct GNUNET_ARM_Handle)); 269 ret = GNUNET_malloc (sizeof (struct GNUNET_ARM_Handle));
293 ret->cfg = GNUNET_CONFIGURATION_dup (cfg); 270 ret->cfg = GNUNET_CONFIGURATION_dup (cfg);
294 ret->sched = sched;
295 return ret; 271 return ret;
296} 272}
297 273
@@ -517,8 +493,7 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg)
517 : "STOP", 493 : "STOP",
518 (const char*) &sc[1]); 494 (const char*) &sc[1]);
519 GNUNET_CLIENT_disconnect (sc->h->client, GNUNET_NO); 495 GNUNET_CLIENT_disconnect (sc->h->client, GNUNET_NO);
520 sc->h->client = GNUNET_CLIENT_connect (sc->h->sched, 496 sc->h->client = GNUNET_CLIENT_connect ("arm",
521 "arm",
522 sc->h->cfg); 497 sc->h->cfg);
523 GNUNET_assert (NULL != sc->h->client); 498 GNUNET_assert (NULL != sc->h->client);
524 GNUNET_CLIENT_ignore_shutdown (sc->h->client, GNUNET_YES); 499 GNUNET_CLIENT_ignore_shutdown (sc->h->client, GNUNET_YES);
@@ -641,7 +616,6 @@ GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h,
641 struct RequestContext *sctx; 616 struct RequestContext *sctx;
642 struct GNUNET_CLIENT_Connection *client; 617 struct GNUNET_CLIENT_Connection *client;
643 size_t slen; 618 size_t slen;
644
645#if DEBUG_ARM 619#if DEBUG_ARM
646 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 620 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
647 _("Asked to start service `%s' within %llu ms\n"), service_name, 621 _("Asked to start service `%s' within %llu ms\n"), service_name,
@@ -656,14 +630,13 @@ GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h,
656 sctx->cls = cb_cls; 630 sctx->cls = cb_cls;
657 sctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); 631 sctx->timeout = GNUNET_TIME_relative_to_absolute (timeout);
658 memcpy (&sctx[1], service_name, slen); 632 memcpy (&sctx[1], service_name, slen);
659 GNUNET_CLIENT_service_test (h->sched, 633 GNUNET_CLIENT_service_test ("arm",
660 "arm",
661 h->cfg, timeout, &arm_service_report, sctx); 634 h->cfg, timeout, &arm_service_report, sctx);
662 return; 635 return;
663 } 636 }
664 if (h->client == NULL) 637 if (h->client == NULL)
665 { 638 {
666 client = GNUNET_CLIENT_connect (h->sched, "arm", h->cfg); 639 client = GNUNET_CLIENT_connect ("arm", h->cfg);
667 if (client == NULL) 640 if (client == NULL)
668 { 641 {
669 cb (cb_cls, GNUNET_SYSERR); 642 cb (cb_cls, GNUNET_SYSERR);
@@ -718,7 +691,7 @@ GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h,
718 (unsigned long long) timeout.rel_value); 691 (unsigned long long) timeout.rel_value);
719 if (h->client == NULL) 692 if (h->client == NULL)
720 { 693 {
721 client = GNUNET_CLIENT_connect (h->sched, "arm", h->cfg); 694 client = GNUNET_CLIENT_connect ("arm", h->cfg);
722 if (client == NULL) 695 if (client == NULL)
723 { 696 {
724 cb (cb_cls, GNUNET_SYSERR); 697 cb (cb_cls, GNUNET_SYSERR);
@@ -732,7 +705,7 @@ GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h,
732 arm_shutdown_ctx = GNUNET_malloc(sizeof(struct ARM_ShutdownContext)); 705 arm_shutdown_ctx = GNUNET_malloc(sizeof(struct ARM_ShutdownContext));
733 arm_shutdown_ctx->cb = cb; 706 arm_shutdown_ctx->cb = cb;
734 arm_shutdown_ctx->cb_cls = cb_cls; 707 arm_shutdown_ctx->cb_cls = cb_cls;
735 arm_service_shutdown (h->sched, h->client, timeout, &arm_shutdown_callback, arm_shutdown_ctx); 708 arm_service_shutdown (h->client, timeout, &arm_shutdown_callback, arm_shutdown_ctx);
736 h->client = NULL; 709 h->client = NULL;
737 return; 710 return;
738 } 711 }
diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c
index c19020ccb..ba74e8223 100644
--- a/src/arm/gnunet-arm.c
+++ b/src/arm/gnunet-arm.c
@@ -116,11 +116,6 @@ static int ret;
116static struct GNUNET_ARM_Handle *h; 116static struct GNUNET_ARM_Handle *h;
117 117
118/** 118/**
119 * Our scheduler.
120 */
121static struct GNUNET_SCHEDULER_Handle *sched;
122
123/**
124 * Our configuration. 119 * Our configuration.
125 */ 120 */
126const struct GNUNET_CONFIGURATION_Handle *cfg; 121const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -184,8 +179,7 @@ confirm_cb (void *cls, int success)
184 break; 179 break;
185 } 180 }
186 181
187 GNUNET_SCHEDULER_add_continuation (sched, 182 GNUNET_SCHEDULER_add_continuation (&cps_loop,
188 &cps_loop,
189 NULL, 183 NULL,
190 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 184 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
191} 185}
@@ -213,8 +207,7 @@ confirm_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
213 if (quiet != GNUNET_YES) 207 if (quiet != GNUNET_YES)
214 fprintf(stdout, _("Service `%s' is not running.\n"), service); 208 fprintf(stdout, _("Service `%s' is not running.\n"), service);
215 } 209 }
216 GNUNET_SCHEDULER_add_continuation (sched, 210 GNUNET_SCHEDULER_add_continuation (&cps_loop,
217 &cps_loop,
218 NULL, 211 NULL,
219 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 212 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
220} 213}
@@ -224,19 +217,16 @@ confirm_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
224 * Main function that will be run by the scheduler. 217 * Main function that will be run by the scheduler.
225 * 218 *
226 * @param cls closure 219 * @param cls closure
227 * @param s the scheduler to use
228 * @param args remaining command-line arguments 220 * @param args remaining command-line arguments
229 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 221 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
230 * @param c configuration 222 * @param c configuration
231 */ 223 */
232static void 224static void
233run (void *cls, 225run (void *cls,
234 struct GNUNET_SCHEDULER_Handle *s,
235 char *const *args, 226 char *const *args,
236 const char *cfgfile, 227 const char *cfgfile,
237 const struct GNUNET_CONFIGURATION_Handle *c) 228 const struct GNUNET_CONFIGURATION_Handle *c)
238{ 229{
239 sched = s;
240 cfg = c; 230 cfg = c;
241 config_file = cfgfile; 231 config_file = cfgfile;
242 if (GNUNET_CONFIGURATION_get_value_string(cfg, "PATHS", "SERVICEHOME", &dir) != GNUNET_OK) 232 if (GNUNET_CONFIGURATION_get_value_string(cfg, "PATHS", "SERVICEHOME", &dir) != GNUNET_OK)
@@ -247,7 +237,7 @@ run (void *cls,
247 "PATHS"); 237 "PATHS");
248 return; 238 return;
249 } 239 }
250 h = GNUNET_ARM_connect (cfg, sched, NULL); 240 h = GNUNET_ARM_connect (cfg, NULL);
251 if (h == NULL) 241 if (h == NULL)
252 { 242 {
253 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 243 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -255,8 +245,7 @@ run (void *cls,
255 ret = 1; 245 ret = 1;
256 return; 246 return;
257 } 247 }
258 GNUNET_SCHEDULER_add_continuation (sched, 248 GNUNET_SCHEDULER_add_continuation (&cps_loop,
259 &cps_loop,
260 NULL, 249 NULL,
261 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 250 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
262} 251}
@@ -330,7 +319,7 @@ cps_loop (void *cls,
330 case 4: 319 case 4:
331 if (test != NULL) 320 if (test != NULL)
332 { 321 {
333 GNUNET_CLIENT_service_test (sched, test, cfg, TEST_TIMEOUT, &confirm_task, test); 322 GNUNET_CLIENT_service_test (test, cfg, TEST_TIMEOUT, &confirm_task, test);
334 return; 323 return;
335 } 324 }
336 break; 325 break;
@@ -342,7 +331,7 @@ cps_loop (void *cls,
342 end = 0; 331 end = 0;
343 start = 1; 332 start = 1;
344 restart = 0; 333 restart = 0;
345 h = GNUNET_ARM_connect (cfg, sched, NULL); 334 h = GNUNET_ARM_connect (cfg, NULL);
346 if (h == NULL) 335 if (h == NULL)
347 { 336 {
348 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 337 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -350,7 +339,7 @@ cps_loop (void *cls,
350 ret = 1; 339 ret = 1;
351 return; 340 return;
352 } 341 }
353 GNUNET_SCHEDULER_add_now(sched, &cps_loop, NULL); 342 GNUNET_SCHEDULER_add_now(&cps_loop, NULL);
354 return; 343 return;
355 } 344 }
356 /* Fall through */ 345 /* Fall through */
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c
index ab4db97c7..c967c64e6 100644
--- a/src/arm/gnunet-service-arm.c
+++ b/src/arm/gnunet-service-arm.c
@@ -124,11 +124,6 @@ static struct ServiceList *running;
124static const struct GNUNET_CONFIGURATION_Handle *cfg; 124static const struct GNUNET_CONFIGURATION_Handle *cfg;
125 125
126/** 126/**
127 * Our scheduler.
128 */
129static struct GNUNET_SCHEDULER_Handle *sched;
130
131/**
132 * Command to prepend to each actual command. 127 * Command to prepend to each actual command.
133 */ 128 */
134static char *prefix_command; 129static char *prefix_command;
@@ -695,7 +690,7 @@ do_shutdown ()
695{ 690{
696 GNUNET_SERVER_destroy (server); 691 GNUNET_SERVER_destroy (server);
697 server = NULL; 692 server = NULL;
698 GNUNET_SCHEDULER_cancel (sched, child_death_task); 693 GNUNET_SCHEDULER_cancel (child_death_task);
699 child_death_task = GNUNET_SCHEDULER_NO_TASK; 694 child_death_task = GNUNET_SCHEDULER_NO_TASK;
700} 695}
701 696
@@ -741,7 +736,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
741 pos = pos->next; 736 pos = pos->next;
742 } 737 }
743#if DELAY_SHUTDOWN 738#if DELAY_SHUTDOWN
744 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &dummy_task, NULL); 739 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &dummy_task, NULL);
745#endif 740#endif
746 if (running == NULL) 741 if (running == NULL)
747 do_shutdown (); 742 do_shutdown ();
@@ -802,8 +797,7 @@ delayed_restart_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
802 (unsigned long long) lowestRestartDelay.rel_value); 797 (unsigned long long) lowestRestartDelay.rel_value);
803#endif 798#endif
804 child_restart_task 799 child_restart_task
805 = GNUNET_SCHEDULER_add_delayed (sched, 800 = GNUNET_SCHEDULER_add_delayed (lowestRestartDelay,
806 lowestRestartDelay,
807 &delayed_restart_task, 801 &delayed_restart_task,
808 NULL); 802 NULL);
809 } 803 }
@@ -834,7 +828,7 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
834 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) 828 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY))
835 { 829 {
836 child_death_task = 830 child_death_task =
837 GNUNET_SCHEDULER_add_read_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, pr, 831 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, pr,
838 &maint_child_death, NULL); 832 &maint_child_death, NULL);
839 return; 833 return;
840 } 834 }
@@ -909,10 +903,9 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
909 pos->backoff 903 pos->backoff
910 = GNUNET_TIME_relative_multiply (pos->backoff, 2); 904 = GNUNET_TIME_relative_multiply (pos->backoff, 2);
911 if (GNUNET_SCHEDULER_NO_TASK != child_restart_task) 905 if (GNUNET_SCHEDULER_NO_TASK != child_restart_task)
912 GNUNET_SCHEDULER_cancel (sched, child_restart_task); 906 GNUNET_SCHEDULER_cancel (child_restart_task);
913 child_restart_task 907 child_restart_task
914 = GNUNET_SCHEDULER_add_with_priority (sched, 908 = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
915 GNUNET_SCHEDULER_PRIORITY_IDLE,
916 &delayed_restart_task, 909 &delayed_restart_task,
917 NULL); 910 NULL);
918 } 911 }
@@ -934,7 +927,7 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
934 else 927 else
935 { 928 {
936 child_death_task = 929 child_death_task =
937 GNUNET_SCHEDULER_add_read_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, pr, 930 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, pr,
938 &maint_child_death, NULL); 931 &maint_child_death, NULL);
939 } 932 }
940} 933}
@@ -986,7 +979,7 @@ handle_shutdown (void *cls,
986 GNUNET_TIME_UNIT_FOREVER_REL, 979 GNUNET_TIME_UNIT_FOREVER_REL,
987 &transmit_shutdown_ack, client); 980 &transmit_shutdown_ack, client);
988 GNUNET_SERVER_client_persist_ (client); 981 GNUNET_SERVER_client_persist_ (client);
989 GNUNET_SCHEDULER_shutdown (sched); 982 GNUNET_SCHEDULER_shutdown ();
990} 983}
991 984
992 985
@@ -1011,13 +1004,11 @@ sighandler_child_death ()
1011 * Process arm requests. 1004 * Process arm requests.
1012 * 1005 *
1013 * @param cls closure 1006 * @param cls closure
1014 * @param s scheduler to use
1015 * @param serv the initialized server 1007 * @param serv the initialized server
1016 * @param c configuration to use 1008 * @param c configuration to use
1017 */ 1009 */
1018static void 1010static void
1019run (void *cls, 1011run (void *cls,
1020 struct GNUNET_SCHEDULER_Handle *s,
1021 struct GNUNET_SERVER_Handle *serv, 1012 struct GNUNET_SERVER_Handle *serv,
1022 const struct GNUNET_CONFIGURATION_Handle *c) 1013 const struct GNUNET_CONFIGURATION_Handle *c)
1023{ 1014{
@@ -1032,18 +1023,16 @@ run (void *cls,
1032 char *pos; 1023 char *pos;
1033 1024
1034 cfg = c; 1025 cfg = c;
1035 sched = s;
1036 server = serv; 1026 server = serv;
1037 GNUNET_assert (serv != NULL); 1027 GNUNET_assert (serv != NULL);
1038 pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ); 1028 pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ);
1039 GNUNET_assert (pr != NULL); 1029 GNUNET_assert (pr != NULL);
1040 GNUNET_SERVER_ignore_shutdown (serv, GNUNET_YES); 1030 GNUNET_SERVER_ignore_shutdown (serv, GNUNET_YES);
1041 GNUNET_SCHEDULER_add_delayed (sched, 1031 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
1042 GNUNET_TIME_UNIT_FOREVER_REL,
1043 &shutdown_task, 1032 &shutdown_task,
1044 NULL); 1033 NULL);
1045 child_death_task = 1034 child_death_task =
1046 GNUNET_SCHEDULER_add_read_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, pr, 1035 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, pr,
1047 &maint_child_death, NULL); 1036 &maint_child_death, NULL);
1048 1037
1049 if (GNUNET_OK != 1038 if (GNUNET_OK !=
@@ -1089,14 +1078,13 @@ run (void *cls,
1089 } 1078 }
1090 1079
1091 /* create listening sockets for future services*/ 1080 /* create listening sockets for future services*/
1092 prepareServices (cfg, sched); 1081 prepareServices (cfg);
1093 1082
1094 /* process client requests */ 1083 /* process client requests */
1095 GNUNET_SERVER_add_handlers (server, handlers); 1084 GNUNET_SERVER_add_handlers (server, handlers);
1096 1085
1097 /* manage services */ 1086 /* manage services */
1098 GNUNET_SCHEDULER_add_with_priority (sched, 1087 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
1099 GNUNET_SCHEDULER_PRIORITY_IDLE,
1100 &config_change_task, NULL); 1088 &config_change_task, NULL);
1101} 1089}
1102 1090
diff --git a/src/arm/gnunet-service-arm.h b/src/arm/gnunet-service-arm.h
index 1f9085889..0ef557157 100644
--- a/src/arm/gnunet-service-arm.h
+++ b/src/arm/gnunet-service-arm.h
@@ -49,7 +49,6 @@ int start_service (struct GNUNET_SERVER_Client *client,
49int stop_listening (const char *serviceName); 49int stop_listening (const char *serviceName);
50 50
51void prepareServices (const struct GNUNET_CONFIGURATION_Handle 51void prepareServices (const struct GNUNET_CONFIGURATION_Handle
52 *configurationHandle, 52 *configurationHandle);
53 struct GNUNET_SCHEDULER_Handle *sched);
54 53
55#endif 54#endif
diff --git a/src/arm/gnunet-service-arm_interceptor.c b/src/arm/gnunet-service-arm_interceptor.c
index 8f79db6c5..56268b2d0 100644
--- a/src/arm/gnunet-service-arm_interceptor.c
+++ b/src/arm/gnunet-service-arm_interceptor.c
@@ -208,11 +208,6 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
208/** 208/**
209 * 209 *
210 */ 210 */
211static struct GNUNET_SCHEDULER_Handle *scheduler;
212
213/**
214 *
215 */
216static struct ServiceListeningInfo *serviceListeningInfoList_head; 211static struct ServiceListeningInfo *serviceListeningInfoList_head;
217 212
218/** 213/**
@@ -293,7 +288,7 @@ closeClientAndServiceSockets (struct ForwardedConnection *fc,
293#endif 288#endif
294 if (fc->service_to_client_task != GNUNET_SCHEDULER_NO_TASK) 289 if (fc->service_to_client_task != GNUNET_SCHEDULER_NO_TASK)
295 { 290 {
296 GNUNET_SCHEDULER_cancel (scheduler, fc->service_to_client_task); 291 GNUNET_SCHEDULER_cancel (fc->service_to_client_task);
297 fc->service_to_client_task = GNUNET_SCHEDULER_NO_TASK; 292 fc->service_to_client_task = GNUNET_SCHEDULER_NO_TASK;
298 } 293 }
299 if (fc->armClientSocket != NULL) 294 if (fc->armClientSocket != NULL)
@@ -312,8 +307,7 @@ closeClientAndServiceSockets (struct ForwardedConnection *fc,
312#endif 307#endif
313 if (fc->client_to_service_task != GNUNET_SCHEDULER_NO_TASK) 308 if (fc->client_to_service_task != GNUNET_SCHEDULER_NO_TASK)
314 { 309 {
315 GNUNET_SCHEDULER_cancel (scheduler, 310 GNUNET_SCHEDULER_cancel ( fc->client_to_service_task);
316 fc->client_to_service_task);
317 fc->client_to_service_task = GNUNET_SCHEDULER_NO_TASK; 311 fc->client_to_service_task = GNUNET_SCHEDULER_NO_TASK;
318 } 312 }
319 if (fc->armClientSocket != NULL) 313 if (fc->armClientSocket != NULL)
@@ -331,8 +325,7 @@ closeClientAndServiceSockets (struct ForwardedConnection *fc,
331 "Closing forwarding connection (done with both directions)\n"); 325 "Closing forwarding connection (done with both directions)\n");
332#endif 326#endif
333 if (fc->start_task != GNUNET_SCHEDULER_NO_TASK) 327 if (fc->start_task != GNUNET_SCHEDULER_NO_TASK)
334 GNUNET_SCHEDULER_cancel (scheduler, 328 GNUNET_SCHEDULER_cancel ( fc->start_task);
335 fc->start_task);
336 if ( (NULL != fc->armClientSocket) && 329 if ( (NULL != fc->armClientSocket) &&
337 (GNUNET_SYSERR == 330 (GNUNET_SYSERR ==
338 GNUNET_NETWORK_socket_close (fc->armClientSocket)) ) 331 GNUNET_NETWORK_socket_close (fc->armClientSocket)) )
@@ -388,7 +381,7 @@ forwardToClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
388 fc->armClientSocket)) 381 fc->armClientSocket))
389 { 382 {
390 fc->service_to_client_task = 383 fc->service_to_client_task =
391 GNUNET_SCHEDULER_add_write_net (scheduler, 384 GNUNET_SCHEDULER_add_write_net (
392 GNUNET_TIME_UNIT_FOREVER_REL, 385 GNUNET_TIME_UNIT_FOREVER_REL,
393 fc->armClientSocket, 386 fc->armClientSocket,
394 &forwardToClient, fc); 387 &forwardToClient, fc);
@@ -421,7 +414,7 @@ forwardToClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
421 fc->service_to_client_bufferPos += numberOfBytesSent; 414 fc->service_to_client_bufferPos += numberOfBytesSent;
422 fc->service_to_client_bufferDataLength -= numberOfBytesSent; 415 fc->service_to_client_bufferDataLength -= numberOfBytesSent;
423 fc->service_to_client_task = 416 fc->service_to_client_task =
424 GNUNET_SCHEDULER_add_write_net (scheduler, 417 GNUNET_SCHEDULER_add_write_net (
425 GNUNET_TIME_UNIT_FOREVER_REL, 418 GNUNET_TIME_UNIT_FOREVER_REL,
426 fc->armClientSocket, 419 fc->armClientSocket,
427 &forwardToClient, 420 &forwardToClient,
@@ -429,8 +422,7 @@ forwardToClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
429 return; 422 return;
430 } 423 }
431 fc->service_to_client_task = 424 fc->service_to_client_task =
432 GNUNET_SCHEDULER_add_read_net (scheduler, 425 GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
433 GNUNET_TIME_UNIT_FOREVER_REL,
434 fc->armServiceSocket, 426 fc->armServiceSocket,
435 &receiveFromService, 427 &receiveFromService,
436 fc); 428 fc);
@@ -461,7 +453,7 @@ receiveFromService (void *cls,
461 fc->armServiceSocket)) 453 fc->armServiceSocket))
462 { 454 {
463 fc->service_to_client_task = 455 fc->service_to_client_task =
464 GNUNET_SCHEDULER_add_read_net (scheduler, 456 GNUNET_SCHEDULER_add_read_net (
465 GNUNET_TIME_UNIT_FOREVER_REL, 457 GNUNET_TIME_UNIT_FOREVER_REL,
466 fc->armServiceSocket, 458 fc->armServiceSocket,
467 &receiveFromService, fc); 459 &receiveFromService, fc);
@@ -491,8 +483,7 @@ receiveFromService (void *cls,
491 if ( (fc->client_to_service_bufferDataLength > 0) && 483 if ( (fc->client_to_service_bufferDataLength > 0) &&
492 (fc->client_to_service_task != GNUNET_SCHEDULER_NO_TASK) ) 484 (fc->client_to_service_task != GNUNET_SCHEDULER_NO_TASK) )
493 { 485 {
494 GNUNET_SCHEDULER_cancel (scheduler, 486 GNUNET_SCHEDULER_cancel (fc->client_to_service_task);
495 fc->client_to_service_task);
496 fc->client_to_service_task = GNUNET_SCHEDULER_NO_TASK; 487 fc->client_to_service_task = GNUNET_SCHEDULER_NO_TASK;
497 } 488 }
498 fc->back_off = GNUNET_TIME_relative_multiply (fc->back_off, 2); 489 fc->back_off = GNUNET_TIME_relative_multiply (fc->back_off, 2);
@@ -508,7 +499,7 @@ receiveFromService (void *cls,
508 rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); 499 rem = GNUNET_TIME_absolute_get_remaining (fc->timeout);
509 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); 500 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task);
510 fc->start_task 501 fc->start_task
511 = GNUNET_SCHEDULER_add_delayed (scheduler, 502 = GNUNET_SCHEDULER_add_delayed (
512 GNUNET_TIME_relative_min (fc->back_off, 503 GNUNET_TIME_relative_min (fc->back_off,
513 rem), 504 rem),
514 &start_forwarding, 505 &start_forwarding,
@@ -533,7 +524,7 @@ receiveFromService (void *cls,
533 fc->service_to_client_bufferDataLength); 524 fc->service_to_client_bufferDataLength);
534#endif 525#endif
535 fc->service_to_client_task = 526 fc->service_to_client_task =
536 GNUNET_SCHEDULER_add_write_net (scheduler, 527 GNUNET_SCHEDULER_add_write_net (
537 GNUNET_TIME_UNIT_FOREVER_REL, 528 GNUNET_TIME_UNIT_FOREVER_REL,
538 fc->armClientSocket, 529 fc->armClientSocket,
539 &forwardToClient, fc); 530 &forwardToClient, fc);
@@ -565,7 +556,7 @@ forwardToService (void *cls,
565 fc->armServiceSocket)) 556 fc->armServiceSocket))
566 { 557 {
567 fc->client_to_service_task = 558 fc->client_to_service_task =
568 GNUNET_SCHEDULER_add_write_net (scheduler, 559 GNUNET_SCHEDULER_add_write_net (
569 GNUNET_TIME_UNIT_FOREVER_REL, 560 GNUNET_TIME_UNIT_FOREVER_REL,
570 fc->armServiceSocket, 561 fc->armServiceSocket,
571 &forwardToService, fc); 562 &forwardToService, fc);
@@ -585,8 +576,7 @@ forwardToService (void *cls,
585 if ( (fc->service_to_client_bufferDataLength == 0) && 576 if ( (fc->service_to_client_bufferDataLength == 0) &&
586 (fc->service_to_client_task != GNUNET_SCHEDULER_NO_TASK) ) 577 (fc->service_to_client_task != GNUNET_SCHEDULER_NO_TASK) )
587 { 578 {
588 GNUNET_SCHEDULER_cancel (scheduler, 579 GNUNET_SCHEDULER_cancel (fc->service_to_client_task);
589 fc->service_to_client_task);
590 fc->service_to_client_task = GNUNET_SCHEDULER_NO_TASK; 580 fc->service_to_client_task = GNUNET_SCHEDULER_NO_TASK;
591 } 581 }
592 fc->back_off = GNUNET_TIME_relative_multiply (fc->back_off, 2); 582 fc->back_off = GNUNET_TIME_relative_multiply (fc->back_off, 2);
@@ -602,8 +592,7 @@ forwardToService (void *cls,
602 rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); 592 rem = GNUNET_TIME_absolute_get_remaining (fc->timeout);
603 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); 593 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task);
604 fc->start_task 594 fc->start_task
605 = GNUNET_SCHEDULER_add_delayed (scheduler, 595 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_min (fc->back_off,
606 GNUNET_TIME_relative_min (fc->back_off,
607 rem), 596 rem),
608 &start_forwarding, 597 &start_forwarding,
609 fc); 598 fc);
@@ -631,15 +620,14 @@ forwardToService (void *cls,
631 fc->client_to_service_bufferPos += numberOfBytesSent; 620 fc->client_to_service_bufferPos += numberOfBytesSent;
632 fc->client_to_service_bufferDataLength -= numberOfBytesSent; 621 fc->client_to_service_bufferDataLength -= numberOfBytesSent;
633 fc->client_to_service_task = 622 fc->client_to_service_task =
634 GNUNET_SCHEDULER_add_write_net (scheduler, 623 GNUNET_SCHEDULER_add_write_net (
635 GNUNET_TIME_UNIT_FOREVER_REL, 624 GNUNET_TIME_UNIT_FOREVER_REL,
636 fc->armServiceSocket, 625 fc->armServiceSocket,
637 &forwardToService, fc); 626 &forwardToService, fc);
638 return; 627 return;
639 } 628 }
640 fc->client_to_service_task = 629 fc->client_to_service_task =
641 GNUNET_SCHEDULER_add_read_net (scheduler, 630 GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
642 GNUNET_TIME_UNIT_FOREVER_REL,
643 fc->armClientSocket, 631 fc->armClientSocket,
644 &receiveFromClient, fc); 632 &receiveFromClient, fc);
645} 633}
@@ -661,7 +649,7 @@ receiveFromClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
661 fc->armClientSocket)) 649 fc->armClientSocket))
662 { 650 {
663 fc->client_to_service_task = 651 fc->client_to_service_task =
664 GNUNET_SCHEDULER_add_read_net (scheduler, 652 GNUNET_SCHEDULER_add_read_net (
665 GNUNET_TIME_UNIT_FOREVER_REL, 653 GNUNET_TIME_UNIT_FOREVER_REL,
666 fc->armClientSocket, 654 fc->armClientSocket,
667 &receiveFromClient, fc); 655 &receiveFromClient, fc);
@@ -700,7 +688,7 @@ receiveFromClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
700#endif 688#endif
701 if (fc->armServiceSocket != NULL) 689 if (fc->armServiceSocket != NULL)
702 fc->client_to_service_task = 690 fc->client_to_service_task =
703 GNUNET_SCHEDULER_add_write_net (scheduler, 691 GNUNET_SCHEDULER_add_write_net (
704 GNUNET_TIME_UNIT_FOREVER_REL, 692 GNUNET_TIME_UNIT_FOREVER_REL,
705 fc->armServiceSocket, 693 fc->armServiceSocket,
706 &forwardToService, fc); 694 &forwardToService, fc);
@@ -769,8 +757,7 @@ start_forwarding (void *cls,
769#endif 757#endif
770 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); 758 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task);
771 fc->start_task 759 fc->start_task
772 = GNUNET_SCHEDULER_add_delayed (scheduler, 760 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_min (fc->back_off,
773 GNUNET_TIME_relative_min (fc->back_off,
774 rem), 761 rem),
775 &start_forwarding, 762 &start_forwarding,
776 fc); 763 fc);
@@ -784,13 +771,13 @@ start_forwarding (void *cls,
784 { 771 {
785 if (fc->client_to_service_bufferDataLength == 0) 772 if (fc->client_to_service_bufferDataLength == 0)
786 fc->client_to_service_task = 773 fc->client_to_service_task =
787 GNUNET_SCHEDULER_add_read_net (scheduler, 774 GNUNET_SCHEDULER_add_read_net (
788 GNUNET_TIME_UNIT_FOREVER_REL, 775 GNUNET_TIME_UNIT_FOREVER_REL,
789 fc->armClientSocket, 776 fc->armClientSocket,
790 &receiveFromClient, fc); 777 &receiveFromClient, fc);
791 else 778 else
792 fc->client_to_service_task = 779 fc->client_to_service_task =
793 GNUNET_SCHEDULER_add_write_net (scheduler, 780 GNUNET_SCHEDULER_add_write_net (
794 GNUNET_TIME_UNIT_FOREVER_REL, 781 GNUNET_TIME_UNIT_FOREVER_REL,
795 fc->armServiceSocket, 782 fc->armServiceSocket,
796 &forwardToService, fc); 783 &forwardToService, fc);
@@ -799,13 +786,13 @@ start_forwarding (void *cls,
799 { 786 {
800 if (fc->service_to_client_bufferDataLength == 0) 787 if (fc->service_to_client_bufferDataLength == 0)
801 fc->service_to_client_task = 788 fc->service_to_client_task =
802 GNUNET_SCHEDULER_add_read_net (scheduler, 789 GNUNET_SCHEDULER_add_read_net (
803 GNUNET_TIME_UNIT_FOREVER_REL, 790 GNUNET_TIME_UNIT_FOREVER_REL,
804 fc->armServiceSocket, 791 fc->armServiceSocket,
805 &receiveFromService, fc); 792 &receiveFromService, fc);
806 else 793 else
807 fc->service_to_client_task = 794 fc->service_to_client_task =
808 GNUNET_SCHEDULER_add_write_net (scheduler, 795 GNUNET_SCHEDULER_add_write_net (
809 GNUNET_TIME_UNIT_FOREVER_REL, 796 GNUNET_TIME_UNIT_FOREVER_REL,
810 fc->armClientSocket, 797 fc->armClientSocket,
811 &forwardToClient, fc); 798 &forwardToClient, fc);
@@ -833,7 +820,7 @@ stop_listening (const char *serviceName)
833 (strcmp (pos->serviceName, serviceName) != 0) ) 820 (strcmp (pos->serviceName, serviceName) != 0) )
834 continue; 821 continue;
835 if (pos->acceptTask != GNUNET_SCHEDULER_NO_TASK) 822 if (pos->acceptTask != GNUNET_SCHEDULER_NO_TASK)
836 GNUNET_SCHEDULER_cancel (scheduler, pos->acceptTask); 823 GNUNET_SCHEDULER_cancel (pos->acceptTask);
837 GNUNET_break (GNUNET_OK == 824 GNUNET_break (GNUNET_OK ==
838 GNUNET_NETWORK_socket_close (pos->listeningSocket)); 825 GNUNET_NETWORK_socket_close (pos->listeningSocket));
839 GNUNET_CONTAINER_DLL_remove (serviceListeningInfoList_head, 826 GNUNET_CONTAINER_DLL_remove (serviceListeningInfoList_head,
@@ -882,7 +869,7 @@ accept_and_forward (struct ServiceListeningInfo *serviceListeningInfo)
882 serviceListeningInfoList_tail, 869 serviceListeningInfoList_tail,
883 serviceListeningInfo); 870 serviceListeningInfo);
884 serviceListeningInfo->acceptTask = 871 serviceListeningInfo->acceptTask =
885 GNUNET_SCHEDULER_add_read_net (scheduler, 872 GNUNET_SCHEDULER_add_read_net (
886 GNUNET_TIME_UNIT_FOREVER_REL, 873 GNUNET_TIME_UNIT_FOREVER_REL,
887 serviceListeningInfo->listeningSocket, 874 serviceListeningInfo->listeningSocket,
888 &acceptConnection, 875 &acceptConnection,
@@ -898,14 +885,13 @@ accept_and_forward (struct ServiceListeningInfo *serviceListeningInfo)
898 fc->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_SERVICE_TIMEOUT); 885 fc->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_SERVICE_TIMEOUT);
899 fc->back_off = GNUNET_TIME_UNIT_MILLISECONDS; 886 fc->back_off = GNUNET_TIME_UNIT_MILLISECONDS;
900 fc->client_to_service_task = 887 fc->client_to_service_task =
901 GNUNET_SCHEDULER_add_read_net (scheduler, 888 GNUNET_SCHEDULER_add_read_net (
902 GNUNET_TIME_UNIT_FOREVER_REL, 889 GNUNET_TIME_UNIT_FOREVER_REL,
903 fc->armClientSocket, 890 fc->armClientSocket,
904 &receiveFromClient, fc); 891 &receiveFromClient, fc);
905 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); 892 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task);
906 fc->start_task 893 fc->start_task
907 = GNUNET_SCHEDULER_add_now (scheduler, 894 = GNUNET_SCHEDULER_add_now (&start_forwarding,
908 &start_forwarding,
909 fc); 895 fc);
910} 896}
911 897
@@ -963,8 +949,7 @@ acceptConnection (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
963 GNUNET_free (pos->listeningSocket); /* deliberately no closing! */ 949 GNUNET_free (pos->listeningSocket); /* deliberately no closing! */
964 GNUNET_free (pos->service_addr); 950 GNUNET_free (pos->service_addr);
965 GNUNET_free (pos->serviceName); 951 GNUNET_free (pos->serviceName);
966 GNUNET_SCHEDULER_cancel (scheduler, 952 GNUNET_SCHEDULER_cancel ( pos->acceptTask);
967 pos->acceptTask);
968 GNUNET_CONTAINER_DLL_remove (serviceListeningInfoList_head, 953 GNUNET_CONTAINER_DLL_remove (serviceListeningInfoList_head,
969 serviceListeningInfoList_tail, 954 serviceListeningInfoList_tail,
970 pos); 955 pos);
@@ -1073,7 +1058,7 @@ createListeningSocket (struct sockaddr *sa,
1073 serviceListeningInfo->service_addr_len = addr_len; 1058 serviceListeningInfo->service_addr_len = addr_len;
1074 serviceListeningInfo->listeningSocket = sock; 1059 serviceListeningInfo->listeningSocket = sock;
1075 serviceListeningInfo->acceptTask = 1060 serviceListeningInfo->acceptTask =
1076 GNUNET_SCHEDULER_add_read_net (scheduler, 1061 GNUNET_SCHEDULER_add_read_net (
1077 GNUNET_TIME_UNIT_FOREVER_REL, sock, 1062 GNUNET_TIME_UNIT_FOREVER_REL, sock,
1078 &acceptConnection, 1063 &acceptConnection,
1079 serviceListeningInfo); 1064 serviceListeningInfo);
@@ -1123,15 +1108,13 @@ checkPortNumberCB (void *cls,
1123 * Entry point to the Service Manager 1108 * Entry point to the Service Manager
1124 * 1109 *
1125 * @param configurationHandle configuration to use to get services 1110 * @param configurationHandle configuration to use to get services
1126 * @param sched scheduler to handle clients and services communications
1127 */ 1111 */
1128void 1112void
1129prepareServices (const struct GNUNET_CONFIGURATION_Handle 1113prepareServices (const struct GNUNET_CONFIGURATION_Handle
1130 *configurationHandle, struct GNUNET_SCHEDULER_Handle *sched) 1114 *configurationHandle)
1131{ 1115{
1132 char *defaultServicesString; 1116 char *defaultServicesString;
1133 1117
1134 scheduler = sched;
1135 cfg = configurationHandle; 1118 cfg = configurationHandle;
1136 /* Split the default services into a list */ 1119 /* Split the default services into a list */
1137 if (GNUNET_OK == 1120 if (GNUNET_OK ==
diff --git a/src/arm/mockup-service.c b/src/arm/mockup-service.c
index da8ada1db..4dae8ffb4 100644
--- a/src/arm/mockup-service.c
+++ b/src/arm/mockup-service.c
@@ -28,8 +28,6 @@
28#include "gnunet_strings_lib.h" 28#include "gnunet_strings_lib.h"
29#include "gnunet_time_lib.h" 29#include "gnunet_time_lib.h"
30 30
31static struct GNUNET_SCHEDULER_Handle *sched;
32
33 31
34static size_t 32static size_t
35transmit_shutdown_ack (void *cls, size_t size, void *buf) 33transmit_shutdown_ack (void *cls, size_t size, void *buf)
@@ -77,13 +75,12 @@ handle_shutdown (void *cls,
77 GNUNET_TIME_UNIT_FOREVER_REL, 75 GNUNET_TIME_UNIT_FOREVER_REL,
78 &transmit_shutdown_ack, client); 76 &transmit_shutdown_ack, client);
79 GNUNET_SERVER_client_persist_ (client); 77 GNUNET_SERVER_client_persist_ (client);
80 GNUNET_SCHEDULER_shutdown (sched); 78 GNUNET_SCHEDULER_shutdown ();
81} 79}
82 80
83 81
84static void 82static void
85run (void *cls, 83run (void *cls,
86 struct GNUNET_SCHEDULER_Handle *s,
87 struct GNUNET_SERVER_Handle *server, 84 struct GNUNET_SERVER_Handle *server,
88 const struct GNUNET_CONFIGURATION_Handle *cfg) 85 const struct GNUNET_CONFIGURATION_Handle *cfg)
89{ 86{
@@ -92,7 +89,6 @@ run (void *cls,
92 sizeof (struct GNUNET_MessageHeader)}, 89 sizeof (struct GNUNET_MessageHeader)},
93 {NULL, NULL, 0, 0} 90 {NULL, NULL, 0, 0}
94 }; 91 };
95 sched = s;
96 /* process client requests */ 92 /* process client requests */
97 GNUNET_SERVER_ignore_shutdown (server, GNUNET_YES); 93 GNUNET_SERVER_ignore_shutdown (server, GNUNET_YES);
98 GNUNET_SERVER_add_handlers (server, handlers); 94 GNUNET_SERVER_add_handlers (server, handlers);
diff --git a/src/arm/test_arm_api.c b/src/arm/test_arm_api.c
index 6ec95f4a0..6952b2e59 100644
--- a/src/arm/test_arm_api.c
+++ b/src/arm/test_arm_api.c
@@ -38,8 +38,6 @@
38 38
39#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) 39#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
40 40
41static struct GNUNET_SCHEDULER_Handle *sched;
42
43static const struct GNUNET_CONFIGURATION_Handle *cfg; 41static const struct GNUNET_CONFIGURATION_Handle *cfg;
44 42
45static struct GNUNET_ARM_Handle *arm; 43static struct GNUNET_ARM_Handle *arm;
@@ -95,8 +93,7 @@ resolver_notify (void *cls, int success)
95#endif 93#endif
96 return; 94 return;
97 } 95 }
98 GNUNET_RESOLVER_ip_get (sched, 96 GNUNET_RESOLVER_ip_get (cfg,
99 cfg,
100 "localhost", AF_INET, TIMEOUT, &dns_notify, NULL); 97 "localhost", AF_INET, TIMEOUT, &dns_notify, NULL);
101} 98}
102 99
@@ -118,14 +115,12 @@ arm_notify (void *cls, int success)
118 115
119static void 116static void
120task (void *cls, 117task (void *cls,
121 struct GNUNET_SCHEDULER_Handle *s,
122 char *const *args, 118 char *const *args,
123 const char *cfgfile, 119 const char *cfgfile,
124 const struct GNUNET_CONFIGURATION_Handle *c) 120 const struct GNUNET_CONFIGURATION_Handle *c)
125{ 121{
126 cfg = c; 122 cfg = c;
127 sched = s; 123 arm = GNUNET_ARM_connect (cfg, NULL);
128 arm = GNUNET_ARM_connect (cfg, sched, NULL);
129#if START_ARM 124#if START_ARM
130 GNUNET_ARM_start_service (arm, "arm", START_TIMEOUT, &arm_notify, NULL); 125 GNUNET_ARM_start_service (arm, "arm", START_TIMEOUT, &arm_notify, NULL);
131#else 126#else
diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c
index dd32f6a5d..8e5ac9bc1 100644
--- a/src/arm/test_exponential_backoff.c
+++ b/src/arm/test_exponential_backoff.c
@@ -35,7 +35,6 @@
35#define SERVICE_TEST_TIMEOUT GNUNET_TIME_UNIT_FOREVER_REL 35#define SERVICE_TEST_TIMEOUT GNUNET_TIME_UNIT_FOREVER_REL
36#define FIVE_MILLISECONDS GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 5) 36#define FIVE_MILLISECONDS GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 5)
37 37
38static struct GNUNET_SCHEDULER_Handle *sched;
39static const struct GNUNET_CONFIGURATION_Handle *cfg; 38static const struct GNUNET_CONFIGURATION_Handle *cfg;
40static struct GNUNET_ARM_Handle *arm; 39static struct GNUNET_ARM_Handle *arm;
41static int ok = 1; 40static int ok = 1;
@@ -56,10 +55,6 @@ static char *killLogFileName;
56struct ShutdownContext 55struct ShutdownContext
57{ 56{
58 /** 57 /**
59 * Scheduler to be used to call continuation
60 */
61 struct GNUNET_SCHEDULER_Handle *sched;
62 /**
63 * Connection to the service that is being shutdown. 58 * Connection to the service that is being shutdown.
64 */ 59 */
65 struct GNUNET_CLIENT_Connection *sock; 60 struct GNUNET_CLIENT_Connection *sock;
@@ -114,7 +109,7 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg)
114 "Service handle shutdown before ACK!\n"); 109 "Service handle shutdown before ACK!\n");
115 if (shutdown_ctx->cont != NULL) 110 if (shutdown_ctx->cont != NULL)
116 shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_SYSERR); 111 shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_SYSERR);
117 GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->cancel_task); 112 GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task);
118 GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); 113 GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO);
119 GNUNET_free(shutdown_ctx); 114 GNUNET_free(shutdown_ctx);
120 } 115 }
@@ -127,7 +122,7 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg)
127 if (shutdown_ctx->cont != NULL) 122 if (shutdown_ctx->cont != NULL)
128 shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_NO); 123 shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_NO);
129 124
130 GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->cancel_task); 125 GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task);
131 GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); 126 GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO);
132 GNUNET_free(shutdown_ctx); 127 GNUNET_free(shutdown_ctx);
133 } 128 }
@@ -153,7 +148,7 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg)
153 if (shutdown_ctx->cont != NULL) 148 if (shutdown_ctx->cont != NULL)
154 shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_YES); 149 shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_YES);
155 150
156 GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->cancel_task); 151 GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task);
157 GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); 152 GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO);
158 GNUNET_free(shutdown_ctx); 153 GNUNET_free(shutdown_ctx);
159 break; 154 break;
@@ -206,8 +201,7 @@ write_shutdown (void *cls, size_t size, void *buf)
206 GNUNET_CLIENT_receive (shutdown_ctx->sock, 201 GNUNET_CLIENT_receive (shutdown_ctx->sock,
207 &service_shutdown_handler, shutdown_ctx, 202 &service_shutdown_handler, shutdown_ctx,
208 GNUNET_TIME_UNIT_FOREVER_REL); 203 GNUNET_TIME_UNIT_FOREVER_REL);
209 shutdown_ctx->cancel_task = GNUNET_SCHEDULER_add_delayed (shutdown_ctx->sched, 204 shutdown_ctx->cancel_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining(shutdown_ctx->timeout),
210 GNUNET_TIME_absolute_get_remaining(shutdown_ctx->timeout),
211 &service_shutdown_cancel, 205 &service_shutdown_cancel,
212 shutdown_ctx); 206 shutdown_ctx);
213 msg = (struct GNUNET_MessageHeader *) buf; 207 msg = (struct GNUNET_MessageHeader *) buf;
@@ -224,7 +218,6 @@ write_shutdown (void *cls, size_t size, void *buf)
224 * be used by the caller after this call 218 * be used by the caller after this call
225 * (calling this function frees "sock" after a while). 219 * (calling this function frees "sock" after a while).
226 * 220 *
227 * @param sched the scheduler to use for calling shutdown continuation
228 * @param sock the socket connected to the service 221 * @param sock the socket connected to the service
229 * @param timeout how long to wait before giving up on transmission 222 * @param timeout how long to wait before giving up on transmission
230 * @param cont continuation to call once the service is really down 223 * @param cont continuation to call once the service is really down
@@ -232,15 +225,13 @@ write_shutdown (void *cls, size_t size, void *buf)
232 * 225 *
233 */ 226 */
234static void 227static void
235arm_service_shutdown (struct GNUNET_SCHEDULER_Handle *sched, 228arm_service_shutdown (struct GNUNET_CLIENT_Connection *sock,
236 struct GNUNET_CLIENT_Connection *sock,
237 struct GNUNET_TIME_Relative timeout, 229 struct GNUNET_TIME_Relative timeout,
238 GNUNET_CLIENT_ShutdownTask cont, 230 GNUNET_CLIENT_ShutdownTask cont,
239 void *cont_cls) 231 void *cont_cls)
240{ 232{
241 struct ShutdownContext *shutdown_ctx; 233 struct ShutdownContext *shutdown_ctx;
242 shutdown_ctx = GNUNET_malloc(sizeof(struct ShutdownContext)); 234 shutdown_ctx = GNUNET_malloc(sizeof(struct ShutdownContext));
243 shutdown_ctx->sched = sched;
244 shutdown_ctx->cont = cont; 235 shutdown_ctx->cont = cont;
245 shutdown_ctx->cont_cls = cont_cls; 236 shutdown_ctx->cont_cls = cont_cls;
246 shutdown_ctx->sock = sock; 237 shutdown_ctx->sock = sock;
@@ -274,7 +265,7 @@ do_nothing_notify (void *cls, int success)
274{ 265{
275 GNUNET_assert (success == GNUNET_YES); 266 GNUNET_assert (success == GNUNET_YES);
276 ok = 1; 267 ok = 1;
277 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_UNIT_SECONDS, 268 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
278 &kill_task, NULL); 269 &kill_task, NULL);
279} 270}
280 271
@@ -322,7 +313,7 @@ do_nothing_restarted_notify_task (void *cls,
322 trialCount); 313 trialCount);
323 } 314 }
324#endif 315#endif
325 GNUNET_SCHEDULER_add_now (sched, &kill_task, &a); 316 GNUNET_SCHEDULER_add_now (&kill_task, &a);
326} 317}
327 318
328 319
@@ -330,7 +321,7 @@ static void
330do_test (void *cbData, 321do_test (void *cbData,
331 const struct GNUNET_SCHEDULER_TaskContext *tc) 322 const struct GNUNET_SCHEDULER_TaskContext *tc)
332{ 323{
333 GNUNET_CLIENT_service_test(sched, "do-nothing", 324 GNUNET_CLIENT_service_test("do-nothing",
334 cfg, TIMEOUT, 325 cfg, TIMEOUT,
335 &do_nothing_restarted_notify_task, NULL); 326 &do_nothing_restarted_notify_task, NULL);
336} 327}
@@ -341,8 +332,7 @@ shutdown_cont (void *cls, int reason)
341{ 332{
342 trialCount++; 333 trialCount++;
343 startedWaitingAt = GNUNET_TIME_absolute_get(); 334 startedWaitingAt = GNUNET_TIME_absolute_get();
344 GNUNET_SCHEDULER_add_delayed (sched, 335 GNUNET_SCHEDULER_add_delayed (waitedFor,
345 waitedFor,
346 &do_test, 336 &do_test,
347 NULL); 337 NULL);
348} 338}
@@ -369,7 +359,7 @@ kill_task (void *cbData,
369 waitedFor.rel_value = 0; 359 waitedFor.rel_value = 0;
370 } 360 }
371 /* Connect to the doNothing task */ 361 /* Connect to the doNothing task */
372 doNothingConnection = GNUNET_CLIENT_connect (sched, "do-nothing", cfg); 362 doNothingConnection = GNUNET_CLIENT_connect ("do-nothing", cfg);
373#if LOG_BACKOFF 363#if LOG_BACKOFF
374 if (NULL == doNothingConnection) 364 if (NULL == doNothingConnection)
375 fprintf(killLogFilePtr, 365 fprintf(killLogFilePtr,
@@ -385,8 +375,7 @@ kill_task (void *cbData,
385 } 375 }
386 376
387 /* Use the created connection to kill the doNothingTask */ 377 /* Use the created connection to kill the doNothingTask */
388 arm_service_shutdown(sched, 378 arm_service_shutdown(doNothingConnection,
389 doNothingConnection,
390 TIMEOUT, 379 TIMEOUT,
391 &shutdown_cont, NULL); 380 &shutdown_cont, NULL);
392} 381}
@@ -394,15 +383,13 @@ kill_task (void *cbData,
394 383
395static void 384static void
396task (void *cls, 385task (void *cls,
397 struct GNUNET_SCHEDULER_Handle *s,
398 char *const *args, 386 char *const *args,
399 const char *cfgfile, 387 const char *cfgfile,
400 const struct GNUNET_CONFIGURATION_Handle *c) 388 const struct GNUNET_CONFIGURATION_Handle *c)
401{ 389{
402 cfg = c; 390 cfg = c;
403 sched = s;
404 391
405 arm = GNUNET_ARM_connect (cfg, sched, NULL); 392 arm = GNUNET_ARM_connect (cfg,NULL);
406#if START_ARM 393#if START_ARM
407 GNUNET_ARM_start_service (arm, "arm", GNUNET_TIME_UNIT_ZERO, &arm_notify, NULL); 394 GNUNET_ARM_start_service (arm, "arm", GNUNET_TIME_UNIT_ZERO, &arm_notify, NULL);
408#else 395#else
diff --git a/src/arm/test_gnunet_service_manager.c b/src/arm/test_gnunet_service_manager.c
index 26ea774d6..e4aecb8c4 100644
--- a/src/arm/test_gnunet_service_manager.c
+++ b/src/arm/test_gnunet_service_manager.c
@@ -43,7 +43,6 @@
43 43
44static int ret = 1; 44static int ret = 1;
45 45
46static struct GNUNET_SCHEDULER_Handle *sched;
47 46
48static const struct GNUNET_CONFIGURATION_Handle *cfg; 47static const struct GNUNET_CONFIGURATION_Handle *cfg;
49 48
@@ -108,8 +107,7 @@ arm_notify (void *cls, int success)
108 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 107 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
109 "Trying to resolve our own hostname!\n"); 108 "Trying to resolve our own hostname!\n");
110 /* connect to the resolver service */ 109 /* connect to the resolver service */
111 if (NULL == GNUNET_RESOLVER_hostname_resolve (sched, 110 if (NULL == GNUNET_RESOLVER_hostname_resolve (cfg, AF_UNSPEC,
112 cfg, AF_UNSPEC,
113 TIMEOUT, 111 TIMEOUT,
114 &hostNameResolveCB, 112 &hostNameResolveCB,
115 NULL)) 113 NULL))
@@ -125,16 +123,14 @@ arm_notify (void *cls, int success)
125 123
126 124
127static void 125static void
128run(void *cls, 126run(void *cls,
129 struct GNUNET_SCHEDULER_Handle *s,
130 char * const *args, 127 char * const *args,
131 const char *cfgfile, 128 const char *cfgfile,
132 const struct GNUNET_CONFIGURATION_Handle *c) 129 const struct GNUNET_CONFIGURATION_Handle *c)
133{ 130{
134 cfg = c; 131 cfg = c;
135 sched = s;
136#if START_ARM 132#if START_ARM
137 arm = GNUNET_ARM_connect (cfg, sched, NULL); 133 arm = GNUNET_ARM_connect (cfg, NULL);
138 GNUNET_ARM_start_service (arm, "arm", START_TIMEOUT, &arm_notify, NULL); 134 GNUNET_ARM_start_service (arm, "arm", START_TIMEOUT, &arm_notify, NULL);
139#else 135#else
140 arm_notify (NULL, GNUNET_YES); 136 arm_notify (NULL, GNUNET_YES);
diff --git a/src/core/core_api.c b/src/core/core_api.c
index dd8919ea1..cb5ba3ecb 100644
--- a/src/core/core_api.c
+++ b/src/core/core_api.c
@@ -36,10 +36,6 @@
36struct GNUNET_CORE_Handle 36struct GNUNET_CORE_Handle
37{ 37{
38 38
39 /**
40 * Our scheduler.
41 */
42 struct GNUNET_SCHEDULER_Handle *sched;
43 39
44 /** 40 /**
45 * Configuration we're using. 41 * Configuration we're using.
@@ -263,10 +259,9 @@ reconnect (struct GNUNET_CORE_Handle *h)
263 if (h->client_notifications != NULL) 259 if (h->client_notifications != NULL)
264 GNUNET_CLIENT_disconnect (h->client_notifications, GNUNET_NO); 260 GNUNET_CLIENT_disconnect (h->client_notifications, GNUNET_NO);
265 h->currently_down = GNUNET_YES; 261 h->currently_down = GNUNET_YES;
266 h->client_notifications = GNUNET_CLIENT_connect (h->sched, "core", h->cfg); 262 h->client_notifications = GNUNET_CLIENT_connect ("core", h->cfg);
267 if (h->client_notifications == NULL) 263 if (h->client_notifications == NULL)
268 h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->sched, 264 h->reconnect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
269 GNUNET_TIME_UNIT_SECONDS,
270 &reconnect_task, 265 &reconnect_task,
271 h); 266 h);
272 else 267 else
@@ -328,7 +323,7 @@ request_start (void *cls, size_t size, void *buf)
328 { 323 {
329 if (th->timeout_task != GNUNET_SCHEDULER_NO_TASK) 324 if (th->timeout_task != GNUNET_SCHEDULER_NO_TASK)
330 { 325 {
331 GNUNET_SCHEDULER_cancel(h->sched, th->timeout_task); 326 GNUNET_SCHEDULER_cancel(th->timeout_task);
332 th->timeout_task = GNUNET_SCHEDULER_NO_TASK; 327 th->timeout_task = GNUNET_SCHEDULER_NO_TASK;
333 } 328 }
334 timeout_request (th, NULL); 329 timeout_request (th, NULL);
@@ -673,8 +668,7 @@ transmit_start (void *cls, size_t size, void *buf)
673 h->startup_timeout = 668 h->startup_timeout =
674 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); 669 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES);
675 h->reconnect_task = 670 h->reconnect_task =
676 GNUNET_SCHEDULER_add_delayed (h->sched, 671 GNUNET_SCHEDULER_add_delayed (delay, &reconnect_task, h);
677 delay, &reconnect_task, h);
678 return 0; 672 return 0;
679 } 673 }
680 /* timeout on initial connect */ 674 /* timeout on initial connect */
@@ -727,7 +721,6 @@ transmit_start (void *cls, size_t size, void *buf)
727 * Connect to the core service. Note that the connection may 721 * Connect to the core service. Note that the connection may
728 * complete (or fail) asynchronously. 722 * complete (or fail) asynchronously.
729 * 723 *
730 * @param sched scheduler to use
731 * @param cfg configuration to use 724 * @param cfg configuration to use
732 * @param timeout after how long should we give up trying to connect to the core service? 725 * @param timeout after how long should we give up trying to connect to the core service?
733 * @param cls closure for the various callbacks that follow (including handlers in the handlers array) 726 * @param cls closure for the various callbacks that follow (including handlers in the handlers array)
@@ -749,8 +742,7 @@ transmit_start (void *cls, size_t size, void *buf)
749 * NULL on error (in this case, init is never called) 742 * NULL on error (in this case, init is never called)
750 */ 743 */
751struct GNUNET_CORE_Handle * 744struct GNUNET_CORE_Handle *
752GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, 745GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
753 const struct GNUNET_CONFIGURATION_Handle *cfg,
754 struct GNUNET_TIME_Relative timeout, 746 struct GNUNET_TIME_Relative timeout,
755 void *cls, 747 void *cls,
756 GNUNET_CORE_StartupCallback init, 748 GNUNET_CORE_StartupCallback init,
@@ -766,7 +758,6 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched,
766 struct GNUNET_CORE_Handle *h; 758 struct GNUNET_CORE_Handle *h;
767 759
768 h = GNUNET_malloc (sizeof (struct GNUNET_CORE_Handle)); 760 h = GNUNET_malloc (sizeof (struct GNUNET_CORE_Handle));
769 h->sched = sched;
770 h->cfg = cfg; 761 h->cfg = cfg;
771 h->cls = cls; 762 h->cls = cls;
772 h->init = init; 763 h->init = init;
@@ -778,7 +769,7 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched,
778 h->inbound_hdr_only = inbound_hdr_only; 769 h->inbound_hdr_only = inbound_hdr_only;
779 h->outbound_hdr_only = outbound_hdr_only; 770 h->outbound_hdr_only = outbound_hdr_only;
780 h->handlers = handlers; 771 h->handlers = handlers;
781 h->client_notifications = GNUNET_CLIENT_connect (sched, "core", cfg); 772 h->client_notifications = GNUNET_CLIENT_connect ("core", cfg);
782 if (h->client_notifications == NULL) 773 if (h->client_notifications == NULL)
783 { 774 {
784 GNUNET_free (h); 775 GNUNET_free (h);
@@ -819,7 +810,7 @@ GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle)
819 if (handle->solicit_transmit_req != NULL) 810 if (handle->solicit_transmit_req != NULL)
820 GNUNET_CORE_notify_transmit_ready_cancel (handle->solicit_transmit_req); 811 GNUNET_CORE_notify_transmit_ready_cancel (handle->solicit_transmit_req);
821 if (handle->reconnect_task != GNUNET_SCHEDULER_NO_TASK) 812 if (handle->reconnect_task != GNUNET_SCHEDULER_NO_TASK)
822 GNUNET_SCHEDULER_cancel (handle->sched, handle->reconnect_task); 813 GNUNET_SCHEDULER_cancel (handle->reconnect_task);
823 if (handle->client_notifications != NULL) 814 if (handle->client_notifications != NULL)
824 GNUNET_CLIENT_disconnect (handle->client_notifications, GNUNET_NO); 815 GNUNET_CLIENT_disconnect (handle->client_notifications, GNUNET_NO);
825 GNUNET_break (handle->pending_head == NULL); 816 GNUNET_break (handle->pending_head == NULL);
@@ -950,8 +941,7 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle,
950 th->notify_cls = notify_cls; 941 th->notify_cls = notify_cls;
951 th->peer = *target; 942 th->peer = *target;
952 th->timeout = GNUNET_TIME_relative_to_absolute (maxdelay); 943 th->timeout = GNUNET_TIME_relative_to_absolute (maxdelay);
953 th->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->sched, 944 th->timeout_task = GNUNET_SCHEDULER_add_delayed (maxdelay,
954 maxdelay,
955 &timeout_request, th); 945 &timeout_request, th);
956 th->priority = priority; 946 th->priority = priority;
957 th->msize = sizeof (struct SendMessage) + notify_size; 947 th->msize = sizeof (struct SendMessage) + notify_size;
@@ -965,7 +955,7 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle,
965 955
966/** 956/**
967 * Cancel the specified transmission-ready notification. 957 * Cancel the specified transmission-ready notification.
968 * 958 *s
969 * @param th handle that was returned by "notify_transmit_ready". 959 * @param th handle that was returned by "notify_transmit_ready".
970 */ 960 */
971void 961void
@@ -981,7 +971,7 @@ GNUNET_CORE_notify_transmit_ready_cancel (struct GNUNET_CORE_TransmitHandle
981 h->pending_tail, 971 h->pending_tail,
982 th); 972 th);
983 if (th->timeout_task != GNUNET_SCHEDULER_NO_TASK) 973 if (th->timeout_task != GNUNET_SCHEDULER_NO_TASK)
984 GNUNET_SCHEDULER_cancel (h->sched, th->timeout_task); 974 GNUNET_SCHEDULER_cancel (th->timeout_task);
985 GNUNET_free (th); 975 GNUNET_free (th);
986} 976}
987 977
diff --git a/src/core/core_api_iterate_peers.c b/src/core/core_api_iterate_peers.c
index 08cb9797c..aeef67f88 100644
--- a/src/core/core_api_iterate_peers.c
+++ b/src/core/core_api_iterate_peers.c
@@ -134,22 +134,20 @@ transmit_request(void *cls,
134/** 134/**
135 * Obtain statistics and/or change preferences for the given peer. 135 * Obtain statistics and/or change preferences for the given peer.
136 * 136 *
137 * @param sched scheduler to use
138 * @param cfg configuration to use 137 * @param cfg configuration to use
139 * @param peer_cb function to call with the peer information 138 * @param peer_cb function to call with the peer information
140 * @param cb_cls closure for peer_cb 139 * @param cb_cls closure for peer_cb
141 * @return GNUNET_OK if iterating, GNUNET_SYSERR on error 140 * @return GNUNET_OK if iterating, GNUNET_SYSERR on error
142 */ 141 */
143int 142int
144GNUNET_CORE_iterate_peers (struct GNUNET_SCHEDULER_Handle *sched, 143GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
145 const struct GNUNET_CONFIGURATION_Handle *cfg,
146 GNUNET_CORE_ConnectEventHandler peer_cb, 144 GNUNET_CORE_ConnectEventHandler peer_cb,
147 void *cb_cls) 145 void *cb_cls)
148{ 146{
149 struct GNUNET_CORE_RequestContext *request_context; 147 struct GNUNET_CORE_RequestContext *request_context;
150 struct GNUNET_CLIENT_Connection *client; 148 struct GNUNET_CLIENT_Connection *client;
151 149
152 client = GNUNET_CLIENT_connect (sched, "core", cfg); 150 client = GNUNET_CLIENT_connect ("core", cfg);
153 if (client == NULL) 151 if (client == NULL)
154 return GNUNET_SYSERR; 152 return GNUNET_SYSERR;
155 request_context = GNUNET_malloc (sizeof (struct GNUNET_CORE_RequestContext)); 153 request_context = GNUNET_malloc (sizeof (struct GNUNET_CORE_RequestContext));
diff --git a/src/core/core_api_peer_get_info.c b/src/core/core_api_peer_get_info.c
index 68cf2da11..1ca8d82af 100644
--- a/src/core/core_api_peer_get_info.c
+++ b/src/core/core_api_peer_get_info.c
@@ -99,7 +99,6 @@ receive_info (void *cls,
99/** 99/**
100 * Obtain statistics and/or change preferences for the given peer. 100 * Obtain statistics and/or change preferences for the given peer.
101 * 101 *
102 * @param sched scheduler to use
103 * @param cfg configuration to use 102 * @param cfg configuration to use
104 * @param peer identifies the peer 103 * @param peer identifies the peer
105 * @param timeout after how long should we give up (and call "info" with NULL 104 * @param timeout after how long should we give up (and call "info" with NULL
@@ -122,8 +121,7 @@ receive_info (void *cls,
122 * @return NULL on error 121 * @return NULL on error
123 */ 122 */
124struct GNUNET_CORE_InformationRequestContext * 123struct GNUNET_CORE_InformationRequestContext *
125GNUNET_CORE_peer_change_preference (struct GNUNET_SCHEDULER_Handle *sched, 124GNUNET_CORE_peer_change_preference (const struct GNUNET_CONFIGURATION_Handle *cfg,
126 const struct GNUNET_CONFIGURATION_Handle *cfg,
127 const struct GNUNET_PeerIdentity *peer, 125 const struct GNUNET_PeerIdentity *peer,
128 struct GNUNET_TIME_Relative timeout, 126 struct GNUNET_TIME_Relative timeout,
129 struct GNUNET_BANDWIDTH_Value32NBO bw_out, 127 struct GNUNET_BANDWIDTH_Value32NBO bw_out,
@@ -137,7 +135,7 @@ GNUNET_CORE_peer_change_preference (struct GNUNET_SCHEDULER_Handle *sched,
137 struct GNUNET_CLIENT_Connection *client; 135 struct GNUNET_CLIENT_Connection *client;
138 int retry; 136 int retry;
139 137
140 client = GNUNET_CLIENT_connect (sched, "core", cfg); 138 client = GNUNET_CLIENT_connect ("core", cfg);
141 if (client == NULL) 139 if (client == NULL)
142 return NULL; 140 return NULL;
143 irc = GNUNET_malloc (sizeof (struct GNUNET_CORE_InformationRequestContext)); 141 irc = GNUNET_malloc (sizeof (struct GNUNET_CORE_InformationRequestContext));
diff --git a/src/core/core_api_peer_request.c b/src/core/core_api_peer_request.c
index 96640990a..0f13f15f9 100644
--- a/src/core/core_api_peer_request.c
+++ b/src/core/core_api_peer_request.c
@@ -41,10 +41,6 @@ struct GNUNET_CORE_PeerRequestHandle
41 */ 41 */
42 struct GNUNET_CLIENT_Connection *client; 42 struct GNUNET_CLIENT_Connection *client;
43 43
44 /**
45 * Scheduler.
46 */
47 struct GNUNET_SCHEDULER_Handle *sched;
48 44
49 /** 45 /**
50 * Function to call once done. 46 * Function to call once done.
@@ -92,8 +88,7 @@ send_request (void *cls,
92 if (buf == NULL) 88 if (buf == NULL)
93 { 89 {
94 if (prh->cont != NULL) 90 if (prh->cont != NULL)
95 GNUNET_SCHEDULER_add_continuation (prh->sched, 91 GNUNET_SCHEDULER_add_continuation (prh->cont,
96 prh->cont,
97 prh->cont_cls, 92 prh->cont_cls,
98 GNUNET_SCHEDULER_REASON_TIMEOUT); 93 GNUNET_SCHEDULER_REASON_TIMEOUT);
99 GNUNET_CLIENT_disconnect (prh->client, GNUNET_NO); 94 GNUNET_CLIENT_disconnect (prh->client, GNUNET_NO);
@@ -109,8 +104,7 @@ send_request (void *cls,
109 memcpy (buf, &msg, sizeof (msg)); 104 memcpy (buf, &msg, sizeof (msg));
110 if (prh->cont != NULL) 105 if (prh->cont != NULL)
111 { 106 {
112 GNUNET_SCHEDULER_add_continuation (prh->sched, 107 GNUNET_SCHEDULER_add_continuation (prh->cont,
113 prh->cont,
114 prh->cont_cls, 108 prh->cont_cls,
115 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 109 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
116 } 110 }
@@ -131,7 +125,6 @@ send_request (void *cls,
131 * to our connection attempt within the given time frame, 'cont' will 125 * to our connection attempt within the given time frame, 'cont' will
132 * be called with the TIMEOUT reason code. 126 * be called with the TIMEOUT reason code.
133 * 127 *
134 * @param sched scheduler to use
135 * @param cfg configuration to use 128 * @param cfg configuration to use
136 * @param timeout how long to try to talk to core 129 * @param timeout how long to try to talk to core
137 * @param peer who should we connect to 130 * @param peer who should we connect to
@@ -140,8 +133,7 @@ send_request (void *cls,
140 * @return NULL on error (cont will not be called), otherwise handle for cancellation 133 * @return NULL on error (cont will not be called), otherwise handle for cancellation
141 */ 134 */
142struct GNUNET_CORE_PeerRequestHandle * 135struct GNUNET_CORE_PeerRequestHandle *
143GNUNET_CORE_peer_request_connect (struct GNUNET_SCHEDULER_Handle *sched, 136GNUNET_CORE_peer_request_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
144 const struct GNUNET_CONFIGURATION_Handle *cfg,
145 struct GNUNET_TIME_Relative timeout, 137 struct GNUNET_TIME_Relative timeout,
146 const struct GNUNET_PeerIdentity * peer, 138 const struct GNUNET_PeerIdentity * peer,
147 GNUNET_SCHEDULER_Task cont, 139 GNUNET_SCHEDULER_Task cont,
@@ -150,12 +142,11 @@ GNUNET_CORE_peer_request_connect (struct GNUNET_SCHEDULER_Handle *sched,
150 struct GNUNET_CORE_PeerRequestHandle *ret; 142 struct GNUNET_CORE_PeerRequestHandle *ret;
151 struct GNUNET_CLIENT_Connection *client; 143 struct GNUNET_CLIENT_Connection *client;
152 144
153 client = GNUNET_CLIENT_connect (sched, "core", cfg); 145 client = GNUNET_CLIENT_connect ("core", cfg);
154 if (client == NULL) 146 if (client == NULL)
155 return NULL; 147 return NULL;
156 ret = GNUNET_malloc (sizeof (struct GNUNET_CORE_PeerRequestHandle)); 148 ret = GNUNET_malloc (sizeof (struct GNUNET_CORE_PeerRequestHandle));
157 ret->client = client; 149 ret->client = client;
158 ret->sched = sched;
159 ret->cont = cont; 150 ret->cont = cont;
160 ret->cont_cls = cont_cls; 151 ret->cont_cls = cont_cls;
161 ret->peer = *peer; 152 ret->peer = *peer;
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c
index 6b662982d..c1ebdb9df 100644
--- a/src/core/gnunet-service-core.c
+++ b/src/core/gnunet-service-core.c
@@ -657,10 +657,6 @@ static struct GNUNET_PeerIdentity my_identity;
657 */ 657 */
658static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key; 658static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key;
659 659
660/**
661 * Our scheduler.
662 */
663struct GNUNET_SCHEDULER_Handle *sched;
664 660
665/** 661/**
666 * Handle to peerinfo service. 662 * Handle to peerinfo service.
@@ -1259,15 +1255,15 @@ free_neighbour (struct Neighbour *n)
1259 n->th = NULL; 1255 n->th = NULL;
1260 } 1256 }
1261 if (n->retry_plaintext_task != GNUNET_SCHEDULER_NO_TASK) 1257 if (n->retry_plaintext_task != GNUNET_SCHEDULER_NO_TASK)
1262 GNUNET_SCHEDULER_cancel (sched, n->retry_plaintext_task); 1258 GNUNET_SCHEDULER_cancel (n->retry_plaintext_task);
1263 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) 1259 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK)
1264 GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task); 1260 GNUNET_SCHEDULER_cancel (n->retry_set_key_task);
1265 if (n->quota_update_task != GNUNET_SCHEDULER_NO_TASK) 1261 if (n->quota_update_task != GNUNET_SCHEDULER_NO_TASK)
1266 GNUNET_SCHEDULER_cancel (sched, n->quota_update_task); 1262 GNUNET_SCHEDULER_cancel (n->quota_update_task);
1267 if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK) 1263 if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK)
1268 GNUNET_SCHEDULER_cancel (sched, n->dead_clean_task); 1264 GNUNET_SCHEDULER_cancel (n->dead_clean_task);
1269 if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) 1265 if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK)
1270 GNUNET_SCHEDULER_cancel (sched, n->keep_alive_task); 1266 GNUNET_SCHEDULER_cancel (n->keep_alive_task);
1271 if (n->status == PEER_STATE_KEY_CONFIRMED) 1267 if (n->status == PEER_STATE_KEY_CONFIRMED)
1272 GNUNET_STATISTICS_update (stats, gettext_noop ("# established sessions"), -1, GNUNET_NO); 1268 GNUNET_STATISTICS_update (stats, gettext_noop ("# established sessions"), -1, GNUNET_NO);
1273 GNUNET_free_non_null (n->public_key); 1269 GNUNET_free_non_null (n->public_key);
@@ -1397,8 +1393,7 @@ send_keep_alive (void *cls,
1397 retry = GNUNET_TIME_relative_max (GNUNET_TIME_relative_divide (left, 2), 1393 retry = GNUNET_TIME_relative_max (GNUNET_TIME_relative_divide (left, 2),
1398 MIN_PING_FREQUENCY); 1394 MIN_PING_FREQUENCY);
1399 n->keep_alive_task 1395 n->keep_alive_task
1400 = GNUNET_SCHEDULER_add_delayed (sched, 1396 = GNUNET_SCHEDULER_add_delayed (retry,
1401 retry,
1402 &send_keep_alive, 1397 &send_keep_alive,
1403 n); 1398 n);
1404 1399
@@ -1445,9 +1440,8 @@ consider_free_neighbour (struct Neighbour *n)
1445 if (left.rel_value > 0) 1440 if (left.rel_value > 0)
1446 { 1441 {
1447 if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK) 1442 if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK)
1448 GNUNET_SCHEDULER_cancel (sched, n->dead_clean_task); 1443 GNUNET_SCHEDULER_cancel (n->dead_clean_task);
1449 n->dead_clean_task = GNUNET_SCHEDULER_add_delayed (sched, 1444 n->dead_clean_task = GNUNET_SCHEDULER_add_delayed (left,
1450 left,
1451 &consider_free_task, 1445 &consider_free_task,
1452 n); 1446 n);
1453 return; 1447 return;
@@ -2087,7 +2081,7 @@ process_plaintext_neighbour_queue (struct Neighbour *n)
2087 2081
2088 if (n->retry_plaintext_task != GNUNET_SCHEDULER_NO_TASK) 2082 if (n->retry_plaintext_task != GNUNET_SCHEDULER_NO_TASK)
2089 { 2083 {
2090 GNUNET_SCHEDULER_cancel (sched, n->retry_plaintext_task); 2084 GNUNET_SCHEDULER_cancel (n->retry_plaintext_task);
2091 n->retry_plaintext_task = GNUNET_SCHEDULER_NO_TASK; 2085 n->retry_plaintext_task = GNUNET_SCHEDULER_NO_TASK;
2092 } 2086 }
2093 switch (n->status) 2087 switch (n->status)
@@ -2103,8 +2097,7 @@ process_plaintext_neighbour_queue (struct Neighbour *n)
2103 case PEER_STATE_KEY_SENT: 2097 case PEER_STATE_KEY_SENT:
2104 if (n->retry_set_key_task == GNUNET_SCHEDULER_NO_TASK) 2098 if (n->retry_set_key_task == GNUNET_SCHEDULER_NO_TASK)
2105 n->retry_set_key_task 2099 n->retry_set_key_task
2106 = GNUNET_SCHEDULER_add_delayed (sched, 2100 = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency,
2107 n->set_key_retry_frequency,
2108 &set_key_retry_task, n); 2101 &set_key_retry_task, n);
2109#if DEBUG_CORE 2102#if DEBUG_CORE
2110 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2115,8 +2108,7 @@ process_plaintext_neighbour_queue (struct Neighbour *n)
2115 case PEER_STATE_KEY_RECEIVED: 2108 case PEER_STATE_KEY_RECEIVED:
2116 if (n->retry_set_key_task == GNUNET_SCHEDULER_NO_TASK) 2109 if (n->retry_set_key_task == GNUNET_SCHEDULER_NO_TASK)
2117 n->retry_set_key_task 2110 n->retry_set_key_task
2118 = GNUNET_SCHEDULER_add_delayed (sched, 2111 = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency,
2119 n->set_key_retry_frequency,
2120 &set_key_retry_task, n); 2112 &set_key_retry_task, n);
2121#if DEBUG_CORE 2113#if DEBUG_CORE
2122 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2114 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2165,8 +2157,7 @@ process_plaintext_neighbour_queue (struct Neighbour *n)
2165#endif 2157#endif
2166 /* no messages selected for sending, try again later... */ 2158 /* no messages selected for sending, try again later... */
2167 n->retry_plaintext_task = 2159 n->retry_plaintext_task =
2168 GNUNET_SCHEDULER_add_delayed (sched, 2160 GNUNET_SCHEDULER_add_delayed (retry_time,
2169 retry_time,
2170 &retry_plaintext_processing, n); 2161 &retry_plaintext_processing, n);
2171 return; 2162 return;
2172 } 2163 }
@@ -2252,8 +2243,7 @@ schedule_quota_update (struct Neighbour *n)
2252 GNUNET_assert (n->quota_update_task == 2243 GNUNET_assert (n->quota_update_task ==
2253 GNUNET_SCHEDULER_NO_TASK); 2244 GNUNET_SCHEDULER_NO_TASK);
2254 n->quota_update_task 2245 n->quota_update_task
2255 = GNUNET_SCHEDULER_add_delayed (sched, 2246 = GNUNET_SCHEDULER_add_delayed (QUOTA_UPDATE_FREQUENCY,
2256 QUOTA_UPDATE_FREQUENCY,
2257 &neighbour_quota_update, 2247 &neighbour_quota_update,
2258 n); 2248 n);
2259} 2249}
@@ -2475,10 +2465,8 @@ notify_transport_connect_done (void *cls, size_t size, void *buf)
2475 _("TRANSPORT connection to peer `%4s' is up, trying to establish CORE connection\n"), 2465 _("TRANSPORT connection to peer `%4s' is up, trying to establish CORE connection\n"),
2476 GNUNET_i2s (&n->peer)); 2466 GNUNET_i2s (&n->peer));
2477 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) 2467 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK)
2478 GNUNET_SCHEDULER_cancel (sched, 2468 GNUNET_SCHEDULER_cancel (n->retry_set_key_task);
2479 n->retry_set_key_task); 2469 n->retry_set_key_task = GNUNET_SCHEDULER_add_now (&set_key_retry_task,
2480 n->retry_set_key_task = GNUNET_SCHEDULER_add_now (sched,
2481 &set_key_retry_task,
2482 n); 2470 n);
2483 return 0; 2471 return 0;
2484} 2472}
@@ -2567,7 +2555,7 @@ process_hello_retry_send_key (void *cls,
2567 { 2555 {
2568 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) 2556 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK)
2569 { 2557 {
2570 GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task); 2558 GNUNET_SCHEDULER_cancel (n->retry_set_key_task);
2571 n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK; 2559 n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK;
2572 } 2560 }
2573 GNUNET_STATISTICS_update (stats, 2561 GNUNET_STATISTICS_update (stats,
@@ -2589,8 +2577,7 @@ process_hello_retry_send_key (void *cls,
2589 GNUNET_NO); 2577 GNUNET_NO);
2590 if (GNUNET_SCHEDULER_NO_TASK == n->retry_set_key_task) 2578 if (GNUNET_SCHEDULER_NO_TASK == n->retry_set_key_task)
2591 n->retry_set_key_task 2579 n->retry_set_key_task
2592 = GNUNET_SCHEDULER_add_delayed (sched, 2580 = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency,
2593 n->set_key_retry_frequency,
2594 &set_key_retry_task, n); 2581 &set_key_retry_task, n);
2595 } 2582 }
2596 return; 2583 return;
@@ -2651,7 +2638,7 @@ send_key (struct Neighbour *n)
2651 2638
2652 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) 2639 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK)
2653 { 2640 {
2654 GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task); 2641 GNUNET_SCHEDULER_cancel (n->retry_set_key_task);
2655 n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK; 2642 n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK;
2656 } 2643 }
2657 if (n->pitr != NULL) 2644 if (n->pitr != NULL)
@@ -2829,8 +2816,7 @@ send_key (struct Neighbour *n)
2829 if ( (n->status != PEER_STATE_KEY_CONFIRMED) && 2816 if ( (n->status != PEER_STATE_KEY_CONFIRMED) &&
2830 (GNUNET_SCHEDULER_NO_TASK == n->retry_set_key_task) ) 2817 (GNUNET_SCHEDULER_NO_TASK == n->retry_set_key_task) )
2831 n->retry_set_key_task 2818 n->retry_set_key_task
2832 = GNUNET_SCHEDULER_add_delayed (sched, 2819 = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency,
2833 n->set_key_retry_frequency,
2834 &set_key_retry_task, n); 2820 &set_key_retry_task, n);
2835} 2821}
2836 2822
@@ -3096,7 +3082,7 @@ handle_pong (struct Neighbour *n,
3096#endif 3082#endif
3097 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) 3083 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK)
3098 { 3084 {
3099 GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task); 3085 GNUNET_SCHEDULER_cancel (n->retry_set_key_task);
3100 n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK; 3086 n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK;
3101 } 3087 }
3102 cnm.header.size = htons (sizeof (struct ConnectNotifyMessage)); 3088 cnm.header.size = htons (sizeof (struct ConnectNotifyMessage));
@@ -3110,10 +3096,9 @@ handle_pong (struct Neighbour *n,
3110 case PEER_STATE_KEY_CONFIRMED: 3096 case PEER_STATE_KEY_CONFIRMED:
3111 n->last_activity = GNUNET_TIME_absolute_get (); 3097 n->last_activity = GNUNET_TIME_absolute_get ();
3112 if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) 3098 if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK)
3113 GNUNET_SCHEDULER_cancel (sched, n->keep_alive_task); 3099 GNUNET_SCHEDULER_cancel (n->keep_alive_task);
3114 n->keep_alive_task 3100 n->keep_alive_task
3115 = GNUNET_SCHEDULER_add_delayed (sched, 3101 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2),
3116 GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2),
3117 &send_keep_alive, 3102 &send_keep_alive,
3118 n); 3103 n);
3119 handle_peer_status_change (n); 3104 handle_peer_status_change (n);
@@ -3560,10 +3545,9 @@ handle_encrypted_message (struct Neighbour *n,
3560 } 3545 }
3561 n->last_activity = GNUNET_TIME_absolute_get (); 3546 n->last_activity = GNUNET_TIME_absolute_get ();
3562 if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) 3547 if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK)
3563 GNUNET_SCHEDULER_cancel (sched, n->keep_alive_task); 3548 GNUNET_SCHEDULER_cancel (n->keep_alive_task);
3564 n->keep_alive_task 3549 n->keep_alive_task
3565 = GNUNET_SCHEDULER_add_delayed (sched, 3550 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2),
3566 GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2),
3567 &send_keep_alive, 3551 &send_keep_alive,
3568 n); 3552 n);
3569 GNUNET_STATISTICS_set (stats, 3553 GNUNET_STATISTICS_set (stats,
@@ -3711,10 +3695,9 @@ handle_transport_receive (void *cls,
3711 n->time_established = now; 3695 n->time_established = now;
3712 } 3696 }
3713 if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) 3697 if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK)
3714 GNUNET_SCHEDULER_cancel (sched, n->keep_alive_task); 3698 GNUNET_SCHEDULER_cancel (n->keep_alive_task);
3715 n->keep_alive_task 3699 n->keep_alive_task
3716 = GNUNET_SCHEDULER_add_delayed (sched, 3700 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2),
3717 GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2),
3718 &send_keep_alive, 3701 &send_keep_alive,
3719 n); 3702 n);
3720 } 3703 }
@@ -3912,14 +3895,12 @@ handle_transport_notify_disconnect (void *cls,
3912 -1, 3895 -1,
3913 GNUNET_NO); 3896 GNUNET_NO);
3914 if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK) 3897 if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK)
3915 GNUNET_SCHEDULER_cancel (sched, 3898 GNUNET_SCHEDULER_cancel (n->dead_clean_task);
3916 n->dead_clean_task);
3917 left = GNUNET_TIME_relative_subtract (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 3899 left = GNUNET_TIME_relative_subtract (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
3918 GNUNET_CONSTANTS_DISCONNECT_SESSION_TIMEOUT); 3900 GNUNET_CONSTANTS_DISCONNECT_SESSION_TIMEOUT);
3919 n->last_activity = GNUNET_TIME_absolute_subtract (GNUNET_TIME_absolute_get (), 3901 n->last_activity = GNUNET_TIME_absolute_subtract (GNUNET_TIME_absolute_get (),
3920 left); 3902 left);
3921 n->dead_clean_task = GNUNET_SCHEDULER_add_delayed (sched, 3903 n->dead_clean_task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_DISCONNECT_SESSION_TIMEOUT,
3922 GNUNET_CONSTANTS_DISCONNECT_SESSION_TIMEOUT,
3923 &consider_free_task, 3904 &consider_free_task,
3924 n); 3905 n);
3925} 3906}
@@ -3969,13 +3950,11 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3969 * Initiate core service. 3950 * Initiate core service.
3970 * 3951 *
3971 * @param cls closure 3952 * @param cls closure
3972 * @param s scheduler to use
3973 * @param server the initialized server 3953 * @param server the initialized server
3974 * @param c configuration to use 3954 * @param c configuration to use
3975 */ 3955 */
3976static void 3956static void
3977run (void *cls, 3957run (void *cls,
3978 struct GNUNET_SCHEDULER_Handle *s,
3979 struct GNUNET_SERVER_Handle *server, 3958 struct GNUNET_SERVER_Handle *server,
3980 const struct GNUNET_CONFIGURATION_Handle *c) 3959 const struct GNUNET_CONFIGURATION_Handle *c)
3981{ 3960{
@@ -3997,7 +3976,6 @@ run (void *cls,
3997 }; 3976 };
3998 char *keyfile; 3977 char *keyfile;
3999 3978
4000 sched = s;
4001 cfg = c; 3979 cfg = c;
4002 /* parse configuration */ 3980 /* parse configuration */
4003 if ( 3981 if (
@@ -4019,15 +3997,15 @@ run (void *cls,
4019 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 3997 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
4020 _ 3998 _
4021 ("Core service is lacking key configuration settings. Exiting.\n")); 3999 ("Core service is lacking key configuration settings. Exiting.\n"));
4022 GNUNET_SCHEDULER_shutdown (s); 4000 GNUNET_SCHEDULER_shutdown ();
4023 return; 4001 return;
4024 } 4002 }
4025 peerinfo = GNUNET_PEERINFO_connect (sched, cfg); 4003 peerinfo = GNUNET_PEERINFO_connect (cfg);
4026 if (NULL == peerinfo) 4004 if (NULL == peerinfo)
4027 { 4005 {
4028 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 4006 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
4029 _("Could not access PEERINFO service. Exiting.\n")); 4007 _("Could not access PEERINFO service. Exiting.\n"));
4030 GNUNET_SCHEDULER_shutdown (s); 4008 GNUNET_SCHEDULER_shutdown ();
4031 GNUNET_free (keyfile); 4009 GNUNET_free (keyfile);
4032 return; 4010 return;
4033 } 4011 }
@@ -4038,7 +4016,7 @@ run (void *cls,
4038 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 4016 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
4039 _("Core service could not access hostkey. Exiting.\n")); 4017 _("Core service could not access hostkey. Exiting.\n"));
4040 GNUNET_PEERINFO_disconnect (peerinfo); 4018 GNUNET_PEERINFO_disconnect (peerinfo);
4041 GNUNET_SCHEDULER_shutdown (s); 4019 GNUNET_SCHEDULER_shutdown ();
4042 return; 4020 return;
4043 } 4021 }
4044 GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); 4022 GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key);
@@ -4049,23 +4027,21 @@ run (void *cls,
4049 MAX_NOTIFY_QUEUE); 4027 MAX_NOTIFY_QUEUE);
4050 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); 4028 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
4051 /* setup transport connection */ 4029 /* setup transport connection */
4052 transport = GNUNET_TRANSPORT_connect (sched, 4030 transport = GNUNET_TRANSPORT_connect (cfg,
4053 cfg,
4054 &my_identity, 4031 &my_identity,
4055 NULL, 4032 NULL,
4056 &handle_transport_receive, 4033 &handle_transport_receive,
4057 &handle_transport_notify_connect, 4034 &handle_transport_notify_connect,
4058 &handle_transport_notify_disconnect); 4035 &handle_transport_notify_disconnect);
4059 GNUNET_assert (NULL != transport); 4036 GNUNET_assert (NULL != transport);
4060 stats = GNUNET_STATISTICS_create (sched, "core", cfg); 4037 stats = GNUNET_STATISTICS_create ("core", cfg);
4061 4038
4062 GNUNET_STATISTICS_set (stats, gettext_noop ("# discarded CORE_SEND requests"), 0, GNUNET_NO); 4039 GNUNET_STATISTICS_set (stats, gettext_noop ("# discarded CORE_SEND requests"), 0, GNUNET_NO);
4063 GNUNET_STATISTICS_set (stats, gettext_noop ("# discarded lower priority CORE_SEND requests"), 0, GNUNET_NO); 4040 GNUNET_STATISTICS_set (stats, gettext_noop ("# discarded lower priority CORE_SEND requests"), 0, GNUNET_NO);
4064 4041
4065 mst = GNUNET_SERVER_mst_create (&deliver_message, 4042 mst = GNUNET_SERVER_mst_create (&deliver_message,
4066 NULL); 4043 NULL);
4067 GNUNET_SCHEDULER_add_delayed (sched, 4044 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
4068 GNUNET_TIME_UNIT_FOREVER_REL,
4069 &cleaning_task, NULL); 4045 &cleaning_task, NULL);
4070 /* process client requests */ 4046 /* process client requests */
4071 GNUNET_SERVER_add_handlers (server, handlers); 4047 GNUNET_SERVER_add_handlers (server, handlers);
diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c
index 3fbeca419..65b09c835 100644
--- a/src/core/test_core_api.c
+++ b/src/core/test_core_api.c
@@ -62,7 +62,6 @@ static struct PeerContext p1;
62 62
63static struct PeerContext p2; 63static struct PeerContext p2;
64 64
65static struct GNUNET_SCHEDULER_Handle *sched;
66 65
67static int ok; 66static int ok;
68 67
@@ -168,8 +167,8 @@ process_mtype (void *cls,
168 "Receiving message from `%4s'.\n", GNUNET_i2s (peer)); 167 "Receiving message from `%4s'.\n", GNUNET_i2s (peer));
169 GNUNET_assert (ok == 5); 168 GNUNET_assert (ok == 5);
170 OKPP; 169 OKPP;
171 GNUNET_SCHEDULER_cancel (sched, err_task); 170 GNUNET_SCHEDULER_cancel (err_task);
172 GNUNET_SCHEDULER_add_now (sched, &terminate_task, NULL); 171 GNUNET_SCHEDULER_add_now (&terminate_task, NULL);
173 return GNUNET_OK; 172 return GNUNET_OK;
174} 173}
175 174
@@ -194,8 +193,7 @@ transmit_ready (void *cls, size_t size, void *buf)
194 m->type = htons (MTYPE); 193 m->type = htons (MTYPE);
195 m->size = htons (sizeof (struct GNUNET_MessageHeader)); 194 m->size = htons (sizeof (struct GNUNET_MessageHeader));
196 err_task = 195 err_task =
197 GNUNET_SCHEDULER_add_delayed (sched, 196 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 120), &terminate_task_error, NULL);
198 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 120), &terminate_task_error, NULL);
199 197
200 return sizeof (struct GNUNET_MessageHeader); 198 return sizeof (struct GNUNET_MessageHeader);
201} 199}
@@ -221,8 +219,7 @@ init_notify (void *cls,
221 GNUNET_assert (ok == 2); 219 GNUNET_assert (ok == 2);
222 OKPP; 220 OKPP;
223 /* connect p2 */ 221 /* connect p2 */
224 GNUNET_CORE_connect (sched, 222 GNUNET_CORE_connect (p2.cfg,
225 p2.cfg,
226 TIMEOUT, 223 TIMEOUT,
227 &p2, 224 &p2,
228 &init_notify, 225 &init_notify,
@@ -297,7 +294,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
297 "-c", cfgname, NULL); 294 "-c", cfgname, NULL);
298#endif 295#endif
299 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 296 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
300 p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, p, NULL, NULL, NULL); 297 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
301 GNUNET_assert (p->th != NULL); 298 GNUNET_assert (p->th != NULL);
302 GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); 299 GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
303} 300}
@@ -305,18 +302,15 @@ setup_peer (struct PeerContext *p, const char *cfgname)
305 302
306static void 303static void
307run (void *cls, 304run (void *cls,
308 struct GNUNET_SCHEDULER_Handle *s,
309 char *const *args, 305 char *const *args,
310 const char *cfgfile, 306 const char *cfgfile,
311 const struct GNUNET_CONFIGURATION_Handle *cfg) 307 const struct GNUNET_CONFIGURATION_Handle *cfg)
312{ 308{
313 GNUNET_assert (ok == 1); 309 GNUNET_assert (ok == 1);
314 OKPP; 310 OKPP;
315 sched = s;
316 setup_peer (&p1, "test_core_api_peer1.conf"); 311 setup_peer (&p1, "test_core_api_peer1.conf");
317 setup_peer (&p2, "test_core_api_peer2.conf"); 312 setup_peer (&p2, "test_core_api_peer2.conf");
318 GNUNET_CORE_connect (sched, 313 GNUNET_CORE_connect (p1.cfg,
319 p1.cfg,
320 TIMEOUT, 314 TIMEOUT,
321 &p1, 315 &p1,
322 &init_notify, 316 &init_notify,
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c
index 49fe8f9de..da67bb4d4 100644
--- a/src/core/test_core_api_reliability.c
+++ b/src/core/test_core_api_reliability.c
@@ -82,8 +82,6 @@ static struct PeerContext p1;
82 82
83static struct PeerContext p2; 83static struct PeerContext p2;
84 84
85static struct GNUNET_SCHEDULER_Handle *sched;
86
87static int ok; 85static int ok;
88 86
89#if VERBOSE 87#if VERBOSE
@@ -235,8 +233,8 @@ process_mtype (void *cls,
235 n, s, 233 n, s,
236 ntohs (message->size), 234 ntohs (message->size),
237 ntohl (hdr->num)); 235 ntohl (hdr->num));
238 GNUNET_SCHEDULER_cancel (sched, err_task); 236 GNUNET_SCHEDULER_cancel (err_task);
239 err_task = GNUNET_SCHEDULER_add_now (sched, &terminate_task_error, NULL); 237 err_task = GNUNET_SCHEDULER_add_now (&terminate_task_error, NULL);
240 return GNUNET_SYSERR; 238 return GNUNET_SYSERR;
241 } 239 }
242 if (ntohl (hdr->num) != n) 240 if (ntohl (hdr->num) != n)
@@ -246,8 +244,8 @@ process_mtype (void *cls,
246 n, s, 244 n, s,
247 ntohs (message->size), 245 ntohs (message->size),
248 ntohl (hdr->num)); 246 ntohl (hdr->num));
249 GNUNET_SCHEDULER_cancel (sched, err_task); 247 GNUNET_SCHEDULER_cancel (err_task);
250 err_task = GNUNET_SCHEDULER_add_now (sched, &terminate_task_error, NULL); 248 err_task = GNUNET_SCHEDULER_add_now (&terminate_task_error, NULL);
251 return GNUNET_SYSERR; 249 return GNUNET_SYSERR;
252 } 250 }
253#if VERBOSE 251#if VERBOSE
@@ -261,8 +259,8 @@ process_mtype (void *cls,
261 fprintf (stderr, "."); 259 fprintf (stderr, ".");
262 if (n == TOTAL_MSGS) 260 if (n == TOTAL_MSGS)
263 { 261 {
264 GNUNET_SCHEDULER_cancel (sched, err_task); 262 GNUNET_SCHEDULER_cancel (err_task);
265 GNUNET_SCHEDULER_add_now (sched, &terminate_task, NULL); 263 GNUNET_SCHEDULER_add_now (&terminate_task, NULL);
266 } 264 }
267 else 265 else
268 { 266 {
@@ -334,10 +332,9 @@ transmit_ready (void *cls, size_t size, void *buf)
334 break; /* sometimes pack buffer full, sometimes not */ 332 break; /* sometimes pack buffer full, sometimes not */
335 } 333 }
336 while (size - ret >= s); 334 while (size - ret >= s);
337 GNUNET_SCHEDULER_cancel (sched, err_task); 335 GNUNET_SCHEDULER_cancel (err_task);
338 err_task = 336 err_task =
339 GNUNET_SCHEDULER_add_delayed (sched, 337 GNUNET_SCHEDULER_add_delayed (TIMEOUT,
340 TIMEOUT,
341 &terminate_task_error, 338 &terminate_task_error,
342 NULL); 339 NULL);
343 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 340 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -368,8 +365,7 @@ init_notify (void *cls,
368 GNUNET_assert (ok == 2); 365 GNUNET_assert (ok == 2);
369 OKPP; 366 OKPP;
370 /* connect p2 */ 367 /* connect p2 */
371 GNUNET_CORE_connect (sched, 368 GNUNET_CORE_connect (p2.cfg,
372 p2.cfg,
373 TIMEOUT, 369 TIMEOUT,
374 &p2, 370 &p2,
375 &init_notify, 371 &init_notify,
@@ -389,8 +385,7 @@ init_notify (void *cls,
389 "Asking core (1) for transmission to peer `%4s'\n", 385 "Asking core (1) for transmission to peer `%4s'\n",
390 GNUNET_i2s (&p2.id)); 386 GNUNET_i2s (&p2.id));
391 err_task = 387 err_task =
392 GNUNET_SCHEDULER_add_delayed (sched, 388 GNUNET_SCHEDULER_add_delayed (TIMEOUT,
393 TIMEOUT,
394 &terminate_task_error, 389 &terminate_task_error,
395 NULL); 390 NULL);
396 start_time = GNUNET_TIME_absolute_get (); 391 start_time = GNUNET_TIME_absolute_get ();
@@ -444,7 +439,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
444 "-c", cfgname, NULL); 439 "-c", cfgname, NULL);
445#endif 440#endif
446 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 441 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
447 p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, p, NULL, NULL, NULL); 442 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
448 GNUNET_assert (p->th != NULL); 443 GNUNET_assert (p->th != NULL);
449 GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); 444 GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
450} 445}
@@ -452,18 +447,15 @@ setup_peer (struct PeerContext *p, const char *cfgname)
452 447
453static void 448static void
454run (void *cls, 449run (void *cls,
455 struct GNUNET_SCHEDULER_Handle *s,
456 char *const *args, 450 char *const *args,
457 const char *cfgfile, 451 const char *cfgfile,
458 const struct GNUNET_CONFIGURATION_Handle *cfg) 452 const struct GNUNET_CONFIGURATION_Handle *cfg)
459{ 453{
460 GNUNET_assert (ok == 1); 454 GNUNET_assert (ok == 1);
461 OKPP; 455 OKPP;
462 sched = s;
463 setup_peer (&p1, "test_core_api_peer1.conf"); 456 setup_peer (&p1, "test_core_api_peer1.conf");
464 setup_peer (&p2, "test_core_api_peer2.conf"); 457 setup_peer (&p2, "test_core_api_peer2.conf");
465 GNUNET_CORE_connect (sched, 458 GNUNET_CORE_connect (p1.cfg,
466 p1.cfg,
467 TIMEOUT, 459 TIMEOUT,
468 &p1, 460 &p1,
469 &init_notify, 461 &init_notify,
diff --git a/src/core/test_core_api_start_only.c b/src/core/test_core_api_start_only.c
index 958defbf9..da7217f39 100644
--- a/src/core/test_core_api_start_only.c
+++ b/src/core/test_core_api_start_only.c
@@ -57,7 +57,6 @@ static struct PeerContext p1;
57 57
58static struct PeerContext p2; 58static struct PeerContext p2;
59 59
60static struct GNUNET_SCHEDULER_Handle *sched;
61 60
62static int ok; 61static int ok;
63 62
@@ -126,8 +125,7 @@ init_notify (void *cls,
126 if (cls == &p1) 125 if (cls == &p1)
127 { 126 {
128 /* connect p2 */ 127 /* connect p2 */
129 GNUNET_CORE_connect (sched, 128 GNUNET_CORE_connect (p2.cfg,
130 p2.cfg,
131 TIMEOUT, 129 TIMEOUT,
132 &p2, 130 &p2,
133 &init_notify, 131 &init_notify,
@@ -166,18 +164,15 @@ setup_peer (struct PeerContext *p, const char *cfgname)
166 164
167static void 165static void
168run (void *cls, 166run (void *cls,
169 struct GNUNET_SCHEDULER_Handle *s,
170 char *const *args, 167 char *const *args,
171 const char *cfgfile, 168 const char *cfgfile,
172 const struct GNUNET_CONFIGURATION_Handle *cfg) 169 const struct GNUNET_CONFIGURATION_Handle *cfg)
173{ 170{
174 GNUNET_assert (ok == 1); 171 GNUNET_assert (ok == 1);
175 OKPP; 172 OKPP;
176 sched = s;
177 setup_peer (&p1, "test_core_api_peer1.conf"); 173 setup_peer (&p1, "test_core_api_peer1.conf");
178 setup_peer (&p2, "test_core_api_peer2.conf"); 174 setup_peer (&p2, "test_core_api_peer2.conf");
179 GNUNET_CORE_connect (sched, 175 GNUNET_CORE_connect (p1.cfg,
180 p1.cfg,
181 TIMEOUT, 176 TIMEOUT,
182 &p1, 177 &p1,
183 &init_notify, 178 &init_notify,
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c
index d69fb0905..822dc2c46 100644
--- a/src/core/test_core_quota_compliance.c
+++ b/src/core/test_core_quota_compliance.c
@@ -105,8 +105,6 @@ static struct PeerContext p1;
105 105
106static struct PeerContext p2; 106static struct PeerContext p2;
107 107
108static struct GNUNET_SCHEDULER_Handle *sched;
109
110static int ok; 108static int ok;
111static int measurement_running; 109static int measurement_running;
112 110
@@ -147,7 +145,7 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
147{ 145{
148 GNUNET_break (0); 146 GNUNET_break (0);
149 if (send_task != GNUNET_SCHEDULER_NO_TASK) 147 if (send_task != GNUNET_SCHEDULER_NO_TASK)
150 GNUNET_SCHEDULER_cancel (sched,send_task); 148 GNUNET_SCHEDULER_cancel (send_task);
151 GNUNET_CORE_disconnect (p1.ch); 149 GNUNET_CORE_disconnect (p1.ch);
152 p1.ch = NULL; 150 p1.ch = NULL;
153 GNUNET_CORE_disconnect (p2.ch); 151 GNUNET_CORE_disconnect (p2.ch);
@@ -247,9 +245,9 @@ measurement_end (void *cls,
247 return; 245 return;
248 246
249 if (err_task != GNUNET_SCHEDULER_NO_TASK) 247 if (err_task != GNUNET_SCHEDULER_NO_TASK)
250 GNUNET_SCHEDULER_cancel (sched, err_task); 248 GNUNET_SCHEDULER_cancel (err_task);
251 if (send_task != GNUNET_SCHEDULER_NO_TASK) 249 if (send_task != GNUNET_SCHEDULER_NO_TASK)
252 GNUNET_SCHEDULER_cancel (sched,send_task); 250 GNUNET_SCHEDULER_cancel (send_task);
253 251
254 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1); 252 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1);
255 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2); 253 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2);
@@ -271,7 +269,7 @@ measurement_end (void *cls,
271 (total_bytes_sent/(duration.rel_value / 1000)/1024),current_quota_p1_in/1024); 269 (total_bytes_sent/(duration.rel_value / 1000)/1024),current_quota_p1_in/1024);
272 270
273 271
274 GNUNET_SCHEDULER_add_now (sched, &terminate_task, NULL); 272 GNUNET_SCHEDULER_add_now (&terminate_task, NULL);
275} 273}
276 274
277static size_t 275static size_t
@@ -307,12 +305,10 @@ static void measure (unsigned long long quota_p1, unsigned long long quota_p2 )
307 "Asking core (1) for transmission to peer `%4s'\n", 305 "Asking core (1) for transmission to peer `%4s'\n",
308 GNUNET_i2s (&p2.id)); 306 GNUNET_i2s (&p2.id));
309#endif 307#endif
310 err_task = GNUNET_SCHEDULER_add_delayed (sched, 308 err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
311 TIMEOUT,
312 &terminate_task_error, 309 &terminate_task_error,
313 NULL); 310 NULL);
314 measure_task = GNUNET_SCHEDULER_add_delayed (sched, 311 measure_task = GNUNET_SCHEDULER_add_delayed (MEASUREMENT_INTERVALL,
315 MEASUREMENT_INTERVALL,
316 &measurement_end, 312 &measurement_end,
317 NULL); 313 NULL);
318 start_time = GNUNET_TIME_absolute_get (); 314 start_time = GNUNET_TIME_absolute_get ();
@@ -420,17 +416,16 @@ transmit_ready (void *cls, size_t size, void *buf)
420 break; /* sometimes pack buffer full, sometimes not */ 416 break; /* sometimes pack buffer full, sometimes not */
421 } 417 }
422 while (size - ret >= s); 418 while (size - ret >= s);
423 GNUNET_SCHEDULER_cancel (sched, err_task); 419 GNUNET_SCHEDULER_cancel (err_task);
424 err_task = GNUNET_SCHEDULER_add_delayed (sched, 420 err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
425 TIMEOUT,
426 &terminate_task_error, 421 &terminate_task_error,
427 NULL); 422 NULL);
428 423
429 total_bytes += ret; 424 total_bytes += ret;
430 total_bytes_sent += ret; 425 total_bytes_sent += ret;
431 if (send_task != GNUNET_SCHEDULER_NO_TASK) 426 if (send_task != GNUNET_SCHEDULER_NO_TASK)
432 GNUNET_SCHEDULER_cancel(sched, send_task); 427 GNUNET_SCHEDULER_cancel(send_task);
433 send_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 20), &send_tsk, NULL); 428 send_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 20), &send_tsk, NULL);
434 429
435 return ret; 430 return ret;
436} 431}
@@ -457,8 +452,7 @@ init_notify (void *cls,
457 GNUNET_assert (ok == 2); 452 GNUNET_assert (ok == 2);
458 OKPP; 453 OKPP;
459 /* connect p2 */ 454 /* connect p2 */
460 GNUNET_CORE_connect (sched, 455 GNUNET_CORE_connect (p2.cfg,
461 p2.cfg,
462 TIMEOUT, 456 TIMEOUT,
463 &p2, 457 &p2,
464 &init_notify, 458 &init_notify,
@@ -521,9 +515,9 @@ setup_peer (struct PeerContext *p, const char *cfgname)
521 "-c", cfgname, NULL); 515 "-c", cfgname, NULL);
522#endif 516#endif
523 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 517 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
524 p->stats = GNUNET_STATISTICS_create (sched, "core", p->cfg); 518 p->stats = GNUNET_STATISTICS_create ("core", p->cfg);
525 GNUNET_assert (p->stats != NULL); 519 GNUNET_assert (p->stats != NULL);
526 p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, p, NULL, NULL, NULL); 520 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
527 GNUNET_assert (p->th != NULL); 521 GNUNET_assert (p->th != NULL);
528 GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); 522 GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
529} 523}
@@ -531,18 +525,15 @@ setup_peer (struct PeerContext *p, const char *cfgname)
531 525
532static void 526static void
533run (void *cls, 527run (void *cls,
534 struct GNUNET_SCHEDULER_Handle *s,
535 char *const *args, 528 char *const *args,
536 const char *cfgfile, 529 const char *cfgfile,
537 const struct GNUNET_CONFIGURATION_Handle *cfg) 530 const struct GNUNET_CONFIGURATION_Handle *cfg)
538{ 531{
539 GNUNET_assert (ok == 1); 532 GNUNET_assert (ok == 1);
540 OKPP; 533 OKPP;
541 sched = s;
542 setup_peer (&p1, "test_core_quota_peer1.conf"); 534 setup_peer (&p1, "test_core_quota_peer1.conf");
543 setup_peer (&p2, "test_core_quota_peer2.conf"); 535 setup_peer (&p2, "test_core_quota_peer2.conf");
544 GNUNET_CORE_connect (sched, 536 GNUNET_CORE_connect (p1.cfg,
545 p1.cfg,
546 TIMEOUT, 537 TIMEOUT,
547 &p1, 538 &p1,
548 &init_notify, 539 &init_notify,
diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c
index d2aa2616a..9bb0f14b9 100644
--- a/src/datacache/datacache.c
+++ b/src/datacache/datacache.c
@@ -116,14 +116,12 @@ env_delete_notify (void *cls,
116/** 116/**
117 * Create a data cache. 117 * Create a data cache.
118 * 118 *
119 * @param sched scheduler to use
120 * @param cfg configuration to use 119 * @param cfg configuration to use
121 * @param section section in the configuration that contains our options 120 * @param section section in the configuration that contains our options
122 * @return handle to use to access the service 121 * @return handle to use to access the service
123 */ 122 */
124struct GNUNET_DATACACHE_Handle * 123struct GNUNET_DATACACHE_Handle *
125GNUNET_DATACACHE_create (struct GNUNET_SCHEDULER_Handle *sched, 124GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
126 const struct GNUNET_CONFIGURATION_Handle *cfg,
127 const char *section) 125 const char *section)
128{ 126{
129 unsigned int bf_size; 127 unsigned int bf_size;
@@ -167,11 +165,9 @@ GNUNET_DATACACHE_create (struct GNUNET_SCHEDULER_Handle *sched,
167 { 165 {
168 ret->filter = GNUNET_CONTAINER_bloomfilter_load (NULL, bf_size, 5); /* approx. 3% false positives at max use */ 166 ret->filter = GNUNET_CONTAINER_bloomfilter_load (NULL, bf_size, 5); /* approx. 3% false positives at max use */
169 } 167 }
170 ret->stats = GNUNET_STATISTICS_create (sched, 168 ret->stats = GNUNET_STATISTICS_create ("datacache",
171 "datacache",
172 cfg); 169 cfg);
173 ret->section = GNUNET_strdup (section); 170 ret->section = GNUNET_strdup (section);
174 ret->env.sched = sched;
175 ret->env.cfg = cfg; 171 ret->env.cfg = cfg;
176 ret->env.delete_notify = &env_delete_notify; 172 ret->env.delete_notify = &env_delete_notify;
177 ret->env.section = ret->section; 173 ret->env.section = ret->section;
diff --git a/src/datacache/perf_datacache.c b/src/datacache/perf_datacache.c
index 904238f85..f32574019 100644
--- a/src/datacache/perf_datacache.c
+++ b/src/datacache/perf_datacache.c
@@ -59,7 +59,6 @@ checkIt (void *cls,
59 59
60static void 60static void
61run (void *cls, 61run (void *cls,
62 struct GNUNET_SCHEDULER_Handle *sched,
63 char *const *args, 62 char *const *args,
64 const char *cfgfile, 63 const char *cfgfile,
65 const struct GNUNET_CONFIGURATION_Handle *cfg) 64 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -72,8 +71,7 @@ run (void *cls,
72 unsigned int i; 71 unsigned int i;
73 72
74 ok = 0; 73 ok = 0;
75 h = GNUNET_DATACACHE_create (sched, 74 h = GNUNET_DATACACHE_create (cfg,
76 cfg,
77 "perfcache"); 75 "perfcache");
78 76
79 if (h == NULL) 77 if (h == NULL)
diff --git a/src/datacache/plugin_datacache.h b/src/datacache/plugin_datacache.h
index bf35b2619..850d3961e 100644
--- a/src/datacache/plugin_datacache.h
+++ b/src/datacache/plugin_datacache.h
@@ -58,10 +58,6 @@ typedef void (*GNUNET_DATACACHE_DeleteNotifyCallback)(void *cls,
58struct GNUNET_DATACACHE_PluginEnvironment 58struct GNUNET_DATACACHE_PluginEnvironment
59{ 59{
60 60
61 /**
62 * Scheduler to use.
63 */
64 struct GNUNET_SCHEDULER_Handle *sched;
65 61
66 /** 62 /**
67 * Configuration to use. 63 * Configuration to use.
diff --git a/src/datacache/test_datacache.c b/src/datacache/test_datacache.c
index d0785173e..b626ce67d 100644
--- a/src/datacache/test_datacache.c
+++ b/src/datacache/test_datacache.c
@@ -62,7 +62,6 @@ checkIt (void *cls,
62 62
63static void 63static void
64run (void *cls, 64run (void *cls,
65 struct GNUNET_SCHEDULER_Handle *sched,
66 char *const *args, 65 char *const *args,
67 const char *cfgfile, 66 const char *cfgfile,
68 const struct GNUNET_CONFIGURATION_Handle *cfg) 67 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -74,8 +73,7 @@ run (void *cls,
74 unsigned int i; 73 unsigned int i;
75 74
76 ok = 0; 75 ok = 0;
77 h = GNUNET_DATACACHE_create (sched, 76 h = GNUNET_DATACACHE_create (cfg,
78 cfg,
79 "testcache"); 77 "testcache");
80 if (h == NULL) 78 if (h == NULL)
81 { 79 {
diff --git a/src/datacache/test_datacache_quota.c b/src/datacache/test_datacache_quota.c
index 4674a7da9..77ad63815 100644
--- a/src/datacache/test_datacache_quota.c
+++ b/src/datacache/test_datacache_quota.c
@@ -45,7 +45,6 @@ static const char *plugin_name;
45 */ 45 */
46static void 46static void
47run (void *cls, 47run (void *cls,
48 struct GNUNET_SCHEDULER_Handle *sched,
49 char *const *args, 48 char *const *args,
50 const char *cfgfile, 49 const char *cfgfile,
51 const struct GNUNET_CONFIGURATION_Handle *cfg) 50 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -59,8 +58,7 @@ run (void *cls,
59 struct GNUNET_TIME_Absolute exp; 58 struct GNUNET_TIME_Absolute exp;
60 59
61 ok = 0; 60 ok = 0;
62 h = GNUNET_DATACACHE_create (sched, 61 h = GNUNET_DATACACHE_create (cfg,
63 cfg,
64 "testcache"); 62 "testcache");
65 63
66 if (h == NULL) 64 if (h == NULL)
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
index 6c817a840..f9b3db81b 100644
--- a/src/datastore/datastore_api.c
+++ b/src/datastore/datastore_api.c
@@ -181,10 +181,6 @@ struct GNUNET_DATASTORE_Handle
181 */ 181 */
182 const struct GNUNET_CONFIGURATION_Handle *cfg; 182 const struct GNUNET_CONFIGURATION_Handle *cfg;
183 183
184 /**
185 * Our scheduler.
186 */
187 struct GNUNET_SCHEDULER_Handle *sched;
188 184
189 /** 185 /**
190 * Current connection to the datastore service. 186 * Current connection to the datastore service.
@@ -247,30 +243,24 @@ struct GNUNET_DATASTORE_Handle
247 * Connect to the datastore service. 243 * Connect to the datastore service.
248 * 244 *
249 * @param cfg configuration to use 245 * @param cfg configuration to use
250 * @param sched scheduler to use
251 * @return handle to use to access the service 246 * @return handle to use to access the service
252 */ 247 */
253struct GNUNET_DATASTORE_Handle * 248struct GNUNET_DATASTORE_Handle *
254GNUNET_DATASTORE_connect (const struct 249GNUNET_DATASTORE_connect (const struct
255 GNUNET_CONFIGURATION_Handle 250 GNUNET_CONFIGURATION_Handle
256 *cfg, 251 *cfg)
257 struct
258 GNUNET_SCHEDULER_Handle
259 *sched)
260{ 252{
261 struct GNUNET_CLIENT_Connection *c; 253 struct GNUNET_CLIENT_Connection *c;
262 struct GNUNET_DATASTORE_Handle *h; 254 struct GNUNET_DATASTORE_Handle *h;
263 255
264 c = GNUNET_CLIENT_connect (sched, "datastore", cfg); 256 c = GNUNET_CLIENT_connect ("datastore", cfg);
265 if (c == NULL) 257 if (c == NULL)
266 return NULL; /* oops */ 258 return NULL; /* oops */
267 h = GNUNET_malloc (sizeof(struct GNUNET_DATASTORE_Handle) + 259 h = GNUNET_malloc (sizeof(struct GNUNET_DATASTORE_Handle) +
268 GNUNET_SERVER_MAX_MESSAGE_SIZE - 1); 260 GNUNET_SERVER_MAX_MESSAGE_SIZE - 1);
269 h->client = c; 261 h->client = c;
270 h->cfg = cfg; 262 h->cfg = cfg;
271 h->sched = sched; 263 h->stats = GNUNET_STATISTICS_create ("datastore-api",
272 h->stats = GNUNET_STATISTICS_create (sched,
273 "datastore-api",
274 cfg); 264 cfg);
275 return h; 265 return h;
276} 266}
@@ -327,8 +317,7 @@ void GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h,
327 } 317 }
328 if (h->reconnect_task != GNUNET_SCHEDULER_NO_TASK) 318 if (h->reconnect_task != GNUNET_SCHEDULER_NO_TASK)
329 { 319 {
330 GNUNET_SCHEDULER_cancel (h->sched, 320 GNUNET_SCHEDULER_cancel (h->reconnect_task);
331 h->reconnect_task);
332 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; 321 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
333 } 322 }
334 while (NULL != (qe = h->queue_head)) 323 while (NULL != (qe = h->queue_head))
@@ -338,7 +327,7 @@ void GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h,
338 } 327 }
339 if (GNUNET_YES == drop) 328 if (GNUNET_YES == drop)
340 { 329 {
341 h->client = GNUNET_CLIENT_connect (h->sched, "datastore", h->cfg); 330 h->client = GNUNET_CLIENT_connect ("datastore", h->cfg);
342 if (h->client != NULL) 331 if (h->client != NULL)
343 { 332 {
344 if (NULL != 333 if (NULL !=
@@ -459,8 +448,7 @@ make_queue_entry (struct GNUNET_DATASTORE_Handle *h,
459 response_proc (ret, NULL); 448 response_proc (ret, NULL);
460 return NULL; 449 return NULL;
461 } 450 }
462 ret->task = GNUNET_SCHEDULER_add_delayed (h->sched, 451 ret->task = GNUNET_SCHEDULER_add_delayed (timeout,
463 timeout,
464 &timeout_queue_entry, 452 &timeout_queue_entry,
465 ret); 453 ret);
466 pos = ret->next; 454 pos = ret->next;
@@ -507,7 +495,7 @@ try_reconnect (void *cls,
507 if (h->retry_time.rel_value > GNUNET_CONSTANTS_SERVICE_TIMEOUT.rel_value) 495 if (h->retry_time.rel_value > GNUNET_CONSTANTS_SERVICE_TIMEOUT.rel_value)
508 h->retry_time = GNUNET_CONSTANTS_SERVICE_TIMEOUT; 496 h->retry_time = GNUNET_CONSTANTS_SERVICE_TIMEOUT;
509 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; 497 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
510 h->client = GNUNET_CLIENT_connect (h->sched, "datastore", h->cfg); 498 h->client = GNUNET_CLIENT_connect ("datastore", h->cfg);
511 if (h->client == NULL) 499 if (h->client == NULL)
512 { 500 {
513 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 501 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -551,8 +539,7 @@ do_disconnect (struct GNUNET_DATASTORE_Handle *h)
551#endif 539#endif
552 GNUNET_CLIENT_disconnect (h->client, GNUNET_NO); 540 GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
553 h->client = NULL; 541 h->client = NULL;
554 h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->sched, 542 h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->retry_time,
555 h->retry_time,
556 &try_reconnect, 543 &try_reconnect,
557 h); 544 h);
558} 545}
@@ -601,8 +588,7 @@ transmit_request (void *cls,
601#endif 588#endif
602 memcpy (buf, &qe[1], msize); 589 memcpy (buf, &qe[1], msize);
603 qe->was_transmitted = GNUNET_YES; 590 qe->was_transmitted = GNUNET_YES;
604 GNUNET_SCHEDULER_cancel (h->sched, 591 GNUNET_SCHEDULER_cancel (qe->task);
605 qe->task);
606 qe->task = GNUNET_SCHEDULER_NO_TASK; 592 qe->task = GNUNET_SCHEDULER_NO_TASK;
607 h->in_receive = GNUNET_YES; 593 h->in_receive = GNUNET_YES;
608 GNUNET_CLIENT_receive (h->client, 594 GNUNET_CLIENT_receive (h->client,
@@ -698,8 +684,7 @@ free_queue_entry (struct GNUNET_DATASTORE_QueueEntry *qe)
698 qe); 684 qe);
699 if (qe->task != GNUNET_SCHEDULER_NO_TASK) 685 if (qe->task != GNUNET_SCHEDULER_NO_TASK)
700 { 686 {
701 GNUNET_SCHEDULER_cancel (h->sched, 687 GNUNET_SCHEDULER_cancel (qe->task);
702 qe->task);
703 qe->task = GNUNET_SCHEDULER_NO_TASK; 688 qe->task = GNUNET_SCHEDULER_NO_TASK;
704 } 689 }
705 h->queue_size--; 690 h->queue_size--;
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index 6c064743e..09df51d9b 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -179,10 +179,6 @@ static GNUNET_SCHEDULER_TaskIdentifier expired_kill_task;
179 */ 179 */
180const struct GNUNET_CONFIGURATION_Handle *cfg; 180const struct GNUNET_CONFIGURATION_Handle *cfg;
181 181
182/**
183 * Our scheduler.
184 */
185struct GNUNET_SCHEDULER_Handle *sched;
186 182
187/** 183/**
188 * Handle for reporting statistics. 184 * Handle for reporting statistics.
@@ -343,8 +339,7 @@ expired_processor (void *cls,
343 if (key == NULL) 339 if (key == NULL)
344 { 340 {
345 expired_kill_task 341 expired_kill_task
346 = GNUNET_SCHEDULER_add_delayed (sched, 342 = GNUNET_SCHEDULER_add_delayed (MAX_EXPIRE_DELAY,
347 MAX_EXPIRE_DELAY,
348 &delete_expired, 343 &delete_expired,
349 NULL); 344 NULL);
350 return GNUNET_SYSERR; 345 return GNUNET_SYSERR;
@@ -1527,7 +1522,6 @@ load_plugin ()
1527 } 1522 }
1528 ret = GNUNET_malloc (sizeof(struct DatastorePlugin)); 1523 ret = GNUNET_malloc (sizeof(struct DatastorePlugin));
1529 ret->env.cfg = cfg; 1524 ret->env.cfg = cfg;
1530 ret->env.sched = sched;
1531 ret->env.duc = &disk_utilization_change_cb; 1525 ret->env.duc = &disk_utilization_change_cb;
1532 ret->env.cls = NULL; 1526 ret->env.cls = NULL;
1533 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1527 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -1625,12 +1619,10 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1625 } 1619 }
1626 if (expired_kill_task != GNUNET_SCHEDULER_NO_TASK) 1620 if (expired_kill_task != GNUNET_SCHEDULER_NO_TASK)
1627 { 1621 {
1628 GNUNET_SCHEDULER_cancel (sched, 1622 GNUNET_SCHEDULER_cancel (expired_kill_task);
1629 expired_kill_task);
1630 expired_kill_task = GNUNET_SCHEDULER_NO_TASK; 1623 expired_kill_task = GNUNET_SCHEDULER_NO_TASK;
1631 } 1624 }
1632 GNUNET_SCHEDULER_add_continuation (sched, 1625 GNUNET_SCHEDULER_add_continuation (&unload_task,
1633 &unload_task,
1634 NULL, 1626 NULL,
1635 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 1627 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
1636} 1628}
@@ -1686,13 +1678,11 @@ cleanup_reservations (void *cls,
1686 * Process datastore requests. 1678 * Process datastore requests.
1687 * 1679 *
1688 * @param cls closure 1680 * @param cls closure
1689 * @param s scheduler to use
1690 * @param server the initialized server 1681 * @param server the initialized server
1691 * @param c configuration to use 1682 * @param c configuration to use
1692 */ 1683 */
1693static void 1684static void
1694run (void *cls, 1685run (void *cls,
1695 struct GNUNET_SCHEDULER_Handle *s,
1696 struct GNUNET_SERVER_Handle *server, 1686 struct GNUNET_SERVER_Handle *server,
1697 const struct GNUNET_CONFIGURATION_Handle *c) 1687 const struct GNUNET_CONFIGURATION_Handle *c)
1698{ 1688{
@@ -1717,7 +1707,6 @@ run (void *cls,
1717 char *fn; 1707 char *fn;
1718 unsigned int bf_size; 1708 unsigned int bf_size;
1719 1709
1720 sched = s;
1721 cfg = c; 1710 cfg = c;
1722 if (GNUNET_OK != 1711 if (GNUNET_OK !=
1723 GNUNET_CONFIGURATION_get_value_number (cfg, 1712 GNUNET_CONFIGURATION_get_value_number (cfg,
@@ -1729,7 +1718,7 @@ run (void *cls,
1729 "DATASTORE"); 1718 "DATASTORE");
1730 return; 1719 return;
1731 } 1720 }
1732 stats = GNUNET_STATISTICS_create (sched, "datastore", cfg); 1721 stats = GNUNET_STATISTICS_create ("datastore", cfg);
1733 GNUNET_STATISTICS_set (stats, 1722 GNUNET_STATISTICS_set (stats,
1734 gettext_noop ("# quota"), 1723 gettext_noop ("# quota"),
1735 quota, 1724 quota,
@@ -1790,11 +1779,9 @@ run (void *cls,
1790 GNUNET_SERVER_disconnect_notify (server, &cleanup_reservations, NULL); 1779 GNUNET_SERVER_disconnect_notify (server, &cleanup_reservations, NULL);
1791 GNUNET_SERVER_add_handlers (server, handlers); 1780 GNUNET_SERVER_add_handlers (server, handlers);
1792 expired_kill_task 1781 expired_kill_task
1793 = GNUNET_SCHEDULER_add_with_priority (sched, 1782 = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
1794 GNUNET_SCHEDULER_PRIORITY_IDLE,
1795 &delete_expired, NULL); 1783 &delete_expired, NULL);
1796 GNUNET_SCHEDULER_add_delayed (sched, 1784 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
1797 GNUNET_TIME_UNIT_FOREVER_REL,
1798 &cleaning_task, NULL); 1785 &cleaning_task, NULL);
1799} 1786}
1800 1787
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c
index 8dd7e6680..1f7c828e0 100644
--- a/src/datastore/perf_datastore_api.c
+++ b/src/datastore/perf_datastore_api.c
@@ -93,7 +93,6 @@ enum RunPhase
93 93
94struct CpsRunContext 94struct CpsRunContext
95{ 95{
96 struct GNUNET_SCHEDULER_Handle *sched;
97 const struct GNUNET_CONFIGURATION_Handle *cfg; 96 const struct GNUNET_CONFIGURATION_Handle *cfg;
98 enum RunPhase phase; 97 enum RunPhase phase;
99 int j; 98 int j;
@@ -140,8 +139,7 @@ check_success (void *cls,
140 else 139 else
141 crc->phase = RP_CUT; 140 crc->phase = RP_CUT;
142 } 141 }
143 GNUNET_SCHEDULER_add_continuation (crc->sched, 142 GNUNET_SCHEDULER_add_continuation (&run_continuation,
144 &run_continuation,
145 crc, 143 crc,
146 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 144 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
147} 145}
@@ -166,8 +164,7 @@ remove_next(void *cls,
166 fprintf (stderr, "D"); 164 fprintf (stderr, "D");
167#endif 165#endif
168 GNUNET_assert (GNUNET_OK == success); 166 GNUNET_assert (GNUNET_OK == success);
169 GNUNET_SCHEDULER_add_continuation (crc->sched, 167 GNUNET_SCHEDULER_add_continuation (&run_continuation,
170 &run_continuation,
171 crc, 168 crc,
172 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 169 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
173} 170}
@@ -212,14 +209,12 @@ delete_value (void *cls,
212 if (stored_bytes < MAX_SIZE) 209 if (stored_bytes < MAX_SIZE)
213 { 210 {
214 crc->phase = RP_REPORT; 211 crc->phase = RP_REPORT;
215 GNUNET_SCHEDULER_add_continuation (crc->sched, 212 GNUNET_SCHEDULER_add_continuation (&run_continuation,
216 &run_continuation,
217 crc, 213 crc,
218 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 214 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
219 return; 215 return;
220 } 216 }
221 GNUNET_SCHEDULER_add_with_priority (crc->sched, 217 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_HIGH,
222 GNUNET_SCHEDULER_PRIORITY_HIGH,
223 &do_delete, 218 &do_delete,
224 crc); 219 crc);
225 return; 220 return;
@@ -298,8 +293,7 @@ run_continuation (void *cls,
298 1000 * stored_ops / (1 + GNUNET_TIME_absolute_get_duration(start_time).rel_value)); 293 1000 * stored_ops / (1 + GNUNET_TIME_absolute_get_duration(start_time).rel_value));
299 crc->phase = RP_PUT; 294 crc->phase = RP_PUT;
300 crc->j = 0; 295 crc->j = 0;
301 GNUNET_SCHEDULER_add_continuation (crc->sched, 296 GNUNET_SCHEDULER_add_continuation (&run_continuation,
302 &run_continuation,
303 crc, 297 crc,
304 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 298 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
305 break; 299 break;
@@ -330,8 +324,7 @@ run_tests (void *cls,
330 GNUNET_free (crc); 324 GNUNET_free (crc);
331 return; 325 return;
332 } 326 }
333 GNUNET_SCHEDULER_add_continuation (crc->sched, 327 GNUNET_SCHEDULER_add_continuation (&run_continuation,
334 &run_continuation,
335 crc, 328 crc,
336 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 329 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
337} 330}
@@ -339,7 +332,6 @@ run_tests (void *cls,
339 332
340static void 333static void
341run (void *cls, 334run (void *cls,
342 struct GNUNET_SCHEDULER_Handle *sched,
343 char *const *args, 335 char *const *args,
344 const char *cfgfile, 336 const char *cfgfile,
345 const struct GNUNET_CONFIGURATION_Handle *cfg) 337 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -347,10 +339,9 @@ run (void *cls,
347 struct CpsRunContext *crc; 339 struct CpsRunContext *crc;
348 static GNUNET_HashCode zkey; 340 static GNUNET_HashCode zkey;
349 341
350 datastore = GNUNET_DATASTORE_connect (cfg, sched); 342 datastore = GNUNET_DATASTORE_connect (cfg);
351 start_time = GNUNET_TIME_absolute_get (); 343 start_time = GNUNET_TIME_absolute_get ();
352 crc = GNUNET_malloc(sizeof(struct CpsRunContext)); 344 crc = GNUNET_malloc(sizeof(struct CpsRunContext));
353 crc->sched = sched;
354 crc->cfg = cfg; 345 crc->cfg = cfg;
355 crc->phase = RP_PUT; 346 crc->phase = RP_PUT;
356 if (NULL == 347 if (NULL ==
diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c
index d870c0da3..b60bb07c6 100644
--- a/src/datastore/perf_plugin_datastore.c
+++ b/src/datastore/perf_plugin_datastore.c
@@ -72,7 +72,6 @@ struct CpsRunContext
72 unsigned int i; 72 unsigned int i;
73 struct GNUNET_TIME_Absolute start; 73 struct GNUNET_TIME_Absolute start;
74 struct GNUNET_TIME_Absolute end; 74 struct GNUNET_TIME_Absolute end;
75 struct GNUNET_SCHEDULER_Handle *sched;
76 const struct GNUNET_CONFIGURATION_Handle *cfg; 75 const struct GNUNET_CONFIGURATION_Handle *cfg;
77 struct GNUNET_DATASTORE_PluginFunctions * api; 76 struct GNUNET_DATASTORE_PluginFunctions * api;
78 const char *msg; 77 const char *msg;
@@ -183,8 +182,7 @@ iterateDummy (void *cls,
183 else 182 else
184 crc->phase = RP_PUT; 183 crc->phase = RP_PUT;
185 } 184 }
186 GNUNET_SCHEDULER_add_after (crc->sched, 185 GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK,
187 GNUNET_SCHEDULER_NO_TASK,
188 &test, crc); 186 &test, crc);
189 return GNUNET_OK; 187 return GNUNET_OK;
190 } 188 }
@@ -267,8 +265,7 @@ test (void *cls,
267 (unsigned int) PUT_10); 265 (unsigned int) PUT_10);
268 crc->i++; 266 crc->i++;
269 crc->phase = RP_LP_GET; 267 crc->phase = RP_LP_GET;
270 GNUNET_SCHEDULER_add_after (crc->sched, 268 GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK,
271 GNUNET_SCHEDULER_NO_TASK,
272 &test, crc); 269 &test, crc);
273 break; 270 break;
274 case RP_LP_GET: 271 case RP_LP_GET:
@@ -313,8 +310,7 @@ test (void *cls,
313 break; 310 break;
314 case RP_DONE: 311 case RP_DONE:
315 crc->api->drop (crc->api->cls); 312 crc->api->drop (crc->api->cls);
316 GNUNET_SCHEDULER_add_with_priority (crc->sched, 313 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
317 GNUNET_SCHEDULER_PRIORITY_IDLE,
318 &cleaning_task, crc); 314 &cleaning_task, crc);
319 break; 315 break;
320 } 316 }
@@ -325,8 +321,7 @@ test (void *cls,
325 * Load the datastore plugin. 321 * Load the datastore plugin.
326 */ 322 */
327static struct GNUNET_DATASTORE_PluginFunctions * 323static struct GNUNET_DATASTORE_PluginFunctions *
328load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg, 324load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg)
329 struct GNUNET_SCHEDULER_Handle *sched)
330{ 325{
331 static struct GNUNET_DATASTORE_PluginEnvironment env; 326 static struct GNUNET_DATASTORE_PluginEnvironment env;
332 struct GNUNET_DATASTORE_PluginFunctions * ret; 327 struct GNUNET_DATASTORE_PluginFunctions * ret;
@@ -344,7 +339,6 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg,
344 return NULL; 339 return NULL;
345 } 340 }
346 env.cfg = cfg; 341 env.cfg = cfg;
347 env.sched = sched;
348 env.duc = &disk_utilization_change_cb; 342 env.duc = &disk_utilization_change_cb;
349 env.cls = NULL; 343 env.cls = NULL;
350 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 344 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -365,7 +359,6 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg,
365 359
366static void 360static void
367run (void *cls, 361run (void *cls,
368 struct GNUNET_SCHEDULER_Handle *s,
369 char *const *args, 362 char *const *args,
370 const char *cfgfile, 363 const char *cfgfile,
371 const struct GNUNET_CONFIGURATION_Handle *c) 364 const struct GNUNET_CONFIGURATION_Handle *c)
@@ -373,7 +366,7 @@ run (void *cls,
373 struct GNUNET_DATASTORE_PluginFunctions *api; 366 struct GNUNET_DATASTORE_PluginFunctions *api;
374 struct CpsRunContext *crc; 367 struct CpsRunContext *crc;
375 368
376 api = load_plugin (c, s); 369 api = load_plugin (c);
377 if (api == NULL) 370 if (api == NULL)
378 { 371 {
379 fprintf (stderr, 372 fprintf (stderr,
@@ -382,11 +375,9 @@ run (void *cls,
382 } 375 }
383 crc = GNUNET_malloc(sizeof(struct CpsRunContext)); 376 crc = GNUNET_malloc(sizeof(struct CpsRunContext));
384 crc->api = api; 377 crc->api = api;
385 crc->sched = s;
386 crc->cfg = c; 378 crc->cfg = c;
387 crc->phase = RP_PUT; 379 crc->phase = RP_PUT;
388 GNUNET_SCHEDULER_add_now (crc->sched, 380 GNUNET_SCHEDULER_add_now (&test, crc);
389 &test, crc);
390} 381}
391 382
392 383
diff --git a/src/datastore/plugin_datastore.h b/src/datastore/plugin_datastore.h
index fa08501cc..cb8686c62 100644
--- a/src/datastore/plugin_datastore.h
+++ b/src/datastore/plugin_datastore.h
@@ -64,10 +64,6 @@ struct GNUNET_DATASTORE_PluginEnvironment
64 */ 64 */
65 const struct GNUNET_CONFIGURATION_Handle *cfg; 65 const struct GNUNET_CONFIGURATION_Handle *cfg;
66 66
67 /**
68 * Scheduler to use.
69 */
70 struct GNUNET_SCHEDULER_Handle *sched;
71 67
72 /** 68 /**
73 * Function to call on disk utilization change. 69 * Function to call on disk utilization change.
diff --git a/src/datastore/plugin_datastore_mysql.c b/src/datastore/plugin_datastore_mysql.c
index 0aefbb75d..ae6a98c6e 100644
--- a/src/datastore/plugin_datastore_mysql.c
+++ b/src/datastore/plugin_datastore_mysql.c
@@ -1258,8 +1258,7 @@ mysql_plugin_next_request (void *next_cls,
1258 if (GNUNET_YES == end_it) 1258 if (GNUNET_YES == end_it)
1259 nrc->end_it = GNUNET_YES; 1259 nrc->end_it = GNUNET_YES;
1260 nrc->plugin->next_task_nc = nrc; 1260 nrc->plugin->next_task_nc = nrc;
1261 nrc->plugin->next_task = GNUNET_SCHEDULER_add_now (nrc->plugin->env->sched, 1261 nrc->plugin->next_task = GNUNET_SCHEDULER_add_now (&mysql_next_request_cont,
1262 &mysql_next_request_cont,
1263 nrc); 1262 nrc);
1264} 1263}
1265 1264
@@ -1968,8 +1967,7 @@ libgnunet_plugin_datastore_mysql_done (void *cls)
1968 iclose (plugin); 1967 iclose (plugin);
1969 if (plugin->next_task != GNUNET_SCHEDULER_NO_TASK) 1968 if (plugin->next_task != GNUNET_SCHEDULER_NO_TASK)
1970 { 1969 {
1971 GNUNET_SCHEDULER_cancel (plugin->env->sched, 1970 GNUNET_SCHEDULER_cancel (plugin->next_task);
1972 plugin->next_task);
1973 plugin->next_task = GNUNET_SCHEDULER_NO_TASK; 1971 plugin->next_task = GNUNET_SCHEDULER_NO_TASK;
1974 plugin->next_task_nc->prep (plugin->next_task_nc->prep_cls, NULL); 1972 plugin->next_task_nc->prep (plugin->next_task_nc->prep_cls, NULL);
1975 GNUNET_free (plugin->next_task_nc); 1973 GNUNET_free (plugin->next_task_nc);
diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c
index 44a01fcb8..9886b1c8b 100644
--- a/src/datastore/plugin_datastore_postgres.c
+++ b/src/datastore/plugin_datastore_postgres.c
@@ -847,8 +847,7 @@ postgres_plugin_next_request (void *next_cls,
847 if (GNUNET_YES == end_it) 847 if (GNUNET_YES == end_it)
848 nrc->end_it = GNUNET_YES; 848 nrc->end_it = GNUNET_YES;
849 nrc->plugin->next_task_nc = nrc; 849 nrc->plugin->next_task_nc = nrc;
850 nrc->plugin->next_task = GNUNET_SCHEDULER_add_now (nrc->plugin->env->sched, 850 nrc->plugin->next_task = GNUNET_SCHEDULER_add_now (&postgres_next_request_cont,
851 &postgres_next_request_cont,
852 nrc); 851 nrc);
853} 852}
854 853
@@ -1358,8 +1357,7 @@ libgnunet_plugin_datastore_postgres_done (void *cls)
1358 1357
1359 if (plugin->next_task != GNUNET_SCHEDULER_NO_TASK) 1358 if (plugin->next_task != GNUNET_SCHEDULER_NO_TASK)
1360 { 1359 {
1361 GNUNET_SCHEDULER_cancel (plugin->env->sched, 1360 GNUNET_SCHEDULER_cancel (plugin->next_task);
1362 plugin->next_task);
1363 plugin->next_task = GNUNET_SCHEDULER_NO_TASK; 1361 plugin->next_task = GNUNET_SCHEDULER_NO_TASK;
1364 GNUNET_free (plugin->next_task_nc); 1362 GNUNET_free (plugin->next_task_nc);
1365 plugin->next_task_nc = NULL; 1363 plugin->next_task_nc = NULL;
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c
index 01df7b670..b9edb4e57 100644
--- a/src/datastore/plugin_datastore_sqlite.c
+++ b/src/datastore/plugin_datastore_sqlite.c
@@ -623,8 +623,7 @@ sqlite_next_request (void *next_cls,
623 if (GNUNET_YES == end_it) 623 if (GNUNET_YES == end_it)
624 nc->end_it = GNUNET_YES; 624 nc->end_it = GNUNET_YES;
625 nc->plugin->next_task_nc = nc; 625 nc->plugin->next_task_nc = nc;
626 nc->plugin->next_task = GNUNET_SCHEDULER_add_now (nc->plugin->env->sched, 626 nc->plugin->next_task = GNUNET_SCHEDULER_add_now (&sqlite_next_request_cont,
627 &sqlite_next_request_cont,
628 nc); 627 nc);
629} 628}
630 629
@@ -1598,8 +1597,7 @@ libgnunet_plugin_datastore_sqlite_done (void *cls)
1598 1597
1599 if (plugin->next_task != GNUNET_SCHEDULER_NO_TASK) 1598 if (plugin->next_task != GNUNET_SCHEDULER_NO_TASK)
1600 { 1599 {
1601 GNUNET_SCHEDULER_cancel (plugin->env->sched, 1600 GNUNET_SCHEDULER_cancel (plugin->next_task);
1602 plugin->next_task);
1603 plugin->next_task = GNUNET_SCHEDULER_NO_TASK; 1601 plugin->next_task = GNUNET_SCHEDULER_NO_TASK;
1604 plugin->next_task_nc->prep (plugin->next_task_nc->prep_cls, NULL); 1602 plugin->next_task_nc->prep (plugin->next_task_nc->prep_cls, NULL);
1605 GNUNET_free (plugin->next_task_nc); 1603 GNUNET_free (plugin->next_task_nc);
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c
index 3b7202005..06abc0c0f 100644
--- a/src/datastore/test_datastore_api.c
+++ b/src/datastore/test_datastore_api.c
@@ -125,7 +125,6 @@ struct CpsRunContext
125 GNUNET_HashCode key; 125 GNUNET_HashCode key;
126 int i; 126 int i;
127 int rid; 127 int rid;
128 struct GNUNET_SCHEDULER_Handle *sched;
129 const struct GNUNET_CONFIGURATION_Handle *cfg; 128 const struct GNUNET_CONFIGURATION_Handle *cfg;
130 void *data; 129 void *data;
131 size_t size; 130 size_t size;
@@ -150,13 +149,12 @@ check_success (void *cls,
150 ok = 42; 149 ok = 42;
151 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 150 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
152 "%s\n", msg); 151 "%s\n", msg);
153 GNUNET_SCHEDULER_shutdown (crc->sched); 152 GNUNET_SCHEDULER_shutdown ();
154 return; 153 return;
155 } 154 }
156 GNUNET_free_non_null (crc->data); 155 GNUNET_free_non_null (crc->data);
157 crc->data = NULL; 156 crc->data = NULL;
158 GNUNET_SCHEDULER_add_continuation (crc->sched, 157 GNUNET_SCHEDULER_add_continuation (&run_continuation,
159 &run_continuation,
160 crc, 158 crc,
161 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 159 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
162} 160}
@@ -173,8 +171,7 @@ get_reserved (void *cls,
173 "%s\n", msg); 171 "%s\n", msg);
174 GNUNET_assert (0 < success); 172 GNUNET_assert (0 < success);
175 crc->rid = success; 173 crc->rid = success;
176 GNUNET_SCHEDULER_add_continuation (crc->sched, 174 GNUNET_SCHEDULER_add_continuation (&run_continuation,
177 &run_continuation,
178 crc, 175 crc,
179 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 176 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
180} 177}
@@ -201,8 +198,7 @@ check_value (void *cls,
201 crc->phase = RP_DEL; 198 crc->phase = RP_DEL;
202 crc->i = ITERATIONS; 199 crc->i = ITERATIONS;
203 } 200 }
204 GNUNET_SCHEDULER_add_continuation (crc->sched, 201 GNUNET_SCHEDULER_add_continuation (&run_continuation,
205 &run_continuation,
206 crc, 202 crc,
207 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 203 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
208 return; 204 return;
@@ -243,8 +239,7 @@ delete_value (void *cls,
243 { 239 {
244 crc->phase = RP_DO_DEL; 240 crc->phase = RP_DO_DEL;
245 } 241 }
246 GNUNET_SCHEDULER_add_continuation (crc->sched, 242 GNUNET_SCHEDULER_add_continuation (&run_continuation,
247 &run_continuation,
248 crc, 243 crc,
249 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 244 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
250 return; 245 return;
@@ -275,8 +270,7 @@ check_nothing (void *cls,
275 { 270 {
276 crc->phase = RP_RESERVE; 271 crc->phase = RP_RESERVE;
277 } 272 }
278 GNUNET_SCHEDULER_add_continuation (crc->sched, 273 GNUNET_SCHEDULER_add_continuation (&run_continuation,
279 &run_continuation,
280 crc, 274 crc,
281 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 275 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
282} 276}
@@ -309,8 +303,7 @@ check_multiple (void *cls,
309 { 303 {
310 crc->phase = RP_UPDATE; 304 crc->phase = RP_UPDATE;
311 } 305 }
312 GNUNET_SCHEDULER_add_continuation (crc->sched, 306 GNUNET_SCHEDULER_add_continuation (&run_continuation,
313 &run_continuation,
314 crc, 307 crc,
315 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 308 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
316 return; 309 return;
@@ -364,8 +357,7 @@ check_update (void *cls,
364 { 357 {
365 crc->phase = RP_DONE; 358 crc->phase = RP_DONE;
366 } 359 }
367 GNUNET_SCHEDULER_add_continuation (crc->sched, 360 GNUNET_SCHEDULER_add_continuation (&run_continuation,
368 &run_continuation,
369 crc, 361 crc,
370 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 362 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
371 return; 363 return;
@@ -597,8 +589,7 @@ run_tests (void *cls,
597 GNUNET_free (crc); 589 GNUNET_free (crc);
598 return; 590 return;
599 } 591 }
600 GNUNET_SCHEDULER_add_continuation (crc->sched, 592 GNUNET_SCHEDULER_add_continuation (&run_continuation,
601 &run_continuation,
602 crc, 593 crc,
603 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 594 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
604} 595}
@@ -606,7 +597,6 @@ run_tests (void *cls,
606 597
607static void 598static void
608run (void *cls, 599run (void *cls,
609 struct GNUNET_SCHEDULER_Handle *sched,
610 char *const *args, 600 char *const *args,
611 const char *cfgfile, 601 const char *cfgfile,
612 const struct GNUNET_CONFIGURATION_Handle *cfg) 602 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -615,11 +605,10 @@ run (void *cls,
615 static GNUNET_HashCode zkey; 605 static GNUNET_HashCode zkey;
616 606
617 crc = GNUNET_malloc(sizeof(struct CpsRunContext)); 607 crc = GNUNET_malloc(sizeof(struct CpsRunContext));
618 crc->sched = sched;
619 crc->cfg = cfg; 608 crc->cfg = cfg;
620 crc->phase = RP_PUT; 609 crc->phase = RP_PUT;
621 now = GNUNET_TIME_absolute_get (); 610 now = GNUNET_TIME_absolute_get ();
622 datastore = GNUNET_DATASTORE_connect (cfg, sched); 611 datastore = GNUNET_DATASTORE_connect (cfg);
623 if (NULL == 612 if (NULL ==
624 GNUNET_DATASTORE_put (datastore, 0, 613 GNUNET_DATASTORE_put (datastore, 0,
625 &zkey, 4, "TEST", 614 &zkey, 4, "TEST",
diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c
index 81450d12a..d17d8fbc8 100644
--- a/src/datastore/test_datastore_api_management.c
+++ b/src/datastore/test_datastore_api_management.c
@@ -109,7 +109,6 @@ struct CpsRunContext
109 GNUNET_HashCode key; 109 GNUNET_HashCode key;
110 int i; 110 int i;
111 int found; 111 int found;
112 struct GNUNET_SCHEDULER_Handle *sched;
113 const struct GNUNET_CONFIGURATION_Handle *cfg; 112 const struct GNUNET_CONFIGURATION_Handle *cfg;
114 void *data; 113 void *data;
115 enum RunPhase phase; 114 enum RunPhase phase;
@@ -133,8 +132,7 @@ check_success (void *cls,
133 GNUNET_assert (GNUNET_OK == success); 132 GNUNET_assert (GNUNET_OK == success);
134 GNUNET_free_non_null (crc->data); 133 GNUNET_free_non_null (crc->data);
135 crc->data = NULL; 134 crc->data = NULL;
136 GNUNET_SCHEDULER_add_continuation (crc->sched, 135 GNUNET_SCHEDULER_add_continuation (&run_continuation,
137 &run_continuation,
138 crc, 136 crc,
139 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 137 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
140} 138}
@@ -170,8 +168,7 @@ check_value (void *cls,
170 } 168 }
171 if (0 == crc->i) 169 if (0 == crc->i)
172 crc->phase = RP_DONE; 170 crc->phase = RP_DONE;
173 GNUNET_SCHEDULER_add_continuation (crc->sched, 171 GNUNET_SCHEDULER_add_continuation (&run_continuation,
174 &run_continuation,
175 crc, 172 crc,
176 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 173 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
177 return; 174 return;
@@ -204,8 +201,7 @@ check_nothing (void *cls,
204 GNUNET_assert (key == NULL); 201 GNUNET_assert (key == NULL);
205 if (0 == --crc->i) 202 if (0 == --crc->i)
206 crc->phase = RP_DONE; 203 crc->phase = RP_DONE;
207 GNUNET_SCHEDULER_add_continuation (crc->sched, 204 GNUNET_SCHEDULER_add_continuation (&run_continuation,
208 &run_continuation,
209 crc, 205 crc,
210 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 206 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
211} 207}
@@ -307,8 +303,7 @@ run_tests (void *cls,
307 GNUNET_free (crc); 303 GNUNET_free (crc);
308 return; 304 return;
309 } 305 }
310 GNUNET_SCHEDULER_add_continuation (crc->sched, 306 GNUNET_SCHEDULER_add_continuation (&run_continuation,
311 &run_continuation,
312 crc, 307 crc,
313 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 308 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
314} 309}
@@ -316,7 +311,6 @@ run_tests (void *cls,
316 311
317static void 312static void
318run (void *cls, 313run (void *cls,
319 struct GNUNET_SCHEDULER_Handle *sched,
320 char *const *args, 314 char *const *args,
321 const char *cfgfile, 315 const char *cfgfile,
322 const struct GNUNET_CONFIGURATION_Handle *cfg) 316 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -325,11 +319,10 @@ run (void *cls,
325 static GNUNET_HashCode zkey; 319 static GNUNET_HashCode zkey;
326 320
327 crc = GNUNET_malloc(sizeof(struct CpsRunContext)); 321 crc = GNUNET_malloc(sizeof(struct CpsRunContext));
328 crc->sched = sched;
329 crc->cfg = cfg; 322 crc->cfg = cfg;
330 crc->phase = RP_PUT; 323 crc->phase = RP_PUT;
331 now = GNUNET_TIME_absolute_get (); 324 now = GNUNET_TIME_absolute_get ();
332 datastore = GNUNET_DATASTORE_connect (cfg, sched); 325 datastore = GNUNET_DATASTORE_connect (cfg);
333 if (NULL == 326 if (NULL ==
334 GNUNET_DATASTORE_put (datastore, 0, 327 GNUNET_DATASTORE_put (datastore, 0,
335 &zkey, 4, "TEST", 328 &zkey, 4, "TEST",
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c
index d04e4d206..68e662269 100644
--- a/src/dht/dht_api.c
+++ b/src/dht/dht_api.c
@@ -149,10 +149,6 @@ struct GNUNET_DHT_RouteHandle
149 */ 149 */
150struct GNUNET_DHT_Handle 150struct GNUNET_DHT_Handle
151{ 151{
152 /**
153 * Our scheduler.
154 */
155 struct GNUNET_SCHEDULER_Handle *sched;
156 152
157 /** 153 /**
158 * Configuration to use. 154 * Configuration to use.
@@ -224,7 +220,7 @@ try_connect (struct GNUNET_DHT_Handle *handle)
224{ 220{
225 if (handle->client != NULL) 221 if (handle->client != NULL)
226 return GNUNET_OK; 222 return GNUNET_OK;
227 handle->client = GNUNET_CLIENT_connect (handle->sched, "dht", handle->cfg); 223 handle->client = GNUNET_CLIENT_connect ("dht", handle->cfg);
228 if (handle->client == NULL) 224 if (handle->client == NULL)
229 { 225 {
230 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 226 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -359,14 +355,12 @@ transmit_pending (void *cls,
359 head); 355 head);
360 if (head->timeout_task != GNUNET_SCHEDULER_NO_TASK) 356 if (head->timeout_task != GNUNET_SCHEDULER_NO_TASK)
361 { 357 {
362 GNUNET_SCHEDULER_cancel (handle->sched, 358 GNUNET_SCHEDULER_cancel (head->timeout_task);
363 head->timeout_task);
364 head->timeout_task = GNUNET_SCHEDULER_NO_TASK; 359 head->timeout_task = GNUNET_SCHEDULER_NO_TASK;
365 } 360 }
366 if (NULL != head->cont) 361 if (NULL != head->cont)
367 { 362 {
368 GNUNET_SCHEDULER_add_continuation (handle->sched, 363 GNUNET_SCHEDULER_add_continuation (head->cont,
369 head->cont,
370 head->cont_cls, 364 head->cont_cls,
371 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 365 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
372 head->cont = NULL; 366 head->cont = NULL;
@@ -527,7 +521,6 @@ service_message_handler (void *cls,
527/** 521/**
528 * Initialize the connection with the DHT service. 522 * Initialize the connection with the DHT service.
529 * 523 *
530 * @param sched scheduler to use
531 * @param cfg configuration to use 524 * @param cfg configuration to use
532 * @param ht_len size of the internal hash table to use for 525 * @param ht_len size of the internal hash table to use for
533 * processing multiple GET/FIND requests in parallel 526 * processing multiple GET/FIND requests in parallel
@@ -535,15 +528,13 @@ service_message_handler (void *cls,
535 * @return handle to the DHT service, or NULL on error 528 * @return handle to the DHT service, or NULL on error
536 */ 529 */
537struct GNUNET_DHT_Handle * 530struct GNUNET_DHT_Handle *
538GNUNET_DHT_connect (struct GNUNET_SCHEDULER_Handle *sched, 531GNUNET_DHT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
539 const struct GNUNET_CONFIGURATION_Handle *cfg,
540 unsigned int ht_len) 532 unsigned int ht_len)
541{ 533{
542 struct GNUNET_DHT_Handle *handle; 534 struct GNUNET_DHT_Handle *handle;
543 535
544 handle = GNUNET_malloc (sizeof (struct GNUNET_DHT_Handle)); 536 handle = GNUNET_malloc (sizeof (struct GNUNET_DHT_Handle));
545 handle->cfg = cfg; 537 handle->cfg = cfg;
546 handle->sched = sched;
547 handle->uid_gen = GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); 538 handle->uid_gen = GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
548 handle->active_requests = GNUNET_CONTAINER_multihashmap_create (ht_len); 539 handle->active_requests = GNUNET_CONTAINER_multihashmap_create (ht_len);
549 if (GNUNET_NO == try_connect (handle)) 540 if (GNUNET_NO == try_connect (handle))
@@ -578,11 +569,9 @@ GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle)
578 pm); 569 pm);
579 GNUNET_assert (GNUNET_YES == pm->free_on_send); 570 GNUNET_assert (GNUNET_YES == pm->free_on_send);
580 if (GNUNET_SCHEDULER_NO_TASK != pm->timeout_task) 571 if (GNUNET_SCHEDULER_NO_TASK != pm->timeout_task)
581 GNUNET_SCHEDULER_cancel (handle->sched, 572 GNUNET_SCHEDULER_cancel (pm->timeout_task);
582 pm->timeout_task);
583 if (NULL != pm->cont) 573 if (NULL != pm->cont)
584 GNUNET_SCHEDULER_add_continuation (handle->sched, 574 GNUNET_SCHEDULER_add_continuation (pm->cont,
585 pm->cont,
586 pm->cont_cls, 575 pm->cont_cls,
587 GNUNET_SCHEDULER_REASON_TIMEOUT); 576 GNUNET_SCHEDULER_REASON_TIMEOUT);
588 pm->in_pending_queue = GNUNET_NO; 577 pm->in_pending_queue = GNUNET_NO;
@@ -713,8 +702,7 @@ GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle,
713 { 702 {
714 route_handle = NULL; 703 route_handle = NULL;
715 pending->free_on_send = GNUNET_YES; 704 pending->free_on_send = GNUNET_YES;
716 pending->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->sched, 705 pending->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout,
717 timeout,
718 &timeout_route_request, 706 &timeout_route_request,
719 pending); 707 pending);
720 } 708 }
diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c
index 649d8ff13..b74e8a367 100644
--- a/src/dht/gnunet-dht-driver.c
+++ b/src/dht/gnunet-dht-driver.c
@@ -503,10 +503,6 @@ static unsigned long long peers_left;
503 */ 503 */
504static struct GNUNET_TESTING_PeerGroup *pg; 504static struct GNUNET_TESTING_PeerGroup *pg;
505 505
506/**
507 * Global scheduler, used for all GNUNET_SCHEDULER_* functions.
508 */
509static struct GNUNET_SCHEDULER_Handle *sched;
510 506
511/** 507/**
512 * Global config handle. 508 * Global config handle.
@@ -743,7 +739,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
743 while (test_put != NULL) 739 while (test_put != NULL)
744 { 740 {
745 if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK) 741 if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
746 GNUNET_SCHEDULER_cancel(sched, test_put->disconnect_task); 742 GNUNET_SCHEDULER_cancel(test_put->disconnect_task);
747 if (test_put->dht_handle != NULL) 743 if (test_put->dht_handle != NULL)
748 GNUNET_DHT_disconnect(test_put->dht_handle); 744 GNUNET_DHT_disconnect(test_put->dht_handle);
749 test_put = test_put->next; 745 test_put = test_put->next;
@@ -752,7 +748,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
752 while (test_get != NULL) 748 while (test_get != NULL)
753 { 749 {
754 if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK) 750 if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
755 GNUNET_SCHEDULER_cancel(sched, test_get->disconnect_task); 751 GNUNET_SCHEDULER_cancel(test_get->disconnect_task);
756 if (test_get->get_handle != NULL) 752 if (test_get->get_handle != NULL)
757 GNUNET_DHT_get_stop(test_get->get_handle); 753 GNUNET_DHT_get_stop(test_get->get_handle);
758 if (test_get->dht_handle != NULL) 754 if (test_get->dht_handle != NULL)
@@ -813,7 +809,7 @@ log_topology_cb (void *cls,
813 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Topology iteration (%u/%u) finished (%u connections, %u peers)\n", topo_ctx->current_iteration, topo_ctx->total_iterations, topo_ctx->total_connections, topo_ctx->total_peers); 809 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Topology iteration (%u/%u) finished (%u connections, %u peers)\n", topo_ctx->current_iteration, topo_ctx->total_iterations, topo_ctx->total_connections, topo_ctx->total_peers);
814 dhtlog_handle->update_topology(topo_ctx->total_connections); 810 dhtlog_handle->update_topology(topo_ctx->total_connections);
815 if (topo_ctx->cont != NULL) 811 if (topo_ctx->cont != NULL)
816 GNUNET_SCHEDULER_add_now (sched, topo_ctx->cont, topo_ctx->cls); 812 GNUNET_SCHEDULER_add_now (topo_ctx->cont, topo_ctx->cls);
817 if (topo_ctx->peers_seen != NULL) 813 if (topo_ctx->peers_seen != NULL)
818 GNUNET_CONTAINER_multihashmap_destroy(topo_ctx->peers_seen); 814 GNUNET_CONTAINER_multihashmap_destroy(topo_ctx->peers_seen);
819 GNUNET_free(topo_ctx); 815 GNUNET_free(topo_ctx);
@@ -854,7 +850,7 @@ stats_finished (void *cls, int result)
854 fprintf(stderr, "Finished getting all peers statistics, iterating!\n"); 850 fprintf(stderr, "Finished getting all peers statistics, iterating!\n");
855 GNUNET_CONTAINER_multihashmap_iterate(stats_map, &stats_iterate, NULL); 851 GNUNET_CONTAINER_multihashmap_iterate(stats_map, &stats_iterate, NULL);
856 GNUNET_CONTAINER_multihashmap_destroy(stats_map); 852 GNUNET_CONTAINER_multihashmap_destroy(stats_map);
857 GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); 853 GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
858} 854}
859 855
860/** 856/**
@@ -969,7 +965,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
969 while (test_put != NULL) 965 while (test_put != NULL)
970 { 966 {
971 if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK) 967 if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
972 GNUNET_SCHEDULER_cancel(sched, test_put->disconnect_task); 968 GNUNET_SCHEDULER_cancel(test_put->disconnect_task);
973 if (test_put->dht_handle != NULL) 969 if (test_put->dht_handle != NULL)
974 GNUNET_DHT_disconnect(test_put->dht_handle); 970 GNUNET_DHT_disconnect(test_put->dht_handle);
975 test_put = test_put->next; 971 test_put = test_put->next;
@@ -978,7 +974,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
978 while (test_get != NULL) 974 while (test_get != NULL)
979 { 975 {
980 if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK) 976 if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
981 GNUNET_SCHEDULER_cancel(sched, test_get->disconnect_task); 977 GNUNET_SCHEDULER_cancel(test_get->disconnect_task);
982 if (test_get->get_handle != NULL) 978 if (test_get->get_handle != NULL)
983 GNUNET_DHT_get_stop(test_get->get_handle); 979 GNUNET_DHT_get_stop(test_get->get_handle);
984 if (test_get->dht_handle != NULL) 980 if (test_get->dht_handle != NULL)
@@ -1067,7 +1063,7 @@ decrement_find_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
1067 if ((0 == test_find_peer->find_peer_context->total) && 1063 if ((0 == test_find_peer->find_peer_context->total) &&
1068 (GNUNET_TIME_absolute_get_remaining(test_find_peer->find_peer_context->endtime).rel_value > 60)) 1064 (GNUNET_TIME_absolute_get_remaining(test_find_peer->find_peer_context->endtime).rel_value > 60))
1069 { 1065 {
1070 GNUNET_SCHEDULER_add_now(sched, &count_new_peers, test_find_peer->find_peer_context); 1066 GNUNET_SCHEDULER_add_now(&count_new_peers, test_find_peer->find_peer_context);
1071 } 1067 }
1072 GNUNET_free(test_find_peer); 1068 GNUNET_free(test_find_peer);
1073} 1069}
@@ -1085,7 +1081,7 @@ handle_find_peer_sent (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc
1085 struct TestFindPeer *test_find_peer = cls; 1081 struct TestFindPeer *test_find_peer = cls;
1086 1082
1087 GNUNET_DHT_disconnect(test_find_peer->dht_handle); 1083 GNUNET_DHT_disconnect(test_find_peer->dht_handle);
1088 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_divide(find_peer_delay, 2), &decrement_find_peers, test_find_peer); 1084 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_divide(find_peer_delay, 2), &decrement_find_peers, test_find_peer);
1089} 1085}
1090 1086
1091 1087
@@ -1096,18 +1092,18 @@ send_find_peer_request (void *cls, const struct GNUNET_SCHEDULER_TaskContext * t
1096 1092
1097 if (test_find_peer->find_peer_context->outstanding > max_outstanding_find_peers) 1093 if (test_find_peer->find_peer_context->outstanding > max_outstanding_find_peers)
1098 { 1094 {
1099 GNUNET_SCHEDULER_add_delayed(sched, find_peer_offset, &send_find_peer_request, test_find_peer); 1095 GNUNET_SCHEDULER_add_delayed(find_peer_offset, &send_find_peer_request, test_find_peer);
1100 return; 1096 return;
1101 } 1097 }
1102 1098
1103 test_find_peer->find_peer_context->outstanding++; 1099 test_find_peer->find_peer_context->outstanding++;
1104 if (GNUNET_TIME_absolute_get_remaining(test_find_peer->find_peer_context->endtime).rel_value == 0) 1100 if (GNUNET_TIME_absolute_get_remaining(test_find_peer->find_peer_context->endtime).rel_value == 0)
1105 { 1101 {
1106 GNUNET_SCHEDULER_add_now(sched, &decrement_find_peers, test_find_peer); 1102 GNUNET_SCHEDULER_add_now(&decrement_find_peers, test_find_peer);
1107 return; 1103 return;
1108 } 1104 }
1109 1105
1110 test_find_peer->dht_handle = GNUNET_DHT_connect(sched, test_find_peer->daemon->cfg, 1); 1106 test_find_peer->dht_handle = GNUNET_DHT_connect(test_find_peer->daemon->cfg, 1);
1111 GNUNET_assert(test_find_peer->dht_handle != NULL); 1107 GNUNET_assert(test_find_peer->dht_handle != NULL);
1112 GNUNET_DHT_find_peers (test_find_peer->dht_handle, 1108 GNUNET_DHT_find_peers (test_find_peer->dht_handle,
1113 &handle_find_peer_sent, test_find_peer); 1109 &handle_find_peer_sent, test_find_peer);
@@ -1290,11 +1286,11 @@ count_peers_churn_cb (void *cls,
1290 { 1286 {
1291 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Found peer with no connections, will choose some peer(s) at random to connect to!\n"); 1287 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Found peer with no connections, will choose some peer(s) at random to connect to!\n");
1292 GNUNET_CONTAINER_heap_iterate (find_peer_context->peer_min_heap, &iterate_min_heap_peers, find_peer_context); 1288 GNUNET_CONTAINER_heap_iterate (find_peer_context->peer_min_heap, &iterate_min_heap_peers, find_peer_context);
1293 GNUNET_SCHEDULER_add_now(sched, &schedule_churn_find_peer_requests, find_peer_context); 1289 GNUNET_SCHEDULER_add_now(&schedule_churn_find_peer_requests, find_peer_context);
1294 } 1290 }
1295 else if ((GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0) && (find_peer_context->last_sent != 0)) 1291 else if ((GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0) && (find_peer_context->last_sent != 0))
1296 { 1292 {
1297 GNUNET_SCHEDULER_add_now(sched, &schedule_churn_find_peer_requests, find_peer_context); 1293 GNUNET_SCHEDULER_add_now(&schedule_churn_find_peer_requests, find_peer_context);
1298 } 1294 }
1299 else 1295 else
1300 { 1296 {
@@ -1310,15 +1306,15 @@ count_peers_churn_cb (void *cls,
1310 topo_ctx->cls = all_gets; 1306 topo_ctx->cls = all_gets;
1311 topo_ctx->timeout = DEFAULT_GET_TIMEOUT; 1307 topo_ctx->timeout = DEFAULT_GET_TIMEOUT;
1312 topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); 1308 topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers);
1313 die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), 1309 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT),
1314 &end_badly, "from do gets (count_peers_churn_cb)"); 1310 &end_badly, "from do gets (count_peers_churn_cb)");
1315 GNUNET_SCHEDULER_add_now(sched, &capture_current_topology, topo_ctx); 1311 GNUNET_SCHEDULER_add_now(&capture_current_topology, topo_ctx);
1316 } 1312 }
1317 else 1313 else
1318 { 1314 {
1319 die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), 1315 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT),
1320 &end_badly, "from do gets (count_peers_churn_cb)"); 1316 &end_badly, "from do gets (count_peers_churn_cb)");
1321 GNUNET_SCHEDULER_add_now(sched, &do_get, all_gets); 1317 GNUNET_SCHEDULER_add_now(&do_get, all_gets);
1322 } 1318 }
1323 } 1319 }
1324 } 1320 }
@@ -1372,7 +1368,7 @@ schedule_churn_find_peer_requests (void *cls, const struct GNUNET_SCHEDULER_Task
1372 test_find_peer->daemon = GNUNET_TESTING_daemon_get_by_id(pg, &peer_count->peer_id); 1368 test_find_peer->daemon = GNUNET_TESTING_daemon_get_by_id(pg, &peer_count->peer_id);
1373 GNUNET_assert(test_find_peer->daemon != NULL); 1369 GNUNET_assert(test_find_peer->daemon != NULL);
1374 test_find_peer->find_peer_context = find_peer_ctx; 1370 test_find_peer->find_peer_context = find_peer_ctx;
1375 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(find_peer_offset, i), &send_find_peer_request, test_find_peer); 1371 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(find_peer_offset, i), &send_find_peer_request, test_find_peer);
1376 } 1372 }
1377 1373
1378 if ((find_peer_ctx->peer_hash == NULL) && (find_peer_ctx->peer_min_heap == NULL)) 1374 if ((find_peer_ctx->peer_hash == NULL) && (find_peer_ctx->peer_min_heap == NULL))
@@ -1416,7 +1412,7 @@ static void churn_complete (void *cls, const char *emsg)
1416 if (emsg != NULL) 1412 if (emsg != NULL)
1417 { 1413 {
1418 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Ending test, churning of peers failed with error `%s'", emsg); 1414 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Ending test, churning of peers failed with error `%s'", emsg);
1419 GNUNET_SCHEDULER_add_now(sched, &end_badly, (void *)emsg); 1415 GNUNET_SCHEDULER_add_now(&end_badly, (void *)emsg);
1420 return; 1416 return;
1421 } 1417 }
1422 1418
@@ -1443,7 +1439,7 @@ static void churn_complete (void *cls, const char *emsg)
1443 } 1439 }
1444 } 1440 }
1445 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Added %d peers to heap, total size %d\n", count_added, GNUNET_CONTAINER_heap_get_size(find_peer_context->peer_min_heap)); 1441 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Added %d peers to heap, total size %d\n", count_added, GNUNET_CONTAINER_heap_get_size(find_peer_context->peer_min_heap));
1446 GNUNET_SCHEDULER_add_delayed(sched, DEFAULT_PEER_DISCONNECT_TIMEOUT, &schedule_churn_get_topology, find_peer_context); 1442 GNUNET_SCHEDULER_add_delayed(DEFAULT_PEER_DISCONNECT_TIMEOUT, &schedule_churn_get_topology, find_peer_context);
1447 //GNUNET_TESTING_get_topology (pg, &count_peers_churn_cb, find_peer_context); 1443 //GNUNET_TESTING_get_topology (pg, &count_peers_churn_cb, find_peer_context);
1448 } 1444 }
1449 else 1445 else
@@ -1459,19 +1455,19 @@ static void churn_complete (void *cls, const char *emsg)
1459 calc_timeout = GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout); 1455 calc_timeout = GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout);
1460 calc_timeout = GNUNET_TIME_relative_add(calc_timeout, DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT); 1456 calc_timeout = GNUNET_TIME_relative_add(calc_timeout, DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT);
1461 calc_timeout = GNUNET_TIME_relative_add(calc_timeout, DEFAULT_PEER_DISCONNECT_TIMEOUT); 1457 calc_timeout = GNUNET_TIME_relative_add(calc_timeout, DEFAULT_PEER_DISCONNECT_TIMEOUT);
1462 die_task = GNUNET_SCHEDULER_add_delayed (sched, calc_timeout, 1458 die_task = GNUNET_SCHEDULER_add_delayed (calc_timeout,
1463 &end_badly, "from do gets (churn_complete)"); 1459 &end_badly, "from do gets (churn_complete)");
1464 GNUNET_SCHEDULER_add_delayed(sched, DEFAULT_PEER_DISCONNECT_TIMEOUT, &capture_current_topology, topo_ctx); 1460 GNUNET_SCHEDULER_add_delayed(DEFAULT_PEER_DISCONNECT_TIMEOUT, &capture_current_topology, topo_ctx);
1465 } 1461 }
1466 else 1462 else
1467 { 1463 {
1468 calc_timeout = GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout); 1464 calc_timeout = GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout);
1469 calc_timeout = GNUNET_TIME_relative_add(calc_timeout, DEFAULT_PEER_DISCONNECT_TIMEOUT); 1465 calc_timeout = GNUNET_TIME_relative_add(calc_timeout, DEFAULT_PEER_DISCONNECT_TIMEOUT);
1470 die_task = GNUNET_SCHEDULER_add_delayed (sched, calc_timeout, 1466 die_task = GNUNET_SCHEDULER_add_delayed (calc_timeout,
1471 &end_badly, "from do gets (churn_complete)"); 1467 &end_badly, "from do gets (churn_complete)");
1472 if (dhtlog_handle != NULL) 1468 if (dhtlog_handle != NULL)
1473 dhtlog_handle->insert_round(DHT_ROUND_GET, rounds_finished); 1469 dhtlog_handle->insert_round(DHT_ROUND_GET, rounds_finished);
1474 GNUNET_SCHEDULER_add_delayed(sched, DEFAULT_PEER_DISCONNECT_TIMEOUT, &do_get, all_gets); 1470 GNUNET_SCHEDULER_add_delayed(DEFAULT_PEER_DISCONNECT_TIMEOUT, &do_get, all_gets);
1475 } 1471 }
1476 } 1472 }
1477} 1473}
@@ -1565,7 +1561,7 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
1565 if ((gets_completed + gets_failed == num_gets) && (outstanding_gets == 0)) 1561 if ((gets_completed + gets_failed == num_gets) && (outstanding_gets == 0))
1566 { 1562 {
1567 fprintf(stderr, "Canceling die task (get_stop_finished) %llu gets completed, %llu gets failed\n", gets_completed, gets_failed); 1563 fprintf(stderr, "Canceling die task (get_stop_finished) %llu gets completed, %llu gets failed\n", gets_completed, gets_failed);
1568 GNUNET_SCHEDULER_cancel(sched, die_task); 1564 GNUNET_SCHEDULER_cancel(die_task);
1569 reset_meter(put_meter); 1565 reset_meter(put_meter);
1570 reset_meter(get_meter); 1566 reset_meter(get_meter);
1571 /** 1567 /**
@@ -1581,10 +1577,10 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
1581 topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext)); 1577 topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext));
1582 topo_ctx->cont = &log_dht_statistics; 1578 topo_ctx->cont = &log_dht_statistics;
1583 topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); 1579 topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers);
1584 GNUNET_SCHEDULER_add_now(sched, &capture_current_topology, topo_ctx); 1580 GNUNET_SCHEDULER_add_now(&capture_current_topology, topo_ctx);
1585 } 1581 }
1586 else 1582 else
1587 GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); 1583 GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
1588 } 1584 }
1589 else if (current_churn_round < churns_per_round * (rounds_finished + 1)) /* Do next round of churn */ 1585 else if (current_churn_round < churns_per_round * (rounds_finished + 1)) /* Do next round of churn */
1590 { 1586 {
@@ -1595,7 +1591,7 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
1595 if (dhtlog_handle != NULL) 1591 if (dhtlog_handle != NULL)
1596 dhtlog_handle->insert_round(DHT_ROUND_CHURN, rounds_finished); 1592 dhtlog_handle->insert_round(DHT_ROUND_CHURN, rounds_finished);
1597 1593
1598 GNUNET_SCHEDULER_add_now(sched, &churn_peers, NULL); 1594 GNUNET_SCHEDULER_add_now(&churn_peers, NULL);
1599 } 1595 }
1600 else if (rounds_finished < total_rounds - 1) /* Start a new complete round */ 1596 else if (rounds_finished < total_rounds - 1) /* Start a new complete round */
1601 { 1597 {
@@ -1610,17 +1606,17 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
1610 if (dhtlog_handle != NULL) 1606 if (dhtlog_handle != NULL)
1611 dhtlog_handle->insert_round(DHT_ROUND_GET, rounds_finished); 1607 dhtlog_handle->insert_round(DHT_ROUND_GET, rounds_finished);
1612 1608
1613 die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), 1609 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT),
1614 &end_badly, "from do gets (next round)"); 1610 &end_badly, "from do gets (next round)");
1615 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), &do_get, all_gets); 1611 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), &do_get, all_gets);
1616 } 1612 }
1617 else 1613 else
1618 { 1614 {
1619 if (dhtlog_handle != NULL) 1615 if (dhtlog_handle != NULL)
1620 dhtlog_handle->insert_round(DHT_ROUND_NORMAL, rounds_finished); 1616 dhtlog_handle->insert_round(DHT_ROUND_NORMAL, rounds_finished);
1621 die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_add(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, num_puts * 2)), 1617 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, num_puts * 2)),
1622 &end_badly, "from do puts"); 1618 &end_badly, "from do puts");
1623 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), &do_put, all_puts); 1619 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), &do_put, all_puts);
1624 } 1620 }
1625 } 1621 }
1626 } 1622 }
@@ -1640,7 +1636,7 @@ get_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
1640 GNUNET_DHT_get_stop(test_get->get_handle); 1636 GNUNET_DHT_get_stop(test_get->get_handle);
1641 test_get->get_handle = NULL; 1637 test_get->get_handle = NULL;
1642 test_get->disconnect_task = GNUNET_SCHEDULER_NO_TASK; 1638 test_get->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
1643 GNUNET_SCHEDULER_add_now (sched, &get_stop_finished, test_get); 1639 GNUNET_SCHEDULER_add_now (&get_stop_finished, test_get);
1644} 1640}
1645 1641
1646/** 1642/**
@@ -1685,8 +1681,8 @@ get_result_iterator (void *cls,
1685#if VERBOSE > 1 1681#if VERBOSE > 1
1686 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received correct GET response!\n"); 1682 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received correct GET response!\n");
1687#endif 1683#endif
1688 GNUNET_SCHEDULER_cancel(sched, test_get->disconnect_task); 1684 GNUNET_SCHEDULER_cancel(test_get->disconnect_task);
1689 GNUNET_SCHEDULER_add_continuation(sched, &get_stop_task, test_get, GNUNET_SCHEDULER_REASON_PREREQ_DONE); 1685 GNUNET_SCHEDULER_add_continuation(&get_stop_task, test_get, GNUNET_SCHEDULER_REASON_PREREQ_DONE);
1690} 1686}
1691 1687
1692 1688
@@ -1701,8 +1697,8 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
1701 1697
1702 if (num_gets == 0) 1698 if (num_gets == 0)
1703 { 1699 {
1704 GNUNET_SCHEDULER_cancel(sched, die_task); 1700 GNUNET_SCHEDULER_cancel(die_task);
1705 GNUNET_SCHEDULER_add_now(sched, &finish_testing, NULL); 1701 GNUNET_SCHEDULER_add_now(&finish_testing, NULL);
1706 } 1702 }
1707 1703
1708 if (test_get == NULL) 1704 if (test_get == NULL)
@@ -1715,20 +1711,20 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
1715 { 1711 {
1716 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Peer we should issue get request from is down, skipping.\n"); 1712 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Peer we should issue get request from is down, skipping.\n");
1717 gets_failed++; 1713 gets_failed++;
1718 GNUNET_SCHEDULER_add_now (sched, &get_stop_finished, test_get); 1714 GNUNET_SCHEDULER_add_now (&get_stop_finished, test_get);
1719 GNUNET_SCHEDULER_add_now (sched, &do_get, test_get->next); 1715 GNUNET_SCHEDULER_add_now (&do_get, test_get->next);
1720 return; 1716 return;
1721 } 1717 }
1722 1718
1723 /* Check if more gets are outstanding than should be */ 1719 /* Check if more gets are outstanding than should be */
1724 if (outstanding_gets > max_outstanding_gets) 1720 if (outstanding_gets > max_outstanding_gets)
1725 { 1721 {
1726 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 200), &do_get, test_get); 1722 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 200), &do_get, test_get);
1727 return; 1723 return;
1728 } 1724 }
1729 1725
1730 /* Connect to the first peer's DHT */ 1726 /* Connect to the first peer's DHT */
1731 test_get->dht_handle = GNUNET_DHT_connect(sched, test_get->daemon->cfg, 10); 1727 test_get->dht_handle = GNUNET_DHT_connect(test_get->daemon->cfg, 10);
1732 GNUNET_assert(test_get->dht_handle != NULL); 1728 GNUNET_assert(test_get->dht_handle != NULL);
1733 outstanding_gets++; 1729 outstanding_gets++;
1734 1730
@@ -1748,10 +1744,10 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
1748 test_get->uid, 1744 test_get->uid,
1749 test_get->daemon->shortname); 1745 test_get->daemon->shortname);
1750#endif 1746#endif
1751 test_get->disconnect_task = GNUNET_SCHEDULER_add_delayed(sched, get_timeout, &get_stop_task, test_get); 1747 test_get->disconnect_task = GNUNET_SCHEDULER_add_delayed(get_timeout, &get_stop_task, test_get);
1752 1748
1753 /* Schedule the next request in the linked list of get requests */ 1749 /* Schedule the next request in the linked list of get requests */
1754 GNUNET_SCHEDULER_add_now (sched, &do_get, test_get->next); 1750 GNUNET_SCHEDULER_add_now (&do_get, test_get->next);
1755} 1751}
1756 1752
1757/** 1753/**
@@ -1773,12 +1769,12 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
1773 if (replicate_same == GNUNET_NO) 1769 if (replicate_same == GNUNET_NO)
1774 test_put->daemon = GNUNET_TESTING_daemon_get(pg, GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers)); 1770 test_put->daemon = GNUNET_TESTING_daemon_get(pg, GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers));
1775 1771
1776 GNUNET_SCHEDULER_cancel(sched, test_put->disconnect_task); 1772 GNUNET_SCHEDULER_cancel(test_put->disconnect_task);
1777 test_put->disconnect_task = GNUNET_SCHEDULER_add_now(sched, &put_disconnect_task, test_put); 1773 test_put->disconnect_task = GNUNET_SCHEDULER_add_now(&put_disconnect_task, test_put);
1778 if (GNUNET_YES == update_meter(put_meter)) 1774 if (GNUNET_YES == update_meter(put_meter))
1779 { 1775 {
1780 GNUNET_assert(outstanding_puts == 0); 1776 GNUNET_assert(outstanding_puts == 0);
1781 GNUNET_SCHEDULER_cancel (sched, die_task); 1777 GNUNET_SCHEDULER_cancel (die_task);
1782 if (dhtlog_handle != NULL) 1778 if (dhtlog_handle != NULL)
1783 { 1779 {
1784 topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext)); 1780 topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext));
@@ -1786,16 +1782,16 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
1786 topo_ctx->cls = all_gets; 1782 topo_ctx->cls = all_gets;
1787 topo_ctx->timeout = DEFAULT_GET_TIMEOUT; 1783 topo_ctx->timeout = DEFAULT_GET_TIMEOUT;
1788 topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); 1784 topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers);
1789 die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), 1785 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT),
1790 &end_badly, "from do gets (put finished)"); 1786 &end_badly, "from do gets (put finished)");
1791 GNUNET_SCHEDULER_add_now(sched, &capture_current_topology, topo_ctx); 1787 GNUNET_SCHEDULER_add_now(&capture_current_topology, topo_ctx);
1792 } 1788 }
1793 else 1789 else
1794 { 1790 {
1795 fprintf(stderr, "Scheduling die task (put finished)\n"); 1791 fprintf(stderr, "Scheduling die task (put finished)\n");
1796 die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), 1792 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout),
1797 &end_badly, "from do gets (put finished)"); 1793 &end_badly, "from do gets (put finished)");
1798 GNUNET_SCHEDULER_add_delayed(sched, DEFAULT_GET_TIMEOUT, &do_get, all_gets); 1794 GNUNET_SCHEDULER_add_delayed(DEFAULT_GET_TIMEOUT, &do_get, all_gets);
1799 } 1795 }
1800 return; 1796 return;
1801 } 1797 }
@@ -1819,7 +1815,7 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
1819 { 1815 {
1820 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Peer we should issue put request at is down, skipping.\n"); 1816 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Peer we should issue put request at is down, skipping.\n");
1821 update_meter(put_meter); 1817 update_meter(put_meter);
1822 GNUNET_SCHEDULER_add_now (sched, &do_put, test_put->next); 1818 GNUNET_SCHEDULER_add_now (&do_put, test_put->next);
1823 return; 1819 return;
1824 } 1820 }
1825 1821
@@ -1830,7 +1826,7 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
1830 1826
1831 if (outstanding_puts > max_outstanding_puts) 1827 if (outstanding_puts > max_outstanding_puts)
1832 { 1828 {
1833 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 200), &do_put, test_put); 1829 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 200), &do_put, test_put);
1834 return; 1830 return;
1835 } 1831 }
1836 1832
@@ -1839,7 +1835,7 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
1839 test_put->uid, 1835 test_put->uid,
1840 test_put->daemon->shortname); 1836 test_put->daemon->shortname);
1841#endif 1837#endif
1842 test_put->dht_handle = GNUNET_DHT_connect(sched, test_put->daemon->cfg, 10); 1838 test_put->dht_handle = GNUNET_DHT_connect(test_put->daemon->cfg, 10);
1843 1839
1844 GNUNET_assert(test_put->dht_handle != NULL); 1840 GNUNET_assert(test_put->dht_handle != NULL);
1845 outstanding_puts++; 1841 outstanding_puts++;
@@ -1851,9 +1847,9 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
1851 GNUNET_TIME_UNIT_FOREVER_ABS, 1847 GNUNET_TIME_UNIT_FOREVER_ABS,
1852 put_delay, 1848 put_delay,
1853 &put_finished, test_put); 1849 &put_finished, test_put);
1854 test_put->disconnect_task = GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_get_forever(), &put_disconnect_task, test_put); 1850 test_put->disconnect_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_get_forever(), &put_disconnect_task, test_put);
1855 rand = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 2); 1851 rand = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 2);
1856 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, rand), &do_put, test_put->next); 1852 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, rand), &do_put, test_put->next);
1857} 1853}
1858 1854
1859static void 1855static void
@@ -1911,7 +1907,7 @@ count_peers_cb (void *cls,
1911 (find_peer_context->current_peers < 2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)) && 1907 (find_peer_context->current_peers < 2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)) &&
1912 (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0)) 1908 (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0))
1913 { 1909 {
1914 GNUNET_SCHEDULER_add_now(sched, &schedule_find_peer_requests, find_peer_context); 1910 GNUNET_SCHEDULER_add_now(&schedule_find_peer_requests, find_peer_context);
1915 } 1911 }
1916 else 1912 else
1917 { 1913 {
@@ -1993,7 +1989,7 @@ schedule_find_peer_requests (void *cls, const struct GNUNET_SCHEDULER_TaskContex
1993 } 1989 }
1994 1990
1995 test_find_peer->find_peer_context = find_peer_ctx; 1991 test_find_peer->find_peer_context = find_peer_ctx;
1996 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(find_peer_offset, i), &send_find_peer_request, test_find_peer); 1992 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(find_peer_offset, i), &send_find_peer_request, test_find_peer);
1997 } 1993 }
1998 1994
1999 if ((find_peer_ctx->peer_hash == NULL) && (find_peer_ctx->peer_min_heap == NULL)) 1995 if ((find_peer_ctx->peer_hash == NULL) && (find_peer_ctx->peer_min_heap == NULL))
@@ -2055,10 +2051,10 @@ setup_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
2055 all_gets = test_get; 2051 all_gets = test_get;
2056 } 2052 }
2057 2053
2058 /*GNUNET_SCHEDULER_cancel (sched, die_task);*/ 2054 /*GNUNET_SCHEDULER_cancel (die_task);*/
2059 die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, num_puts * 2), 2055 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, num_puts * 2),
2060 &end_badly, "from do puts"); 2056 &end_badly, "from do puts");
2061 GNUNET_SCHEDULER_add_now (sched, &do_put, all_puts); 2057 GNUNET_SCHEDULER_add_now (&do_put, all_puts);
2062 2058
2063} 2059}
2064 2060
@@ -2087,15 +2083,15 @@ continue_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext * t
2087 topo_ctx->total_iterations = max; 2083 topo_ctx->total_iterations = max;
2088 topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); 2084 topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers);
2089 //fprintf(stderr, "scheduled topology iteration in %d minutes\n", i); 2085 //fprintf(stderr, "scheduled topology iteration in %d minutes\n", i);
2090 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, i * 3), &capture_current_topology, topo_ctx); 2086 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, i * 3), &capture_current_topology, topo_ctx);
2091 } 2087 }
2092 topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext)); 2088 topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext));
2093 topo_ctx->cont = &setup_puts_and_gets; 2089 topo_ctx->cont = &setup_puts_and_gets;
2094 topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); 2090 topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers);
2095 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, (settle_time + 90)), &capture_current_topology, topo_ctx); 2091 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, (settle_time + 90)), &capture_current_topology, topo_ctx);
2096 } 2092 }
2097 else 2093 else
2098 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, (settle_time + 90)), &setup_puts_and_gets, NULL); 2094 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, (settle_time + 90)), &setup_puts_and_gets, NULL);
2099 2095
2100 if (dhtlog_handle != NULL) 2096 if (dhtlog_handle != NULL)
2101 dhtlog_handle->insert_round(DHT_ROUND_NORMAL, rounds_finished); 2097 dhtlog_handle->insert_round(DHT_ROUND_NORMAL, rounds_finished);
@@ -2106,7 +2102,7 @@ continue_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext * t
2106 find_peer_context = GNUNET_malloc(sizeof(struct FindPeerContext)); 2102 find_peer_context = GNUNET_malloc(sizeof(struct FindPeerContext));
2107 find_peer_context->count_peers_cb = &count_peers_cb; 2103 find_peer_context->count_peers_cb = &count_peers_cb;
2108 find_peer_context->endtime = GNUNET_TIME_relative_to_absolute(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time)); 2104 find_peer_context->endtime = GNUNET_TIME_relative_to_absolute(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time));
2109 GNUNET_SCHEDULER_add_now(sched, &schedule_find_peer_requests, find_peer_context); 2105 GNUNET_SCHEDULER_add_now(&schedule_find_peer_requests, find_peer_context);
2110 } 2106 }
2111 else 2107 else
2112 { 2108 {
@@ -2130,14 +2126,12 @@ malicious_disconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext
2130 2126
2131 if (malicious_completed == malicious_getters + malicious_putters + malicious_droppers) 2127 if (malicious_completed == malicious_getters + malicious_putters + malicious_droppers)
2132 { 2128 {
2133 GNUNET_SCHEDULER_cancel(sched, die_task); 2129 GNUNET_SCHEDULER_cancel(die_task);
2134 fprintf(stderr, "Finished setting all malicious peers up, calling continuation!\n"); 2130 fprintf(stderr, "Finished setting all malicious peers up, calling continuation!\n");
2135 if (dhtlog_handle != NULL) 2131 if (dhtlog_handle != NULL)
2136 GNUNET_SCHEDULER_add_now (sched, 2132 GNUNET_SCHEDULER_add_now (&continue_puts_and_gets, NULL);
2137 &continue_puts_and_gets, NULL);
2138 else 2133 else
2139 GNUNET_SCHEDULER_add_delayed (sched, 2134 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time),
2140 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time),
2141 &continue_puts_and_gets, NULL); 2135 &continue_puts_and_gets, NULL);
2142 } 2136 }
2143 2137
@@ -2150,8 +2144,8 @@ static void
2150malicious_done_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 2144malicious_done_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
2151{ 2145{
2152 struct MaliciousContext *ctx = cls; 2146 struct MaliciousContext *ctx = cls;
2153 GNUNET_SCHEDULER_cancel(sched, ctx->disconnect_task); 2147 GNUNET_SCHEDULER_cancel(ctx->disconnect_task);
2154 GNUNET_SCHEDULER_add_now(sched, &malicious_disconnect_task, ctx); 2148 GNUNET_SCHEDULER_add_now(&malicious_disconnect_task, ctx);
2155} 2149}
2156 2150
2157/** 2151/**
@@ -2164,13 +2158,13 @@ set_malicious (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
2164 2158
2165 if (outstanding_malicious > DEFAULT_MAX_OUTSTANDING_GETS) 2159 if (outstanding_malicious > DEFAULT_MAX_OUTSTANDING_GETS)
2166 { 2160 {
2167 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &set_malicious, ctx); 2161 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &set_malicious, ctx);
2168 return; 2162 return;
2169 } 2163 }
2170 2164
2171 if (ctx->dht_handle == NULL) 2165 if (ctx->dht_handle == NULL)
2172 { 2166 {
2173 ctx->dht_handle = GNUNET_DHT_connect(sched, ctx->daemon->cfg, 1); 2167 ctx->dht_handle = GNUNET_DHT_connect(ctx->daemon->cfg, 1);
2174 outstanding_malicious++; 2168 outstanding_malicious++;
2175 } 2169 }
2176 2170
@@ -2186,24 +2180,21 @@ set_malicious (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
2186 { 2180 {
2187 case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET: 2181 case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET:
2188 GNUNET_DHT_set_malicious_getter(ctx->dht_handle, malicious_get_frequency); 2182 GNUNET_DHT_set_malicious_getter(ctx->dht_handle, malicious_get_frequency);
2189 GNUNET_SCHEDULER_add_now (sched, 2183 GNUNET_SCHEDULER_add_now (&malicious_done_task, ctx);
2190 &malicious_done_task, ctx);
2191 break; 2184 break;
2192 case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT: 2185 case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT:
2193 GNUNET_DHT_set_malicious_putter(ctx->dht_handle, malicious_put_frequency); 2186 GNUNET_DHT_set_malicious_putter(ctx->dht_handle, malicious_put_frequency);
2194 GNUNET_SCHEDULER_add_now (sched, 2187 GNUNET_SCHEDULER_add_now (&malicious_done_task, ctx);
2195 &malicious_done_task, ctx);
2196 break; 2188 break;
2197 case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_DROP: 2189 case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_DROP:
2198 GNUNET_DHT_set_malicious_dropper(ctx->dht_handle); 2190 GNUNET_DHT_set_malicious_dropper(ctx->dht_handle);
2199 GNUNET_SCHEDULER_add_now (sched, &malicious_done_task, ctx); 2191 GNUNET_SCHEDULER_add_now (&malicious_done_task, ctx);
2200 break; 2192 break;
2201 default: 2193 default:
2202 break; 2194 break;
2203 } 2195 }
2204 2196
2205 ctx->disconnect_task = GNUNET_SCHEDULER_add_delayed(sched, 2197 ctx->disconnect_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_FOREVER_REL,
2206 GNUNET_TIME_UNIT_FOREVER_REL,
2207 &malicious_disconnect_task, ctx); 2198 &malicious_disconnect_task, ctx);
2208} 2199}
2209 2200
@@ -2225,7 +2216,7 @@ setup_malicious_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc
2225 temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers); 2216 temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers);
2226 ctx->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon); 2217 ctx->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon);
2227 ctx->malicious_type = GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET; 2218 ctx->malicious_type = GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET;
2228 GNUNET_SCHEDULER_add_now (sched, &set_malicious, ctx); 2219 GNUNET_SCHEDULER_add_now (&set_malicious, ctx);
2229 2220
2230 } 2221 }
2231 2222
@@ -2235,7 +2226,7 @@ setup_malicious_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc
2235 temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers); 2226 temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers);
2236 ctx->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon); 2227 ctx->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon);
2237 ctx->malicious_type = GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT; 2228 ctx->malicious_type = GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT;
2238 GNUNET_SCHEDULER_add_now (sched, &set_malicious, ctx); 2229 GNUNET_SCHEDULER_add_now (&set_malicious, ctx);
2239 2230
2240 } 2231 }
2241 2232
@@ -2245,7 +2236,7 @@ setup_malicious_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc
2245 temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers); 2236 temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers);
2246 ctx->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon); 2237 ctx->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon);
2247 ctx->malicious_type = GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_DROP; 2238 ctx->malicious_type = GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_DROP;
2248 GNUNET_SCHEDULER_add_now (sched, &set_malicious, ctx); 2239 GNUNET_SCHEDULER_add_now (&set_malicious, ctx);
2249 } 2240 }
2250 2241
2251 /** 2242 /**
@@ -2255,14 +2246,13 @@ setup_malicious_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc
2255 if (malicious_getters + malicious_putters + malicious_droppers > 0) 2246 if (malicious_getters + malicious_putters + malicious_droppers > 0)
2256 { 2247 {
2257 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Giving malicious set tasks some time before starting testing!\n"); 2248 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Giving malicious set tasks some time before starting testing!\n");
2258 die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, (malicious_getters + malicious_putters + malicious_droppers) * 2), 2249 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, (malicious_getters + malicious_putters + malicious_droppers) * 2),
2259 &end_badly, "from set malicious"); 2250 &end_badly, "from set malicious");
2260 } 2251 }
2261 else /* Otherwise, continue testing */ 2252 else /* Otherwise, continue testing */
2262 { 2253 {
2263 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Scheduling continue_puts_and_gets now!\n"); 2254 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Scheduling continue_puts_and_gets now!\n");
2264 GNUNET_SCHEDULER_add_now (sched, 2255 GNUNET_SCHEDULER_add_now (&continue_puts_and_gets, NULL);
2265 &continue_puts_and_gets, NULL);
2266 } 2256 }
2267} 2257}
2268 2258
@@ -2321,8 +2311,8 @@ topology_callback (void *cls,
2321 dhtlog_handle->insert_topology(expected_connections); 2311 dhtlog_handle->insert_topology(expected_connections);
2322 } 2312 }
2323 2313
2324 GNUNET_SCHEDULER_cancel (sched, die_task); 2314 GNUNET_SCHEDULER_cancel (die_task);
2325 /*die_task = GNUNET_SCHEDULER_add_delayed (sched, DEFAULT_TIMEOUT, 2315 /*die_task = GNUNET_SCHEDULER_add_delayed (DEFAULT_TIMEOUT,
2326 &end_badly, "from setup puts/gets");*/ 2316 &end_badly, "from setup puts/gets");*/
2327 if ((dhtlog_handle != NULL) && (settle_time > 0)) 2317 if ((dhtlog_handle != NULL) && (settle_time > 0))
2328 { 2318 {
@@ -2330,21 +2320,19 @@ topology_callback (void *cls,
2330 topo_ctx->cont = &setup_malicious_peers; 2320 topo_ctx->cont = &setup_malicious_peers;
2331 topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); 2321 topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers);
2332 //topo_ctx->cont = &continue_puts_and_gets; 2322 //topo_ctx->cont = &continue_puts_and_gets;
2333 GNUNET_SCHEDULER_add_now(sched, &capture_current_topology, topo_ctx); 2323 GNUNET_SCHEDULER_add_now(&capture_current_topology, topo_ctx);
2334 } 2324 }
2335 else 2325 else
2336 { 2326 {
2337 GNUNET_SCHEDULER_add_now(sched, &setup_malicious_peers, NULL); 2327 GNUNET_SCHEDULER_add_now(&setup_malicious_peers, NULL);
2338 /*GNUNET_SCHEDULER_add_delayed (sched, 2328 /*GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time),
2339 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time),
2340 &continue_puts_and_gets, NULL);*/ 2329 &continue_puts_and_gets, NULL);*/
2341 } 2330 }
2342 } 2331 }
2343 else if (total_connections + failed_connections == expected_connections) 2332 else if (total_connections + failed_connections == expected_connections)
2344 { 2333 {
2345 GNUNET_SCHEDULER_cancel (sched, die_task); 2334 GNUNET_SCHEDULER_cancel (die_task);
2346 die_task = GNUNET_SCHEDULER_add_now (sched, 2335 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many failed connections)");
2347 &end_badly, "from topology_callback (too many failed connections)");
2348 } 2336 }
2349} 2337}
2350 2338
@@ -2376,7 +2364,7 @@ peers_started_callback (void *cls,
2376 "All %d daemons started, now connecting peers!\n", 2364 "All %d daemons started, now connecting peers!\n",
2377 num_peers); 2365 num_peers);
2378#endif 2366#endif
2379 GNUNET_SCHEDULER_cancel (sched, die_task); 2367 GNUNET_SCHEDULER_cancel (die_task);
2380 2368
2381 expected_connections = UINT_MAX; 2369 expected_connections = UINT_MAX;
2382 if ((pg != NULL) && (peers_left == 0)) 2370 if ((pg != NULL) && (peers_left == 0))
@@ -2389,12 +2377,10 @@ peers_started_callback (void *cls,
2389 2377
2390 if (expected_connections == GNUNET_SYSERR) 2378 if (expected_connections == GNUNET_SYSERR)
2391 { 2379 {
2392 die_task = GNUNET_SCHEDULER_add_now (sched, 2380 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)");
2393 &end_badly, "from connect topology (bad return)");
2394 } 2381 }
2395 2382
2396 die_task = GNUNET_SCHEDULER_add_delayed (sched, 2383 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, DEFAULT_CONNECT_TIMEOUT * expected_connections),
2397 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, DEFAULT_CONNECT_TIMEOUT * expected_connections),
2398 &end_badly, "from connect topology (timeout)"); 2384 &end_badly, "from connect topology (timeout)");
2399 2385
2400 ok = 0; 2386 ok = 0;
@@ -2415,14 +2401,12 @@ create_topology ()
2415 } 2401 }
2416 else 2402 else
2417 { 2403 {
2418 GNUNET_SCHEDULER_cancel (sched, die_task); 2404 GNUNET_SCHEDULER_cancel (die_task);
2419 die_task = GNUNET_SCHEDULER_add_now (sched, 2405 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from create topology (bad return)");
2420 &end_badly, "from create topology (bad return)");
2421 } 2406 }
2422 GNUNET_free_non_null(blacklist_transports); 2407 GNUNET_free_non_null(blacklist_transports);
2423 GNUNET_SCHEDULER_cancel (sched, die_task); 2408 GNUNET_SCHEDULER_cancel (die_task);
2424 die_task = GNUNET_SCHEDULER_add_delayed (sched, 2409 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers),
2425 GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers),
2426 &end_badly, "from continue startup (timeout)"); 2410 &end_badly, "from continue startup (timeout)");
2427} 2411}
2428 2412
@@ -2459,13 +2443,12 @@ hostkey_callback (void *cls,
2459 "All %d hostkeys created, now creating topology!\n", 2443 "All %d hostkeys created, now creating topology!\n",
2460 num_peers); 2444 num_peers);
2461#endif 2445#endif
2462 GNUNET_SCHEDULER_cancel (sched, die_task); 2446 GNUNET_SCHEDULER_cancel (die_task);
2463 /* Set up task in case topology creation doesn't finish 2447 /* Set up task in case topology creation doesn't finish
2464 * within a reasonable amount of time */ 2448 * within a reasonable amount of time */
2465 die_task = GNUNET_SCHEDULER_add_delayed (sched, 2449 die_task = GNUNET_SCHEDULER_add_delayed (DEFAULT_TOPOLOGY_TIMEOUT,
2466 DEFAULT_TOPOLOGY_TIMEOUT,
2467 &end_badly, "from create_topology"); 2450 &end_badly, "from create_topology");
2468 GNUNET_SCHEDULER_add_now(sched, &create_topology, NULL); 2451 GNUNET_SCHEDULER_add_now(&create_topology, NULL);
2469 ok = 0; 2452 ok = 0;
2470 } 2453 }
2471} 2454}
@@ -2473,7 +2456,6 @@ hostkey_callback (void *cls,
2473 2456
2474static void 2457static void
2475run (void *cls, 2458run (void *cls,
2476 struct GNUNET_SCHEDULER_Handle *s,
2477 char *const *args, 2459 char *const *args,
2478 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 2460 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
2479{ 2461{
@@ -2503,9 +2485,8 @@ run (void *cls,
2503 char *churn_filename; 2485 char *churn_filename;
2504 int count; 2486 int count;
2505 int ret; 2487 int ret;
2506 unsigned int line_number; 2488 int line_number;
2507 2489
2508 sched = s;
2509 config = cfg; 2490 config = cfg;
2510 rounds_finished = 0; 2491 rounds_finished = 0;
2511 memset(&trial_info, 0, sizeof(struct GNUNET_DHTLOG_TrialInfo)); 2492 memset(&trial_info, 0, sizeof(struct GNUNET_DHTLOG_TrialInfo));
@@ -2986,8 +2967,7 @@ run (void *cls,
2986 2967
2987 2968
2988 /* Set up a task to end testing if peer start fails */ 2969 /* Set up a task to end testing if peer start fails */
2989 die_task = GNUNET_SCHEDULER_add_delayed (sched, 2970 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers),
2990 GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers),
2991 &end_badly, "didn't generate all hostkeys within allowed startup time!"); 2971 &end_badly, "didn't generate all hostkeys within allowed startup time!");
2992 2972
2993 if (dhtlog_handle == NULL) 2973 if (dhtlog_handle == NULL)
@@ -3032,7 +3012,7 @@ run (void *cls,
3032 3012
3033 put_meter = create_meter(num_puts, "Puts completed ", GNUNET_YES); 3013 put_meter = create_meter(num_puts, "Puts completed ", GNUNET_YES);
3034 get_meter = create_meter(num_gets, "Gets completed ", GNUNET_YES); 3014 get_meter = create_meter(num_gets, "Gets completed ", GNUNET_YES);
3035 pg = GNUNET_TESTING_daemons_start (sched, cfg, 3015 pg = GNUNET_TESTING_daemons_start (cfg,
3036 peers_left, 3016 peers_left,
3037 GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers), 3017 GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers),
3038 &hostkey_callback, NULL, 3018 &hostkey_callback, NULL,
diff --git a/src/dht/gnunet-dht-get-peer.c b/src/dht/gnunet-dht-get-peer.c
index f6974cddb..8d318efc2 100644
--- a/src/dht/gnunet-dht-get-peer.c
+++ b/src/dht/gnunet-dht-get-peer.c
@@ -52,10 +52,6 @@ static int verbose;
52 */ 52 */
53static struct GNUNET_DHT_Handle *dht_handle; 53static struct GNUNET_DHT_Handle *dht_handle;
54 54
55/**
56 * Global handle of the scheduler
57 */
58static struct GNUNET_SCHEDULER_Handle *sched;
59 55
60/** 56/**
61 * Global handle of the configuration 57 * Global handle of the configuration
@@ -101,7 +97,7 @@ cleanup_task (void *cls,
101 GNUNET_DHT_find_peer_stop (find_peer_handle); 97 GNUNET_DHT_find_peer_stop (find_peer_handle);
102 find_peer_handle = NULL; 98 find_peer_handle = NULL;
103 } 99 }
104 GNUNET_SCHEDULER_add_now (sched, &shutdown_task, NULL); 100 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
105} 101}
106 102
107/** 103/**
@@ -132,20 +128,17 @@ find_peer_processor (void *cls,
132 * Main function that will be run by the scheduler. 128 * Main function that will be run by the scheduler.
133 * 129 *
134 * @param cls closure 130 * @param cls closure
135 * @param s the scheduler to use
136 * @param args remaining command-line arguments 131 * @param args remaining command-line arguments
137 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 132 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
138 * @param c configuration 133 * @param c configuration
139 */ 134 */
140static void 135static void
141run (void *cls, 136run (void *cls,
142 struct GNUNET_SCHEDULER_Handle *s,
143 char *const *args, 137 char *const *args,
144 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) 138 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
145{ 139{
146 struct GNUNET_TIME_Relative timeout; 140 struct GNUNET_TIME_Relative timeout;
147 GNUNET_HashCode key; 141 GNUNET_HashCode key;
148 sched = s;
149 cfg = c; 142 cfg = c;
150 143
151 if (query_key == NULL) 144 if (query_key == NULL)
@@ -156,7 +149,7 @@ run (void *cls,
156 return; 149 return;
157 } 150 }
158 151
159 dht_handle = GNUNET_DHT_connect (sched, cfg, 1); 152 dht_handle = GNUNET_DHT_connect (cfg, 1);
160 153
161 if (dht_handle == NULL) 154 if (dht_handle == NULL)
162 { 155 {
@@ -185,11 +178,10 @@ run (void *cls,
185 NULL); 178 NULL);
186 if (NULL == find_peer_handle) 179 if (NULL == find_peer_handle)
187 { 180 {
188 GNUNET_SCHEDULER_add_now (sched, &shutdown_task, NULL); 181 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
189 return; 182 return;
190 } 183 }
191 GNUNET_SCHEDULER_add_delayed (sched, 184 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining
192 GNUNET_TIME_absolute_get_remaining
193 (absolute_timeout), 185 (absolute_timeout),
194 &cleanup_task, NULL); 186 &cleanup_task, NULL);
195} 187}
diff --git a/src/dht/gnunet-dht-get.c b/src/dht/gnunet-dht-get.c
index 55d606716..b7dcb6a56 100644
--- a/src/dht/gnunet-dht-get.c
+++ b/src/dht/gnunet-dht-get.c
@@ -56,10 +56,6 @@ static int verbose;
56 */ 56 */
57static struct GNUNET_DHT_Handle *dht_handle; 57static struct GNUNET_DHT_Handle *dht_handle;
58 58
59/**
60 * Global handle of the scheduler
61 */
62static struct GNUNET_SCHEDULER_Handle *sched;
63 59
64/** 60/**
65 * Global handle of the configuration 61 * Global handle of the configuration
@@ -101,7 +97,7 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
101 GNUNET_DHT_get_stop (get_handle); 97 GNUNET_DHT_get_stop (get_handle);
102 get_handle = NULL; 98 get_handle = NULL;
103 } 99 }
104 GNUNET_SCHEDULER_add_now (sched, &shutdown_task, NULL); 100 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
105} 101}
106 102
107 103
@@ -142,20 +138,17 @@ get_result_iterator (void *cls,
142 * Main function that will be run by the scheduler. 138 * Main function that will be run by the scheduler.
143 * 139 *
144 * @param cls closure 140 * @param cls closure
145 * @param s the scheduler to use
146 * @param args remaining command-line arguments 141 * @param args remaining command-line arguments
147 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 142 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
148 * @param c configuration 143 * @param c configuration
149 */ 144 */
150static void 145static void
151run (void *cls, 146run (void *cls,
152 struct GNUNET_SCHEDULER_Handle *s,
153 char *const *args, 147 char *const *args,
154 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) 148 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
155{ 149{
156 struct GNUNET_TIME_Relative timeout; 150 struct GNUNET_TIME_Relative timeout;
157 GNUNET_HashCode key; 151 GNUNET_HashCode key;
158 sched = s;
159 cfg = c; 152 cfg = c;
160 153
161 if (query_key == NULL) 154 if (query_key == NULL)
@@ -166,7 +159,7 @@ run (void *cls,
166 return; 159 return;
167 } 160 }
168 161
169 dht_handle = GNUNET_DHT_connect (sched, cfg, 1); 162 dht_handle = GNUNET_DHT_connect (cfg, 1);
170 163
171 if (dht_handle == NULL) 164 if (dht_handle == NULL)
172 { 165 {
@@ -186,8 +179,7 @@ run (void *cls,
186 179
187 if (verbose) 180 if (verbose)
188 fprintf (stderr, "Issuing GET request for %s!\n", query_key); 181 fprintf (stderr, "Issuing GET request for %s!\n", query_key);
189 GNUNET_SCHEDULER_add_delayed (sched, 182 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining
190 GNUNET_TIME_absolute_get_remaining
191 (absolute_timeout), &cleanup_task, NULL); 183 (absolute_timeout), &cleanup_task, NULL);
192 get_handle = GNUNET_DHT_get_start (dht_handle, 184 get_handle = GNUNET_DHT_get_start (dht_handle,
193 timeout, 185 timeout,
diff --git a/src/dht/gnunet-dht-put.c b/src/dht/gnunet-dht-put.c
index 54c984493..469675409 100644
--- a/src/dht/gnunet-dht-put.c
+++ b/src/dht/gnunet-dht-put.c
@@ -56,10 +56,6 @@ static int verbose;
56 */ 56 */
57static struct GNUNET_DHT_Handle *dht_handle; 57static struct GNUNET_DHT_Handle *dht_handle;
58 58
59/**
60 * Global handle of the scheduler
61 */
62static struct GNUNET_SCHEDULER_Handle *sched;
63 59
64/** 60/**
65 * Global handle of the configuration 61 * Global handle of the configuration
@@ -98,28 +94,25 @@ message_sent_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
98 if (verbose) 94 if (verbose)
99 fprintf (stderr, 95 fprintf (stderr,
100 _("PUT request sent!\n")); 96 _("PUT request sent!\n"));
101 GNUNET_SCHEDULER_add_now (sched, &shutdown_task, NULL); 97 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
102} 98}
103 99
104/** 100/**
105 * Main function that will be run by the scheduler. 101 * Main function that will be run by the scheduler.
106 * 102 *
107 * @param cls closure 103 * @param cls closure
108 * @param s the scheduler to use
109 * @param args remaining command-line arguments 104 * @param args remaining command-line arguments
110 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 105 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
111 * @param c configuration 106 * @param c configuration
112 */ 107 */
113static void 108static void
114run (void *cls, 109run (void *cls,
115 struct GNUNET_SCHEDULER_Handle *s,
116 char *const *args, 110 char *const *args,
117 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) 111 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
118{ 112{
119 struct GNUNET_TIME_Relative timeout; 113 struct GNUNET_TIME_Relative timeout;
120 struct GNUNET_TIME_Absolute expiration; 114 struct GNUNET_TIME_Absolute expiration;
121 GNUNET_HashCode key; 115 GNUNET_HashCode key;
122 sched = s;
123 cfg = c; 116 cfg = c;
124 117
125 if ( (query_key == NULL) || (data == NULL) ) 118 if ( (query_key == NULL) || (data == NULL) )
@@ -130,7 +123,7 @@ run (void *cls,
130 return; 123 return;
131 } 124 }
132 125
133 dht_handle = GNUNET_DHT_connect (sched, cfg, 1); 126 dht_handle = GNUNET_DHT_connect (cfg, 1);
134 if (dht_handle == NULL) 127 if (dht_handle == NULL)
135 { 128 {
136 fprintf (stderr, 129 fprintf (stderr,
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index da82ac841..52e10320c 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -755,10 +755,6 @@ static struct GNUNET_DATACACHE_Handle *datacache;
755 */ 755 */
756struct GNUNET_STATISTICS_Handle *stats; 756struct GNUNET_STATISTICS_Handle *stats;
757 757
758/**
759 * The main scheduler to use for the DHT service
760 */
761static struct GNUNET_SCHEDULER_Handle *sched;
762 758
763/** 759/**
764 * The configuration the DHT service is running with 760 * The configuration the DHT service is running with
@@ -1094,7 +1090,7 @@ forward_result_message (const struct GNUNET_MessageHeader *msg,
1094#endif 1090#endif
1095 GNUNET_CONTAINER_DLL_insert_after(peer->head, peer->tail, peer->tail, pending); 1091 GNUNET_CONTAINER_DLL_insert_after(peer->head, peer->tail, peer->tail, pending);
1096 if (peer->send_task == GNUNET_SCHEDULER_NO_TASK) 1092 if (peer->send_task == GNUNET_SCHEDULER_NO_TASK)
1097 peer->send_task = GNUNET_SCHEDULER_add_now(sched, &try_core_send, peer); 1093 peer->send_task = GNUNET_SCHEDULER_add_now(&try_core_send, peer);
1098} 1094}
1099 1095
1100 1096
@@ -1164,7 +1160,7 @@ core_transmit_notify (void *cls,
1164 } 1160 }
1165#endif 1161#endif
1166 if ((peer->head != NULL) && (peer->send_task == GNUNET_SCHEDULER_NO_TASK)) 1162 if ((peer->head != NULL) && (peer->send_task == GNUNET_SCHEDULER_NO_TASK))
1167 peer->send_task = GNUNET_SCHEDULER_add_now(sched, &try_core_send, peer); 1163 peer->send_task = GNUNET_SCHEDULER_add_now(&try_core_send, peer);
1168#if DEBUG_DHT > 1 1164#if DEBUG_DHT > 1
1169 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "`%s:%s' : transmit_notify (core) called with size %d, available %d, returning %d\n", my_short_id, "dht service", msize, size, off); 1165 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "`%s:%s' : transmit_notify (core) called with size %d, available %d, returning %d\n", my_short_id, "dht service", msize, size, off);
1170#endif 1166#endif
@@ -1401,7 +1397,7 @@ update_core_preference_finish (void *cls,
1401{ 1397{
1402 struct PeerInfo *peer_info = cls; 1398 struct PeerInfo *peer_info = cls;
1403 peer_info->info_ctx = NULL; 1399 peer_info->info_ctx = NULL;
1404 GNUNET_SCHEDULER_add_delayed(sched, DHT_DEFAULT_PREFERENCE_INTERVAL, &update_core_preference, peer_info); 1400 GNUNET_SCHEDULER_add_delayed(DHT_DEFAULT_PREFERENCE_INTERVAL, &update_core_preference, peer_info);
1405} 1401}
1406 1402
1407static void 1403static void
@@ -1422,7 +1418,7 @@ update_core_preference (void *cls,
1422 matching = 63; 1418 matching = 63;
1423 } 1419 }
1424 preference = 1LL << matching; 1420 preference = 1LL << matching;
1425 peer->info_ctx = GNUNET_CORE_peer_change_preference (sched, cfg, 1421 peer->info_ctx = GNUNET_CORE_peer_change_preference (cfg,
1426 &peer->id, 1422 &peer->id,
1427 GNUNET_TIME_relative_get_forever(), 1423 GNUNET_TIME_relative_get_forever(),
1428 GNUNET_BANDWIDTH_value_init (UINT32_MAX), 1424 GNUNET_BANDWIDTH_value_init (UINT32_MAX),
@@ -1468,7 +1464,7 @@ add_peer(const struct GNUNET_PeerIdentity *peer,
1468 if ((GNUNET_CRYPTO_hash_matching_bits(&my_identity.hashPubKey, &peer->hashPubKey) > 0) && (k_buckets[bucket].peers_size <= bucket_size)) 1464 if ((GNUNET_CRYPTO_hash_matching_bits(&my_identity.hashPubKey, &peer->hashPubKey) > 0) && (k_buckets[bucket].peers_size <= bucket_size))
1469 { 1465 {
1470#if DO_UPDATE_PREFERENCE 1466#if DO_UPDATE_PREFERENCE
1471 new_peer->preference_task = GNUNET_SCHEDULER_add_now(sched, &update_core_preference, new_peer); 1467 new_peer->preference_task = GNUNET_SCHEDULER_add_now(&update_core_preference, new_peer);
1472#endif 1468#endif
1473 } 1469 }
1474 1470
@@ -1527,7 +1523,7 @@ static void delete_peer (struct PeerInfo *peer,
1527 remove_peer(peer, bucket); /* First remove the peer from its bucket */ 1523 remove_peer(peer, bucket); /* First remove the peer from its bucket */
1528 1524
1529 if (peer->send_task != GNUNET_SCHEDULER_NO_TASK) 1525 if (peer->send_task != GNUNET_SCHEDULER_NO_TASK)
1530 GNUNET_SCHEDULER_cancel(sched, peer->send_task); 1526 GNUNET_SCHEDULER_cancel(peer->send_task);
1531 if (peer->th != NULL) 1527 if (peer->th != NULL)
1532 GNUNET_CORE_notify_transmit_ready_cancel(peer->th); 1528 GNUNET_CORE_notify_transmit_ready_cancel(peer->th);
1533 1529
@@ -1700,7 +1696,7 @@ static void forward_message (const struct GNUNET_MessageHeader *msg,
1700#endif 1696#endif
1701 GNUNET_CONTAINER_DLL_insert_after(peer->head, peer->tail, peer->tail, pending); 1697 GNUNET_CONTAINER_DLL_insert_after(peer->head, peer->tail, peer->tail, pending);
1702 if (peer->send_task == GNUNET_SCHEDULER_NO_TASK) 1698 if (peer->send_task == GNUNET_SCHEDULER_NO_TASK)
1703 peer->send_task = GNUNET_SCHEDULER_add_now(sched, &try_core_send, peer); 1699 peer->send_task = GNUNET_SCHEDULER_add_now(&try_core_send, peer);
1704} 1700}
1705 1701
1706#if DO_PING 1702#if DO_PING
@@ -1729,7 +1725,7 @@ periodic_ping_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1729 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s Sending periodic ping to %s\n", my_short_id, "DHT", GNUNET_i2s(&peer->id)); 1725 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s Sending periodic ping to %s\n", my_short_id, "DHT", GNUNET_i2s(&peer->id));
1730#endif 1726#endif
1731 forward_message(&ping_message, peer, &message_context); 1727 forward_message(&ping_message, peer, &message_context);
1732 peer->ping_task = GNUNET_SCHEDULER_add_delayed(sched, DHT_DEFAULT_PING_DELAY, &periodic_ping_task, peer); 1728 peer->ping_task = GNUNET_SCHEDULER_add_delayed(DHT_DEFAULT_PING_DELAY, &periodic_ping_task, peer);
1733} 1729}
1734 1730
1735/** 1731/**
@@ -1748,10 +1744,10 @@ void schedule_ping_messages()
1748 while (pos != NULL) 1744 while (pos != NULL)
1749 { 1745 {
1750 if ((count < bucket_size) && (pos->ping_task == GNUNET_SCHEDULER_NO_TASK)) 1746 if ((count < bucket_size) && (pos->ping_task == GNUNET_SCHEDULER_NO_TASK))
1751 GNUNET_SCHEDULER_add_now(sched, &periodic_ping_task, pos); 1747 GNUNET_SCHEDULER_add_now(&periodic_ping_task, pos);
1752 else if ((count >= bucket_size) && (pos->ping_task != GNUNET_SCHEDULER_NO_TASK)) 1748 else if ((count >= bucket_size) && (pos->ping_task != GNUNET_SCHEDULER_NO_TASK))
1753 { 1749 {
1754 GNUNET_SCHEDULER_cancel(sched, pos->ping_task); 1750 GNUNET_SCHEDULER_cancel(pos->ping_task);
1755 pos->ping_task = GNUNET_SCHEDULER_NO_TASK; 1751 pos->ping_task = GNUNET_SCHEDULER_NO_TASK;
1756 } 1752 }
1757 pos = pos->next; 1753 pos = pos->next;
@@ -1997,7 +1993,7 @@ static int route_result_message(struct GNUNET_MessageHeader *msg,
1997 { 1993 {
1998 increment_stats(STAT_HELLOS_PROVIDED); 1994 increment_stats(STAT_HELLOS_PROVIDED);
1999 GNUNET_TRANSPORT_offer_hello(transport_handle, hello_msg); 1995 GNUNET_TRANSPORT_offer_hello(transport_handle, hello_msg);
2000 GNUNET_CORE_peer_request_connect(sched, cfg, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), &new_peer, NULL, NULL); 1996 GNUNET_CORE_peer_request_connect(cfg, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), &new_peer, NULL, NULL);
2001 } 1997 }
2002 } 1998 }
2003 } 1999 }
@@ -2426,7 +2422,7 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg,
2426 { 2422 {
2427 increment_stats(STAT_HELLOS_PROVIDED); 2423 increment_stats(STAT_HELLOS_PROVIDED);
2428 GNUNET_TRANSPORT_offer_hello(transport_handle, other_hello); 2424 GNUNET_TRANSPORT_offer_hello(transport_handle, other_hello);
2429 GNUNET_CORE_peer_request_connect(sched, cfg, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), &peer_id, NULL, NULL); 2425 GNUNET_CORE_peer_request_connect(cfg, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), &peer_id, NULL, NULL);
2430 route_message (find_msg, message_context); 2426 route_message (find_msg, message_context);
2431 GNUNET_free (other_hello); 2427 GNUNET_free (other_hello);
2432 return; 2428 return;
@@ -2507,7 +2503,7 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg,
2507 { 2503 {
2508 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding recent remove task for key `%s`!\n", GNUNET_h2s(&message_context->key)); 2504 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding recent remove task for key `%s`!\n", GNUNET_h2s(&message_context->key));
2509 /* Only add a task if there wasn't one for this key already! */ 2505 /* Only add a task if there wasn't one for this key already! */
2510 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30), 2506 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30),
2511 &remove_recent_find_peer, recent_hash); 2507 &remove_recent_find_peer, recent_hash);
2512 } 2508 }
2513 else 2509 else
@@ -2675,7 +2671,7 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg,
2675 put_context = GNUNET_malloc(sizeof(struct RepublishContext)); 2671 put_context = GNUNET_malloc(sizeof(struct RepublishContext));
2676 memcpy(&put_context->key, &message_context->key, sizeof(GNUNET_HashCode)); 2672 memcpy(&put_context->key, &message_context->key, sizeof(GNUNET_HashCode));
2677 put_context->type = put_type; 2673 put_context->type = put_type;
2678 GNUNET_SCHEDULER_add_delayed (sched, dht_republish_frequency, &republish_content, put_context); 2674 GNUNET_SCHEDULER_add_delayed (dht_republish_frequency, &republish_content, put_context);
2679 } 2675 }
2680 } 2676 }
2681 else 2677 else
@@ -3377,7 +3373,7 @@ static int cache_response(struct DHT_MessageContext *msg_ctx)
3377 GNUNET_free(record); 3373 GNUNET_free(record);
3378 } 3374 }
3379 if (source_info->delete_task != GNUNET_SCHEDULER_NO_TASK) 3375 if (source_info->delete_task != GNUNET_SCHEDULER_NO_TASK)
3380 GNUNET_SCHEDULER_cancel(sched, source_info->delete_task); 3376 GNUNET_SCHEDULER_cancel(source_info->delete_task);
3381 if (source_info->find_peers_responded != NULL) 3377 if (source_info->find_peers_responded != NULL)
3382 GNUNET_CONTAINER_bloomfilter_free(source_info->find_peers_responded); 3378 GNUNET_CONTAINER_bloomfilter_free(source_info->find_peers_responded);
3383 GNUNET_free(source_info); 3379 GNUNET_free(source_info);
@@ -3409,7 +3405,7 @@ static int cache_response(struct DHT_MessageContext *msg_ctx)
3409 3405
3410 source_info = GNUNET_malloc(sizeof(struct DHTRouteSource)); 3406 source_info = GNUNET_malloc(sizeof(struct DHTRouteSource));
3411 source_info->record = record; 3407 source_info->record = record;
3412 source_info->delete_task = GNUNET_SCHEDULER_add_delayed(sched, DHT_FORWARD_TIMEOUT, &remove_forward_entry, source_info); 3408 source_info->delete_task = GNUNET_SCHEDULER_add_delayed(DHT_FORWARD_TIMEOUT, &remove_forward_entry, source_info);
3413 source_info->find_peers_responded = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); 3409 source_info->find_peers_responded = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K);
3414 memcpy(&source_info->source, msg_ctx->peer, sizeof(struct GNUNET_PeerIdentity)); 3410 memcpy(&source_info->source, msg_ctx->peer, sizeof(struct GNUNET_PeerIdentity));
3415 GNUNET_CONTAINER_DLL_insert_after(record->head, record->tail, record->tail, source_info); 3411 GNUNET_CONTAINER_DLL_insert_after(record->head, record->tail, record->tail, source_info);
@@ -3536,7 +3532,7 @@ route_message(const struct GNUNET_MessageHeader *msg,
3536 recent_req = GNUNET_malloc(sizeof(struct RecentRequest)); 3532 recent_req = GNUNET_malloc(sizeof(struct RecentRequest));
3537 recent_req->uid = message_context->unique_id; 3533 recent_req->uid = message_context->unique_id;
3538 memcpy(&recent_req->key, &message_context->key, sizeof(GNUNET_HashCode)); 3534 memcpy(&recent_req->key, &message_context->key, sizeof(GNUNET_HashCode));
3539 recent_req->remove_task = GNUNET_SCHEDULER_add_delayed(sched, DEFAULT_RECENT_REMOVAL, &remove_recent, recent_req); 3535 recent_req->remove_task = GNUNET_SCHEDULER_add_delayed(DEFAULT_RECENT_REMOVAL, &remove_recent, recent_req);
3540 recent_req->heap_node = GNUNET_CONTAINER_heap_insert(recent.minHeap, recent_req, GNUNET_TIME_absolute_get().abs_value); 3536 recent_req->heap_node = GNUNET_CONTAINER_heap_insert(recent.minHeap, recent_req, GNUNET_TIME_absolute_get().abs_value);
3541 recent_req->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); 3537 recent_req->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K);
3542 GNUNET_CONTAINER_multihashmap_put(recent.hashmap, &unique_hash, recent_req, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 3538 GNUNET_CONTAINER_multihashmap_put(recent.hashmap, &unique_hash, recent_req, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
@@ -3546,8 +3542,8 @@ route_message(const struct GNUNET_MessageHeader *msg,
3546 { 3542 {
3547 recent_req = GNUNET_CONTAINER_heap_peek(recent.minHeap); 3543 recent_req = GNUNET_CONTAINER_heap_peek(recent.minHeap);
3548 GNUNET_assert(recent_req != NULL); 3544 GNUNET_assert(recent_req != NULL);
3549 GNUNET_SCHEDULER_cancel(sched, recent_req->remove_task); 3545 GNUNET_SCHEDULER_cancel(recent_req->remove_task);
3550 GNUNET_SCHEDULER_add_now(sched, &remove_recent, recent_req); 3546 GNUNET_SCHEDULER_add_now(&remove_recent, recent_req);
3551 } 3547 }
3552 3548
3553 for (i = 0; i < forward_count; i++) 3549 for (i = 0; i < forward_count; i++)
@@ -3727,7 +3723,7 @@ republish_content(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3727 if (results == 0) /* Data must have expired */ 3723 if (results == 0) /* Data must have expired */
3728 GNUNET_free(put_context); 3724 GNUNET_free(put_context);
3729 else /* Reschedule task for next time period */ 3725 else /* Reschedule task for next time period */
3730 GNUNET_SCHEDULER_add_delayed(sched, dht_republish_frequency, &republish_content, put_context); 3726 GNUNET_SCHEDULER_add_delayed(dht_republish_frequency, &republish_content, put_context);
3731 3727
3732} 3728}
3733 3729
@@ -3760,7 +3756,7 @@ static int find_client_records (void *cls,
3760 GNUNET_CONTAINER_DLL_remove(record->head, record->tail, pos); 3756 GNUNET_CONTAINER_DLL_remove(record->head, record->tail, pos);
3761 GNUNET_CONTAINER_heap_remove_node(forward_list.minHeap, pos->hnode); 3757 GNUNET_CONTAINER_heap_remove_node(forward_list.minHeap, pos->hnode);
3762 if (pos->delete_task != GNUNET_SCHEDULER_NO_TASK) 3758 if (pos->delete_task != GNUNET_SCHEDULER_NO_TASK)
3763 GNUNET_SCHEDULER_cancel(sched, pos->delete_task); 3759 GNUNET_SCHEDULER_cancel(pos->delete_task);
3764 3760
3765 if (pos->find_peers_responded != NULL) 3761 if (pos->find_peers_responded != NULL)
3766 GNUNET_CONTAINER_bloomfilter_free(pos->find_peers_responded); 3762 GNUNET_CONTAINER_bloomfilter_free(pos->find_peers_responded);
@@ -3886,7 +3882,7 @@ malicious_put_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3886 increment_stats(STAT_PUT_START); 3882 increment_stats(STAT_PUT_START);
3887 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious PUT message with hash %s\n", my_short_id, "DHT", GNUNET_h2s(&key)); 3883 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious PUT message with hash %s\n", my_short_id, "DHT", GNUNET_h2s(&key));
3888 demultiplex_message(&put_message.header, &message_context); 3884 demultiplex_message(&put_message.header, &message_context);
3889 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, malicious_put_frequency), &malicious_put_task, NULL); 3885 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, malicious_put_frequency), &malicious_put_task, NULL);
3890 3886
3891} 3887}
3892 3888
@@ -3929,7 +3925,7 @@ malicious_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3929 increment_stats(STAT_GET_START); 3925 increment_stats(STAT_GET_START);
3930 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious GET message with hash %s\n", my_short_id, "DHT", GNUNET_h2s(&key)); 3926 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious GET message with hash %s\n", my_short_id, "DHT", GNUNET_h2s(&key));
3931 demultiplex_message (&get_message.header, &message_context); 3927 demultiplex_message (&get_message.header, &message_context);
3932 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, malicious_get_frequency), &malicious_get_task, NULL); 3928 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, malicious_get_frequency), &malicious_get_task, NULL);
3933} 3929}
3934 3930
3935/** 3931/**
@@ -3979,8 +3975,7 @@ send_find_peer_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc
3979 if ((newly_found_peers > bucket_size) && (GNUNET_YES == do_find_peer)) /* If we are finding peers already, no need to send out our request right now! */ 3975 if ((newly_found_peers > bucket_size) && (GNUNET_YES == do_find_peer)) /* If we are finding peers already, no need to send out our request right now! */
3980 { 3976 {
3981 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Have %d newly found peers since last find peer message sent!\n", newly_found_peers); 3977 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Have %d newly found peers since last find peer message sent!\n", newly_found_peers);
3982 GNUNET_SCHEDULER_add_delayed (sched, 3978 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
3983 GNUNET_TIME_UNIT_MINUTES,
3984 &send_find_peer_message, NULL); 3979 &send_find_peer_message, NULL);
3985 newly_found_peers = 0; 3980 newly_found_peers = 0;
3986 return; 3981 return;
@@ -4049,8 +4044,7 @@ send_find_peer_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc
4049 find_peer_context.start = GNUNET_TIME_absolute_get(); 4044 find_peer_context.start = GNUNET_TIME_absolute_get();
4050 if (GNUNET_YES == do_find_peer) 4045 if (GNUNET_YES == do_find_peer)
4051 { 4046 {
4052 GNUNET_SCHEDULER_add_delayed (sched, 4047 GNUNET_SCHEDULER_add_delayed (next_send_time,
4053 next_send_time,
4054 &send_find_peer_message, NULL); 4048 &send_find_peer_message, NULL);
4055 } 4049 }
4056} 4050}
@@ -4135,7 +4129,7 @@ handle_dht_control_message (void *cls, struct GNUNET_SERVER_Client *client,
4135 { 4129 {
4136 case GNUNET_MESSAGE_TYPE_DHT_FIND_PEER: 4130 case GNUNET_MESSAGE_TYPE_DHT_FIND_PEER:
4137 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending self seeking find peer request!\n"); 4131 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending self seeking find peer request!\n");
4138 GNUNET_SCHEDULER_add_now(sched, &send_find_peer_message, NULL); 4132 GNUNET_SCHEDULER_add_now(&send_find_peer_message, NULL);
4139 break; 4133 break;
4140 case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET: 4134 case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET:
4141 if (ntohs(dht_control_msg->variable) > 0) 4135 if (ntohs(dht_control_msg->variable) > 0)
@@ -4143,7 +4137,7 @@ handle_dht_control_message (void *cls, struct GNUNET_SERVER_Client *client,
4143 if (malicious_get_frequency == 0) 4137 if (malicious_get_frequency == 0)
4144 malicious_get_frequency = DEFAULT_MALICIOUS_GET_FREQUENCY; 4138 malicious_get_frequency = DEFAULT_MALICIOUS_GET_FREQUENCY;
4145 if (malicious_getter != GNUNET_YES) 4139 if (malicious_getter != GNUNET_YES)
4146 GNUNET_SCHEDULER_add_now(sched, &malicious_get_task, NULL); 4140 GNUNET_SCHEDULER_add_now(&malicious_get_task, NULL);
4147 malicious_getter = GNUNET_YES; 4141 malicious_getter = GNUNET_YES;
4148 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 4142 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
4149 "%s:%s Initiating malicious GET behavior, frequency %d\n", my_short_id, "DHT", malicious_get_frequency); 4143 "%s:%s Initiating malicious GET behavior, frequency %d\n", my_short_id, "DHT", malicious_get_frequency);
@@ -4154,7 +4148,7 @@ handle_dht_control_message (void *cls, struct GNUNET_SERVER_Client *client,
4154 if (malicious_put_frequency == 0) 4148 if (malicious_put_frequency == 0)
4155 malicious_put_frequency = DEFAULT_MALICIOUS_PUT_FREQUENCY; 4149 malicious_put_frequency = DEFAULT_MALICIOUS_PUT_FREQUENCY;
4156 if (malicious_putter != GNUNET_YES) 4150 if (malicious_putter != GNUNET_YES)
4157 GNUNET_SCHEDULER_add_now(sched, &malicious_put_task, NULL); 4151 GNUNET_SCHEDULER_add_now(&malicious_put_task, NULL);
4158 malicious_putter = GNUNET_YES; 4152 malicious_putter = GNUNET_YES;
4159 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 4153 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
4160 "%s:%s Initiating malicious PUT behavior, frequency %d\n", my_short_id, "DHT", malicious_put_frequency); 4154 "%s:%s Initiating malicious PUT behavior, frequency %d\n", my_short_id, "DHT", malicious_put_frequency);
@@ -4211,9 +4205,9 @@ handle_dht_local_route_stop(void *cls, struct GNUNET_SERVER_Client *client,
4211 { 4205 {
4212 if ((pos->client != NULL) && (pos->client->client_handle == client)) 4206 if ((pos->client != NULL) && (pos->client->client_handle == client))
4213 { 4207 {
4214 GNUNET_SCHEDULER_cancel(sched, pos->delete_task); 4208 GNUNET_SCHEDULER_cancel(pos->delete_task);
4215 pos->delete_task = GNUNET_SCHEDULER_NO_TASK; 4209 pos->delete_task = GNUNET_SCHEDULER_NO_TASK;
4216 GNUNET_SCHEDULER_add_now(sched, &remove_forward_entry, pos); 4210 GNUNET_SCHEDULER_add_now(&remove_forward_entry, pos);
4217 } 4211 }
4218 pos = pos->next; 4212 pos = pos->next;
4219 } 4213 }
@@ -4431,8 +4425,8 @@ core_init (void *cls,
4431 "%s: Connection to core FAILED!\n", "dht", 4425 "%s: Connection to core FAILED!\n", "dht",
4432 GNUNET_i2s (identity)); 4426 GNUNET_i2s (identity));
4433#endif 4427#endif
4434 GNUNET_SCHEDULER_cancel (sched, cleanup_task); 4428 GNUNET_SCHEDULER_cancel (cleanup_task);
4435 GNUNET_SCHEDULER_add_now (sched, &shutdown_task, NULL); 4429 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
4436 return; 4430 return;
4437 } 4431 }
4438#if DEBUG_DHT 4432#if DEBUG_DHT
@@ -4546,13 +4540,11 @@ void handle_core_disconnect (void *cls,
4546 * Process dht requests. 4540 * Process dht requests.
4547 * 4541 *
4548 * @param cls closure 4542 * @param cls closure
4549 * @param scheduler scheduler to use
4550 * @param server the initialized server 4543 * @param server the initialized server
4551 * @param c configuration to use 4544 * @param c configuration to use
4552 */ 4545 */
4553static void 4546static void
4554run (void *cls, 4547run (void *cls,
4555 struct GNUNET_SCHEDULER_Handle *scheduler,
4556 struct GNUNET_SERVER_Handle *server, 4548 struct GNUNET_SERVER_Handle *server,
4557 const struct GNUNET_CONFIGURATION_Handle *c) 4549 const struct GNUNET_CONFIGURATION_Handle *c)
4558{ 4550{
@@ -4560,13 +4552,11 @@ run (void *cls,
4560 unsigned long long temp_config_num; 4552 unsigned long long temp_config_num;
4561 char *converge_modifier_buf; 4553 char *converge_modifier_buf;
4562 4554
4563 sched = scheduler;
4564 cfg = c; 4555 cfg = c;
4565 datacache = GNUNET_DATACACHE_create (sched, cfg, "dhtcache"); 4556 datacache = GNUNET_DATACACHE_create (cfg, "dhtcache");
4566 GNUNET_SERVER_add_handlers (server, plugin_handlers); 4557 GNUNET_SERVER_add_handlers (server, plugin_handlers);
4567 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); 4558 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
4568 coreAPI = GNUNET_CORE_connect (sched, /* Main scheduler */ 4559 coreAPI = GNUNET_CORE_connect (cfg, /* Main configuration */
4569 cfg, /* Main configuration */
4570 GNUNET_TIME_UNIT_FOREVER_REL, 4560 GNUNET_TIME_UNIT_FOREVER_REL,
4571 NULL, /* Closure passed to DHT functions */ 4561 NULL, /* Closure passed to DHT functions */
4572 &core_init, /* Call core_init once connected */ 4562 &core_init, /* Call core_init once connected */
@@ -4581,7 +4571,7 @@ run (void *cls,
4581 4571
4582 if (coreAPI == NULL) 4572 if (coreAPI == NULL)
4583 return; 4573 return;
4584 transport_handle = GNUNET_TRANSPORT_connect(sched, cfg, 4574 transport_handle = GNUNET_TRANSPORT_connect(cfg,
4585 NULL, NULL, NULL, NULL, NULL); 4575 NULL, NULL, NULL, NULL, NULL);
4586 if (transport_handle != NULL) 4576 if (transport_handle != NULL)
4587 GNUNET_TRANSPORT_get_hello (transport_handle, &process_hello, NULL); 4577 GNUNET_TRANSPORT_get_hello (transport_handle, &process_hello, NULL);
@@ -4744,7 +4734,7 @@ run (void *cls,
4744 GNUNET_free(converge_modifier_buf); 4734 GNUNET_free(converge_modifier_buf);
4745 } 4735 }
4746 4736
4747 stats = GNUNET_STATISTICS_create(sched, "dht", cfg); 4737 stats = GNUNET_STATISTICS_create("dht", cfg);
4748 4738
4749 if (stats != NULL) 4739 if (stats != NULL)
4750 { 4740 {
@@ -4778,14 +4768,12 @@ run (void *cls,
4778 GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, 4768 GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG,
4779 (DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / 2) - DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value); 4769 (DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / 2) - DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value);
4780 find_peer_context.start = GNUNET_TIME_absolute_get(); 4770 find_peer_context.start = GNUNET_TIME_absolute_get();
4781 GNUNET_SCHEDULER_add_delayed (sched, 4771 GNUNET_SCHEDULER_add_delayed (next_send_time,
4782 next_send_time,
4783 &send_find_peer_message, &find_peer_context); 4772 &send_find_peer_message, &find_peer_context);
4784 } 4773 }
4785 4774
4786 /* Scheduled the task to clean up when shutdown is called */ 4775 /* Scheduled the task to clean up when shutdown is called */
4787 cleanup_task = GNUNET_SCHEDULER_add_delayed (sched, 4776 cleanup_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
4788 GNUNET_TIME_UNIT_FOREVER_REL,
4789 &shutdown_task, NULL); 4777 &shutdown_task, NULL);
4790} 4778}
4791 4779
diff --git a/src/dht/test_dht_api.c b/src/dht/test_dht_api.c
index 5eeb44d13..de3d97647 100644
--- a/src/dht/test_dht_api.c
+++ b/src/dht/test_dht_api.c
@@ -93,7 +93,6 @@ static struct PeerContext p1;
93 93
94struct RetryContext retry_context; 94struct RetryContext retry_context;
95 95
96static struct GNUNET_SCHEDULER_Handle *sched;
97 96
98static int ok; 97static int ok;
99 98
@@ -109,7 +108,7 @@ GNUNET_SCHEDULER_TaskIdentifier die_task;
109static void 108static void
110end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 109end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
111{ 110{
112 GNUNET_SCHEDULER_cancel (sched, die_task); 111 GNUNET_SCHEDULER_cancel (die_task);
113 die_task = GNUNET_SCHEDULER_NO_TASK; 112 die_task = GNUNET_SCHEDULER_NO_TASK;
114 GNUNET_DHT_disconnect (p1.dht_handle); 113 GNUNET_DHT_disconnect (p1.dht_handle);
115 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 114 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -152,7 +151,7 @@ end_badly ()
152 GNUNET_DHT_get_stop (retry_context.peer_ctx->get_handle); 151 GNUNET_DHT_get_stop (retry_context.peer_ctx->get_handle);
153 } 152 }
154 if (retry_context.retry_task != GNUNET_SCHEDULER_NO_TASK) 153 if (retry_context.retry_task != GNUNET_SCHEDULER_NO_TASK)
155 GNUNET_SCHEDULER_cancel(sched, retry_context.retry_task); 154 GNUNET_SCHEDULER_cancel(retry_context.retry_task);
156 GNUNET_DHT_disconnect (p1.dht_handle); 155 GNUNET_DHT_disconnect (p1.dht_handle);
157 ok = 1; 156 ok = 1;
158} 157}
@@ -173,8 +172,8 @@ test_find_peer_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
173 if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT) 172 if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT)
174 { 173 {
175 GNUNET_break (0); 174 GNUNET_break (0);
176 GNUNET_SCHEDULER_cancel (sched, die_task); 175 GNUNET_SCHEDULER_cancel (die_task);
177 GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL); 176 GNUNET_SCHEDULER_add_now (&end_badly, NULL);
178 return; 177 return;
179 } 178 }
180 179
@@ -187,8 +186,7 @@ test_find_peer_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
187 GNUNET_DHT_set_malicious_putter (peer->dht_handle, GNUNET_TIME_UNIT_SECONDS); 186 GNUNET_DHT_set_malicious_putter (peer->dht_handle, GNUNET_TIME_UNIT_SECONDS);
188 GNUNET_DHT_set_malicious_dropper (peer->dht_handle); 187 GNUNET_DHT_set_malicious_dropper (peer->dht_handle);
189#endif 188#endif
190 GNUNET_SCHEDULER_add_delayed(sched, 189 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1),
191 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1),
192 &end, &p1); 190 &end, &p1);
193} 191}
194 192
@@ -214,11 +212,11 @@ void test_find_peer_processor (void *cls,
214 212
215 if (retry_ctx->retry_task != GNUNET_SCHEDULER_NO_TASK) 213 if (retry_ctx->retry_task != GNUNET_SCHEDULER_NO_TASK)
216 { 214 {
217 GNUNET_SCHEDULER_cancel(sched, retry_ctx->retry_task); 215 GNUNET_SCHEDULER_cancel(retry_ctx->retry_task);
218 retry_ctx->retry_task = GNUNET_SCHEDULER_NO_TASK; 216 retry_ctx->retry_task = GNUNET_SCHEDULER_NO_TASK;
219 } 217 }
220 218
221 GNUNET_SCHEDULER_add_continuation (sched, &test_find_peer_stop, &p1, 219 GNUNET_SCHEDULER_add_continuation (&test_find_peer_stop, &p1,
222 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 220 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
223 } 221 }
224 else 222 else
@@ -273,11 +271,11 @@ retry_find_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
273 if (retry_ctx->peer_ctx->find_peer_handle == NULL) 271 if (retry_ctx->peer_ctx->find_peer_handle == NULL)
274 { 272 {
275 GNUNET_break (0); 273 GNUNET_break (0);
276 GNUNET_SCHEDULER_cancel (sched, die_task); 274 GNUNET_SCHEDULER_cancel (die_task);
277 GNUNET_SCHEDULER_add_now (sched, &end_badly, &p1); 275 GNUNET_SCHEDULER_add_now (&end_badly, &p1);
278 return; 276 return;
279 } 277 }
280 retry_ctx->retry_task = GNUNET_SCHEDULER_add_delayed(sched, retry_ctx->next_timeout, &retry_find_peer_stop, retry_ctx); 278 retry_ctx->retry_task = GNUNET_SCHEDULER_add_delayed(retry_ctx->next_timeout, &retry_find_peer_stop, retry_ctx);
281} 279}
282 280
283/** 281/**
@@ -298,7 +296,7 @@ retry_find_peer_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
298 GNUNET_DHT_find_peer_stop(retry_ctx->peer_ctx->find_peer_handle); 296 GNUNET_DHT_find_peer_stop(retry_ctx->peer_ctx->find_peer_handle);
299 retry_ctx->peer_ctx->find_peer_handle = NULL; 297 retry_ctx->peer_ctx->find_peer_handle = NULL;
300 } 298 }
301 GNUNET_SCHEDULER_add_now (sched, &retry_find_peer, retry_ctx); 299 GNUNET_SCHEDULER_add_now (&retry_find_peer, retry_ctx);
302} 300}
303 301
304/** 302/**
@@ -330,11 +328,11 @@ test_find_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
330 if (peer->find_peer_handle == NULL) 328 if (peer->find_peer_handle == NULL)
331 { 329 {
332 GNUNET_break (0); 330 GNUNET_break (0);
333 GNUNET_SCHEDULER_cancel (sched, die_task); 331 GNUNET_SCHEDULER_cancel (die_task);
334 GNUNET_SCHEDULER_add_now (sched, &end_badly, &p1); 332 GNUNET_SCHEDULER_add_now (&end_badly, &p1);
335 return; 333 return;
336 } 334 }
337 retry_context.retry_task = GNUNET_SCHEDULER_add_delayed(sched, retry_context.next_timeout, &retry_find_peer_stop, &retry_context); 335 retry_context.retry_task = GNUNET_SCHEDULER_add_delayed(retry_context.next_timeout, &retry_find_peer_stop, &retry_context);
338} 336}
339 337
340/** 338/**
@@ -352,14 +350,13 @@ test_get_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
352 if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT) 350 if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT)
353 { 351 {
354 GNUNET_break (0); 352 GNUNET_break (0);
355 GNUNET_SCHEDULER_cancel (sched, die_task); 353 GNUNET_SCHEDULER_cancel (die_task);
356 GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL); 354 GNUNET_SCHEDULER_add_now (&end_badly, NULL);
357 return; 355 return;
358 } 356 }
359 GNUNET_assert (peer->dht_handle != NULL); 357 GNUNET_assert (peer->dht_handle != NULL);
360 GNUNET_DHT_get_stop (peer->get_handle); 358 GNUNET_DHT_get_stop (peer->get_handle);
361 GNUNET_SCHEDULER_add_now(sched, 359 GNUNET_SCHEDULER_add_now(&test_find_peer,
362 &test_find_peer,
363 &p1); 360 &p1);
364} 361}
365 362
@@ -375,7 +372,7 @@ test_get_iterator (void *cls,
375 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 372 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
376 "test_get_iterator called (we got a result), stopping get request!\n"); 373 "test_get_iterator called (we got a result), stopping get request!\n");
377 374
378 GNUNET_SCHEDULER_add_continuation (sched, &test_get_stop, &p1, 375 GNUNET_SCHEDULER_add_continuation (&test_get_stop, &p1,
379 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 376 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
380} 377}
381 378
@@ -411,8 +408,8 @@ test_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
411 if (peer->get_handle == NULL) 408 if (peer->get_handle == NULL)
412 { 409 {
413 GNUNET_break (0); 410 GNUNET_break (0);
414 GNUNET_SCHEDULER_cancel (sched, die_task); 411 GNUNET_SCHEDULER_cancel (die_task);
415 GNUNET_SCHEDULER_add_now (sched, &end_badly, &p1); 412 GNUNET_SCHEDULER_add_now (&end_badly, &p1);
416 return; 413 return;
417 } 414 }
418 415
@@ -436,7 +433,7 @@ test_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
436 data = GNUNET_malloc (data_size); 433 data = GNUNET_malloc (data_size);
437 memset (data, 43, data_size); 434 memset (data, 43, data_size);
438 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called test_put!\n"); 435 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called test_put!\n");
439 peer->dht_handle = GNUNET_DHT_connect (sched, peer->cfg, 100); 436 peer->dht_handle = GNUNET_DHT_connect (peer->cfg, 100);
440 437
441 GNUNET_assert (peer->dht_handle != NULL); 438 GNUNET_assert (peer->dht_handle != NULL);
442 439
@@ -468,23 +465,19 @@ setup_peer (struct PeerContext *p, const char *cfgname)
468 465
469static void 466static void
470run (void *cls, 467run (void *cls,
471 struct GNUNET_SCHEDULER_Handle *s,
472 char *const *args, 468 char *const *args,
473 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 469 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
474{ 470{
475 GNUNET_assert (ok == 1); 471 GNUNET_assert (ok == 1);
476 OKPP; 472 OKPP;
477 sched = s;
478 473
479 die_task = GNUNET_SCHEDULER_add_delayed (sched, 474 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
480 GNUNET_TIME_relative_multiply
481 (GNUNET_TIME_UNIT_MINUTES, 1), 475 (GNUNET_TIME_UNIT_MINUTES, 1),
482 &end_badly, NULL); 476 &end_badly, NULL);
483 477
484 setup_peer (&p1, "test_dht_api_peer1.conf"); 478 setup_peer (&p1, "test_dht_api_peer1.conf");
485 479
486 GNUNET_SCHEDULER_add_delayed (sched, 480 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
487 GNUNET_TIME_relative_multiply
488 (GNUNET_TIME_UNIT_SECONDS, 1), &test_put, 481 (GNUNET_TIME_UNIT_SECONDS, 1), &test_put,
489 &p1); 482 &p1);
490} 483}
diff --git a/src/dht/test_dht_multipeer.c b/src/dht/test_dht_multipeer.c
index dc877c28b..9c18c4f2e 100644
--- a/src/dht/test_dht_multipeer.c
+++ b/src/dht/test_dht_multipeer.c
@@ -153,11 +153,6 @@ static struct GNUNET_TESTING_PeerGroup *pg;
153 153
154 154
155/** 155/**
156 * Global scheduler, used for all GNUNET_SCHEDULER_* functions.
157 */
158static struct GNUNET_SCHEDULER_Handle *sched;
159
160/**
161 * Total number of peers to run, set based on config file. 156 * Total number of peers to run, set based on config file.
162 */ 157 */
163static unsigned long long num_peers; 158static unsigned long long num_peers;
@@ -269,7 +264,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
269 while (test_put != NULL) 264 while (test_put != NULL)
270 { 265 {
271 if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK) 266 if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
272 GNUNET_SCHEDULER_cancel(sched, test_put->disconnect_task); 267 GNUNET_SCHEDULER_cancel(test_put->disconnect_task);
273 if (test_put->dht_handle != NULL) 268 if (test_put->dht_handle != NULL)
274 GNUNET_DHT_disconnect(test_put->dht_handle); 269 GNUNET_DHT_disconnect(test_put->dht_handle);
275 test_put = test_put->next; 270 test_put = test_put->next;
@@ -278,7 +273,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
278 while (test_get != NULL) 273 while (test_get != NULL)
279 { 274 {
280 if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK) 275 if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
281 GNUNET_SCHEDULER_cancel(sched, test_get->disconnect_task); 276 GNUNET_SCHEDULER_cancel(test_get->disconnect_task);
282 if (test_get->get_handle != NULL) 277 if (test_get->get_handle != NULL)
283 GNUNET_DHT_get_stop(test_get->get_handle); 278 GNUNET_DHT_get_stop(test_get->get_handle);
284 if (test_get->dht_handle != NULL) 279 if (test_get->dht_handle != NULL)
@@ -307,7 +302,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
307 while (test_put != NULL) 302 while (test_put != NULL)
308 { 303 {
309 if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK) 304 if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
310 GNUNET_SCHEDULER_cancel(sched, test_put->disconnect_task); 305 GNUNET_SCHEDULER_cancel(test_put->disconnect_task);
311 if (test_put->dht_handle != NULL) 306 if (test_put->dht_handle != NULL)
312 GNUNET_DHT_disconnect(test_put->dht_handle); 307 GNUNET_DHT_disconnect(test_put->dht_handle);
313 test_put = test_put->next; 308 test_put = test_put->next;
@@ -316,7 +311,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
316 while (test_get != NULL) 311 while (test_get != NULL)
317 { 312 {
318 if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK) 313 if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
319 GNUNET_SCHEDULER_cancel(sched, test_get->disconnect_task); 314 GNUNET_SCHEDULER_cancel(test_get->disconnect_task);
320 if (test_get->get_handle != NULL) 315 if (test_get->get_handle != NULL)
321 GNUNET_DHT_get_stop(test_get->get_handle); 316 GNUNET_DHT_get_stop(test_get->get_handle);
322 if (test_get->dht_handle != NULL) 317 if (test_get->dht_handle != NULL)
@@ -342,14 +337,14 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
342 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%d gets succeeded, %d gets failed!\n", gets_completed, gets_failed); 337 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%d gets succeeded, %d gets failed!\n", gets_completed, gets_failed);
343 if ((gets_completed == num_gets) && (outstanding_gets == 0))/* All gets successful */ 338 if ((gets_completed == num_gets) && (outstanding_gets == 0))/* All gets successful */
344 { 339 {
345 GNUNET_SCHEDULER_cancel (sched, die_task); 340 GNUNET_SCHEDULER_cancel (die_task);
346 //GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5), &get_topology, NULL); 341 //GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5), &get_topology, NULL);
347 GNUNET_SCHEDULER_add_now(sched, &finish_testing, NULL); 342 GNUNET_SCHEDULER_add_now(&finish_testing, NULL);
348 } 343 }
349 else if ((gets_completed + gets_failed == num_gets) && (outstanding_gets == 0)) /* Had some failures */ 344 else if ((gets_completed + gets_failed == num_gets) && (outstanding_gets == 0)) /* Had some failures */
350 { 345 {
351 GNUNET_SCHEDULER_cancel(sched, die_task); 346 GNUNET_SCHEDULER_cancel(die_task);
352 GNUNET_SCHEDULER_add_now(sched, &end_badly, "not all gets succeeded!\n"); 347 GNUNET_SCHEDULER_add_now(&end_badly, "not all gets succeeded!\n");
353 } 348 }
354} 349}
355 350
@@ -373,7 +368,7 @@ get_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
373 } 368 }
374 GNUNET_assert(test_get->get_handle != NULL); 369 GNUNET_assert(test_get->get_handle != NULL);
375 GNUNET_DHT_get_stop(test_get->get_handle); 370 GNUNET_DHT_get_stop(test_get->get_handle);
376 GNUNET_SCHEDULER_add_now (sched, &get_stop_finished, test_get); 371 GNUNET_SCHEDULER_add_now (&get_stop_finished, test_get);
377 test_get->get_handle = NULL; 372 test_get->get_handle = NULL;
378 test_get->disconnect_task = GNUNET_SCHEDULER_NO_TASK; 373 test_get->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
379} 374}
@@ -418,8 +413,8 @@ void get_result_iterator (void *cls,
418 } 413 }
419 414
420 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received correct GET response!\n"); 415 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received correct GET response!\n");
421 GNUNET_SCHEDULER_cancel(sched, test_get->disconnect_task); 416 GNUNET_SCHEDULER_cancel(test_get->disconnect_task);
422 GNUNET_SCHEDULER_add_continuation(sched, &get_stop_task, test_get, GNUNET_SCHEDULER_REASON_PREREQ_DONE); 417 GNUNET_SCHEDULER_add_continuation(&get_stop_task, test_get, GNUNET_SCHEDULER_REASON_PREREQ_DONE);
423} 418}
424 419
425 420
@@ -440,11 +435,11 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
440 435
441 if (outstanding_gets > MAX_OUTSTANDING_GETS) 436 if (outstanding_gets > MAX_OUTSTANDING_GETS)
442 { 437 {
443 GNUNET_SCHEDULER_add_delayed (sched, GET_DELAY, &do_get, test_get); 438 GNUNET_SCHEDULER_add_delayed (GET_DELAY, &do_get, test_get);
444 return; 439 return;
445 } 440 }
446 441
447 test_get->dht_handle = GNUNET_DHT_connect(sched, test_get->daemon->cfg, 10); 442 test_get->dht_handle = GNUNET_DHT_connect(test_get->daemon->cfg, 10);
448 /* Insert the data at the first peer */ 443 /* Insert the data at the first peer */
449 GNUNET_assert(test_get->dht_handle != NULL); 444 GNUNET_assert(test_get->dht_handle != NULL);
450 outstanding_gets++; 445 outstanding_gets++;
@@ -462,8 +457,8 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
462 test_get->uid, 457 test_get->uid,
463 test_get->daemon->shortname); 458 test_get->daemon->shortname);
464#endif 459#endif
465 test_get->disconnect_task = GNUNET_SCHEDULER_add_delayed(sched, GET_TIMEOUT, &get_stop_task, test_get); 460 test_get->disconnect_task = GNUNET_SCHEDULER_add_delayed(GET_TIMEOUT, &get_stop_task, test_get);
466 GNUNET_SCHEDULER_add_now (sched, &do_get, test_get->next); 461 GNUNET_SCHEDULER_add_now (&do_get, test_get->next);
467} 462}
468 463
469/** 464/**
@@ -477,12 +472,12 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
477 outstanding_puts--; 472 outstanding_puts--;
478 puts_completed++; 473 puts_completed++;
479 474
480 GNUNET_SCHEDULER_cancel(sched, test_put->disconnect_task); 475 GNUNET_SCHEDULER_cancel(test_put->disconnect_task);
481 test_put->disconnect_task = GNUNET_SCHEDULER_add_now(sched, &put_disconnect_task, test_put); 476 test_put->disconnect_task = GNUNET_SCHEDULER_add_now(&put_disconnect_task, test_put);
482 if (puts_completed == num_puts) 477 if (puts_completed == num_puts)
483 { 478 {
484 GNUNET_assert(outstanding_puts == 0); 479 GNUNET_assert(outstanding_puts == 0);
485 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), &do_get, all_gets); 480 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), &do_get, all_gets);
486 return; 481 return;
487 } 482 }
488} 483}
@@ -505,7 +500,7 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
505 500
506 if (outstanding_puts > MAX_OUTSTANDING_PUTS) 501 if (outstanding_puts > MAX_OUTSTANDING_PUTS)
507 { 502 {
508 GNUNET_SCHEDULER_add_delayed (sched, PUT_DELAY, &do_put, test_put); 503 GNUNET_SCHEDULER_add_delayed (PUT_DELAY, &do_put, test_put);
509 return; 504 return;
510 } 505 }
511 506
@@ -514,7 +509,7 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
514 test_put->uid, 509 test_put->uid,
515 test_put->daemon->shortname); 510 test_put->daemon->shortname);
516#endif 511#endif
517 test_put->dht_handle = GNUNET_DHT_connect(sched, test_put->daemon->cfg, 10); 512 test_put->dht_handle = GNUNET_DHT_connect(test_put->daemon->cfg, 10);
518 513
519 GNUNET_assert(test_put->dht_handle != NULL); 514 GNUNET_assert(test_put->dht_handle != NULL);
520 outstanding_puts++; 515 outstanding_puts++;
@@ -526,8 +521,8 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
526 GNUNET_TIME_UNIT_FOREVER_ABS, 521 GNUNET_TIME_UNIT_FOREVER_ABS,
527 GNUNET_TIME_UNIT_FOREVER_REL, 522 GNUNET_TIME_UNIT_FOREVER_REL,
528 &put_finished, test_put); 523 &put_finished, test_put);
529 test_put->disconnect_task = GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_get_forever(), &put_disconnect_task, test_put); 524 test_put->disconnect_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_get_forever(), &put_disconnect_task, test_put);
530 GNUNET_SCHEDULER_add_now(sched, &do_put, test_put->next); 525 GNUNET_SCHEDULER_add_now(&do_put, test_put->next);
531} 526}
532 527
533 528
@@ -568,7 +563,7 @@ setup_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
568 all_gets = test_get; 563 all_gets = test_get;
569 } 564 }
570 565
571 GNUNET_SCHEDULER_add_now (sched, &do_put, all_puts); 566 GNUNET_SCHEDULER_add_now (&do_put, all_puts);
572} 567}
573 568
574 569
@@ -619,17 +614,16 @@ topology_callback (void *cls,
619 "Created %d total connections, which is our target number! Starting next phase of testing.\n", 614 "Created %d total connections, which is our target number! Starting next phase of testing.\n",
620 total_connections); 615 total_connections);
621#endif 616#endif
622 GNUNET_SCHEDULER_cancel (sched, die_task); 617 GNUNET_SCHEDULER_cancel (die_task);
623 die_task = GNUNET_SCHEDULER_add_delayed (sched, TIMEOUT, 618 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
624 &end_badly, "from setup puts/gets"); 619 &end_badly, "from setup puts/gets");
625 620
626 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &setup_puts_and_gets, NULL); 621 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &setup_puts_and_gets, NULL);
627 } 622 }
628 else if (total_connections + failed_connections == expected_connections) 623 else if (total_connections + failed_connections == expected_connections)
629 { 624 {
630 GNUNET_SCHEDULER_cancel (sched, die_task); 625 GNUNET_SCHEDULER_cancel (die_task);
631 die_task = GNUNET_SCHEDULER_add_now (sched, 626 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many failed connections)");
632 &end_badly, "from topology_callback (too many failed connections)");
633 } 627 }
634} 628}
635 629
@@ -661,7 +655,7 @@ peers_started_callback (void *cls,
661 "All %d daemons started, now connecting peers!\n", 655 "All %d daemons started, now connecting peers!\n",
662 num_peers); 656 num_peers);
663#endif 657#endif
664 GNUNET_SCHEDULER_cancel (sched, die_task); 658 GNUNET_SCHEDULER_cancel (die_task);
665 659
666 expected_connections = -1; 660 expected_connections = -1;
667 if ((pg != NULL) && (peers_left == 0)) 661 if ((pg != NULL) && (peers_left == 0))
@@ -675,12 +669,10 @@ peers_started_callback (void *cls,
675 669
676 if (expected_connections == GNUNET_SYSERR) 670 if (expected_connections == GNUNET_SYSERR)
677 { 671 {
678 die_task = GNUNET_SCHEDULER_add_now (sched, 672 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)");
679 &end_badly, "from connect topology (bad return)");
680 } 673 }
681 674
682 die_task = GNUNET_SCHEDULER_add_delayed (sched, 675 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
683 TIMEOUT,
684 &end_badly, "from connect topology (timeout)"); 676 &end_badly, "from connect topology (timeout)");
685 677
686 ok = 0; 678 ok = 0;
@@ -701,13 +693,11 @@ create_topology ()
701 } 693 }
702 else 694 else
703 { 695 {
704 GNUNET_SCHEDULER_cancel (sched, die_task); 696 GNUNET_SCHEDULER_cancel (die_task);
705 die_task = GNUNET_SCHEDULER_add_now (sched, 697 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from create topology (bad return)");
706 &end_badly, "from create topology (bad return)");
707 } 698 }
708 GNUNET_SCHEDULER_cancel (sched, die_task); 699 GNUNET_SCHEDULER_cancel (die_task);
709 die_task = GNUNET_SCHEDULER_add_delayed (sched, 700 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
710 TIMEOUT,
711 &end_badly, "from continue startup (timeout)"); 701 &end_badly, "from continue startup (timeout)");
712} 702}
713 703
@@ -744,13 +734,12 @@ void hostkey_callback (void *cls,
744 "All %d hostkeys created, now creating topology!\n", 734 "All %d hostkeys created, now creating topology!\n",
745 num_peers); 735 num_peers);
746#endif 736#endif
747 GNUNET_SCHEDULER_cancel (sched, die_task); 737 GNUNET_SCHEDULER_cancel (die_task);
748 /* Set up task in case topology creation doesn't finish 738 /* Set up task in case topology creation doesn't finish
749 * within a reasonable amount of time */ 739 * within a reasonable amount of time */
750 die_task = GNUNET_SCHEDULER_add_delayed (sched, 740 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
751 TIMEOUT,
752 &end_badly, "from create_topology"); 741 &end_badly, "from create_topology");
753 GNUNET_SCHEDULER_add_now(sched, &create_topology, NULL); 742 GNUNET_SCHEDULER_add_now(&create_topology, NULL);
754 ok = 0; 743 ok = 0;
755 } 744 }
756} 745}
@@ -758,7 +747,6 @@ void hostkey_callback (void *cls,
758 747
759static void 748static void
760run (void *cls, 749run (void *cls,
761 struct GNUNET_SCHEDULER_Handle *s,
762 char *const *args, 750 char *const *args,
763 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 751 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
764{ 752{
@@ -767,7 +755,6 @@ run (void *cls,
767 char * blacklist_topology_str; 755 char * blacklist_topology_str;
768 char * connect_topology_option_str; 756 char * connect_topology_option_str;
769 char * connect_topology_option_modifier_string; 757 char * connect_topology_option_modifier_string;
770 sched = s;
771 758
772 /* Get path from configuration file */ 759 /* Get path from configuration file */
773 if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string(cfg, "paths", "servicehome", &test_directory)) 760 if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string(cfg, "paths", "servicehome", &test_directory))
@@ -851,11 +838,10 @@ run (void *cls,
851 peers_left = num_peers; 838 peers_left = num_peers;
852 839
853 /* Set up a task to end testing if peer start fails */ 840 /* Set up a task to end testing if peer start fails */
854 die_task = GNUNET_SCHEDULER_add_delayed (sched, 841 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers),
855 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers),
856 &end_badly, "didn't generate all hostkeys within a reasonable amount of time!!!"); 842 &end_badly, "didn't generate all hostkeys within a reasonable amount of time!!!");
857 843
858 pg = GNUNET_TESTING_daemons_start (sched, cfg, 844 pg = GNUNET_TESTING_daemons_start (cfg,
859 peers_left, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), &hostkey_callback, NULL, &peers_started_callback, NULL, 845 peers_left, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), &hostkey_callback, NULL, &peers_started_callback, NULL,
860 &topology_callback, NULL, NULL); 846 &topology_callback, NULL, NULL);
861 847
diff --git a/src/dht/test_dht_twopeer.c b/src/dht/test_dht_twopeer.c
index 06807f82a..6f3d5060d 100644
--- a/src/dht/test_dht_twopeer.c
+++ b/src/dht/test_dht_twopeer.c
@@ -62,8 +62,6 @@ static unsigned long long peers_left;
62 62
63static struct GNUNET_TESTING_PeerGroup *pg; 63static struct GNUNET_TESTING_PeerGroup *pg;
64 64
65static struct GNUNET_SCHEDULER_Handle *sched;
66
67static unsigned long long num_peers; 65static unsigned long long num_peers;
68 66
69static unsigned int total_gets; 67static unsigned int total_gets;
@@ -124,21 +122,21 @@ end_badly_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
124 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); 122 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
125 123
126 if (curr_get_ctx.retry_task != GNUNET_SCHEDULER_NO_TASK) 124 if (curr_get_ctx.retry_task != GNUNET_SCHEDULER_NO_TASK)
127 GNUNET_SCHEDULER_cancel(sched, curr_get_ctx.retry_task); 125 GNUNET_SCHEDULER_cancel(curr_get_ctx.retry_task);
128} 126}
129 127
130static void 128static void
131end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 129end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
132{ 130{
133 if (curr_get_ctx.retry_task != GNUNET_SCHEDULER_NO_TASK) 131 if (curr_get_ctx.retry_task != GNUNET_SCHEDULER_NO_TASK)
134 GNUNET_SCHEDULER_cancel(sched, curr_get_ctx.retry_task); 132 GNUNET_SCHEDULER_cancel(curr_get_ctx.retry_task);
135 133
136 if (curr_get_ctx.get_handle != NULL) 134 if (curr_get_ctx.get_handle != NULL)
137 { 135 {
138 GNUNET_DHT_get_stop(curr_get_ctx.get_handle); 136 GNUNET_DHT_get_stop(curr_get_ctx.get_handle);
139 } 137 }
140 138
141 GNUNET_SCHEDULER_add_now (sched, &end_badly_cont, NULL); 139 GNUNET_SCHEDULER_add_now (&end_badly_cont, NULL);
142 ok = 1; 140 ok = 1;
143} 141}
144 142
@@ -171,14 +169,14 @@ void get_result_iterator (void *cls,
171 if (0 != memcmp(&get_context->peer->hashPubKey, key, sizeof (GNUNET_HashCode))) 169 if (0 != memcmp(&get_context->peer->hashPubKey, key, sizeof (GNUNET_HashCode)))
172 { 170 {
173 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Key returned is not the same key as was searched for!\n"); 171 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Key returned is not the same key as was searched for!\n");
174 GNUNET_SCHEDULER_cancel(sched, die_task); 172 GNUNET_SCHEDULER_cancel(die_task);
175 GNUNET_SCHEDULER_add_now(sched, &end_badly, "key mismatch in get response!\n"); 173 GNUNET_SCHEDULER_add_now(&end_badly, "key mismatch in get response!\n");
176 return; 174 return;
177 } 175 }
178 176
179 if (get_context->retry_task != GNUNET_SCHEDULER_NO_TASK) 177 if (get_context->retry_task != GNUNET_SCHEDULER_NO_TASK)
180 { 178 {
181 GNUNET_SCHEDULER_cancel(sched, get_context->retry_task); 179 GNUNET_SCHEDULER_cancel(get_context->retry_task);
182 get_context->retry_task = GNUNET_SCHEDULER_NO_TASK; 180 get_context->retry_task = GNUNET_SCHEDULER_NO_TASK;
183 } 181 }
184 182
@@ -188,14 +186,14 @@ void get_result_iterator (void *cls,
188 get_context->dht_handle = peer2dht; 186 get_context->dht_handle = peer2dht;
189 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received first correct GET request response!\n"); 187 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received first correct GET request response!\n");
190 GNUNET_DHT_get_stop(get_context->get_handle); 188 GNUNET_DHT_get_stop(get_context->get_handle);
191 GNUNET_SCHEDULER_add_now (sched, &do_get, get_context); 189 GNUNET_SCHEDULER_add_now (&do_get, get_context);
192 } 190 }
193 else 191 else
194 { 192 {
195 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received second correct GET request response!\n"); 193 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received second correct GET request response!\n");
196 GNUNET_SCHEDULER_cancel(sched, die_task); 194 GNUNET_SCHEDULER_cancel(die_task);
197 GNUNET_DHT_get_stop(get_context->get_handle); 195 GNUNET_DHT_get_stop(get_context->get_handle);
198 GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); 196 GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
199 } 197 }
200 198
201} 199}
@@ -213,14 +211,13 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
213 else 211 else
214 { 212 {
215 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Too many attempts failed, ending test!\n", get_context->get_attempts); 213 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Too many attempts failed, ending test!\n", get_context->get_attempts);
216 GNUNET_SCHEDULER_cancel(sched, die_task); 214 GNUNET_SCHEDULER_cancel(die_task);
217 GNUNET_SCHEDULER_add_now(sched, &end_badly, "key mismatch in get response!\n"); 215 GNUNET_SCHEDULER_add_now(&end_badly, "key mismatch in get response!\n");
218 return; 216 return;
219 } 217 }
220 get_context->get_attempts++; 218 get_context->get_attempts++;
221 get_context->retry_task = GNUNET_SCHEDULER_add_delayed(sched, 219 get_context->retry_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10),
222 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), 220 &stop_retry_get, get_context);
223 &stop_retry_get, get_context);
224 get_context->get_handle = GNUNET_DHT_get_start(get_context->dht_handle, 221 get_context->get_handle = GNUNET_DHT_get_start(get_context->dht_handle,
225 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), 222 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5),
226 0 /* fixme: use real type */, &get_context->peer->hashPubKey, 223 0 /* fixme: use real type */, &get_context->peer->hashPubKey,
@@ -238,7 +235,7 @@ stop_retry_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
238 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Get attempt %u failed, canceling request!\n", get_context->get_attempts); 235 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Get attempt %u failed, canceling request!\n", get_context->get_attempts);
239 GNUNET_DHT_get_stop(get_context->get_handle); 236 GNUNET_DHT_get_stop(get_context->get_handle);
240 get_context->get_handle = NULL; 237 get_context->get_handle = NULL;
241 GNUNET_SCHEDULER_add_now(sched, &get_stop_finished, get_context); 238 GNUNET_SCHEDULER_add_now(&get_stop_finished, get_context);
242} 239}
243 240
244static void 241static void
@@ -246,8 +243,7 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
246{ 243{
247 struct PeerGetContext *get_context = cls; 244 struct PeerGetContext *get_context = cls;
248 245
249 get_context->retry_task = GNUNET_SCHEDULER_add_delayed(sched, 246 get_context->retry_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10),
250 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10),
251 &stop_retry_get, get_context); 247 &stop_retry_get, get_context);
252 248
253 get_context->get_handle = GNUNET_DHT_get_start(get_context->dht_handle, 249 get_context->get_handle = GNUNET_DHT_get_start(get_context->dht_handle,
@@ -299,20 +295,19 @@ topology_callback (void *cls,
299 "Created %d total connections, which is our target number! Starting next phase of testing.\n", 295 "Created %d total connections, which is our target number! Starting next phase of testing.\n",
300 total_connections); 296 total_connections);
301#endif 297#endif
302 GNUNET_SCHEDULER_cancel (sched, die_task); 298 GNUNET_SCHEDULER_cancel (die_task);
303 die_task = GNUNET_SCHEDULER_add_delayed (sched, TIMEOUT, 299 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
304 &end_badly, "from test gets"); 300 &end_badly, "from test gets");
305 301
306 curr_get_ctx.dht_handle = peer1dht; 302 curr_get_ctx.dht_handle = peer1dht;
307 curr_get_ctx.peer = &peer2id; 303 curr_get_ctx.peer = &peer2id;
308 //GNUNET_SCHEDULER_add_now (sched, &do_get, &curr_get_ctx); 304 //GNUNET_SCHEDULER_add_now (&do_get, &curr_get_ctx);
309 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &do_get, &curr_get_ctx); 305 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &do_get, &curr_get_ctx);
310 } 306 }
311 else if (total_connections + failed_connections == expected_connections) 307 else if (total_connections + failed_connections == expected_connections)
312 { 308 {
313 GNUNET_SCHEDULER_cancel (sched, die_task); 309 GNUNET_SCHEDULER_cancel (die_task);
314 die_task = GNUNET_SCHEDULER_add_now (sched, 310 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many failed connections)");
315 &end_badly, "from topology_callback (too many failed connections)");
316 } 311 }
317} 312}
318 313
@@ -323,14 +318,12 @@ connect_topology (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
323 if ((pg != NULL) && (peers_left == 0)) 318 if ((pg != NULL) && (peers_left == 0))
324 expected_connections = GNUNET_TESTING_connect_topology (pg, GNUNET_TESTING_TOPOLOGY_CLIQUE, GNUNET_TESTING_TOPOLOGY_OPTION_ALL, 0.0, NULL, NULL); 319 expected_connections = GNUNET_TESTING_connect_topology (pg, GNUNET_TESTING_TOPOLOGY_CLIQUE, GNUNET_TESTING_TOPOLOGY_OPTION_ALL, 0.0, NULL, NULL);
325 320
326 GNUNET_SCHEDULER_cancel (sched, die_task); 321 GNUNET_SCHEDULER_cancel (die_task);
327 if (expected_connections == GNUNET_SYSERR) 322 if (expected_connections == GNUNET_SYSERR)
328 die_task = GNUNET_SCHEDULER_add_now (sched, 323 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)");
329 &end_badly, "from connect topology (bad return)");
330 324
331 325
332 die_task = GNUNET_SCHEDULER_add_delayed (sched, 326 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
333 TIMEOUT,
334 &end_badly, "from connect topology (timeout)"); 327 &end_badly, "from connect topology (timeout)");
335} 328}
336 329
@@ -350,21 +343,21 @@ peers_started_callback (void *cls,
350 if (peers_left == num_peers) 343 if (peers_left == num_peers)
351 { 344 {
352 memcpy(&peer1id, id, sizeof(struct GNUNET_PeerIdentity)); 345 memcpy(&peer1id, id, sizeof(struct GNUNET_PeerIdentity));
353 peer1dht = GNUNET_DHT_connect(sched, cfg, 100); 346 peer1dht = GNUNET_DHT_connect(cfg, 100);
354 if (peer1dht == NULL) 347 if (peer1dht == NULL)
355 { 348 {
356 GNUNET_SCHEDULER_cancel (sched, die_task); 349 GNUNET_SCHEDULER_cancel (die_task);
357 GNUNET_SCHEDULER_add_now(sched, &end_badly, "Failed to get dht handle!\n"); 350 GNUNET_SCHEDULER_add_now(&end_badly, "Failed to get dht handle!\n");
358 } 351 }
359 } 352 }
360 else 353 else
361 { 354 {
362 memcpy(&peer2id, id, sizeof(struct GNUNET_PeerIdentity)); 355 memcpy(&peer2id, id, sizeof(struct GNUNET_PeerIdentity));
363 peer2dht = GNUNET_DHT_connect(sched, cfg, 100); 356 peer2dht = GNUNET_DHT_connect(cfg, 100);
364 if (peer2dht == NULL) 357 if (peer2dht == NULL)
365 { 358 {
366 GNUNET_SCHEDULER_cancel (sched, die_task); 359 GNUNET_SCHEDULER_cancel (die_task);
367 GNUNET_SCHEDULER_add_now(sched, &end_badly, "Failed to get dht handle!\n"); 360 GNUNET_SCHEDULER_add_now(&end_badly, "Failed to get dht handle!\n");
368 } 361 }
369 } 362 }
370 363
@@ -378,25 +371,22 @@ peers_started_callback (void *cls,
378 "All %d daemons started, now connecting peers!\n", 371 "All %d daemons started, now connecting peers!\n",
379 num_peers); 372 num_peers);
380#endif 373#endif
381 GNUNET_SCHEDULER_cancel (sched, die_task); 374 GNUNET_SCHEDULER_cancel (die_task);
382 /* Set up task in case topology creation doesn't finish 375 /* Set up task in case topology creation doesn't finish
383 * within a reasonable amount of time */ 376 * within a reasonable amount of time */
384 die_task = GNUNET_SCHEDULER_add_delayed (sched, 377 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
385 TIMEOUT,
386 &end_badly, "from peers_started_callback"); 378 &end_badly, "from peers_started_callback");
387 379
388 GNUNET_SCHEDULER_add_now(sched, &connect_topology, NULL); 380 GNUNET_SCHEDULER_add_now(&connect_topology, NULL);
389 ok = 0; 381 ok = 0;
390 } 382 }
391} 383}
392 384
393static void 385static void
394run (void *cls, 386run (void *cls,
395 struct GNUNET_SCHEDULER_Handle *s,
396 char *const *args, 387 char *const *args,
397 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 388 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
398{ 389{
399 sched = s;
400 390
401 if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string(cfg, "paths", "servicehome", &test_directory)) 391 if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string(cfg, "paths", "servicehome", &test_directory))
402 { 392 {
@@ -413,11 +403,10 @@ run (void *cls,
413 total_gets = num_peers; 403 total_gets = num_peers;
414 gets_succeeded = 0; 404 gets_succeeded = 0;
415 /* Set up a task to end testing if peer start fails */ 405 /* Set up a task to end testing if peer start fails */
416 die_task = GNUNET_SCHEDULER_add_delayed (sched, 406 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
417 TIMEOUT,
418 &end_badly, "didn't start all daemons in reasonable amount of time!!!"); 407 &end_badly, "didn't start all daemons in reasonable amount of time!!!");
419 408
420 pg = GNUNET_TESTING_daemons_start (sched, cfg, 409 pg = GNUNET_TESTING_daemons_start (cfg,
421 num_peers, TIMEOUT, NULL, NULL, &peers_started_callback, NULL, 410 num_peers, TIMEOUT, NULL, NULL, &peers_started_callback, NULL,
422 &topology_callback, NULL, NULL); 411 &topology_callback, NULL, NULL);
423 412
diff --git a/src/dht/test_dht_twopeer_put_get.c b/src/dht/test_dht_twopeer_put_get.c
index b57faeb83..0f61f4930 100644
--- a/src/dht/test_dht_twopeer_put_get.c
+++ b/src/dht/test_dht_twopeer_put_get.c
@@ -80,10 +80,6 @@ static struct GNUNET_TESTING_PeerGroup *pg;
80 */ 80 */
81struct GNUNET_DHT_GetHandle *global_get_handle; 81struct GNUNET_DHT_GetHandle *global_get_handle;
82 82
83/**
84 * Global scheduler, used for all GNUNET_SCHEDULER_* functions.
85 */
86static struct GNUNET_SCHEDULER_Handle *sched;
87 83
88/** 84/**
89 * Total number of peers to run, set based on config file. 85 * Total number of peers to run, set based on config file.
@@ -190,7 +186,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
190 GNUNET_DHT_get_stop(global_get_handle); 186 GNUNET_DHT_get_stop(global_get_handle);
191 global_get_handle = NULL; 187 global_get_handle = NULL;
192 } 188 }
193 GNUNET_SCHEDULER_add_now(sched, &end_badly_cont, NULL); 189 GNUNET_SCHEDULER_add_now(&end_badly_cont, NULL);
194 ok = 1; 190 ok = 1;
195} 191}
196 192
@@ -221,15 +217,15 @@ void get_result_iterator (void *cls,
221 if ((0 != memcmp(&original_key, key, sizeof (GNUNET_HashCode))) || (0 != memcmp(original_data, data, sizeof(original_data)))) 217 if ((0 != memcmp(&original_key, key, sizeof (GNUNET_HashCode))) || (0 != memcmp(original_data, data, sizeof(original_data))))
222 { 218 {
223 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Key or data is not the same as was inserted!\n"); 219 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Key or data is not the same as was inserted!\n");
224 GNUNET_SCHEDULER_cancel(sched, die_task); 220 GNUNET_SCHEDULER_cancel(die_task);
225 GNUNET_SCHEDULER_add_now(sched, &end_badly, "key or data mismatch in get response!\n"); 221 GNUNET_SCHEDULER_add_now(&end_badly, "key or data mismatch in get response!\n");
226 return; 222 return;
227 } 223 }
228 224
229 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received correct GET response!\n"); 225 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received correct GET response!\n");
230 GNUNET_SCHEDULER_cancel(sched, die_task); 226 GNUNET_SCHEDULER_cancel(die_task);
231 GNUNET_DHT_get_stop(global_get_handle); 227 GNUNET_DHT_get_stop(global_get_handle);
232 GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); 228 GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
233} 229}
234 230
235/** 231/**
@@ -256,10 +252,10 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
256static void 252static void
257put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 253put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
258{ 254{
259 GNUNET_SCHEDULER_cancel (sched, die_task); 255 GNUNET_SCHEDULER_cancel (die_task);
260 die_task = GNUNET_SCHEDULER_add_delayed (sched, GET_TIMEOUT, 256 die_task = GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT,
261 &end_badly, "waiting for get response (data not found)"); 257 &end_badly, "waiting for get response (data not found)");
262 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), &do_get, NULL); 258 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), &do_get, NULL);
263} 259}
264 260
265/** 261/**
@@ -331,17 +327,16 @@ topology_callback (void *cls,
331 "Created %d total connections, which is our target number! Starting next phase of testing.\n", 327 "Created %d total connections, which is our target number! Starting next phase of testing.\n",
332 total_connections); 328 total_connections);
333#endif 329#endif
334 GNUNET_SCHEDULER_cancel (sched, die_task); 330 GNUNET_SCHEDULER_cancel (die_task);
335 die_task = GNUNET_SCHEDULER_add_delayed (sched, TIMEOUT, 331 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
336 &end_badly, "from test gets"); 332 &end_badly, "from test gets");
337 333
338 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &do_put, NULL); 334 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &do_put, NULL);
339 } 335 }
340 else if (total_connections + failed_connections == expected_connections) 336 else if (total_connections + failed_connections == expected_connections)
341 { 337 {
342 GNUNET_SCHEDULER_cancel (sched, die_task); 338 GNUNET_SCHEDULER_cancel (die_task);
343 die_task = GNUNET_SCHEDULER_add_now (sched, 339 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many failed connections)");
344 &end_badly, "from topology_callback (too many failed connections)");
345 } 340 }
346} 341}
347 342
@@ -375,21 +370,21 @@ peers_started_callback (void *cls,
375 if (peers_left == num_peers) 370 if (peers_left == num_peers)
376 { 371 {
377 memcpy(&peer1id, id, sizeof(struct GNUNET_PeerIdentity)); /* Save the peer id */ 372 memcpy(&peer1id, id, sizeof(struct GNUNET_PeerIdentity)); /* Save the peer id */
378 peer1dht = GNUNET_DHT_connect(sched, cfg, 100); /* Connect to the first peers DHT service */ 373 peer1dht = GNUNET_DHT_connect(cfg, 100); /* Connect to the first peers DHT service */
379 if (peer1dht == NULL) /* If DHT connect failed */ 374 if (peer1dht == NULL) /* If DHT connect failed */
380 { 375 {
381 GNUNET_SCHEDULER_cancel (sched, die_task); 376 GNUNET_SCHEDULER_cancel (die_task);
382 GNUNET_SCHEDULER_add_now(sched, &end_badly, "Failed to get dht handle!\n"); 377 GNUNET_SCHEDULER_add_now(&end_badly, "Failed to get dht handle!\n");
383 } 378 }
384 } 379 }
385 else /* This is the second peer started */ 380 else /* This is the second peer started */
386 { 381 {
387 memcpy(&peer2id, id, sizeof(struct GNUNET_PeerIdentity)); /* Same as for first peer... */ 382 memcpy(&peer2id, id, sizeof(struct GNUNET_PeerIdentity)); /* Same as for first peer... */
388 peer2dht = GNUNET_DHT_connect(sched, cfg, 100); 383 peer2dht = GNUNET_DHT_connect(cfg, 100);
389 if (peer2dht == NULL) 384 if (peer2dht == NULL)
390 { 385 {
391 GNUNET_SCHEDULER_cancel (sched, die_task); 386 GNUNET_SCHEDULER_cancel (die_task);
392 GNUNET_SCHEDULER_add_now(sched, &end_badly, "Failed to get dht handle!\n"); 387 GNUNET_SCHEDULER_add_now(&end_badly, "Failed to get dht handle!\n");
393 } 388 }
394 } 389 }
395 390
@@ -411,14 +406,12 @@ peers_started_callback (void *cls,
411 } 406 }
412 407
413 /* Cancel current timeout fail task */ 408 /* Cancel current timeout fail task */
414 GNUNET_SCHEDULER_cancel (sched, die_task); 409 GNUNET_SCHEDULER_cancel (die_task);
415 if (expected_connections == GNUNET_SYSERR) /* Some error happened */ 410 if (expected_connections == GNUNET_SYSERR) /* Some error happened */
416 die_task = GNUNET_SCHEDULER_add_now (sched, 411 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)");
417 &end_badly, "from connect topology (bad return)");
418 412
419 /* Schedule timeout on failure task */ 413 /* Schedule timeout on failure task */
420 die_task = GNUNET_SCHEDULER_add_delayed (sched, 414 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
421 TIMEOUT,
422 &end_badly, "from connect topology (timeout)"); 415 &end_badly, "from connect topology (timeout)");
423 ok = 0; 416 ok = 0;
424 } 417 }
@@ -426,11 +419,9 @@ peers_started_callback (void *cls,
426 419
427static void 420static void
428run (void *cls, 421run (void *cls,
429 struct GNUNET_SCHEDULER_Handle *s,
430 char *const *args, 422 char *const *args,
431 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 423 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
432{ 424{
433 sched = s;
434 425
435 /* Get path from configuration file */ 426 /* Get path from configuration file */
436 if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string(cfg, "paths", "servicehome", &test_directory)) 427 if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string(cfg, "paths", "servicehome", &test_directory))
@@ -449,13 +440,12 @@ run (void *cls,
449 peers_left = num_peers; 440 peers_left = num_peers;
450 441
451 /* Set up a task to end testing if peer start fails */ 442 /* Set up a task to end testing if peer start fails */
452 die_task = GNUNET_SCHEDULER_add_delayed (sched, 443 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
453 TIMEOUT,
454 &end_badly, "didn't start all daemons in reasonable amount of time!!!"); 444 &end_badly, "didn't start all daemons in reasonable amount of time!!!");
455 445
456 /* Start num_peers peers, call peers_started_callback on peer start, topology_callback on peer connect */ 446 /* Start num_peers peers, call peers_started_callback on peer start, topology_callback on peer connect */
457 /* Read the API documentation for other parameters! */ 447 /* Read the API documentation for other parameters! */
458 pg = GNUNET_TESTING_daemons_start (sched, cfg, 448 pg = GNUNET_TESTING_daemons_start (cfg,
459 num_peers, TIMEOUT, NULL, NULL, &peers_started_callback, NULL, 449 num_peers, TIMEOUT, NULL, NULL, &peers_started_callback, NULL,
460 &topology_callback, NULL, NULL); 450 &topology_callback, NULL, NULL);
461 451
diff --git a/src/dht/test_dhtlog.c b/src/dht/test_dhtlog.c
index 667bf3d2a..06e2db2c4 100644
--- a/src/dht/test_dhtlog.c
+++ b/src/dht/test_dhtlog.c
@@ -190,7 +190,6 @@ test (struct GNUNET_DHTLOG_Handle * api)
190 190
191static void 191static void
192run (void *cls, 192run (void *cls,
193 struct GNUNET_SCHEDULER_Handle *sched,
194 char *const *args, 193 char *const *args,
195 const char *cfgfile, 194 const char *cfgfile,
196 const struct GNUNET_CONFIGURATION_Handle *cfg) 195 const struct GNUNET_CONFIGURATION_Handle *cfg)
diff --git a/src/dv/dv.h b/src/dv/dv.h
index 9916e1056..10b531ced 100644
--- a/src/dv/dv.h
+++ b/src/dv/dv.h
@@ -258,8 +258,7 @@ typedef struct
258 258
259 259
260struct GNUNET_DV_Handle * 260struct GNUNET_DV_Handle *
261GNUNET_DV_connect (struct GNUNET_SCHEDULER_Handle *sched, 261GNUNET_DV_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
262 const struct GNUNET_CONFIGURATION_Handle *cfg,
263 GNUNET_DV_MessageReceivedHandler receive_handler, 262 GNUNET_DV_MessageReceivedHandler receive_handler,
264 void *receive_handler_cls); 263 void *receive_handler_cls);
265 264
diff --git a/src/dv/dv_api.c b/src/dv/dv_api.c
index d9aef03c8..28c66af41 100644
--- a/src/dv/dv_api.c
+++ b/src/dv/dv_api.c
@@ -65,10 +65,6 @@ struct PendingMessages
65 */ 65 */
66struct GNUNET_DV_Handle 66struct GNUNET_DV_Handle
67{ 67{
68 /**
69 * Our scheduler.
70 */
71 struct GNUNET_SCHEDULER_Handle *sched;
72 68
73 /** 69 /**
74 * Configuration to use. 70 * Configuration to use.
@@ -175,7 +171,7 @@ try_connect (struct GNUNET_DV_Handle *ret)
175{ 171{
176 if (ret->client != NULL) 172 if (ret->client != NULL)
177 return GNUNET_OK; 173 return GNUNET_OK;
178 ret->client = GNUNET_CLIENT_connect (ret->sched, "dv", ret->cfg); 174 ret->client = GNUNET_CLIENT_connect ("dv", ret->cfg);
179 if (ret->client != NULL) 175 if (ret->client != NULL)
180 return GNUNET_YES; 176 return GNUNET_YES;
181#if DEBUG_DV_MESSAGES 177#if DEBUG_DV_MESSAGES
@@ -529,7 +525,6 @@ transmit_start (void *cls, size_t size, void *buf)
529/** 525/**
530 * Connect to the DV service 526 * Connect to the DV service
531 * 527 *
532 * @param sched the scheduler to use
533 * @param cfg the configuration to use 528 * @param cfg the configuration to use
534 * @param receive_handler method call when on receipt from the service 529 * @param receive_handler method call when on receipt from the service
535 * @param receive_handler_cls closure for receive_handler 530 * @param receive_handler_cls closure for receive_handler
@@ -537,8 +532,7 @@ transmit_start (void *cls, size_t size, void *buf)
537 * @return handle to the DV service 532 * @return handle to the DV service
538 */ 533 */
539struct GNUNET_DV_Handle * 534struct GNUNET_DV_Handle *
540GNUNET_DV_connect (struct GNUNET_SCHEDULER_Handle *sched, 535GNUNET_DV_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
541 const struct GNUNET_CONFIGURATION_Handle *cfg,
542 GNUNET_DV_MessageReceivedHandler receive_handler, 536 GNUNET_DV_MessageReceivedHandler receive_handler,
543 void *receive_handler_cls) 537 void *receive_handler_cls)
544{ 538{
@@ -548,11 +542,10 @@ GNUNET_DV_connect (struct GNUNET_SCHEDULER_Handle *sched,
548 handle = GNUNET_malloc(sizeof(struct GNUNET_DV_Handle)); 542 handle = GNUNET_malloc(sizeof(struct GNUNET_DV_Handle));
549 543
550 handle->cfg = cfg; 544 handle->cfg = cfg;
551 handle->sched = sched;
552 handle->pending_list = NULL; 545 handle->pending_list = NULL;
553 handle->current = NULL; 546 handle->current = NULL;
554 handle->th = NULL; 547 handle->th = NULL;
555 handle->client = GNUNET_CLIENT_connect(sched, "dv", cfg); 548 handle->client = GNUNET_CLIENT_connect("dv", cfg);
556 handle->receive_handler = receive_handler; 549 handle->receive_handler = receive_handler;
557 handle->receive_cls = receive_handler_cls; 550 handle->receive_cls = receive_handler_cls;
558 551
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c
index 2d91bce41..cfc1cd2d1 100644
--- a/src/dv/gnunet-service-dv.c
+++ b/src/dv/gnunet-service-dv.c
@@ -565,10 +565,6 @@ static struct GNUNET_PeerIdentity my_identity;
565 */ 565 */
566static const struct GNUNET_CONFIGURATION_Handle *cfg; 566static const struct GNUNET_CONFIGURATION_Handle *cfg;
567 567
568/**
569 * The scheduler for this service.
570 */
571static struct GNUNET_SCHEDULER_Handle *sched;
572 568
573/** 569/**
574 * The client, the DV plugin connected to us. Hopefully 570 * The client, the DV plugin connected to us. Hopefully
@@ -944,7 +940,7 @@ size_t core_transmit_notify (void *cls,
944 } 940 }
945 /*reply = core_pending_head;*/ 941 /*reply = core_pending_head;*/
946 942
947 GNUNET_SCHEDULER_add_now(sched, &try_core_send, NULL); 943 GNUNET_SCHEDULER_add_now(&try_core_send, NULL);
948 /*if (reply != NULL) 944 /*if (reply != NULL)
949 core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, reply->importance, reply->timeout, &reply->recipient, reply->msg_size, &core_transmit_notify, NULL);*/ 945 core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, reply->importance, reply->timeout, &reply->recipient, reply->msg_size, &core_transmit_notify, NULL);*/
950 946
@@ -1043,7 +1039,7 @@ send_message_via (const struct GNUNET_PeerIdentity *sender,
1043 core_pending_tail, 1039 core_pending_tail,
1044 pending_message); 1040 pending_message);
1045 1041
1046 GNUNET_SCHEDULER_add_now(sched, try_core_send, NULL); 1042 GNUNET_SCHEDULER_add_now(try_core_send, NULL);
1047 1043
1048 return GNUNET_YES; 1044 return GNUNET_YES;
1049} 1045}
@@ -1199,7 +1195,7 @@ send_message (const struct GNUNET_PeerIdentity * recipient,
1199 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Notifying core of send size %d to destination `%s'\n", "DV SEND MESSAGE", msg_size, GNUNET_i2s(recipient)); 1195 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Notifying core of send size %d to destination `%s'\n", "DV SEND MESSAGE", msg_size, GNUNET_i2s(recipient));
1200#endif 1196#endif
1201 1197
1202 GNUNET_SCHEDULER_add_now(sched, try_core_send, NULL); 1198 GNUNET_SCHEDULER_add_now(try_core_send, NULL);
1203 return (int) cost; 1199 return (int) cost;
1204} 1200}
1205 1201
@@ -1514,7 +1510,7 @@ static int handle_dv_data_message (void *cls,
1514 memcpy(delayed_context->message, packed_message, packed_message_size); 1510 memcpy(delayed_context->message, packed_message, packed_message_size);
1515 delayed_context->message_size = packed_message_size; 1511 delayed_context->message_size = packed_message_size;
1516 delayed_context->uid = ntohl(incoming->uid); 1512 delayed_context->uid = ntohl(incoming->uid);
1517 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 2500), &send_message_delayed, delayed_context); 1513 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 2500), &send_message_delayed, delayed_context);
1518 return GNUNET_OK; 1514 return GNUNET_OK;
1519 } 1515 }
1520 else 1516 else
@@ -1669,7 +1665,7 @@ neighbor_send_task (void *cls,
1669 core_pending_tail, 1665 core_pending_tail,
1670 pending_message); 1666 pending_message);
1671 1667
1672 GNUNET_SCHEDULER_add_now(sched, try_core_send, NULL); 1668 GNUNET_SCHEDULER_add_now(try_core_send, NULL);
1673 /*if (core_transmit_handle == NULL) 1669 /*if (core_transmit_handle == NULL)
1674 core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, default_dv_priority, GNUNET_TIME_relative_get_forever(), &to->identity, sizeof(p2p_dv_MESSAGE_NeighborInfo), &core_transmit_notify, NULL);*/ 1670 core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, default_dv_priority, GNUNET_TIME_relative_get_forever(), &to->identity, sizeof(p2p_dv_MESSAGE_NeighborInfo), &core_transmit_notify, NULL);*/
1675 1671
@@ -1680,14 +1676,14 @@ neighbor_send_task (void *cls,
1680#if DEBUG_DV_PEER_NUMBERS 1676#if DEBUG_DV_PEER_NUMBERS
1681 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "DV SERVICE: still in fast send mode\n"); 1677 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "DV SERVICE: still in fast send mode\n");
1682#endif 1678#endif
1683 send_context->task = GNUNET_SCHEDULER_add_now(sched, &neighbor_send_task, send_context); 1679 send_context->task = GNUNET_SCHEDULER_add_now(&neighbor_send_task, send_context);
1684 } 1680 }
1685 else 1681 else
1686 { 1682 {
1687#if DEBUG_DV_PEER_NUMBERS 1683#if DEBUG_DV_PEER_NUMBERS
1688 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "DV SERVICE: entering slow send mode\n"); 1684 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "DV SERVICE: entering slow send mode\n");
1689#endif 1685#endif
1690 send_context->task = GNUNET_SCHEDULER_add_delayed(sched, GNUNET_DV_DEFAULT_SEND_INTERVAL, &neighbor_send_task, send_context); 1686 send_context->task = GNUNET_SCHEDULER_add_delayed(GNUNET_DV_DEFAULT_SEND_INTERVAL, &neighbor_send_task, send_context);
1691 } 1687 }
1692 1688
1693 return; 1689 return;
@@ -1994,7 +1990,7 @@ direct_neighbor_free (struct DirectNeighbor *direct)
1994 send_context = direct->send_context; 1990 send_context = direct->send_context;
1995 1991
1996 if (send_context->task != GNUNET_SCHEDULER_NO_TASK) 1992 if (send_context->task != GNUNET_SCHEDULER_NO_TASK)
1997 GNUNET_SCHEDULER_cancel(sched, send_context->task); 1993 GNUNET_SCHEDULER_cancel(send_context->task);
1998 1994
1999 about_list = send_context->fast_gossip_list_head; 1995 about_list = send_context->fast_gossip_list_head;
2000 while (about_list != NULL) 1996 while (about_list != NULL)
@@ -2047,7 +2043,7 @@ static int schedule_disconnect_messages (void *cls,
2047 core_pending_tail, 2043 core_pending_tail,
2048 pending_message); 2044 pending_message);
2049 2045
2050 GNUNET_SCHEDULER_add_now(sched, try_core_send, NULL); 2046 GNUNET_SCHEDULER_add_now(try_core_send, NULL);
2051 /*if (core_transmit_handle == NULL) 2047 /*if (core_transmit_handle == NULL)
2052 core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, default_dv_priority, GNUNET_TIME_relative_get_forever(), &notify->identity, sizeof(p2p_dv_MESSAGE_Disconnect), &core_transmit_notify, NULL);*/ 2048 core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, default_dv_priority, GNUNET_TIME_relative_get_forever(), &notify->identity, sizeof(p2p_dv_MESSAGE_Disconnect), &core_transmit_notify, NULL);*/
2053 2049
@@ -2133,8 +2129,8 @@ void core_init (void *cls,
2133 2129
2134 if (server == NULL) 2130 if (server == NULL)
2135 { 2131 {
2136 GNUNET_SCHEDULER_cancel(sched, cleanup_task); 2132 GNUNET_SCHEDULER_cancel(cleanup_task);
2137 GNUNET_SCHEDULER_add_now(sched, &shutdown_task, NULL); 2133 GNUNET_SCHEDULER_add_now(&shutdown_task, NULL);
2138 return; 2134 return;
2139 } 2135 }
2140#if DEBUG_DV 2136#if DEBUG_DV
@@ -2265,9 +2261,9 @@ static int add_distant_all_direct_neighbors (void *cls,
2265 GNUNET_free(encPeerTo); 2261 GNUNET_free(encPeerTo);
2266#endif 2262#endif
2267 /*if (send_context->task != GNUNET_SCHEDULER_NO_TASK) 2263 /*if (send_context->task != GNUNET_SCHEDULER_NO_TASK)
2268 GNUNET_SCHEDULER_cancel(sched, send_context->task);*/ 2264 GNUNET_SCHEDULER_cancel(send_context->task);*/
2269 2265
2270 send_context->task = GNUNET_SCHEDULER_add_now(sched, &neighbor_send_task, send_context); 2266 send_context->task = GNUNET_SCHEDULER_add_now(&neighbor_send_task, send_context);
2271 return GNUNET_YES; 2267 return GNUNET_YES;
2272} 2268}
2273 2269
@@ -2673,9 +2669,9 @@ static int gossip_all_to_all_iterator (void *cls,
2673 GNUNET_CONTAINER_multihashmap_iterate (extended_neighbors, &add_all_extended_peers, direct->send_context); 2669 GNUNET_CONTAINER_multihashmap_iterate (extended_neighbors, &add_all_extended_peers, direct->send_context);
2674 2670
2675 if (direct->send_context->task != GNUNET_SCHEDULER_NO_TASK) 2671 if (direct->send_context->task != GNUNET_SCHEDULER_NO_TASK)
2676 GNUNET_SCHEDULER_cancel(sched, direct->send_context->task); 2672 GNUNET_SCHEDULER_cancel(direct->send_context->task);
2677 2673
2678 direct->send_context->task = GNUNET_SCHEDULER_add_now(sched, &neighbor_send_task, direct->send_context); 2674 direct->send_context->task = GNUNET_SCHEDULER_add_now(&neighbor_send_task, direct->send_context);
2679 return GNUNET_YES; 2675 return GNUNET_YES;
2680} 2676}
2681 2677
@@ -2691,8 +2687,7 @@ gossip_all_to_all (void *cls,
2691{ 2687{
2692 GNUNET_CONTAINER_multihashmap_iterate (direct_neighbors, &gossip_all_to_all_iterator, NULL); 2688 GNUNET_CONTAINER_multihashmap_iterate (direct_neighbors, &gossip_all_to_all_iterator, NULL);
2693 2689
2694 GNUNET_SCHEDULER_add_delayed (sched, 2690 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5),
2695 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5),
2696 &gossip_all_to_all, 2691 &gossip_all_to_all,
2697 NULL); 2692 NULL);
2698 2693
@@ -2749,9 +2744,9 @@ static int add_all_direct_neighbors (void *cls,
2749 send_context->fast_gossip_list_tail, 2744 send_context->fast_gossip_list_tail,
2750 gossip_entry); 2745 gossip_entry);
2751 if (send_context->task != GNUNET_SCHEDULER_NO_TASK) 2746 if (send_context->task != GNUNET_SCHEDULER_NO_TASK)
2752 GNUNET_SCHEDULER_cancel(sched, send_context->task); 2747 GNUNET_SCHEDULER_cancel(send_context->task);
2753 2748
2754 send_context->task = GNUNET_SCHEDULER_add_now(sched, &neighbor_send_task, send_context); 2749 send_context->task = GNUNET_SCHEDULER_add_now(&neighbor_send_task, send_context);
2755 //tc.reason = GNUNET_SCHEDULER_REASON_TIMEOUT; 2750 //tc.reason = GNUNET_SCHEDULER_REASON_TIMEOUT;
2756 //neighbor_send_task(send_context, &tc); 2751 //neighbor_send_task(send_context, &tc);
2757 return GNUNET_YES; 2752 return GNUNET_YES;
@@ -2827,7 +2822,7 @@ process_peerinfo (void *cls,
2827 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Gossipped about %s to %d direct peers\n", GNUNET_i2s(&my_identity), neighbor_pid, sent); 2822 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Gossipped about %s to %d direct peers\n", GNUNET_i2s(&my_identity), neighbor_pid, sent);
2828 GNUNET_free(neighbor_pid); 2823 GNUNET_free(neighbor_pid);
2829#endif 2824#endif
2830 neighbor->send_context->task = GNUNET_SCHEDULER_add_now(sched, &neighbor_send_task, neighbor->send_context); 2825 neighbor->send_context->task = GNUNET_SCHEDULER_add_now(&neighbor_send_task, neighbor->send_context);
2831 } 2826 }
2832} 2827}
2833 2828
@@ -2951,7 +2946,7 @@ void handle_core_disconnect (void *cls,
2951 GNUNET_break(0); 2946 GNUNET_break(0);
2952 } 2947 }
2953 if ((neighbor->send_context != NULL) && (neighbor->send_context->task != GNUNET_SCHEDULER_NO_TASK)) 2948 if ((neighbor->send_context != NULL) && (neighbor->send_context->task != GNUNET_SCHEDULER_NO_TASK))
2954 GNUNET_SCHEDULER_cancel(sched, neighbor->send_context->task); 2949 GNUNET_SCHEDULER_cancel(neighbor->send_context->task);
2955 GNUNET_free (neighbor); 2950 GNUNET_free (neighbor);
2956} 2951}
2957 2952
@@ -2960,18 +2955,15 @@ void handle_core_disconnect (void *cls,
2960 * Process dv requests. 2955 * Process dv requests.
2961 * 2956 *
2962 * @param cls closure 2957 * @param cls closure
2963 * @param scheduler scheduler to use
2964 * @param server the initialized server 2958 * @param server the initialized server
2965 * @param c configuration to use 2959 * @param c configuration to use
2966 */ 2960 */
2967static void 2961static void
2968run (void *cls, 2962run (void *cls,
2969 struct GNUNET_SCHEDULER_Handle *scheduler,
2970 struct GNUNET_SERVER_Handle *server, 2963 struct GNUNET_SERVER_Handle *server,
2971 const struct GNUNET_CONFIGURATION_Handle *c) 2964 const struct GNUNET_CONFIGURATION_Handle *c)
2972{ 2965{
2973 unsigned long long max_hosts; 2966 unsigned long long max_hosts;
2974 sched = scheduler;
2975 cfg = c; 2967 cfg = c;
2976 2968
2977 /* FIXME: Read from config, or calculate, or something other than this! */ 2969 /* FIXME: Read from config, or calculate, or something other than this! */
@@ -3000,8 +2992,7 @@ run (void *cls,
3000 2992
3001 GNUNET_SERVER_add_handlers (server, plugin_handlers); 2993 GNUNET_SERVER_add_handlers (server, plugin_handlers);
3002 coreAPI = 2994 coreAPI =
3003 GNUNET_CORE_connect (sched, 2995 GNUNET_CORE_connect (cfg,
3004 cfg,
3005 GNUNET_TIME_relative_get_forever(), 2996 GNUNET_TIME_relative_get_forever(),
3006 NULL, /* FIXME: anything we want to pass around? */ 2997 NULL, /* FIXME: anything we want to pass around? */
3007 &core_init, 2998 &core_init,
@@ -3020,7 +3011,7 @@ run (void *cls,
3020 coreMST = GNUNET_SERVER_mst_create (&tokenized_message_handler, 3011 coreMST = GNUNET_SERVER_mst_create (&tokenized_message_handler,
3021 NULL); 3012 NULL);
3022 3013
3023 peerinfo_handle = GNUNET_PEERINFO_connect(sched, cfg); 3014 peerinfo_handle = GNUNET_PEERINFO_connect(cfg);
3024 3015
3025 if (peerinfo_handle == NULL) 3016 if (peerinfo_handle == NULL)
3026 { 3017 {
@@ -3029,8 +3020,7 @@ run (void *cls,
3029 } 3020 }
3030 3021
3031 /* Scheduled the task to clean up when shutdown is called */ 3022 /* Scheduled the task to clean up when shutdown is called */
3032 cleanup_task = GNUNET_SCHEDULER_add_delayed (sched, 3023 cleanup_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
3033 GNUNET_TIME_UNIT_FOREVER_REL,
3034 &shutdown_task, 3024 &shutdown_task,
3035 NULL); 3025 NULL);
3036} 3026}
diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c
index 41f3a5140..b7616d2ac 100644
--- a/src/dv/plugin_transport_dv.c
+++ b/src/dv/plugin_transport_dv.c
@@ -389,7 +389,7 @@ libgnunet_plugin_transport_dv_init (void *cls)
389 plugin = GNUNET_malloc (sizeof (struct Plugin)); 389 plugin = GNUNET_malloc (sizeof (struct Plugin));
390 plugin->env = env; 390 plugin->env = env;
391 391
392 plugin->dv_handle = GNUNET_DV_connect(env->sched, env->cfg, &handle_dv_message_received, plugin); 392 plugin->dv_handle = GNUNET_DV_connect(env->cfg, &handle_dv_message_received, plugin);
393 393
394 if (plugin->dv_handle == NULL) 394 if (plugin->dv_handle == NULL)
395 { 395 {
diff --git a/src/dv/test_transport_api_dv.c b/src/dv/test_transport_api_dv.c
index d38f378ba..f53aa48f9 100644
--- a/src/dv/test_transport_api_dv.c
+++ b/src/dv/test_transport_api_dv.c
@@ -75,8 +75,6 @@ static unsigned long long peers_left;
75 75
76static struct GNUNET_TESTING_PeerGroup *pg; 76static struct GNUNET_TESTING_PeerGroup *pg;
77 77
78static struct GNUNET_SCHEDULER_Handle *sched;
79
80const struct GNUNET_CONFIGURATION_Handle *main_cfg; 78const struct GNUNET_CONFIGURATION_Handle *main_cfg;
81 79
82GNUNET_SCHEDULER_TaskIdentifier die_task; 80GNUNET_SCHEDULER_TaskIdentifier die_task;
@@ -231,7 +229,7 @@ finish_testing ()
231 pos = pos->next; 229 pos = pos->next;
232 if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK) 230 if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
233 { 231 {
234 GNUNET_SCHEDULER_cancel(sched, free_pos->disconnect_task); 232 GNUNET_SCHEDULER_cancel(free_pos->disconnect_task);
235 } 233 }
236 GNUNET_free(free_pos); 234 GNUNET_free(free_pos);
237 } 235 }
@@ -253,7 +251,7 @@ finish_testing ()
253 pos = pos->next; 251 pos = pos->next;
254 if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK) 252 if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
255 { 253 {
256 GNUNET_SCHEDULER_cancel(sched, free_pos->disconnect_task); 254 GNUNET_SCHEDULER_cancel(free_pos->disconnect_task);
257 } 255 }
258 GNUNET_free(free_pos); 256 GNUNET_free(free_pos);
259 } 257 }
@@ -364,7 +362,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
364 pos = pos->next; 362 pos = pos->next;
365 if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK) 363 if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
366 { 364 {
367 GNUNET_SCHEDULER_cancel(sched, free_pos->disconnect_task); 365 GNUNET_SCHEDULER_cancel(free_pos->disconnect_task);
368 } 366 }
369 GNUNET_free(free_pos); 367 GNUNET_free(free_pos);
370 } 368 }
@@ -423,28 +421,27 @@ process_mtype (void *cls,
423 421
424 if ((total_messages_received == expected_messages) && (total_other_messages == 0)) 422 if ((total_messages_received == expected_messages) && (total_other_messages == 0))
425 { 423 {
426 GNUNET_SCHEDULER_cancel (sched, die_task); 424 GNUNET_SCHEDULER_cancel (die_task);
427 die_task = GNUNET_SCHEDULER_add_delayed (sched, 425 die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT,
428 TEST_TIMEOUT,
429 &end_badly, "waiting for DV peers to connect!"); 426 &end_badly, "waiting for DV peers to connect!");
430 /* 427 /*
431 if ((num_peers == 3) && (total_other_expected_messages == 2)) 428 if ((num_peers == 3) && (total_other_expected_messages == 2))
432 { 429 {
433 GNUNET_SCHEDULER_add_now (sched, &send_other_messages, NULL); 430 GNUNET_SCHEDULER_add_now (&send_other_messages, NULL);
434 } 431 }
435 else 432 else
436 { 433 {
437 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20), &send_other_messages, NULL); 434 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20), &send_other_messages, NULL);
438 }*/ 435 }*/
439 } 436 }
440 else if ((total_other_expected_messages > 0) && (total_other_messages == total_other_expected_messages)) 437 else if ((total_other_expected_messages > 0) && (total_other_messages == total_other_expected_messages))
441 { 438 {
442 GNUNET_SCHEDULER_cancel (sched, die_task); 439 GNUNET_SCHEDULER_cancel (die_task);
443 GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); 440 GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
444 } 441 }
445 else 442 else
446 { 443 {
447 pos->disconnect_task = GNUNET_SCHEDULER_add_now(sched, &disconnect_cores, pos); 444 pos->disconnect_task = GNUNET_SCHEDULER_add_now(&disconnect_cores, pos);
448 } 445 }
449 446
450 return GNUNET_OK; 447 return GNUNET_OK;
@@ -531,8 +528,7 @@ init_notify_peer1 (void *cls,
531 /* 528 /*
532 * Connect to the receiving peer 529 * Connect to the receiving peer
533 */ 530 */
534 pos->peer2handle = GNUNET_CORE_connect (sched, 531 pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg,
535 pos->peer2->cfg,
536 TIMEOUT, 532 TIMEOUT,
537 pos, 533 pos,
538 &init_notify_peer2, 534 &init_notify_peer2,
@@ -554,14 +550,13 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
554 550
555 if (die_task == GNUNET_SCHEDULER_NO_TASK) 551 if (die_task == GNUNET_SCHEDULER_NO_TASK)
556 { 552 {
557 die_task = GNUNET_SCHEDULER_add_delayed (sched, 553 die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT,
558 TEST_TIMEOUT,
559 &end_badly, "from create topology (timeout)"); 554 &end_badly, "from create topology (timeout)");
560 } 555 }
561 556
562 if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) 557 if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS)
563 { 558 {
564 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), 559 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1),
565 &send_test_messages, pos); 560 &send_test_messages, pos);
566 return; /* Otherwise we'll double schedule messages here! */ 561 return; /* Otherwise we'll double schedule messages here! */
567 } 562 }
@@ -571,8 +566,7 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
571 /* 566 /*
572 * Connect to the sending peer 567 * Connect to the sending peer
573 */ 568 */
574 pos->peer1handle = GNUNET_CORE_connect (sched, 569 pos->peer1handle = GNUNET_CORE_connect (pos->peer1->cfg,
575 pos->peer1->cfg,
576 TIMEOUT, 570 TIMEOUT,
577 pos, 571 pos,
578 &init_notify_peer1, 572 &init_notify_peer1,
@@ -585,12 +579,11 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
585 579
586 if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS) 580 if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS)
587 { 581 {
588 GNUNET_SCHEDULER_add_now (sched, 582 GNUNET_SCHEDULER_add_now (&send_test_messages, pos->next);
589 &send_test_messages, pos->next);
590 } 583 }
591 else 584 else
592 { 585 {
593 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), 586 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1),
594 &send_test_messages, pos->next); 587 &send_test_messages, pos->next);
595 } 588 }
596} 589}
@@ -652,7 +645,7 @@ send_other_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
652 pos = pos->next; 645 pos = pos->next;
653 if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK) 646 if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
654 { 647 {
655 GNUNET_SCHEDULER_cancel(sched, free_pos->disconnect_task); 648 GNUNET_SCHEDULER_cancel(free_pos->disconnect_task);
656 } 649 }
657 GNUNET_free(free_pos); 650 GNUNET_free(free_pos);
658 } 651 }
@@ -661,15 +654,15 @@ send_other_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
661 total_other_expected_messages = temp_total_other_messages; 654 total_other_expected_messages = temp_total_other_messages;
662 if (total_other_expected_messages == 0) 655 if (total_other_expected_messages == 0)
663 { 656 {
664 GNUNET_SCHEDULER_add_now (sched, &end_badly, "send_other_messages had 0 messages to send, no DV connections made!"); 657 GNUNET_SCHEDULER_add_now (&end_badly, "send_other_messages had 0 messages to send, no DV connections made!");
665 } 658 }
666#if VERBOSE 659#if VERBOSE
667 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Preparing to send %d other test messages\n", total_other_expected_messages); 660 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Preparing to send %d other test messages\n", total_other_expected_messages);
668#endif 661#endif
669 662
670 GNUNET_SCHEDULER_add_now (sched, &send_test_messages, other_test_messages); 663 GNUNET_SCHEDULER_add_now (&send_test_messages, other_test_messages);
671 GNUNET_SCHEDULER_cancel(sched, die_task); 664 GNUNET_SCHEDULER_cancel(die_task);
672 die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 250), &end_badly, "from send_other_messages"); 665 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 250), &end_badly, "from send_other_messages");
673} 666}
674 667
675void 668void
@@ -722,23 +715,22 @@ topology_callback (void *cls,
722 total_connections); 715 total_connections);
723#endif 716#endif
724 717
725 GNUNET_SCHEDULER_cancel (sched, die_task); 718 GNUNET_SCHEDULER_cancel (die_task);
726 die_task = GNUNET_SCHEDULER_NO_TASK; 719 die_task = GNUNET_SCHEDULER_NO_TASK;
727 GNUNET_SCHEDULER_add_now (sched, &send_test_messages, test_messages); 720 GNUNET_SCHEDULER_add_now (&send_test_messages, test_messages);
728 } 721 }
729 else if (total_connections + failed_connections == expected_connections) 722 else if (total_connections + failed_connections == expected_connections)
730 { 723 {
731 if (failed_connections < (unsigned int)(fail_percentage * total_connections)) 724 if (failed_connections < (unsigned int)(fail_percentage * total_connections))
732 { 725 {
733 GNUNET_SCHEDULER_cancel (sched, die_task); 726 GNUNET_SCHEDULER_cancel (die_task);
734 die_task = GNUNET_SCHEDULER_NO_TASK; 727 die_task = GNUNET_SCHEDULER_NO_TASK;
735 GNUNET_SCHEDULER_add_now (sched, &send_test_messages, test_messages); 728 GNUNET_SCHEDULER_add_now (&send_test_messages, test_messages);
736 } 729 }
737 else 730 else
738 { 731 {
739 GNUNET_SCHEDULER_cancel (sched, die_task); 732 GNUNET_SCHEDULER_cancel (die_task);
740 die_task = GNUNET_SCHEDULER_add_now (sched, 733 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many failed connections)");
741 &end_badly, "from topology_callback (too many failed connections)");
742 } 734 }
743 } 735 }
744 else 736 else
@@ -764,15 +756,13 @@ connect_topology ()
764#endif 756#endif
765 } 757 }
766 758
767 GNUNET_SCHEDULER_cancel (sched, die_task); 759 GNUNET_SCHEDULER_cancel (die_task);
768 if (expected_connections == GNUNET_SYSERR) 760 if (expected_connections == GNUNET_SYSERR)
769 { 761 {
770 die_task = GNUNET_SCHEDULER_add_now (sched, 762 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)");
771 &end_badly, "from connect topology (bad return)");
772 } 763 }
773 764
774 die_task = GNUNET_SCHEDULER_add_delayed (sched, 765 die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT,
775 TEST_TIMEOUT,
776 &end_badly, "from connect topology (timeout)"); 766 &end_badly, "from connect topology (timeout)");
777} 767}
778 768
@@ -790,13 +780,11 @@ create_topology ()
790 } 780 }
791 else 781 else
792 { 782 {
793 GNUNET_SCHEDULER_cancel (sched, die_task); 783 GNUNET_SCHEDULER_cancel (die_task);
794 die_task = GNUNET_SCHEDULER_add_now (sched, 784 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from create topology (bad return)");
795 &end_badly, "from create topology (bad return)");
796 } 785 }
797 GNUNET_SCHEDULER_cancel (sched, die_task); 786 GNUNET_SCHEDULER_cancel (die_task);
798 die_task = GNUNET_SCHEDULER_add_delayed (sched, 787 die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT,
799 TEST_TIMEOUT,
800 &end_badly, "from continue startup (timeout)"); 788 &end_badly, "from continue startup (timeout)");
801} 789}
802 790
@@ -867,7 +855,7 @@ static void all_connect_handler (void *cls,
867 855
868 if (temp_total_other_messages == num_additional_messages) 856 if (temp_total_other_messages == num_additional_messages)
869 { 857 {
870 GNUNET_SCHEDULER_add_now (sched, &send_other_messages, NULL); 858 GNUNET_SCHEDULER_add_now (&send_other_messages, NULL);
871 } 859 }
872} 860}
873 861
@@ -892,7 +880,7 @@ peers_started_callback (void *cls,
892 GNUNET_assert(GNUNET_SYSERR != GNUNET_CONTAINER_multihashmap_put(peer_daemon_hash, &id->hashPubKey, d, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 880 GNUNET_assert(GNUNET_SYSERR != GNUNET_CONTAINER_multihashmap_put(peer_daemon_hash, &id->hashPubKey, d, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
893 881
894 new_peer = GNUNET_malloc(sizeof(struct PeerContext)); 882 new_peer = GNUNET_malloc(sizeof(struct PeerContext));
895 new_peer->peer_handle = GNUNET_CORE_connect(sched, cfg, GNUNET_TIME_UNIT_FOREVER_REL, d, NULL, &all_connect_handler, NULL, NULL, NULL, GNUNET_NO, NULL, GNUNET_NO, no_handlers); 883 new_peer->peer_handle = GNUNET_CORE_connect(cfg, GNUNET_TIME_UNIT_FOREVER_REL, d, NULL, &all_connect_handler, NULL, NULL, NULL, GNUNET_NO, NULL, GNUNET_NO, no_handlers);
896 new_peer->daemon = d; 884 new_peer->daemon = d;
897 new_peer->next = all_peers; 885 new_peer->next = all_peers;
898 all_peers = new_peer; 886 all_peers = new_peer;
@@ -905,11 +893,10 @@ peers_started_callback (void *cls,
905 "All %d daemons started, now creating topology!\n", 893 "All %d daemons started, now creating topology!\n",
906 num_peers); 894 num_peers);
907#endif 895#endif
908 GNUNET_SCHEDULER_cancel (sched, die_task); 896 GNUNET_SCHEDULER_cancel (die_task);
909 /* Set up task in case topology creation doesn't finish 897 /* Set up task in case topology creation doesn't finish
910 * within a reasonable amount of time */ 898 * within a reasonable amount of time */
911 die_task = GNUNET_SCHEDULER_add_delayed (sched, 899 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
912 GNUNET_TIME_relative_multiply
913 (GNUNET_TIME_UNIT_MINUTES, 5), 900 (GNUNET_TIME_UNIT_MINUTES, 5),
914 &end_badly, "from peers_started_callback"); 901 &end_badly, "from peers_started_callback");
915 902
@@ -949,21 +936,19 @@ void hostkey_callback (void *cls,
949 "All %d hostkeys created, now creating topology!\n", 936 "All %d hostkeys created, now creating topology!\n",
950 num_peers); 937 num_peers);
951#endif 938#endif
952 GNUNET_SCHEDULER_cancel (sched, die_task); 939 GNUNET_SCHEDULER_cancel (die_task);
953 /* Set up task in case topology creation doesn't finish 940 /* Set up task in case topology creation doesn't finish
954 * within a reasonable amount of time */ 941 * within a reasonable amount of time */
955 die_task = GNUNET_SCHEDULER_add_delayed (sched, 942 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
956 GNUNET_TIME_relative_multiply
957 (GNUNET_TIME_UNIT_MINUTES, 5), 943 (GNUNET_TIME_UNIT_MINUTES, 5),
958 &end_badly, "from hostkey_callback"); 944 &end_badly, "from hostkey_callback");
959 GNUNET_SCHEDULER_add_now(sched, &create_topology, NULL); 945 GNUNET_SCHEDULER_add_now(&create_topology, NULL);
960 ok = 0; 946 ok = 0;
961 } 947 }
962} 948}
963 949
964static void 950static void
965run (void *cls, 951run (void *cls,
966 struct GNUNET_SCHEDULER_Handle *s,
967 char *const *args, 952 char *const *args,
968 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 953 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
969{ 954{
@@ -972,7 +957,6 @@ run (void *cls,
972 char * blacklist_topology_str; 957 char * blacklist_topology_str;
973 char * connect_topology_option_str; 958 char * connect_topology_option_str;
974 char * connect_topology_option_modifier_string; 959 char * connect_topology_option_modifier_string;
975 sched = s;
976 ok = 1; 960 ok = 1;
977 961
978 dotOutFile = fopen (dotOutFileName, "w"); 962 dotOutFile = fopen (dotOutFileName, "w");
@@ -1062,13 +1046,12 @@ run (void *cls,
1062 peers_left = num_peers; 1046 peers_left = num_peers;
1063 1047
1064 /* Set up a task to end testing if peer start fails */ 1048 /* Set up a task to end testing if peer start fails */
1065 die_task = GNUNET_SCHEDULER_add_delayed (sched, 1049 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
1066 GNUNET_TIME_relative_multiply
1067 (GNUNET_TIME_UNIT_MINUTES, 5), 1050 (GNUNET_TIME_UNIT_MINUTES, 5),
1068 &end_badly, "didn't start all daemons in reasonable amount of time!!!"); 1051 &end_badly, "didn't start all daemons in reasonable amount of time!!!");
1069 1052
1070 peer_daemon_hash = GNUNET_CONTAINER_multihashmap_create(peers_left); 1053 peer_daemon_hash = GNUNET_CONTAINER_multihashmap_create(peers_left);
1071 pg = GNUNET_TESTING_daemons_start (sched, cfg, 1054 pg = GNUNET_TESTING_daemons_start (cfg,
1072 peers_left, TIMEOUT, &hostkey_callback, NULL, &peers_started_callback, NULL, 1055 peers_left, TIMEOUT, &hostkey_callback, NULL, &peers_started_callback, NULL,
1073 &topology_callback, NULL, NULL); 1056 &topology_callback, NULL, NULL);
1074 1057
diff --git a/src/fs/fs.c b/src/fs/fs.c
index e144a0b89..736c3b026 100644
--- a/src/fs/fs.c
+++ b/src/fs/fs.c
@@ -40,7 +40,7 @@
40static void 40static void
41start_job (struct GNUNET_FS_QueueEntry *qe) 41start_job (struct GNUNET_FS_QueueEntry *qe)
42{ 42{
43 qe->client = GNUNET_CLIENT_connect (qe->h->sched, "fs", qe->h->cfg); 43 qe->client = GNUNET_CLIENT_connect ("fs", qe->h->cfg);
44 if (qe->client == NULL) 44 if (qe->client == NULL)
45 { 45 {
46 GNUNET_break (0); 46 GNUNET_break (0);
@@ -138,8 +138,7 @@ process_job_queue (void *cls,
138 continue; 138 continue;
139 stop_job (qe); 139 stop_job (qe);
140 } 140 }
141 h->queue_job = GNUNET_SCHEDULER_add_delayed (h->sched, 141 h->queue_job = GNUNET_SCHEDULER_add_delayed (restart_at,
142 restart_at,
143 &process_job_queue, 142 &process_job_queue,
144 h); 143 h);
145} 144}
@@ -176,11 +175,9 @@ GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h,
176 h->pending_tail, 175 h->pending_tail,
177 qe); 176 qe);
178 if (h->queue_job != GNUNET_SCHEDULER_NO_TASK) 177 if (h->queue_job != GNUNET_SCHEDULER_NO_TASK)
179 GNUNET_SCHEDULER_cancel (h->sched, 178 GNUNET_SCHEDULER_cancel (h->queue_job);
180 h->queue_job);
181 h->queue_job 179 h->queue_job
182 = GNUNET_SCHEDULER_add_now (h->sched, 180 = GNUNET_SCHEDULER_add_now (&process_job_queue,
183 &process_job_queue,
184 h); 181 h);
185 return qe; 182 return qe;
186} 183}
@@ -203,11 +200,9 @@ GNUNET_FS_dequeue_ (struct GNUNET_FS_QueueEntry *qh)
203 qh); 200 qh);
204 GNUNET_free (qh); 201 GNUNET_free (qh);
205 if (h->queue_job != GNUNET_SCHEDULER_NO_TASK) 202 if (h->queue_job != GNUNET_SCHEDULER_NO_TASK)
206 GNUNET_SCHEDULER_cancel (h->sched, 203 GNUNET_SCHEDULER_cancel (h->queue_job);
207 h->queue_job);
208 h->queue_job 204 h->queue_job
209 = GNUNET_SCHEDULER_add_now (h->sched, 205 = GNUNET_SCHEDULER_add_now (&process_job_queue,
210 &process_job_queue,
211 h); 206 h);
212} 207}
213 208
@@ -1449,8 +1444,7 @@ deserialize_publish_file (void *cls,
1449 if ( (0 == (pc->options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) && 1444 if ( (0 == (pc->options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) &&
1450 (GNUNET_YES != pc->all_done) ) 1445 (GNUNET_YES != pc->all_done) )
1451 { 1446 {
1452 pc->dsh = GNUNET_DATASTORE_connect (h->cfg, 1447 pc->dsh = GNUNET_DATASTORE_connect (h->cfg);
1453 h->sched);
1454 if (NULL == pc->dsh) 1448 if (NULL == pc->dsh)
1455 goto cleanup; 1449 goto cleanup;
1456 } 1450 }
@@ -1478,8 +1472,7 @@ deserialize_publish_file (void *cls,
1478 /* re-start publishing (if needed)... */ 1472 /* re-start publishing (if needed)... */
1479 if (pc->all_done != GNUNET_YES) 1473 if (pc->all_done != GNUNET_YES)
1480 pc->upload_task 1474 pc->upload_task
1481 = GNUNET_SCHEDULER_add_with_priority (h->sched, 1475 = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
1482 GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
1483 &GNUNET_FS_publish_main_, 1476 &GNUNET_FS_publish_main_,
1484 pc); 1477 pc);
1485 if (GNUNET_OK != 1478 if (GNUNET_OK !=
@@ -2092,8 +2085,7 @@ deserialize_unindex_file (void *cls,
2092 switch (uc->state) 2085 switch (uc->state)
2093 { 2086 {
2094 case UNINDEX_STATE_HASHING: 2087 case UNINDEX_STATE_HASHING:
2095 uc->fhc = GNUNET_CRYPTO_hash_file (uc->h->sched, 2088 uc->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE,
2096 GNUNET_SCHEDULER_PRIORITY_IDLE,
2097 uc->filename, 2089 uc->filename,
2098 HASHING_BLOCKSIZE, 2090 HASHING_BLOCKSIZE,
2099 &GNUNET_FS_unindex_process_hash_, 2091 &GNUNET_FS_unindex_process_hash_,
@@ -2937,7 +2929,6 @@ deserialization_master (const char *master_path,
2937/** 2929/**
2938 * Setup a connection to the file-sharing service. 2930 * Setup a connection to the file-sharing service.
2939 * 2931 *
2940 * @param sched scheduler to use
2941 * @param cfg configuration to use 2932 * @param cfg configuration to use
2942 * @param client_name unique identifier for this client 2933 * @param client_name unique identifier for this client
2943 * @param upcb function to call to notify about FS actions 2934 * @param upcb function to call to notify about FS actions
@@ -2947,8 +2938,7 @@ deserialization_master (const char *master_path,
2947 * @return NULL on error 2938 * @return NULL on error
2948 */ 2939 */
2949struct GNUNET_FS_Handle * 2940struct GNUNET_FS_Handle *
2950GNUNET_FS_start (struct GNUNET_SCHEDULER_Handle *sched, 2941GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
2951 const struct GNUNET_CONFIGURATION_Handle *cfg,
2952 const char *client_name, 2942 const char *client_name,
2953 GNUNET_FS_ProgressCallback upcb, 2943 GNUNET_FS_ProgressCallback upcb,
2954 void *upcb_cls, 2944 void *upcb_cls,
@@ -2960,7 +2950,6 @@ GNUNET_FS_start (struct GNUNET_SCHEDULER_Handle *sched,
2960 va_list ap; 2950 va_list ap;
2961 2951
2962 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Handle)); 2952 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Handle));
2963 ret->sched = sched;
2964 ret->cfg = cfg; 2953 ret->cfg = cfg;
2965 ret->client_name = GNUNET_strdup (client_name); 2954 ret->client_name = GNUNET_strdup (client_name);
2966 ret->upcb = upcb; 2955 ret->upcb = upcb;
@@ -3021,8 +3010,7 @@ GNUNET_FS_stop (struct GNUNET_FS_Handle *h)
3021 while (h->top_head != NULL) 3010 while (h->top_head != NULL)
3022 h->top_head->ssf (h->top_head->ssf_cls); 3011 h->top_head->ssf (h->top_head->ssf_cls);
3023 if (h->queue_job != GNUNET_SCHEDULER_NO_TASK) 3012 if (h->queue_job != GNUNET_SCHEDULER_NO_TASK)
3024 GNUNET_SCHEDULER_cancel (h->sched, 3013 GNUNET_SCHEDULER_cancel (h->queue_job);
3025 h->queue_job);
3026 GNUNET_free (h->client_name); 3014 GNUNET_free (h->client_name);
3027 GNUNET_free (h); 3015 GNUNET_free (h);
3028} 3016}
diff --git a/src/fs/fs.h b/src/fs/fs.h
index 68ed2184e..ccd949c59 100644
--- a/src/fs/fs.h
+++ b/src/fs/fs.h
@@ -1172,11 +1172,6 @@ GNUNET_FS_end_top (struct GNUNET_FS_Handle *h,
1172struct GNUNET_FS_Handle 1172struct GNUNET_FS_Handle
1173{ 1173{
1174 /** 1174 /**
1175 * Scheduler.
1176 */
1177 struct GNUNET_SCHEDULER_Handle *sched;
1178
1179 /**
1180 * Configuration to use. 1175 * Configuration to use.
1181 */ 1176 */
1182 const struct GNUNET_CONFIGURATION_Handle *cfg; 1177 const struct GNUNET_CONFIGURATION_Handle *cfg;
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c
index b62620c3d..617e28103 100644
--- a/src/fs/fs_download.c
+++ b/src/fs/fs_download.c
@@ -1459,8 +1459,7 @@ do_reconnect (void *cls,
1459 struct GNUNET_CLIENT_Connection *client; 1459 struct GNUNET_CLIENT_Connection *client;
1460 1460
1461 dc->task = GNUNET_SCHEDULER_NO_TASK; 1461 dc->task = GNUNET_SCHEDULER_NO_TASK;
1462 client = GNUNET_CLIENT_connect (dc->h->sched, 1462 client = GNUNET_CLIENT_connect ("fs",
1463 "fs",
1464 dc->h->cfg); 1463 dc->h->cfg);
1465 if (NULL == client) 1464 if (NULL == client)
1466 { 1465 {
@@ -1543,8 +1542,7 @@ try_reconnect (struct GNUNET_FS_DownloadContext *dc)
1543 "Will try to reconnect in 1s\n"); 1542 "Will try to reconnect in 1s\n");
1544#endif 1543#endif
1545 dc->task 1544 dc->task
1546 = GNUNET_SCHEDULER_add_delayed (dc->h->sched, 1545 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
1547 GNUNET_TIME_UNIT_SECONDS,
1548 &do_reconnect, 1546 &do_reconnect,
1549 dc); 1547 dc);
1550} 1548}
@@ -1658,8 +1656,7 @@ GNUNET_FS_download_signal_suspend_ (void *cls)
1658 pi.status = GNUNET_FS_STATUS_DOWNLOAD_SUSPEND; 1656 pi.status = GNUNET_FS_STATUS_DOWNLOAD_SUSPEND;
1659 GNUNET_FS_download_make_status_ (&pi, dc); 1657 GNUNET_FS_download_make_status_ (&pi, dc);
1660 if (GNUNET_SCHEDULER_NO_TASK != dc->task) 1658 if (GNUNET_SCHEDULER_NO_TASK != dc->task)
1661 GNUNET_SCHEDULER_cancel (dc->h->sched, 1659 GNUNET_SCHEDULER_cancel (dc->task);
1662 dc->task);
1663 GNUNET_CONTAINER_multihashmap_iterate (dc->active, 1660 GNUNET_CONTAINER_multihashmap_iterate (dc->active,
1664 &free_entry, 1661 &free_entry,
1665 NULL); 1662 NULL);
@@ -1992,8 +1989,7 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc,
1992 pi.status = GNUNET_FS_STATUS_DOWNLOAD_STOPPED; 1989 pi.status = GNUNET_FS_STATUS_DOWNLOAD_STOPPED;
1993 GNUNET_FS_download_make_status_ (&pi, dc); 1990 GNUNET_FS_download_make_status_ (&pi, dc);
1994 if (GNUNET_SCHEDULER_NO_TASK != dc->task) 1991 if (GNUNET_SCHEDULER_NO_TASK != dc->task)
1995 GNUNET_SCHEDULER_cancel (dc->h->sched, 1992 GNUNET_SCHEDULER_cancel (dc->task);
1996 dc->task);
1997 GNUNET_CONTAINER_multihashmap_iterate (dc->active, 1993 GNUNET_CONTAINER_multihashmap_iterate (dc->active,
1998 &free_entry, 1994 &free_entry,
1999 NULL); 1995 NULL);
diff --git a/src/fs/fs_list_indexed.c b/src/fs/fs_list_indexed.c
index 5850fd94e..fec127763 100644
--- a/src/fs/fs_list_indexed.c
+++ b/src/fs/fs_list_indexed.c
@@ -90,8 +90,7 @@ handle_index_info (void *cls,
90 _("Failed to receive response for `%s' request from `%s' service.\n"), 90 _("Failed to receive response for `%s' request from `%s' service.\n"),
91 "GET_INDEXED", 91 "GET_INDEXED",
92 "fs"); 92 "fs");
93 GNUNET_SCHEDULER_add_continuation (gic->h->sched, 93 GNUNET_SCHEDULER_add_continuation (gic->cont,
94 gic->cont,
95 gic->cont_cls, 94 gic->cont_cls,
96 GNUNET_SCHEDULER_REASON_TIMEOUT); 95 GNUNET_SCHEDULER_REASON_TIMEOUT);
97 GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO); 96 GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO);
@@ -101,8 +100,7 @@ handle_index_info (void *cls,
101 if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_END) 100 if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_END)
102 { 101 {
103 /* normal end-of-list */ 102 /* normal end-of-list */
104 GNUNET_SCHEDULER_add_continuation (gic->h->sched, 103 GNUNET_SCHEDULER_add_continuation (gic->cont,
105 gic->cont,
106 gic->cont_cls, 104 gic->cont_cls,
107 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 105 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
108 GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO); 106 GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO);
@@ -121,8 +119,7 @@ handle_index_info (void *cls,
121 _("Failed to receive valid response for `%s' request from `%s' service.\n"), 119 _("Failed to receive valid response for `%s' request from `%s' service.\n"),
122 "GET_INDEXED", 120 "GET_INDEXED",
123 "fs"); 121 "fs");
124 GNUNET_SCHEDULER_add_continuation (gic->h->sched, 122 GNUNET_SCHEDULER_add_continuation (gic->cont,
125 gic->cont,
126 gic->cont_cls, 123 gic->cont_cls,
127 GNUNET_SCHEDULER_REASON_TIMEOUT); 124 GNUNET_SCHEDULER_REASON_TIMEOUT);
128 GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO); 125 GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO);
@@ -134,8 +131,7 @@ handle_index_info (void *cls,
134 filename, 131 filename,
135 &iim->file_id)) 132 &iim->file_id))
136 { 133 {
137 GNUNET_SCHEDULER_add_continuation (gic->h->sched, 134 GNUNET_SCHEDULER_add_continuation (gic->cont,
138 gic->cont,
139 gic->cont_cls, 135 gic->cont_cls,
140 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 136 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
141 GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO); 137 GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO);
@@ -172,16 +168,14 @@ GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h,
172 struct GetIndexedContext *gic; 168 struct GetIndexedContext *gic;
173 struct GNUNET_MessageHeader msg; 169 struct GNUNET_MessageHeader msg;
174 170
175 client = GNUNET_CLIENT_connect (h->sched, 171 client = GNUNET_CLIENT_connect ("fs",
176 "fs",
177 h->cfg); 172 h->cfg);
178 if (NULL == client) 173 if (NULL == client)
179 { 174 {
180 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 175 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
181 _("Failed to not connect to `%s' service.\n"), 176 _("Failed to not connect to `%s' service.\n"),
182 "fs"); 177 "fs");
183 GNUNET_SCHEDULER_add_continuation (h->sched, 178 GNUNET_SCHEDULER_add_continuation (cont,
184 cont,
185 cont_cls, 179 cont_cls,
186 GNUNET_SCHEDULER_REASON_TIMEOUT); 180 GNUNET_SCHEDULER_REASON_TIMEOUT);
187 return; 181 return;
diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c
index 5c1137eb7..91502e1de 100644
--- a/src/fs/fs_namespace.c
+++ b/src/fs/fs_namespace.c
@@ -265,11 +265,6 @@ struct AdvertisementContext
265 struct GNUNET_DATASTORE_Handle *dsh; 265 struct GNUNET_DATASTORE_Handle *dsh;
266 266
267 /** 267 /**
268 * Our scheduler.
269 */
270 struct GNUNET_SCHEDULER_Handle *sched;
271
272 /**
273 * Our KSK URI. 268 * Our KSK URI.
274 */ 269 */
275 struct GNUNET_FS_Uri *ksk_uri; 270 struct GNUNET_FS_Uri *ksk_uri;
@@ -357,8 +352,7 @@ advertisement_cont (void *cls,
357 if (GNUNET_OK != success) 352 if (GNUNET_OK != success)
358 { 353 {
359 /* error! */ 354 /* error! */
360 GNUNET_SCHEDULER_add_continuation (ac->sched, 355 GNUNET_SCHEDULER_add_continuation (&do_disconnect,
361 &do_disconnect,
362 ac->dsh, 356 ac->dsh,
363 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 357 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
364 if (ac->cont != NULL) 358 if (ac->cont != NULL)
@@ -373,8 +367,7 @@ advertisement_cont (void *cls,
373 if (ac->pos == ac->ksk_uri->data.ksk.keywordCount) 367 if (ac->pos == ac->ksk_uri->data.ksk.keywordCount)
374 { 368 {
375 /* done! */ 369 /* done! */
376 GNUNET_SCHEDULER_add_continuation (ac->sched, 370 GNUNET_SCHEDULER_add_continuation (&do_disconnect,
377 &do_disconnect,
378 ac->dsh, 371 ac->dsh,
379 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 372 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
380 if (ac->cont != NULL) 373 if (ac->cont != NULL)
@@ -501,7 +494,7 @@ GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h,
501 nb->ns_purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK); 494 nb->ns_purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK);
502 nb->ksk_purpose.size = htonl (size - sizeof (struct GNUNET_CRYPTO_RsaSignature)); 495 nb->ksk_purpose.size = htonl (size - sizeof (struct GNUNET_CRYPTO_RsaSignature));
503 nb->ksk_purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG); 496 nb->ksk_purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG);
504 dsh = GNUNET_DATASTORE_connect (h->cfg, h->sched); 497 dsh = GNUNET_DATASTORE_connect (h->cfg);
505 if (NULL == dsh) 498 if (NULL == dsh)
506 { 499 {
507 GNUNET_free (nb); 500 GNUNET_free (nb);
@@ -513,7 +506,6 @@ GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h,
513 ctx->cont = cont; 506 ctx->cont = cont;
514 ctx->cont_cls = cont_cls; 507 ctx->cont_cls = cont_cls;
515 ctx->dsh = dsh; 508 ctx->dsh = dsh;
516 ctx->sched = h->sched;
517 ctx->ksk_uri = GNUNET_FS_uri_dup (ksk_uri); 509 ctx->ksk_uri = GNUNET_FS_uri_dup (ksk_uri);
518 ctx->nb = nb; 510 ctx->nb = nb;
519 ctx->pt = pt; 511 ctx->pt = pt;
@@ -956,7 +948,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
956 NULL); 948 NULL);
957 return; 949 return;
958 } 950 }
959 psc->dsh = GNUNET_DATASTORE_connect (h->cfg, h->sched); 951 psc->dsh = GNUNET_DATASTORE_connect (h->cfg);
960 if (NULL == psc->dsh) 952 if (NULL == psc->dsh)
961 { 953 {
962 GNUNET_free (sb_enc); 954 GNUNET_free (sb_enc);
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c
index ad2258b16..5c1cd0ea2 100644
--- a/src/fs/fs_publish.c
+++ b/src/fs/fs_publish.c
@@ -154,8 +154,7 @@ ds_put_cont (void *cls,
154 if (GNUNET_SYSERR == pcc->sc->in_network_wait) 154 if (GNUNET_SYSERR == pcc->sc->in_network_wait)
155 { 155 {
156 /* we were aborted in the meantime, finish shutdown! */ 156 /* we were aborted in the meantime, finish shutdown! */
157 GNUNET_SCHEDULER_add_continuation (pcc->sc->h->sched, 157 GNUNET_SCHEDULER_add_continuation (&publish_cleanup,
158 &publish_cleanup,
159 pcc->sc, 158 pcc->sc,
160 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 159 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
161 GNUNET_free (pcc); 160 GNUNET_free (pcc);
@@ -184,8 +183,7 @@ ds_put_cont (void *cls,
184 } 183 }
185 if (NULL != pcc->cont) 184 if (NULL != pcc->cont)
186 pcc->sc->upload_task 185 pcc->sc->upload_task
187 = GNUNET_SCHEDULER_add_with_priority (pcc->sc->h->sched, 186 = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
188 GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
189 pcc->cont, 187 pcc->cont,
190 pcc->cont_cls); 188 pcc->cont_cls);
191 GNUNET_free (pcc); 189 GNUNET_free (pcc);
@@ -365,8 +363,7 @@ publish_kblocks_cont (void *cls,
365 GNUNET_FS_file_information_sync_ (p); 363 GNUNET_FS_file_information_sync_ (p);
366 GNUNET_FS_publish_sync_ (pc); 364 GNUNET_FS_publish_sync_ (pc);
367 pc->upload_task 365 pc->upload_task
368 = GNUNET_SCHEDULER_add_with_priority (pc->h->sched, 366 = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
369 GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
370 &GNUNET_FS_publish_main_, 367 &GNUNET_FS_publish_main_,
371 pc); 368 pc);
372 return; 369 return;
@@ -384,8 +381,7 @@ publish_kblocks_cont (void *cls,
384 pc->fi_pos = p->dir; 381 pc->fi_pos = p->dir;
385 GNUNET_FS_publish_sync_ (pc); 382 GNUNET_FS_publish_sync_ (pc);
386 pc->upload_task 383 pc->upload_task
387 = GNUNET_SCHEDULER_add_with_priority (pc->h->sched, 384 = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
388 GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
389 &GNUNET_FS_publish_main_, 385 &GNUNET_FS_publish_main_,
390 pc); 386 pc);
391} 387}
@@ -498,8 +494,7 @@ encode_cont (void *cls,
498 494
499 /* continue with main */ 495 /* continue with main */
500 sc->upload_task 496 sc->upload_task
501 = GNUNET_SCHEDULER_add_with_priority (sc->h->sched, 497 = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
502 GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
503 &GNUNET_FS_publish_main_, 498 &GNUNET_FS_publish_main_,
504 sc); 499 sc);
505} 500}
@@ -539,8 +534,7 @@ block_proc (void *cls,
539 "Waiting for datastore connection\n"); 534 "Waiting for datastore connection\n");
540#endif 535#endif
541 sc->upload_task 536 sc->upload_task
542 = GNUNET_SCHEDULER_add_with_priority (sc->h->sched, 537 = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
543 GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
544 &GNUNET_FS_publish_main_, 538 &GNUNET_FS_publish_main_,
545 sc); 539 sc);
546 return; 540 return;
@@ -841,8 +835,7 @@ hash_for_index_cb (void *cls,
841 p->filename, 835 p->filename,
842 GNUNET_h2s (res)); 836 GNUNET_h2s (res));
843#endif 837#endif
844 client = GNUNET_CLIENT_connect (sc->h->sched, 838 client = GNUNET_CLIENT_connect ("fs",
845 "fs",
846 sc->h->cfg); 839 sc->h->cfg);
847 if (NULL == client) 840 if (NULL == client)
848 { 841 {
@@ -1038,8 +1031,7 @@ GNUNET_FS_publish_main_ (void *cls,
1038 else 1031 else
1039 { 1032 {
1040 p->start_time = GNUNET_TIME_absolute_get (); 1033 p->start_time = GNUNET_TIME_absolute_get ();
1041 pc->fhc = GNUNET_CRYPTO_hash_file (pc->h->sched, 1034 pc->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE,
1042 GNUNET_SCHEDULER_PRIORITY_IDLE,
1043 p->filename, 1035 p->filename,
1044 HASHING_BLOCKSIZE, 1036 HASHING_BLOCKSIZE,
1045 &hash_for_index_cb, 1037 &hash_for_index_cb,
@@ -1180,7 +1172,7 @@ GNUNET_FS_publish_signal_suspend_ (void *cls)
1180 1172
1181 if (GNUNET_SCHEDULER_NO_TASK != pc->upload_task) 1173 if (GNUNET_SCHEDULER_NO_TASK != pc->upload_task)
1182 { 1174 {
1183 GNUNET_SCHEDULER_cancel (pc->h->sched, pc->upload_task); 1175 GNUNET_SCHEDULER_cancel (pc->upload_task);
1184 pc->upload_task = GNUNET_SCHEDULER_NO_TASK; 1176 pc->upload_task = GNUNET_SCHEDULER_NO_TASK;
1185 } 1177 }
1186 GNUNET_FS_file_information_inspect (pc->fi, 1178 GNUNET_FS_file_information_inspect (pc->fi,
@@ -1220,8 +1212,7 @@ finish_reserve (void *cls,
1220 } 1212 }
1221 pc->rid = success; 1213 pc->rid = success;
1222 pc->upload_task 1214 pc->upload_task
1223 = GNUNET_SCHEDULER_add_with_priority (pc->h->sched, 1215 = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
1224 GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
1225 &GNUNET_FS_publish_main_, 1216 &GNUNET_FS_publish_main_,
1226 pc); 1217 pc);
1227} 1218}
@@ -1254,8 +1245,7 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h,
1254 GNUNET_assert (NULL != h); 1245 GNUNET_assert (NULL != h);
1255 if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) 1246 if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY))
1256 { 1247 {
1257 dsh = GNUNET_DATASTORE_connect (h->cfg, 1248 dsh = GNUNET_DATASTORE_connect (h->cfg);
1258 h->sched);
1259 if (NULL == dsh) 1249 if (NULL == dsh)
1260 return NULL; 1250 return NULL;
1261 } 1251 }
@@ -1301,8 +1291,7 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h,
1301 else 1291 else
1302 { 1292 {
1303 ret->upload_task 1293 ret->upload_task
1304 = GNUNET_SCHEDULER_add_with_priority (h->sched, 1294 = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
1305 GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
1306 &GNUNET_FS_publish_main_, 1295 &GNUNET_FS_publish_main_,
1307 ret); 1296 ret);
1308 } 1297 }
@@ -1382,7 +1371,7 @@ GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *pc)
1382 } 1371 }
1383 if (GNUNET_SCHEDULER_NO_TASK != pc->upload_task) 1372 if (GNUNET_SCHEDULER_NO_TASK != pc->upload_task)
1384 { 1373 {
1385 GNUNET_SCHEDULER_cancel (pc->h->sched, pc->upload_task); 1374 GNUNET_SCHEDULER_cancel (pc->upload_task);
1386 pc->upload_task = GNUNET_SCHEDULER_NO_TASK; 1375 pc->upload_task = GNUNET_SCHEDULER_NO_TASK;
1387 } 1376 }
1388 if (pc->serialization != NULL) 1377 if (pc->serialization != NULL)
@@ -1524,8 +1513,7 @@ kb_put_cont (void *cls,
1524 GNUNET_free (pkc); 1513 GNUNET_free (pkc);
1525 return; 1514 return;
1526 } 1515 }
1527 GNUNET_SCHEDULER_add_continuation (pkc->h->sched, 1516 GNUNET_SCHEDULER_add_continuation (&publish_ksk_cont,
1528 &publish_ksk_cont,
1529 pkc, 1517 pkc,
1530 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 1518 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
1531} 1519}
@@ -1649,8 +1637,7 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
1649 pkc->cont_cls = cont_cls; 1637 pkc->cont_cls = cont_cls;
1650 if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) 1638 if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY))
1651 { 1639 {
1652 pkc->dsh = GNUNET_DATASTORE_connect (h->cfg, 1640 pkc->dsh = GNUNET_DATASTORE_connect (h->cfg);
1653 h->sched);
1654 if (pkc->dsh == NULL) 1641 if (pkc->dsh == NULL)
1655 { 1642 {
1656 cont (cont_cls, NULL, _("Could not connect to datastore.")); 1643 cont (cont_cls, NULL, _("Could not connect to datastore."));
@@ -1703,8 +1690,7 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
1703 pkc->slen); 1690 pkc->slen);
1704 pkc->cpy->purpose.purpose = htonl(GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK); 1691 pkc->cpy->purpose.purpose = htonl(GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK);
1705 pkc->ksk_uri = GNUNET_FS_uri_dup (ksk_uri); 1692 pkc->ksk_uri = GNUNET_FS_uri_dup (ksk_uri);
1706 GNUNET_SCHEDULER_add_continuation (h->sched, 1693 GNUNET_SCHEDULER_add_continuation (&publish_ksk_cont,
1707 &publish_ksk_cont,
1708 pkc, 1694 pkc,
1709 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 1695 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
1710} 1696}
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c
index 16e1dd1d5..1ffd681aa 100644
--- a/src/fs/fs_search.c
+++ b/src/fs/fs_search.c
@@ -279,32 +279,27 @@ GNUNET_FS_search_probe_progress_ (void *cls,
279 case GNUNET_FS_STATUS_DOWNLOAD_ERROR: 279 case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
280 if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK) 280 if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK)
281 { 281 {
282 GNUNET_SCHEDULER_cancel (sr->sc->h->sched, 282 GNUNET_SCHEDULER_cancel (sr->probe_cancel_task);
283 sr->probe_cancel_task);
284 sr->probe_cancel_task = GNUNET_SCHEDULER_NO_TASK; 283 sr->probe_cancel_task = GNUNET_SCHEDULER_NO_TASK;
285 } 284 }
286 sr->probe_cancel_task = GNUNET_SCHEDULER_add_delayed (sr->sc->h->sched, 285 sr->probe_cancel_task = GNUNET_SCHEDULER_add_delayed (sr->remaining_probe_time,
287 sr->remaining_probe_time,
288 &probe_failure_handler, 286 &probe_failure_handler,
289 sr); 287 sr);
290 break; 288 break;
291 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: 289 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
292 if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK) 290 if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK)
293 { 291 {
294 GNUNET_SCHEDULER_cancel (sr->sc->h->sched, 292 GNUNET_SCHEDULER_cancel (sr->probe_cancel_task);
295 sr->probe_cancel_task);
296 sr->probe_cancel_task = GNUNET_SCHEDULER_NO_TASK; 293 sr->probe_cancel_task = GNUNET_SCHEDULER_NO_TASK;
297 } 294 }
298 sr->probe_cancel_task = GNUNET_SCHEDULER_add_delayed (sr->sc->h->sched, 295 sr->probe_cancel_task = GNUNET_SCHEDULER_add_delayed (sr->remaining_probe_time,
299 sr->remaining_probe_time,
300 &probe_success_handler, 296 &probe_success_handler,
301 sr); 297 sr);
302 break; 298 break;
303 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: 299 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
304 if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK) 300 if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK)
305 { 301 {
306 GNUNET_SCHEDULER_cancel (sr->sc->h->sched, 302 GNUNET_SCHEDULER_cancel (sr->probe_cancel_task);
307 sr->probe_cancel_task);
308 sr->probe_cancel_task = GNUNET_SCHEDULER_NO_TASK; 303 sr->probe_cancel_task = GNUNET_SCHEDULER_NO_TASK;
309 } 304 }
310 sr = NULL; 305 sr = NULL;
@@ -312,16 +307,14 @@ GNUNET_FS_search_probe_progress_ (void *cls,
312 case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: 307 case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE:
313 GNUNET_assert (sr->probe_cancel_task == GNUNET_SCHEDULER_NO_TASK); 308 GNUNET_assert (sr->probe_cancel_task == GNUNET_SCHEDULER_NO_TASK);
314 sr->probe_active_time = GNUNET_TIME_absolute_get (); 309 sr->probe_active_time = GNUNET_TIME_absolute_get ();
315 sr->probe_cancel_task = GNUNET_SCHEDULER_add_delayed (sr->sc->h->sched, 310 sr->probe_cancel_task = GNUNET_SCHEDULER_add_delayed (sr->remaining_probe_time,
316 sr->remaining_probe_time,
317 &probe_failure_handler, 311 &probe_failure_handler,
318 sr); 312 sr);
319 break; 313 break;
320 case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE: 314 case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE:
321 if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK) 315 if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK)
322 { 316 {
323 GNUNET_SCHEDULER_cancel (sr->sc->h->sched, 317 GNUNET_SCHEDULER_cancel (sr->probe_cancel_task);
324 sr->probe_cancel_task);
325 sr->probe_cancel_task = GNUNET_SCHEDULER_NO_TASK; 318 sr->probe_cancel_task = GNUNET_SCHEDULER_NO_TASK;
326 } 319 }
327 dur = GNUNET_TIME_absolute_get_duration (sr->probe_active_time); 320 dur = GNUNET_TIME_absolute_get_duration (sr->probe_active_time);
@@ -1022,8 +1015,7 @@ do_reconnect (void *cls,
1022 size_t size; 1015 size_t size;
1023 1016
1024 sc->task = GNUNET_SCHEDULER_NO_TASK; 1017 sc->task = GNUNET_SCHEDULER_NO_TASK;
1025 client = GNUNET_CLIENT_connect (sc->h->sched, 1018 client = GNUNET_CLIENT_connect ("fs",
1026 "fs",
1027 sc->h->cfg); 1019 sc->h->cfg);
1028 if (NULL == client) 1020 if (NULL == client)
1029 { 1021 {
@@ -1060,8 +1052,7 @@ try_reconnect (struct GNUNET_FS_SearchContext *sc)
1060 sc->client = NULL; 1052 sc->client = NULL;
1061 } 1053 }
1062 sc->task 1054 sc->task
1063 = GNUNET_SCHEDULER_add_delayed (sc->h->sched, 1055 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
1064 GNUNET_TIME_UNIT_SECONDS,
1065 &do_reconnect, 1056 &do_reconnect,
1066 sc); 1057 sc);
1067} 1058}
@@ -1176,8 +1167,7 @@ GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc)
1176 &sc->requests[i].key); 1167 &sc->requests[i].key);
1177 } 1168 }
1178 } 1169 }
1179 sc->client = GNUNET_CLIENT_connect (sc->h->sched, 1170 sc->client = GNUNET_CLIENT_connect ("fs",
1180 "fs",
1181 sc->h->cfg); 1171 sc->h->cfg);
1182 if (NULL == sc->client) 1172 if (NULL == sc->client)
1183 return GNUNET_SYSERR; 1173 return GNUNET_SYSERR;
@@ -1204,8 +1194,6 @@ search_result_freeze_probes (void *cls,
1204 const GNUNET_HashCode * key, 1194 const GNUNET_HashCode * key,
1205 void *value) 1195 void *value)
1206{ 1196{
1207 struct GNUNET_FS_SearchContext *sc = cls;
1208 struct GNUNET_FS_Handle *h = sc->h;
1209 struct GNUNET_FS_SearchResult *sr = value; 1197 struct GNUNET_FS_SearchResult *sr = value;
1210 1198
1211 if (sr->probe_ctx != NULL) 1199 if (sr->probe_ctx != NULL)
@@ -1215,8 +1203,7 @@ search_result_freeze_probes (void *cls,
1215 } 1203 }
1216 if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK) 1204 if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK)
1217 { 1205 {
1218 GNUNET_SCHEDULER_cancel (h->sched, 1206 GNUNET_SCHEDULER_cancel (sr->probe_cancel_task);
1219 sr->probe_cancel_task);
1220 sr->probe_cancel_task = GNUNET_SCHEDULER_NO_TASK; 1207 sr->probe_cancel_task = GNUNET_SCHEDULER_NO_TASK;
1221 } 1208 }
1222 if (sr->update_search != NULL) 1209 if (sr->update_search != NULL)
@@ -1261,7 +1248,6 @@ search_result_suspend (void *cls,
1261 void *value) 1248 void *value)
1262{ 1249{
1263 struct GNUNET_FS_SearchContext *sc = cls; 1250 struct GNUNET_FS_SearchContext *sc = cls;
1264 struct GNUNET_FS_Handle *h = sc->h;
1265 struct GNUNET_FS_SearchResult *sr = value; 1251 struct GNUNET_FS_SearchResult *sr = value;
1266 struct GNUNET_FS_ProgressInfo pi; 1252 struct GNUNET_FS_ProgressInfo pi;
1267 1253
@@ -1281,8 +1267,7 @@ search_result_suspend (void *cls,
1281 if (sr->probe_ctx != NULL) 1267 if (sr->probe_ctx != NULL)
1282 GNUNET_FS_download_stop (sr->probe_ctx, GNUNET_YES); 1268 GNUNET_FS_download_stop (sr->probe_ctx, GNUNET_YES);
1283 if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK) 1269 if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK)
1284 GNUNET_SCHEDULER_cancel (h->sched, 1270 GNUNET_SCHEDULER_cancel (sr->probe_cancel_task);
1285 sr->probe_cancel_task);
1286 GNUNET_free (sr); 1271 GNUNET_free (sr);
1287 return GNUNET_OK; 1272 return GNUNET_OK;
1288} 1273}
@@ -1309,8 +1294,7 @@ GNUNET_FS_search_signal_suspend_ (void *cls)
1309 sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc); 1294 sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc);
1310 GNUNET_break (NULL == sc->client_info); 1295 GNUNET_break (NULL == sc->client_info);
1311 if (sc->task != GNUNET_SCHEDULER_NO_TASK) 1296 if (sc->task != GNUNET_SCHEDULER_NO_TASK)
1312 GNUNET_SCHEDULER_cancel (sc->h->sched, 1297 GNUNET_SCHEDULER_cancel (sc->task);
1313 sc->task);
1314 if (NULL != sc->client) 1298 if (NULL != sc->client)
1315 GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO); 1299 GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO);
1316 GNUNET_CONTAINER_multihashmap_destroy (sc->master_result_map); 1300 GNUNET_CONTAINER_multihashmap_destroy (sc->master_result_map);
@@ -1366,8 +1350,7 @@ GNUNET_FS_search_pause (struct GNUNET_FS_SearchContext *sc)
1366 struct GNUNET_FS_ProgressInfo pi; 1350 struct GNUNET_FS_ProgressInfo pi;
1367 1351
1368 if (sc->task != GNUNET_SCHEDULER_NO_TASK) 1352 if (sc->task != GNUNET_SCHEDULER_NO_TASK)
1369 GNUNET_SCHEDULER_cancel (sc->h->sched, 1353 GNUNET_SCHEDULER_cancel (sc->task);
1370 sc->task);
1371 sc->task = GNUNET_SCHEDULER_NO_TASK; 1354 sc->task = GNUNET_SCHEDULER_NO_TASK;
1372 if (NULL != sc->client) 1355 if (NULL != sc->client)
1373 GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO); 1356 GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO);
@@ -1417,7 +1400,6 @@ search_result_free (void *cls,
1417 void *value) 1400 void *value)
1418{ 1401{
1419 struct GNUNET_FS_SearchContext *sc = cls; 1402 struct GNUNET_FS_SearchContext *sc = cls;
1420 struct GNUNET_FS_Handle *h = sc->h;
1421 struct GNUNET_FS_SearchResult *sr = value; 1403 struct GNUNET_FS_SearchResult *sr = value;
1422 struct GNUNET_FS_ProgressInfo pi; 1404 struct GNUNET_FS_ProgressInfo pi;
1423 1405
@@ -1458,8 +1440,7 @@ search_result_free (void *cls,
1458 if (sr->probe_ctx != NULL) 1440 if (sr->probe_ctx != NULL)
1459 GNUNET_FS_download_stop (sr->probe_ctx, GNUNET_YES); 1441 GNUNET_FS_download_stop (sr->probe_ctx, GNUNET_YES);
1460 if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK) 1442 if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK)
1461 GNUNET_SCHEDULER_cancel (h->sched, 1443 GNUNET_SCHEDULER_cancel (sr->probe_cancel_task);
1462 sr->probe_cancel_task);
1463 GNUNET_free (sr); 1444 GNUNET_free (sr);
1464 return GNUNET_OK; 1445 return GNUNET_OK;
1465} 1446}
@@ -1501,8 +1482,7 @@ GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc)
1501 sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc); 1482 sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc);
1502 GNUNET_break (NULL == sc->client_info); 1483 GNUNET_break (NULL == sc->client_info);
1503 if (sc->task != GNUNET_SCHEDULER_NO_TASK) 1484 if (sc->task != GNUNET_SCHEDULER_NO_TASK)
1504 GNUNET_SCHEDULER_cancel (sc->h->sched, 1485 GNUNET_SCHEDULER_cancel (sc->task);
1505 sc->task);
1506 if (NULL != sc->client) 1486 if (NULL != sc->client)
1507 GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO); 1487 GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO);
1508 GNUNET_CONTAINER_multihashmap_destroy (sc->master_result_map); 1488 GNUNET_CONTAINER_multihashmap_destroy (sc->master_result_map);
diff --git a/src/fs/fs_test_lib.c b/src/fs/fs_test_lib.c
index f91092c4e..b7f3cb55a 100644
--- a/src/fs/fs_test_lib.c
+++ b/src/fs/fs_test_lib.c
@@ -72,11 +72,6 @@ struct GNUNET_FS_TestDaemon
72 struct GNUNET_PeerIdentity id; 72 struct GNUNET_PeerIdentity id;
73 73
74 /** 74 /**
75 * Scheduler to use (for publish_cont).
76 */
77 struct GNUNET_SCHEDULER_Handle *publish_sched;
78
79 /**
80 * Function to call when upload is done. 75 * Function to call when upload is done.
81 */ 76 */
82 GNUNET_FS_TEST_UriContinuation publish_cont; 77 GNUNET_FS_TEST_UriContinuation publish_cont;
@@ -112,11 +107,6 @@ struct GNUNET_FS_TestDaemon
112 char *publish_tmp_file; 107 char *publish_tmp_file;
113 108
114 /** 109 /**
115 * Scheduler to use (for download_cont).
116 */
117 struct GNUNET_SCHEDULER_Handle *download_sched;
118
119 /**
120 * Function to call when download is done. 110 * Function to call when download is done.
121 */ 111 */
122 GNUNET_SCHEDULER_Task download_cont; 112 GNUNET_SCHEDULER_Task download_cont;
@@ -186,7 +176,6 @@ report_uri (void *cls,
186 176
187 GNUNET_FS_publish_stop (daemon->publish_context); 177 GNUNET_FS_publish_stop (daemon->publish_context);
188 daemon->publish_context = NULL; 178 daemon->publish_context = NULL;
189 daemon->publish_sched = NULL;
190 cont = daemon->publish_cont; 179 cont = daemon->publish_cont;
191 daemon->publish_cont = NULL; 180 daemon->publish_cont = NULL;
192 uri = daemon->publish_uri; 181 uri = daemon->publish_uri;
@@ -204,12 +193,10 @@ report_success (void *cls,
204 193
205 GNUNET_FS_download_stop (daemon->download_context, GNUNET_YES); 194 GNUNET_FS_download_stop (daemon->download_context, GNUNET_YES);
206 daemon->download_context = NULL; 195 daemon->download_context = NULL;
207 GNUNET_SCHEDULER_add_continuation (daemon->download_sched, 196 GNUNET_SCHEDULER_add_continuation (daemon->download_cont,
208 daemon->download_cont,
209 daemon->download_cont_cls, 197 daemon->download_cont_cls,
210 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 198 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
211 daemon->download_cont = NULL; 199 daemon->download_cont = NULL;
212 daemon->download_sched = NULL;
213} 200}
214 201
215 202
@@ -222,12 +209,10 @@ progress_cb (void *cls,
222 switch (info->status) 209 switch (info->status)
223 { 210 {
224 case GNUNET_FS_STATUS_PUBLISH_COMPLETED: 211 case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
225 GNUNET_SCHEDULER_cancel (daemon->publish_sched, 212 GNUNET_SCHEDULER_cancel (daemon->publish_timeout_task);
226 daemon->publish_timeout_task);
227 daemon->publish_timeout_task = GNUNET_SCHEDULER_NO_TASK; 213 daemon->publish_timeout_task = GNUNET_SCHEDULER_NO_TASK;
228 daemon->publish_uri = GNUNET_FS_uri_dup (info->value.publish.specifics.completed.chk_uri); 214 daemon->publish_uri = GNUNET_FS_uri_dup (info->value.publish.specifics.completed.chk_uri);
229 GNUNET_SCHEDULER_add_continuation (daemon->publish_sched, 215 GNUNET_SCHEDULER_add_continuation (&report_uri,
230 &report_uri,
231 daemon, 216 daemon,
232 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 217 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
233 break; 218 break;
@@ -246,11 +231,9 @@ progress_cb (void *cls,
246 (unsigned long long) info->value.download.size); 231 (unsigned long long) info->value.download.size);
247 break; 232 break;
248 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: 233 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
249 GNUNET_SCHEDULER_cancel (daemon->download_sched, 234 GNUNET_SCHEDULER_cancel (daemon->download_timeout_task);
250 daemon->download_timeout_task);
251 daemon->download_timeout_task = GNUNET_SCHEDULER_NO_TASK; 235 daemon->download_timeout_task = GNUNET_SCHEDULER_NO_TASK;
252 GNUNET_SCHEDULER_add_continuation (daemon->download_sched, 236 GNUNET_SCHEDULER_add_continuation (&report_success,
253 &report_success,
254 daemon, 237 daemon,
255 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 238 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
256 break; 239 break;
@@ -269,7 +252,6 @@ progress_cb (void *cls,
269 252
270struct StartContext 253struct StartContext
271{ 254{
272 struct GNUNET_SCHEDULER_Handle *sched;
273 struct GNUNET_TIME_Relative timeout; 255 struct GNUNET_TIME_Relative timeout;
274 unsigned int total; 256 unsigned int total;
275 unsigned int have; 257 unsigned int have;
@@ -317,17 +299,14 @@ notify_running (void *cls,
317 sctx->have++; 299 sctx->have++;
318 if (sctx->have == sctx->total) 300 if (sctx->have == sctx->total)
319 { 301 {
320 GNUNET_SCHEDULER_add_continuation (sctx->sched, 302 GNUNET_SCHEDULER_add_continuation (sctx->cont,
321 sctx->cont,
322 sctx->cont_cls, 303 sctx->cont_cls,
323 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 304 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
324 sctx->daemons[0]->gcfg = sctx->cfg; 305 sctx->daemons[0]->gcfg = sctx->cfg;
325 GNUNET_SCHEDULER_cancel (sctx->sched, 306 GNUNET_SCHEDULER_cancel (sctx->timeout_task);
326 sctx->timeout_task);
327 for (i=0;i<sctx->total;i++) 307 for (i=0;i<sctx->total;i++)
328 { 308 {
329 sctx->daemons[i]->fs = GNUNET_FS_start (sctx->sched, 309 sctx->daemons[i]->fs = GNUNET_FS_start (sctx->daemons[i]->cfg,
330 sctx->daemons[i]->cfg,
331 "<tester>", 310 "<tester>",
332 &progress_cb, 311 &progress_cb,
333 sctx->daemons[i], 312 sctx->daemons[i],
@@ -360,8 +339,7 @@ start_timeout (void *cls,
360 sctx->daemons[i] = NULL; 339 sctx->daemons[i] = NULL;
361 } 340 }
362 GNUNET_CONFIGURATION_destroy (sctx->cfg); 341 GNUNET_CONFIGURATION_destroy (sctx->cfg);
363 GNUNET_SCHEDULER_add_continuation (sctx->sched, 342 GNUNET_SCHEDULER_add_continuation (sctx->cont,
364 sctx->cont,
365 sctx->cont_cls, 343 sctx->cont_cls,
366 GNUNET_SCHEDULER_REASON_TIMEOUT); 344 GNUNET_SCHEDULER_REASON_TIMEOUT);
367 GNUNET_free (sctx); 345 GNUNET_free (sctx);
@@ -371,7 +349,6 @@ start_timeout (void *cls,
371/** 349/**
372 * Start daemons for testing. 350 * Start daemons for testing.
373 * 351 *
374 * @param sched scheduler to use
375 * @param template_cfg_file configuration template to use 352 * @param template_cfg_file configuration template to use
376 * @param timeout if this operation cannot be completed within the 353 * @param timeout if this operation cannot be completed within the
377 * given period, call the continuation with an error code 354 * given period, call the continuation with an error code
@@ -382,8 +359,7 @@ start_timeout (void *cls,
382 * @param cont_cls closure for cont 359 * @param cont_cls closure for cont
383 */ 360 */
384void 361void
385GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, 362GNUNET_FS_TEST_daemons_start (const char *template_cfg_file,
386 const char *template_cfg_file,
387 struct GNUNET_TIME_Relative timeout, 363 struct GNUNET_TIME_Relative timeout,
388 unsigned int total, 364 unsigned int total,
389 struct GNUNET_FS_TestDaemon **daemons, 365 struct GNUNET_FS_TestDaemon **daemons,
@@ -395,7 +371,6 @@ GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
395 371
396 GNUNET_assert (total > 0); 372 GNUNET_assert (total > 0);
397 sctx = GNUNET_malloc (sizeof (struct StartContext)); 373 sctx = GNUNET_malloc (sizeof (struct StartContext));
398 sctx->sched = sched;
399 sctx->daemons = daemons; 374 sctx->daemons = daemons;
400 sctx->total = total; 375 sctx->total = total;
401 sctx->cont = cont; 376 sctx->cont = cont;
@@ -408,16 +383,14 @@ GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
408 GNUNET_break (0); 383 GNUNET_break (0);
409 GNUNET_CONFIGURATION_destroy (sctx->cfg); 384 GNUNET_CONFIGURATION_destroy (sctx->cfg);
410 GNUNET_free (sctx); 385 GNUNET_free (sctx);
411 GNUNET_SCHEDULER_add_continuation (sched, 386 GNUNET_SCHEDULER_add_continuation (cont,
412 cont,
413 cont_cls, 387 cont_cls,
414 GNUNET_SCHEDULER_REASON_TIMEOUT); 388 GNUNET_SCHEDULER_REASON_TIMEOUT);
415 return; 389 return;
416 } 390 }
417 for (i=0;i<total;i++) 391 for (i=0;i<total;i++)
418 daemons[i] = GNUNET_malloc (sizeof (struct GNUNET_FS_TestDaemon)); 392 daemons[i] = GNUNET_malloc (sizeof (struct GNUNET_FS_TestDaemon));
419 sctx->group = GNUNET_TESTING_daemons_start (sched, 393 sctx->group = GNUNET_TESTING_daemons_start (sctx->cfg,
420 sctx->cfg,
421 total, 394 total,
422 timeout, 395 timeout,
423 NULL, 396 NULL,
@@ -426,8 +399,7 @@ GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
426 sctx, 399 sctx,
427 NULL, NULL, 400 NULL, NULL,
428 NULL); 401 NULL);
429 sctx->timeout_task = GNUNET_SCHEDULER_add_delayed (sched, 402 sctx->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout,
430 timeout,
431 &start_timeout, 403 &start_timeout,
432 sctx); 404 sctx);
433} 405}
@@ -435,7 +407,6 @@ GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
435 407
436struct ConnectContext 408struct ConnectContext
437{ 409{
438 struct GNUNET_SCHEDULER_Handle *sched;
439 GNUNET_SCHEDULER_Task cont; 410 GNUNET_SCHEDULER_Task cont;
440 void *cont_cls; 411 void *cont_cls;
441}; 412};
@@ -472,8 +443,7 @@ notify_connection (void *cls,
472 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 443 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
473 "Failed to connect peers: %s\n", 444 "Failed to connect peers: %s\n",
474 emsg); 445 emsg);
475 GNUNET_SCHEDULER_add_continuation (cc->sched, 446 GNUNET_SCHEDULER_add_continuation (cc->cont,
476 cc->cont,
477 cc->cont_cls, 447 cc->cont_cls,
478 (emsg != NULL) 448 (emsg != NULL)
479 ? GNUNET_SCHEDULER_REASON_TIMEOUT 449 ? GNUNET_SCHEDULER_REASON_TIMEOUT
@@ -485,7 +455,6 @@ notify_connection (void *cls,
485/** 455/**
486 * Connect two daemons for testing. 456 * Connect two daemons for testing.
487 * 457 *
488 * @param sched scheduler to use
489 * @param daemon1 first daemon to connect 458 * @param daemon1 first daemon to connect
490 * @param daemon2 second first daemon to connect 459 * @param daemon2 second first daemon to connect
491 * @param timeout if this operation cannot be completed within the 460 * @param timeout if this operation cannot be completed within the
@@ -494,8 +463,7 @@ notify_connection (void *cls,
494 * @param cont_cls closure for cont 463 * @param cont_cls closure for cont
495 */ 464 */
496void 465void
497GNUNET_FS_TEST_daemons_connect (struct GNUNET_SCHEDULER_Handle *sched, 466GNUNET_FS_TEST_daemons_connect (struct GNUNET_FS_TestDaemon *daemon1,
498 struct GNUNET_FS_TestDaemon *daemon1,
499 struct GNUNET_FS_TestDaemon *daemon2, 467 struct GNUNET_FS_TestDaemon *daemon2,
500 struct GNUNET_TIME_Relative timeout, 468 struct GNUNET_TIME_Relative timeout,
501 GNUNET_SCHEDULER_Task cont, 469 GNUNET_SCHEDULER_Task cont,
@@ -504,7 +472,6 @@ GNUNET_FS_TEST_daemons_connect (struct GNUNET_SCHEDULER_Handle *sched,
504 struct ConnectContext *ncc; 472 struct ConnectContext *ncc;
505 473
506 ncc = GNUNET_malloc (sizeof (struct ConnectContext)); 474 ncc = GNUNET_malloc (sizeof (struct ConnectContext));
507 ncc->sched = sched;
508 ncc->cont = cont; 475 ncc->cont = cont;
509 ncc->cont_cls = cont_cls; 476 ncc->cont_cls = cont_cls;
510 GNUNET_TESTING_daemons_connect (daemon1->daemon, 477 GNUNET_TESTING_daemons_connect (daemon1->daemon,
@@ -546,13 +513,11 @@ GNUNET_FS_TEST_get_group (struct GNUNET_FS_TestDaemon **daemons)
546/** 513/**
547 * Stop daemons used for testing. 514 * Stop daemons used for testing.
548 * 515 *
549 * @param sched scheduler to use
550 * @param total number of daemons to stop 516 * @param total number of daemons to stop
551 * @param daemons array with the daemons (values will be clobbered) 517 * @param daemons array with the daemons (values will be clobbered)
552 */ 518 */
553void 519void
554GNUNET_FS_TEST_daemons_stop (struct GNUNET_SCHEDULER_Handle *sched, 520GNUNET_FS_TEST_daemons_stop (unsigned int total,
555 unsigned int total,
556 struct GNUNET_FS_TestDaemon **daemons) 521 struct GNUNET_FS_TestDaemon **daemons)
557{ 522{
558 unsigned int i; 523 unsigned int i;
@@ -633,7 +598,6 @@ file_generator (void *cls,
633/** 598/**
634 * Publish a file at the given daemon. 599 * Publish a file at the given daemon.
635 * 600 *
636 * @param sched scheduler to use
637 * @param daemon where to publish 601 * @param daemon where to publish
638 * @param timeout if this operation cannot be completed within the 602 * @param timeout if this operation cannot be completed within the
639 * given period, call the continuation with an error code 603 * given period, call the continuation with an error code
@@ -647,8 +611,7 @@ file_generator (void *cls,
647 * @param cont_cls closure for cont 611 * @param cont_cls closure for cont
648 */ 612 */
649void 613void
650GNUNET_FS_TEST_publish (struct GNUNET_SCHEDULER_Handle *sched, 614GNUNET_FS_TEST_publish (struct GNUNET_FS_TestDaemon *daemon,
651 struct GNUNET_FS_TestDaemon *daemon,
652 struct GNUNET_TIME_Relative timeout, 615 struct GNUNET_TIME_Relative timeout,
653 uint32_t anonymity, 616 uint32_t anonymity,
654 int do_index, 617 int do_index,
@@ -670,7 +633,6 @@ GNUNET_FS_TEST_publish (struct GNUNET_SCHEDULER_Handle *sched,
670 daemon->publish_cont_cls = cont_cls; 633 daemon->publish_cont_cls = cont_cls;
671 daemon->publish_seed = seed; 634 daemon->publish_seed = seed;
672 daemon->verbose = verbose; 635 daemon->verbose = verbose;
673 daemon->publish_sched = sched;
674 if (GNUNET_YES == do_index) 636 if (GNUNET_YES == do_index)
675 { 637 {
676 GNUNET_assert (daemon->publish_tmp_file == NULL); 638 GNUNET_assert (daemon->publish_tmp_file == NULL);
@@ -727,8 +689,7 @@ GNUNET_FS_TEST_publish (struct GNUNET_SCHEDULER_Handle *sched,
727 fi, 689 fi,
728 NULL, NULL, NULL, 690 NULL, NULL, NULL,
729 GNUNET_FS_PUBLISH_OPTION_NONE); 691 GNUNET_FS_PUBLISH_OPTION_NONE);
730 daemon->publish_timeout_task = GNUNET_SCHEDULER_add_delayed (sched, 692 daemon->publish_timeout_task = GNUNET_SCHEDULER_add_delayed (timeout,
731 timeout,
732 &publish_timeout, 693 &publish_timeout,
733 daemon); 694 daemon);
734} 695}
@@ -745,19 +706,16 @@ download_timeout (void *cls,
745 daemon->download_timeout_task = GNUNET_SCHEDULER_NO_TASK; 706 daemon->download_timeout_task = GNUNET_SCHEDULER_NO_TASK;
746 GNUNET_FS_download_stop (daemon->download_context, GNUNET_YES); 707 GNUNET_FS_download_stop (daemon->download_context, GNUNET_YES);
747 daemon->download_context = NULL; 708 daemon->download_context = NULL;
748 GNUNET_SCHEDULER_add_continuation (daemon->download_sched, 709 GNUNET_SCHEDULER_add_continuation (daemon->download_cont,
749 daemon->download_cont,
750 daemon->download_cont_cls, 710 daemon->download_cont_cls,
751 GNUNET_SCHEDULER_REASON_TIMEOUT); 711 GNUNET_SCHEDULER_REASON_TIMEOUT);
752 daemon->download_cont = NULL; 712 daemon->download_cont = NULL;
753 daemon->download_sched = NULL;
754} 713}
755 714
756 715
757/** 716/**
758 * Perform test download. 717 * Perform test download.
759 * 718 *
760 * @param sched scheduler to use
761 * @param daemon which peer to download from 719 * @param daemon which peer to download from
762 * @param timeout if this operation cannot be completed within the 720 * @param timeout if this operation cannot be completed within the
763 * given period, call the continuation with an error code 721 * given period, call the continuation with an error code
@@ -769,8 +727,7 @@ download_timeout (void *cls,
769 * @param cont_cls closure for cont 727 * @param cont_cls closure for cont
770 */ 728 */
771void 729void
772GNUNET_FS_TEST_download (struct GNUNET_SCHEDULER_Handle *sched, 730GNUNET_FS_TEST_download (struct GNUNET_FS_TestDaemon *daemon,
773 struct GNUNET_FS_TestDaemon *daemon,
774 struct GNUNET_TIME_Relative timeout, 731 struct GNUNET_TIME_Relative timeout,
775 uint32_t anonymity, 732 uint32_t anonymity,
776 uint32_t seed, 733 uint32_t seed,
@@ -784,7 +741,6 @@ GNUNET_FS_TEST_download (struct GNUNET_SCHEDULER_Handle *sched,
784 GNUNET_assert (daemon->download_cont == NULL); 741 GNUNET_assert (daemon->download_cont == NULL);
785 size = GNUNET_FS_uri_chk_get_file_size (uri); 742 size = GNUNET_FS_uri_chk_get_file_size (uri);
786 daemon->verbose = verbose; 743 daemon->verbose = verbose;
787 daemon->download_sched = sched;
788 daemon->download_cont = cont; 744 daemon->download_cont = cont;
789 daemon->download_cont_cls = cont_cls; 745 daemon->download_cont_cls = cont_cls;
790 daemon->download_seed = seed; 746 daemon->download_seed = seed;
@@ -798,8 +754,7 @@ GNUNET_FS_TEST_download (struct GNUNET_SCHEDULER_Handle *sched,
798 GNUNET_FS_DOWNLOAD_OPTION_NONE, 754 GNUNET_FS_DOWNLOAD_OPTION_NONE,
799 NULL, 755 NULL,
800 NULL); 756 NULL);
801 daemon->download_timeout_task = GNUNET_SCHEDULER_add_delayed (sched, 757 daemon->download_timeout_task = GNUNET_SCHEDULER_add_delayed (timeout,
802 timeout,
803 &download_timeout, 758 &download_timeout,
804 daemon); 759 daemon);
805} 760}
diff --git a/src/fs/fs_test_lib.h b/src/fs/fs_test_lib.h
index 666fad196..b348dfe78 100644
--- a/src/fs/fs_test_lib.h
+++ b/src/fs/fs_test_lib.h
@@ -41,7 +41,6 @@ struct GNUNET_FS_TestDaemon;
41/** 41/**
42 * Start daemons for testing. 42 * Start daemons for testing.
43 * 43 *
44 * @param sched scheduler to use
45 * @param template_cfg_file configuration template to use 44 * @param template_cfg_file configuration template to use
46 * @param timeout if this operation cannot be completed within the 45 * @param timeout if this operation cannot be completed within the
47 * given period, call the continuation with an error code 46 * given period, call the continuation with an error code
@@ -55,8 +54,7 @@ struct GNUNET_FS_TestDaemon;
55 * @param cont_cls closure for cont 54 * @param cont_cls closure for cont
56 */ 55 */
57void 56void
58GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, 57GNUNET_FS_TEST_daemons_start (const char *template_cfg_file,
59 const char *template_cfg_file,
60 struct GNUNET_TIME_Relative timeout, 58 struct GNUNET_TIME_Relative timeout,
61 unsigned int total, 59 unsigned int total,
62 struct GNUNET_FS_TestDaemon **daemons, 60 struct GNUNET_FS_TestDaemon **daemons,
@@ -67,7 +65,6 @@ GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
67/** 65/**
68 * Connect two daemons for testing. 66 * Connect two daemons for testing.
69 * 67 *
70 * @param sched scheduler to use
71 * @param daemon1 first daemon to connect 68 * @param daemon1 first daemon to connect
72 * @param daemon2 second first daemon to connect 69 * @param daemon2 second first daemon to connect
73 * @param timeout if this operation cannot be completed within the 70 * @param timeout if this operation cannot be completed within the
@@ -76,8 +73,7 @@ GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
76 * @param cont_cls closure for cont 73 * @param cont_cls closure for cont
77 */ 74 */
78void 75void
79GNUNET_FS_TEST_daemons_connect (struct GNUNET_SCHEDULER_Handle *sched, 76GNUNET_FS_TEST_daemons_connect (struct GNUNET_FS_TestDaemon *daemon1,
80 struct GNUNET_FS_TestDaemon *daemon1,
81 struct GNUNET_FS_TestDaemon *daemon2, 77 struct GNUNET_FS_TestDaemon *daemon2,
82 struct GNUNET_TIME_Relative timeout, 78 struct GNUNET_TIME_Relative timeout,
83 GNUNET_SCHEDULER_Task cont, 79 GNUNET_SCHEDULER_Task cont,
@@ -109,13 +105,11 @@ GNUNET_FS_TEST_get_configuration (struct GNUNET_FS_TestDaemon **daemons,
109/** 105/**
110 * Stop daemons used for testing. 106 * Stop daemons used for testing.
111 * 107 *
112 * @param sched scheduler to use
113 * @param total number of daemons to stop 108 * @param total number of daemons to stop
114 * @param daemons array with the daemons (values will be clobbered) 109 * @param daemons array with the daemons (values will be clobbered)
115 */ 110 */
116void 111void
117GNUNET_FS_TEST_daemons_stop (struct GNUNET_SCHEDULER_Handle *sched, 112GNUNET_FS_TEST_daemons_stop (unsigned int total,
118 unsigned int total,
119 struct GNUNET_FS_TestDaemon **daemons); 113 struct GNUNET_FS_TestDaemon **daemons);
120 114
121 115
@@ -133,7 +127,6 @@ typedef void
133/** 127/**
134 * Publish a file at the given daemon. 128 * Publish a file at the given daemon.
135 * 129 *
136 * @param sched scheduler to use
137 * @param daemon where to publish 130 * @param daemon where to publish
138 * @param timeout if this operation cannot be completed within the 131 * @param timeout if this operation cannot be completed within the
139 * given period, call the continuation with an error code 132 * given period, call the continuation with an error code
@@ -147,8 +140,7 @@ typedef void
147 * @param cont_cls closure for cont 140 * @param cont_cls closure for cont
148 */ 141 */
149void 142void
150GNUNET_FS_TEST_publish (struct GNUNET_SCHEDULER_Handle *sched, 143GNUNET_FS_TEST_publish (struct GNUNET_FS_TestDaemon *daemon,
151 struct GNUNET_FS_TestDaemon *daemon,
152 struct GNUNET_TIME_Relative timeout, 144 struct GNUNET_TIME_Relative timeout,
153 uint32_t anonymity, 145 uint32_t anonymity,
154 int do_index, 146 int do_index,
@@ -162,7 +154,6 @@ GNUNET_FS_TEST_publish (struct GNUNET_SCHEDULER_Handle *sched,
162/** 154/**
163 * Perform test download. 155 * Perform test download.
164 * 156 *
165 * @param sched scheduler to use
166 * @param daemon which peer to download from 157 * @param daemon which peer to download from
167 * @param timeout if this operation cannot be completed within the 158 * @param timeout if this operation cannot be completed within the
168 * given period, call the continuation with an error code 159 * given period, call the continuation with an error code
@@ -174,8 +165,7 @@ GNUNET_FS_TEST_publish (struct GNUNET_SCHEDULER_Handle *sched,
174 * @param cont_cls closure for cont 165 * @param cont_cls closure for cont
175 */ 166 */
176void 167void
177GNUNET_FS_TEST_download (struct GNUNET_SCHEDULER_Handle *sched, 168GNUNET_FS_TEST_download (struct GNUNET_FS_TestDaemon *daemon,
178 struct GNUNET_FS_TestDaemon *daemon,
179 struct GNUNET_TIME_Relative timeout, 169 struct GNUNET_TIME_Relative timeout,
180 uint32_t anonymity, 170 uint32_t anonymity,
181 uint32_t seed, 171 uint32_t seed,
diff --git a/src/fs/fs_tree.c b/src/fs/fs_tree.c
index 55f7b0e09..b38a9c382 100644
--- a/src/fs/fs_tree.c
+++ b/src/fs/fs_tree.c
@@ -329,8 +329,7 @@ void GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder * te)
329 iob, 329 iob,
330 &te->emsg)) 330 &te->emsg))
331 { 331 {
332 GNUNET_SCHEDULER_add_continuation (te->h->sched, 332 GNUNET_SCHEDULER_add_continuation (te->cont,
333 te->cont,
334 te->cls, 333 te->cls,
335 GNUNET_SCHEDULER_REASON_TIMEOUT); 334 GNUNET_SCHEDULER_REASON_TIMEOUT);
336 return; 335 return;
@@ -350,8 +349,7 @@ void GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder * te)
350 te->uri->type = chk; 349 te->uri->type = chk;
351 te->uri->data.chk.chk = te->chk_tree[0]; 350 te->uri->data.chk.chk = te->chk_tree[0];
352 te->uri->data.chk.file_length = GNUNET_htonll (te->size); 351 te->uri->data.chk.file_length = GNUNET_htonll (te->size);
353 GNUNET_SCHEDULER_add_continuation (te->h->sched, 352 GNUNET_SCHEDULER_add_continuation (te->cont,
354 te->cont,
355 te->cls, 353 te->cls,
356 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 354 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
357 return; 355 return;
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c
index e4ac4efd6..b3bcd48bf 100644
--- a/src/fs/fs_unindex.c
+++ b/src/fs/fs_unindex.c
@@ -318,8 +318,7 @@ unindex_finish (void *cls,
318 uc->dsh = NULL; 318 uc->dsh = NULL;
319 uc->state = UNINDEX_STATE_FS_NOTIFY; 319 uc->state = UNINDEX_STATE_FS_NOTIFY;
320 GNUNET_FS_unindex_sync_ (uc); 320 GNUNET_FS_unindex_sync_ (uc);
321 uc->client = GNUNET_CLIENT_connect (uc->h->sched, 321 uc->client = GNUNET_CLIENT_connect ("fs",
322 "fs",
323 uc->h->cfg); 322 uc->h->cfg);
324 if (uc->client == NULL) 323 if (uc->client == NULL)
325 { 324 {
@@ -355,8 +354,7 @@ unindex_finish (void *cls,
355void 354void
356GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc) 355GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc)
357{ 356{
358 uc->dsh = GNUNET_DATASTORE_connect (uc->h->cfg, 357 uc->dsh = GNUNET_DATASTORE_connect (uc->h->cfg);
359 uc->h->sched);
360 if (NULL == uc->dsh) 358 if (NULL == uc->dsh)
361 { 359 {
362 uc->state = UNINDEX_STATE_ERROR; 360 uc->state = UNINDEX_STATE_ERROR;
@@ -506,8 +504,7 @@ GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h,
506 pi.status = GNUNET_FS_STATUS_UNINDEX_START; 504 pi.status = GNUNET_FS_STATUS_UNINDEX_START;
507 pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL; 505 pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL;
508 GNUNET_FS_unindex_make_status_ (&pi, ret, 0); 506 GNUNET_FS_unindex_make_status_ (&pi, ret, 0);
509 ret->fhc = GNUNET_CRYPTO_hash_file (h->sched, 507 ret->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE,
510 GNUNET_SCHEDULER_PRIORITY_IDLE,
511 filename, 508 filename,
512 HASHING_BLOCKSIZE, 509 HASHING_BLOCKSIZE,
513 &GNUNET_FS_unindex_process_hash_, 510 &GNUNET_FS_unindex_process_hash_,
diff --git a/src/fs/gnunet-directory.c b/src/fs/gnunet-directory.c
index 8f58025c5..6de8206f1 100644
--- a/src/fs/gnunet-directory.c
+++ b/src/fs/gnunet-directory.c
@@ -106,14 +106,12 @@ print_entry (void *cls,
106 * Main function that will be run by the scheduler. 106 * Main function that will be run by the scheduler.
107 * 107 *
108 * @param cls closure 108 * @param cls closure
109 * @param sched the scheduler to use
110 * @param args remaining command-line arguments 109 * @param args remaining command-line arguments
111 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 110 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
112 * @param cfg configuration 111 * @param cfg configuration
113 */ 112 */
114static void 113static void
115run (void *cls, 114run (void *cls,
116 struct GNUNET_SCHEDULER_Handle *sched,
117 char *const *args, 115 char *const *args,
118 const char *cfgfile, 116 const char *cfgfile,
119 const struct GNUNET_CONFIGURATION_Handle *cfg) 117 const struct GNUNET_CONFIGURATION_Handle *cfg)
diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c
index 36681e407..99ebb1435 100644
--- a/src/fs/gnunet-download.c
+++ b/src/fs/gnunet-download.c
@@ -38,8 +38,6 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
38 38
39static struct GNUNET_FS_Handle *ctx; 39static struct GNUNET_FS_Handle *ctx;
40 40
41static struct GNUNET_SCHEDULER_Handle *sched;
42
43static struct GNUNET_FS_DownloadContext *dc; 41static struct GNUNET_FS_DownloadContext *dc;
44 42
45static unsigned int anonymity = 1; 43static unsigned int anonymity = 1;
@@ -122,7 +120,7 @@ progress_cb (void *cls,
122 fprintf (stderr, 120 fprintf (stderr,
123 _("Error downloading: %s.\n"), 121 _("Error downloading: %s.\n"),
124 info->value.download.specifics.error.message); 122 info->value.download.specifics.error.message);
125 GNUNET_SCHEDULER_shutdown (sched); 123 GNUNET_SCHEDULER_shutdown ();
126 break; 124 break;
127 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: 125 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
128 s = GNUNET_STRINGS_byte_size_fancy(info->value.download.completed * 1000 / (info->value.download.duration.rel_value + 1)); 126 s = GNUNET_STRINGS_byte_size_fancy(info->value.download.completed * 1000 / (info->value.download.duration.rel_value + 1));
@@ -132,12 +130,11 @@ progress_cb (void *cls,
132 s); 130 s);
133 GNUNET_free (s); 131 GNUNET_free (s);
134 if (info->value.download.dc == dc) 132 if (info->value.download.dc == dc)
135 GNUNET_SCHEDULER_shutdown (sched); 133 GNUNET_SCHEDULER_shutdown ();
136 break; 134 break;
137 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: 135 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
138 if (info->value.download.dc == dc) 136 if (info->value.download.dc == dc)
139 GNUNET_SCHEDULER_add_continuation (sched, 137 GNUNET_SCHEDULER_add_continuation (&cleanup_task,
140 &cleanup_task,
141 NULL, 138 NULL,
142 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 139 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
143 break; 140 break;
@@ -158,14 +155,12 @@ progress_cb (void *cls,
158 * Main function that will be run by the scheduler. 155 * Main function that will be run by the scheduler.
159 * 156 *
160 * @param cls closure 157 * @param cls closure
161 * @param s the scheduler to use
162 * @param args remaining command-line arguments 158 * @param args remaining command-line arguments
163 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 159 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
164 * @param c configuration 160 * @param c configuration
165 */ 161 */
166static void 162static void
167run (void *cls, 163run (void *cls,
168 struct GNUNET_SCHEDULER_Handle *s,
169 char *const *args, 164 char *const *args,
170 const char *cfgfile, 165 const char *cfgfile,
171 const struct GNUNET_CONFIGURATION_Handle *c) 166 const struct GNUNET_CONFIGURATION_Handle *c)
@@ -174,7 +169,6 @@ run (void *cls,
174 char *emsg; 169 char *emsg;
175 enum GNUNET_FS_DownloadOptions options; 170 enum GNUNET_FS_DownloadOptions options;
176 171
177 sched = s;
178 uri = GNUNET_FS_uri_parse (args[0], 172 uri = GNUNET_FS_uri_parse (args[0],
179 &emsg); 173 &emsg);
180 if (NULL == uri) 174 if (NULL == uri)
@@ -204,8 +198,7 @@ run (void *cls,
204 return; 198 return;
205 } 199 }
206 cfg = c; 200 cfg = c;
207 ctx = GNUNET_FS_start (sched, 201 ctx = GNUNET_FS_start (cfg,
208 cfg,
209 "gnunet-download", 202 "gnunet-download",
210 &progress_cb, 203 &progress_cb,
211 NULL, 204 NULL,
@@ -246,8 +239,7 @@ run (void *cls,
246 ctx = NULL; 239 ctx = NULL;
247 return; 240 return;
248 } 241 }
249 GNUNET_SCHEDULER_add_delayed (sched, 242 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
250 GNUNET_TIME_UNIT_FOREVER_REL,
251 &shutdown_task, 243 &shutdown_task,
252 NULL); 244 NULL);
253} 245}
diff --git a/src/fs/gnunet-pseudonym.c b/src/fs/gnunet-pseudonym.c
index ba9213b5d..b7aba8ef4 100644
--- a/src/fs/gnunet-pseudonym.c
+++ b/src/fs/gnunet-pseudonym.c
@@ -221,14 +221,12 @@ post_advertising (void *cls,
221 * Main function that will be run by the scheduler. 221 * Main function that will be run by the scheduler.
222 * 222 *
223 * @param cls closure 223 * @param cls closure
224 * @param sched the scheduler to use
225 * @param args remaining command-line arguments 224 * @param args remaining command-line arguments
226 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 225 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
227 * @param c configuration 226 * @param c configuration
228 */ 227 */
229static void 228static void
230run (void *cls, 229run (void *cls,
231 struct GNUNET_SCHEDULER_Handle *sched,
232 char *const *args, 230 char *const *args,
233 const char *cfgfile, 231 const char *cfgfile,
234 const struct GNUNET_CONFIGURATION_Handle *c) 232 const struct GNUNET_CONFIGURATION_Handle *c)
@@ -237,8 +235,7 @@ run (void *cls,
237 char *emsg; 235 char *emsg;
238 236
239 cfg = c; 237 cfg = c;
240 h = GNUNET_FS_start (sched, 238 h = GNUNET_FS_start (cfg,
241 cfg,
242 "gnunet-pseudonym", 239 "gnunet-pseudonym",
243 &progress_cb, 240 &progress_cb,
244 NULL, 241 NULL,
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c
index 79beacc84..36e75a4ea 100644
--- a/src/fs/gnunet-publish.c
+++ b/src/fs/gnunet-publish.c
@@ -38,8 +38,6 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
38 38
39static struct GNUNET_FS_Handle *ctx; 39static struct GNUNET_FS_Handle *ctx;
40 40
41static struct GNUNET_SCHEDULER_Handle *sched;
42
43static struct GNUNET_FS_PublishContext *pc; 41static struct GNUNET_FS_PublishContext *pc;
44 42
45static struct GNUNET_CONTAINER_MetaData *meta; 43static struct GNUNET_CONTAINER_MetaData *meta;
@@ -135,12 +133,10 @@ progress_cb (void *cls,
135 info->value.publish.specifics.error.message); 133 info->value.publish.specifics.error.message);
136 if (kill_task != GNUNET_SCHEDULER_NO_TASK) 134 if (kill_task != GNUNET_SCHEDULER_NO_TASK)
137 { 135 {
138 GNUNET_SCHEDULER_cancel (sched, 136 GNUNET_SCHEDULER_cancel (kill_task);
139 kill_task);
140 kill_task = GNUNET_SCHEDULER_NO_TASK; 137 kill_task = GNUNET_SCHEDULER_NO_TASK;
141 } 138 }
142 GNUNET_SCHEDULER_add_continuation (sched, 139 GNUNET_SCHEDULER_add_continuation (&do_stop_task,
143 &do_stop_task,
144 NULL, 140 NULL,
145 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 141 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
146 break; 142 break;
@@ -157,12 +153,10 @@ progress_cb (void *cls,
157 { 153 {
158 if (kill_task != GNUNET_SCHEDULER_NO_TASK) 154 if (kill_task != GNUNET_SCHEDULER_NO_TASK)
159 { 155 {
160 GNUNET_SCHEDULER_cancel (sched, 156 GNUNET_SCHEDULER_cancel (kill_task);
161 kill_task);
162 kill_task = GNUNET_SCHEDULER_NO_TASK; 157 kill_task = GNUNET_SCHEDULER_NO_TASK;
163 } 158 }
164 GNUNET_SCHEDULER_add_continuation (sched, 159 GNUNET_SCHEDULER_add_continuation (&do_stop_task,
165 &do_stop_task,
166 NULL, 160 NULL,
167 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 161 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
168 } 162 }
@@ -374,14 +368,12 @@ uri_ksk_continuation (void *cls,
374 * Main function that will be run by the scheduler. 368 * Main function that will be run by the scheduler.
375 * 369 *
376 * @param cls closure 370 * @param cls closure
377 * @param s the scheduler to use
378 * @param args remaining command-line arguments 371 * @param args remaining command-line arguments
379 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 372 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
380 * @param c configuration 373 * @param c configuration
381 */ 374 */
382static void 375static void
383run (void *cls, 376run (void *cls,
384 struct GNUNET_SCHEDULER_Handle *s,
385 char *const *args, 377 char *const *args,
386 const char *cfgfile, 378 const char *cfgfile,
387 const struct GNUNET_CONFIGURATION_Handle *c) 379 const struct GNUNET_CONFIGURATION_Handle *c)
@@ -393,7 +385,6 @@ run (void *cls,
393 char *ex; 385 char *ex;
394 char *emsg; 386 char *emsg;
395 387
396 sched = s;
397 /* check arguments */ 388 /* check arguments */
398 if ((uri_string != NULL) && (extract_only)) 389 if ((uri_string != NULL) && (extract_only))
399 { 390 {
@@ -446,8 +437,7 @@ run (void *cls,
446 } 437 }
447 } 438 }
448 cfg = c; 439 cfg = c;
449 ctx = GNUNET_FS_start (sched, 440 ctx = GNUNET_FS_start (cfg,
450 cfg,
451 "gnunet-publish", 441 "gnunet-publish",
452 &progress_cb, 442 &progress_cb,
453 NULL, 443 NULL,
@@ -600,8 +590,7 @@ run (void *cls,
600 ret = 1; 590 ret = 1;
601 return; 591 return;
602 } 592 }
603 kill_task = GNUNET_SCHEDULER_add_delayed (sched, 593 kill_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
604 GNUNET_TIME_UNIT_FOREVER_REL,
605 &do_stop_task, 594 &do_stop_task,
606 NULL); 595 NULL);
607} 596}
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c
index ab3f6b0c7..dddfe6b75 100644
--- a/src/fs/gnunet-search.c
+++ b/src/fs/gnunet-search.c
@@ -32,8 +32,6 @@ static int ret;
32 32
33static const struct GNUNET_CONFIGURATION_Handle *cfg; 33static const struct GNUNET_CONFIGURATION_Handle *cfg;
34 34
35static struct GNUNET_SCHEDULER_Handle *sched;
36
37static struct GNUNET_FS_Handle *ctx; 35static struct GNUNET_FS_Handle *ctx;
38 36
39static struct GNUNET_FS_SearchContext *sc; 37static struct GNUNET_FS_SearchContext *sc;
@@ -185,11 +183,10 @@ progress_cb (void *cls,
185 fprintf (stderr, 183 fprintf (stderr,
186 _("Error searching: %s.\n"), 184 _("Error searching: %s.\n"),
187 info->value.search.specifics.error.message); 185 info->value.search.specifics.error.message);
188 GNUNET_SCHEDULER_shutdown (sched); 186 GNUNET_SCHEDULER_shutdown ();
189 break; 187 break;
190 case GNUNET_FS_STATUS_SEARCH_STOPPED: 188 case GNUNET_FS_STATUS_SEARCH_STOPPED:
191 GNUNET_SCHEDULER_add_continuation (sched, 189 GNUNET_SCHEDULER_add_continuation (&clean_task,
192 &clean_task,
193 NULL, 190 NULL,
194 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 191 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
195 break; 192 break;
@@ -219,14 +216,12 @@ shutdown_task (void *cls,
219 * Main function that will be run by the scheduler. 216 * Main function that will be run by the scheduler.
220 * 217 *
221 * @param cls closure 218 * @param cls closure
222 * @param s the scheduler to use
223 * @param args remaining command-line arguments 219 * @param args remaining command-line arguments
224 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 220 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
225 * @param c configuration 221 * @param c configuration
226 */ 222 */
227static void 223static void
228run (void *cls, 224run (void *cls,
229 struct GNUNET_SCHEDULER_Handle *s,
230 char *const *args, 225 char *const *args,
231 const char *cfgfile, 226 const char *cfgfile,
232 const struct GNUNET_CONFIGURATION_Handle *c) 227 const struct GNUNET_CONFIGURATION_Handle *c)
@@ -235,7 +230,6 @@ run (void *cls,
235 unsigned int argc; 230 unsigned int argc;
236 enum GNUNET_FS_SearchOptions options; 231 enum GNUNET_FS_SearchOptions options;
237 232
238 sched = s;
239 argc = 0; 233 argc = 0;
240 while (NULL != args[argc]) 234 while (NULL != args[argc])
241 argc++; 235 argc++;
@@ -250,8 +244,7 @@ run (void *cls,
250 return; 244 return;
251 } 245 }
252 cfg = c; 246 cfg = c;
253 ctx = GNUNET_FS_start (sched, 247 ctx = GNUNET_FS_start (cfg,
254 cfg,
255 "gnunet-search", 248 "gnunet-search",
256 &progress_cb, 249 &progress_cb,
257 NULL, 250 NULL,
@@ -285,8 +278,7 @@ run (void *cls,
285 ret = 1; 278 ret = 1;
286 return; 279 return;
287 } 280 }
288 GNUNET_SCHEDULER_add_delayed (sched, 281 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
289 GNUNET_TIME_UNIT_FOREVER_REL,
290 &shutdown_task, 282 &shutdown_task,
291 NULL); 283 NULL);
292} 284}
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index 2defec397..0a537576a 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -771,11 +771,6 @@ static struct GNUNET_BLOCK_Context *block_ctx;
771static struct GNUNET_CONFIGURATION_Handle *block_cfg; 771static struct GNUNET_CONFIGURATION_Handle *block_cfg;
772 772
773/** 773/**
774 * Our scheduler.
775 */
776static struct GNUNET_SCHEDULER_Handle *sched;
777
778/**
779 * Our configuration. 774 * Our configuration.
780 */ 775 */
781static const struct GNUNET_CONFIGURATION_Handle *cfg; 776static const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -1106,7 +1101,7 @@ consider_migration (void *cls,
1106#endif 1101#endif
1107 if (cp->delayed_transmission_request_task != GNUNET_SCHEDULER_NO_TASK) 1102 if (cp->delayed_transmission_request_task != GNUNET_SCHEDULER_NO_TASK)
1108 { 1103 {
1109 GNUNET_SCHEDULER_cancel (sched, cp->delayed_transmission_request_task); 1104 GNUNET_SCHEDULER_cancel (cp->delayed_transmission_request_task);
1110 cp->delayed_transmission_request_task = GNUNET_SCHEDULER_NO_TASK; 1105 cp->delayed_transmission_request_task = GNUNET_SCHEDULER_NO_TASK;
1111 } 1106 }
1112 cp->cth 1107 cp->cth
@@ -1166,8 +1161,7 @@ consider_migration_gathering ()
1166 MAX_MIGRATION_QUEUE); 1161 MAX_MIGRATION_QUEUE);
1167 delay = GNUNET_TIME_relative_max (delay, 1162 delay = GNUNET_TIME_relative_max (delay,
1168 min_migration_delay); 1163 min_migration_delay);
1169 mig_task = GNUNET_SCHEDULER_add_delayed (sched, 1164 mig_task = GNUNET_SCHEDULER_add_delayed (delay,
1170 delay,
1171 &gather_migration_blocks, 1165 &gather_migration_blocks,
1172 NULL); 1166 NULL);
1173} 1167}
@@ -1201,8 +1195,7 @@ consider_dht_put_gathering (void *cls)
1201 (hopefully) appear */ 1195 (hopefully) appear */
1202 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5); 1196 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5);
1203 } 1197 }
1204 dht_task = GNUNET_SCHEDULER_add_delayed (sched, 1198 dht_task = GNUNET_SCHEDULER_add_delayed (delay,
1205 delay,
1206 &gather_dht_put_blocks, 1199 &gather_dht_put_blocks,
1207 cls); 1200 cls);
1208} 1201}
@@ -1542,8 +1535,7 @@ destroy_pending_request (struct PendingRequest *pr)
1542 } 1535 }
1543 if (pr->task != GNUNET_SCHEDULER_NO_TASK) 1536 if (pr->task != GNUNET_SCHEDULER_NO_TASK)
1544 { 1537 {
1545 GNUNET_SCHEDULER_cancel (sched, 1538 GNUNET_SCHEDULER_cancel (pr->task);
1546 pr->task);
1547 pr->task = GNUNET_SCHEDULER_NO_TASK; 1539 pr->task = GNUNET_SCHEDULER_NO_TASK;
1548 } 1540 }
1549 while (NULL != pr->pending_head) 1541 while (NULL != pr->pending_head)
@@ -1743,8 +1735,7 @@ cron_flush_trust (void *cls,
1743 return; 1735 return;
1744 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1736 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1745 return; 1737 return;
1746 GNUNET_SCHEDULER_add_delayed (tc->sched, 1738 GNUNET_SCHEDULER_add_delayed (TRUST_FLUSH_FREQ, &cron_flush_trust, NULL);
1747 TRUST_FLUSH_FREQ, &cron_flush_trust, NULL);
1748} 1739}
1749 1740
1750 1741
@@ -1843,7 +1834,7 @@ peer_disconnect_handler (void *cls,
1843 } 1834 }
1844 if (cp->delayed_transmission_request_task != GNUNET_SCHEDULER_NO_TASK) 1835 if (cp->delayed_transmission_request_task != GNUNET_SCHEDULER_NO_TASK)
1845 { 1836 {
1846 GNUNET_SCHEDULER_cancel (sched, cp->delayed_transmission_request_task); 1837 GNUNET_SCHEDULER_cancel (cp->delayed_transmission_request_task);
1847 cp->delayed_transmission_request_task = GNUNET_SCHEDULER_NO_TASK; 1838 cp->delayed_transmission_request_task = GNUNET_SCHEDULER_NO_TASK;
1848 } 1839 }
1849 while (NULL != (pm = cp->pending_messages_head)) 1840 while (NULL != (pm = cp->pending_messages_head))
@@ -1984,12 +1975,12 @@ shutdown_task (void *cls,
1984 } 1975 }
1985 if (GNUNET_SCHEDULER_NO_TASK != mig_task) 1976 if (GNUNET_SCHEDULER_NO_TASK != mig_task)
1986 { 1977 {
1987 GNUNET_SCHEDULER_cancel (sched, mig_task); 1978 GNUNET_SCHEDULER_cancel (mig_task);
1988 mig_task = GNUNET_SCHEDULER_NO_TASK; 1979 mig_task = GNUNET_SCHEDULER_NO_TASK;
1989 } 1980 }
1990 if (GNUNET_SCHEDULER_NO_TASK != dht_task) 1981 if (GNUNET_SCHEDULER_NO_TASK != dht_task)
1991 { 1982 {
1992 GNUNET_SCHEDULER_cancel (sched, dht_task); 1983 GNUNET_SCHEDULER_cancel (dht_task);
1993 dht_task = GNUNET_SCHEDULER_NO_TASK; 1984 dht_task = GNUNET_SCHEDULER_NO_TASK;
1994 } 1985 }
1995 while (client_list != NULL) 1986 while (client_list != NULL)
@@ -2039,7 +2030,6 @@ shutdown_task (void *cls,
2039 block_ctx = NULL; 2030 block_ctx = NULL;
2040 GNUNET_CONFIGURATION_destroy (block_cfg); 2031 GNUNET_CONFIGURATION_destroy (block_cfg);
2041 block_cfg = NULL; 2032 block_cfg = NULL;
2042 sched = NULL;
2043 cfg = NULL; 2033 cfg = NULL;
2044 GNUNET_free_non_null (trustDirectory); 2034 GNUNET_free_non_null (trustDirectory);
2045 trustDirectory = NULL; 2035 trustDirectory = NULL;
@@ -2157,8 +2147,7 @@ transmit_to_peer (void *cls,
2157 { 2147 {
2158 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == cp->delayed_transmission_request_task); 2148 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == cp->delayed_transmission_request_task);
2159 cp->delayed_transmission_request_task 2149 cp->delayed_transmission_request_task
2160 = GNUNET_SCHEDULER_add_delayed (sched, 2150 = GNUNET_SCHEDULER_add_delayed (min_delay,
2161 min_delay,
2162 &delayed_transmission_request, 2151 &delayed_transmission_request,
2163 cp); 2152 cp);
2164 } 2153 }
@@ -2284,7 +2273,7 @@ add_to_pending_messages_for_peer (struct ConnectedPeer *cp,
2284 } 2273 }
2285 if (cp->delayed_transmission_request_task != GNUNET_SCHEDULER_NO_TASK) 2274 if (cp->delayed_transmission_request_task != GNUNET_SCHEDULER_NO_TASK)
2286 { 2275 {
2287 GNUNET_SCHEDULER_cancel (sched, cp->delayed_transmission_request_task); 2276 GNUNET_SCHEDULER_cancel (cp->delayed_transmission_request_task);
2288 cp->delayed_transmission_request_task = GNUNET_SCHEDULER_NO_TASK; 2277 cp->delayed_transmission_request_task = GNUNET_SCHEDULER_NO_TASK;
2289 } 2278 }
2290 /* need to schedule transmission */ 2279 /* need to schedule transmission */
@@ -2428,8 +2417,7 @@ transmit_query_continuation (void *cls,
2428 "Transmission of request failed, will try again later.\n"); 2417 "Transmission of request failed, will try again later.\n");
2429#endif 2418#endif
2430 if (pr->task == GNUNET_SCHEDULER_NO_TASK) 2419 if (pr->task == GNUNET_SCHEDULER_NO_TASK)
2431 pr->task = GNUNET_SCHEDULER_add_delayed (sched, 2420 pr->task = GNUNET_SCHEDULER_add_delayed (get_processing_delay (),
2432 get_processing_delay (),
2433 &forward_request_task, 2421 &forward_request_task,
2434 pr); 2422 pr);
2435 return; 2423 return;
@@ -2461,8 +2449,7 @@ transmit_query_continuation (void *cls,
2461 pr->used_targets[i].last_request_time = GNUNET_TIME_absolute_get (); 2449 pr->used_targets[i].last_request_time = GNUNET_TIME_absolute_get ();
2462 pr->used_targets[i].num_requests++; 2450 pr->used_targets[i].num_requests++;
2463 if (pr->task == GNUNET_SCHEDULER_NO_TASK) 2451 if (pr->task == GNUNET_SCHEDULER_NO_TASK)
2464 pr->task = GNUNET_SCHEDULER_add_delayed (sched, 2452 pr->task = GNUNET_SCHEDULER_add_delayed (get_processing_delay (),
2465 get_processing_delay (),
2466 &forward_request_task, 2453 &forward_request_task,
2467 pr); 2454 pr);
2468} 2455}
@@ -2572,8 +2559,7 @@ target_reservation_cb (void *cls,
2572 { 2559 {
2573 /* error in communication with core, try again later */ 2560 /* error in communication with core, try again later */
2574 if (pr->task == GNUNET_SCHEDULER_NO_TASK) 2561 if (pr->task == GNUNET_SCHEDULER_NO_TASK)
2575 pr->task = GNUNET_SCHEDULER_add_delayed (sched, 2562 pr->task = GNUNET_SCHEDULER_add_delayed (get_processing_delay (),
2576 get_processing_delay (),
2577 &forward_request_task, 2563 &forward_request_task,
2578 pr); 2564 pr);
2579 return; 2565 return;
@@ -2589,8 +2575,7 @@ target_reservation_cb (void *cls,
2589 "Selected peer disconnected!\n"); 2575 "Selected peer disconnected!\n");
2590#endif 2576#endif
2591 if (pr->task == GNUNET_SCHEDULER_NO_TASK) 2577 if (pr->task == GNUNET_SCHEDULER_NO_TASK)
2592 pr->task = GNUNET_SCHEDULER_add_delayed (sched, 2578 pr->task = GNUNET_SCHEDULER_add_delayed (get_processing_delay (),
2593 get_processing_delay (),
2594 &forward_request_task, 2579 &forward_request_task,
2595 pr); 2580 pr);
2596 return; 2581 return;
@@ -2611,8 +2596,7 @@ target_reservation_cb (void *cls,
2611 1, 2596 1,
2612 GNUNET_NO); 2597 GNUNET_NO);
2613 if (pr->task == GNUNET_SCHEDULER_NO_TASK) 2598 if (pr->task == GNUNET_SCHEDULER_NO_TASK)
2614 pr->task = GNUNET_SCHEDULER_add_delayed (sched, 2599 pr->task = GNUNET_SCHEDULER_add_delayed (get_processing_delay (),
2615 get_processing_delay (),
2616 &forward_request_task, 2600 &forward_request_task,
2617 pr); 2601 pr);
2618 return; /* this target round failed */ 2602 return; /* this target round failed */
@@ -2963,8 +2947,7 @@ forward_request_task (void *cls,
2963 GNUNET_h2s (&pr->query), 2947 GNUNET_h2s (&pr->query),
2964 delay.rel_value); 2948 delay.rel_value);
2965#endif 2949#endif
2966 pr->task = GNUNET_SCHEDULER_add_delayed (sched, 2950 pr->task = GNUNET_SCHEDULER_add_delayed (delay,
2967 delay,
2968 &forward_request_task, 2951 &forward_request_task,
2969 pr); 2952 pr);
2970 return; /* nobody selected */ 2953 return; /* nobody selected */
@@ -2999,7 +2982,7 @@ forward_request_task (void *cls,
2999 cp = GNUNET_CONTAINER_multihashmap_get (connected_peers, 2982 cp = GNUNET_CONTAINER_multihashmap_get (connected_peers,
3000 &psc.target.hashPubKey); 2983 &psc.target.hashPubKey);
3001 GNUNET_assert (NULL != cp); 2984 GNUNET_assert (NULL != cp);
3002 pr->irc = GNUNET_CORE_peer_change_preference (sched, cfg, 2985 pr->irc = GNUNET_CORE_peer_change_preference (cfg,
3003 &psc.target, 2986 &psc.target,
3004 GNUNET_CONSTANTS_SERVICE_TIMEOUT, 2987 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
3005 GNUNET_BANDWIDTH_value_init (UINT32_MAX), 2988 GNUNET_BANDWIDTH_value_init (UINT32_MAX),
@@ -3263,8 +3246,7 @@ struct GNUNET_TIME_Relative art_delay;
3263 pr->do_remove = GNUNET_YES; 3246 pr->do_remove = GNUNET_YES;
3264 if (pr->task != GNUNET_SCHEDULER_NO_TASK) 3247 if (pr->task != GNUNET_SCHEDULER_NO_TASK)
3265 { 3248 {
3266 GNUNET_SCHEDULER_cancel (sched, 3249 GNUNET_SCHEDULER_cancel (pr->task);
3267 pr->task);
3268 pr->task = GNUNET_SCHEDULER_NO_TASK; 3250 pr->task = GNUNET_SCHEDULER_NO_TASK;
3269 } 3251 }
3270 GNUNET_break (GNUNET_YES == 3252 GNUNET_break (GNUNET_YES ==
@@ -3779,8 +3761,7 @@ process_local_reply (void *cls,
3779 } 3761 }
3780 /* no more results */ 3762 /* no more results */
3781 if (pr->task == GNUNET_SCHEDULER_NO_TASK) 3763 if (pr->task == GNUNET_SCHEDULER_NO_TASK)
3782 pr->task = GNUNET_SCHEDULER_add_now (sched, 3764 pr->task = GNUNET_SCHEDULER_add_now (&forward_request_task,
3783 &forward_request_task,
3784 pr); 3765 pr);
3785 return; 3766 return;
3786 } 3767 }
@@ -4267,8 +4248,7 @@ handle_p2p_get (void *cls,
4267 } 4248 }
4268 default: 4249 default:
4269 if (pr->task == GNUNET_SCHEDULER_NO_TASK) 4250 if (pr->task == GNUNET_SCHEDULER_NO_TASK)
4270 pr->task = GNUNET_SCHEDULER_add_now (sched, 4251 pr->task = GNUNET_SCHEDULER_add_now (&forward_request_task,
4271 &forward_request_task,
4272 pr); 4252 pr);
4273 } 4253 }
4274 4254
@@ -4448,13 +4428,11 @@ handle_start_search (void *cls,
4448/** 4428/**
4449 * Process fs requests. 4429 * Process fs requests.
4450 * 4430 *
4451 * @param s scheduler to use
4452 * @param server the initialized server 4431 * @param server the initialized server
4453 * @param c configuration to use 4432 * @param c configuration to use
4454 */ 4433 */
4455static int 4434static int
4456main_init (struct GNUNET_SCHEDULER_Handle *s, 4435main_init (struct GNUNET_SERVER_Handle *server,
4457 struct GNUNET_SERVER_Handle *server,
4458 const struct GNUNET_CONFIGURATION_Handle *c) 4436 const struct GNUNET_CONFIGURATION_Handle *c)
4459{ 4437{
4460 static const struct GNUNET_CORE_MessageHandler p2p_handlers[] = 4438 static const struct GNUNET_CORE_MessageHandler p2p_handlers[] =
@@ -4481,9 +4459,8 @@ main_init (struct GNUNET_SCHEDULER_Handle *s,
4481 }; 4459 };
4482 unsigned long long enc = 128; 4460 unsigned long long enc = 128;
4483 4461
4484 sched = s;
4485 cfg = c; 4462 cfg = c;
4486 stats = GNUNET_STATISTICS_create (sched, "fs", cfg); 4463 stats = GNUNET_STATISTICS_create ("fs", cfg);
4487 min_migration_delay = GNUNET_TIME_UNIT_SECONDS; 4464 min_migration_delay = GNUNET_TIME_UNIT_SECONDS;
4488 if ( (GNUNET_OK != 4465 if ( (GNUNET_OK !=
4489 GNUNET_CONFIGURATION_get_value_number (cfg, 4466 GNUNET_CONFIGURATION_get_value_number (cfg,
@@ -4509,8 +4486,7 @@ main_init (struct GNUNET_SCHEDULER_Handle *s,
4509 rt_entry_lifetime = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_FOREVER_REL); 4486 rt_entry_lifetime = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_FOREVER_REL);
4510 peer_request_map = GNUNET_CONTAINER_multihashmap_create (enc); 4487 peer_request_map = GNUNET_CONTAINER_multihashmap_create (enc);
4511 requests_by_expiration_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 4488 requests_by_expiration_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
4512 core = GNUNET_CORE_connect (sched, 4489 core = GNUNET_CORE_connect (cfg,
4513 cfg,
4514 GNUNET_TIME_UNIT_FOREVER_REL, 4490 GNUNET_TIME_UNIT_FOREVER_REL,
4515 NULL, 4491 NULL,
4516 NULL, 4492 NULL,
@@ -4559,14 +4535,12 @@ main_init (struct GNUNET_SCHEDULER_Handle *s,
4559 "TRUST", 4535 "TRUST",
4560 &trustDirectory)); 4536 &trustDirectory));
4561 GNUNET_DISK_directory_create (trustDirectory); 4537 GNUNET_DISK_directory_create (trustDirectory);
4562 GNUNET_SCHEDULER_add_with_priority (sched, 4538 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_HIGH,
4563 GNUNET_SCHEDULER_PRIORITY_HIGH,
4564 &cron_flush_trust, NULL); 4539 &cron_flush_trust, NULL);
4565 4540
4566 4541
4567 GNUNET_SERVER_add_handlers (server, handlers); 4542 GNUNET_SERVER_add_handlers (server, handlers);
4568 GNUNET_SCHEDULER_add_delayed (sched, 4543 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
4569 GNUNET_TIME_UNIT_FOREVER_REL,
4570 &shutdown_task, 4544 &shutdown_task,
4571 NULL); 4545 NULL);
4572 return GNUNET_OK; 4546 return GNUNET_OK;
@@ -4577,24 +4551,21 @@ main_init (struct GNUNET_SCHEDULER_Handle *s,
4577 * Process fs requests. 4551 * Process fs requests.
4578 * 4552 *
4579 * @param cls closure 4553 * @param cls closure
4580 * @param sched scheduler to use
4581 * @param server the initialized server 4554 * @param server the initialized server
4582 * @param cfg configuration to use 4555 * @param cfg configuration to use
4583 */ 4556 */
4584static void 4557static void
4585run (void *cls, 4558run (void *cls,
4586 struct GNUNET_SCHEDULER_Handle *sched,
4587 struct GNUNET_SERVER_Handle *server, 4559 struct GNUNET_SERVER_Handle *server,
4588 const struct GNUNET_CONFIGURATION_Handle *cfg) 4560 const struct GNUNET_CONFIGURATION_Handle *cfg)
4589{ 4561{
4590 active_migration = GNUNET_CONFIGURATION_get_value_yesno (cfg, 4562 active_migration = GNUNET_CONFIGURATION_get_value_yesno (cfg,
4591 "FS", 4563 "FS",
4592 "ACTIVEMIGRATION"); 4564 "ACTIVEMIGRATION");
4593 dsh = GNUNET_DATASTORE_connect (cfg, 4565 dsh = GNUNET_DATASTORE_connect (cfg);
4594 sched);
4595 if (dsh == NULL) 4566 if (dsh == NULL)
4596 { 4567 {
4597 GNUNET_SCHEDULER_shutdown (sched); 4568 GNUNET_SCHEDULER_shutdown ();
4598 return; 4569 return;
4599 } 4570 }
4600 datastore_get_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE); 4571 datastore_get_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE);
@@ -4606,13 +4577,12 @@ run (void *cls,
4606 "fs"); 4577 "fs");
4607 block_ctx = GNUNET_BLOCK_context_create (block_cfg); 4578 block_ctx = GNUNET_BLOCK_context_create (block_cfg);
4608 GNUNET_assert (NULL != block_ctx); 4579 GNUNET_assert (NULL != block_ctx);
4609 dht_handle = GNUNET_DHT_connect (sched, 4580 dht_handle = GNUNET_DHT_connect (cfg,
4610 cfg,
4611 FS_DHT_HT_SIZE); 4581 FS_DHT_HT_SIZE);
4612 if ( (GNUNET_OK != GNUNET_FS_indexing_init (sched, cfg, dsh)) || 4582 if ( (GNUNET_OK != GNUNET_FS_indexing_init (cfg, dsh)) ||
4613 (GNUNET_OK != main_init (sched, server, cfg)) ) 4583 (GNUNET_OK != main_init (server, cfg)) )
4614 { 4584 {
4615 GNUNET_SCHEDULER_shutdown (sched); 4585 GNUNET_SCHEDULER_shutdown ();
4616 GNUNET_DATASTORE_disconnect (dsh, GNUNET_NO); 4586 GNUNET_DATASTORE_disconnect (dsh, GNUNET_NO);
4617 dsh = NULL; 4587 dsh = NULL;
4618 GNUNET_DHT_disconnect (dht_handle); 4588 GNUNET_DHT_disconnect (dht_handle);
diff --git a/src/fs/gnunet-service-fs_indexing.c b/src/fs/gnunet-service-fs_indexing.c
index 99b5da102..2e95f454f 100644
--- a/src/fs/gnunet-service-fs_indexing.c
+++ b/src/fs/gnunet-service-fs_indexing.c
@@ -91,11 +91,6 @@ static struct IndexInfo *indexed_files;
91static struct GNUNET_CONTAINER_MultiHashMap *ifm; 91static struct GNUNET_CONTAINER_MultiHashMap *ifm;
92 92
93/** 93/**
94 * Our scheduler.
95 */
96static struct GNUNET_SCHEDULER_Handle *sched;
97
98/**
99 * Our configuration. 94 * Our configuration.
100 */ 95 */
101static const struct GNUNET_CONFIGURATION_Handle *cfg; 96static const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -404,8 +399,7 @@ GNUNET_FS_handle_index_start (void *cls,
404 (unsigned int) mydev); 399 (unsigned int) mydev);
405#endif 400#endif
406 /* slow validation, need to hash full file (again) */ 401 /* slow validation, need to hash full file (again) */
407 ii->fhc = GNUNET_CRYPTO_hash_file (sched, 402 ii->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE,
408 GNUNET_SCHEDULER_PRIORITY_IDLE,
409 fn, 403 fn,
410 HASHING_BLOCKSIZE, 404 HASHING_BLOCKSIZE,
411 &hash_for_index_val, 405 &hash_for_index_val,
@@ -710,7 +704,6 @@ shutdown_task (void *cls,
710 indexed_files = pos->next; 704 indexed_files = pos->next;
711 GNUNET_free (pos); 705 GNUNET_free (pos);
712 } 706 }
713 sched = NULL;
714 cfg = NULL; 707 cfg = NULL;
715} 708}
716 709
@@ -718,21 +711,17 @@ shutdown_task (void *cls,
718/** 711/**
719 * Initialize the indexing submodule. 712 * Initialize the indexing submodule.
720 * 713 *
721 * @param s scheduler to use
722 * @param c configuration to use 714 * @param c configuration to use
723 * @param d datastore to use 715 * @param d datastore to use
724 */ 716 */
725int 717int
726GNUNET_FS_indexing_init (struct GNUNET_SCHEDULER_Handle *s, 718GNUNET_FS_indexing_init (const struct GNUNET_CONFIGURATION_Handle *c,
727 const struct GNUNET_CONFIGURATION_Handle *c,
728 struct GNUNET_DATASTORE_Handle *d) 719 struct GNUNET_DATASTORE_Handle *d)
729{ 720{
730 sched = s;
731 cfg = c; 721 cfg = c;
732 dsh = d; 722 dsh = d;
733 ifm = GNUNET_CONTAINER_multihashmap_create (128); 723 ifm = GNUNET_CONTAINER_multihashmap_create (128);
734 GNUNET_SCHEDULER_add_delayed (sched, 724 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
735 GNUNET_TIME_UNIT_FOREVER_REL,
736 &shutdown_task, 725 &shutdown_task,
737 NULL); 726 NULL);
738 read_index_list (); 727 read_index_list ();
diff --git a/src/fs/gnunet-service-fs_indexing.h b/src/fs/gnunet-service-fs_indexing.h
index bf063fcbd..885e141e2 100644
--- a/src/fs/gnunet-service-fs_indexing.h
+++ b/src/fs/gnunet-service-fs_indexing.h
@@ -110,14 +110,12 @@ GNUNET_FS_handle_unindex (void *cls,
110/** 110/**
111 * Initialize the indexing submodule. 111 * Initialize the indexing submodule.
112 * 112 *
113 * @param s scheduler to use
114 * @param c configuration to use 113 * @param c configuration to use
115 * @param d datastore to use 114 * @param d datastore to use
116 * @return GNUNET_OK on success 115 * @return GNUNET_OK on success
117 */ 116 */
118int 117int
119GNUNET_FS_indexing_init (struct GNUNET_SCHEDULER_Handle *s, 118GNUNET_FS_indexing_init (const struct GNUNET_CONFIGURATION_Handle *c,
120 const struct GNUNET_CONFIGURATION_Handle *c,
121 struct GNUNET_DATASTORE_Handle *d); 119 struct GNUNET_DATASTORE_Handle *d);
122 120
123 121
diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c
index 872aa3d3a..f73d2f0cc 100644
--- a/src/fs/gnunet-unindex.c
+++ b/src/fs/gnunet-unindex.c
@@ -38,8 +38,6 @@ static struct GNUNET_FS_Handle *ctx;
38 38
39static struct GNUNET_FS_UnindexContext *uc; 39static struct GNUNET_FS_UnindexContext *uc;
40 40
41static struct GNUNET_SCHEDULER_Handle *sched;
42
43 41
44static void 42static void
45cleanup_task (void *cls, 43cleanup_task (void *cls,
@@ -103,16 +101,15 @@ progress_cb (void *cls,
103 fprintf (stderr, 101 fprintf (stderr,
104 _("Error unindexing: %s.\n"), 102 _("Error unindexing: %s.\n"),
105 info->value.unindex.specifics.error.message); 103 info->value.unindex.specifics.error.message);
106 GNUNET_SCHEDULER_shutdown (sched); 104 GNUNET_SCHEDULER_shutdown ();
107 break; 105 break;
108 case GNUNET_FS_STATUS_UNINDEX_COMPLETED: 106 case GNUNET_FS_STATUS_UNINDEX_COMPLETED:
109 fprintf (stdout, 107 fprintf (stdout,
110 _("Unindexing done.\n")); 108 _("Unindexing done.\n"));
111 GNUNET_SCHEDULER_shutdown (sched); 109 GNUNET_SCHEDULER_shutdown ();
112 break; 110 break;
113 case GNUNET_FS_STATUS_UNINDEX_STOPPED: 111 case GNUNET_FS_STATUS_UNINDEX_STOPPED:
114 GNUNET_SCHEDULER_add_continuation (sched, 112 GNUNET_SCHEDULER_add_continuation (&cleanup_task,
115 &cleanup_task,
116 NULL, 113 NULL,
117 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 114 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
118 break; 115 break;
@@ -130,14 +127,12 @@ progress_cb (void *cls,
130 * Main function that will be run by the scheduler. 127 * Main function that will be run by the scheduler.
131 * 128 *
132 * @param cls closure 129 * @param cls closure
133 * @param s the scheduler to use
134 * @param args remaining command-line arguments 130 * @param args remaining command-line arguments
135 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 131 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
136 * @param c configuration 132 * @param c configuration
137 */ 133 */
138static void 134static void
139run (void *cls, 135run (void *cls,
140 struct GNUNET_SCHEDULER_Handle *s,
141 char *const *args, 136 char *const *args,
142 const char *cfgfile, 137 const char *cfgfile,
143 const struct GNUNET_CONFIGURATION_Handle *c) 138 const struct GNUNET_CONFIGURATION_Handle *c)
@@ -150,10 +145,8 @@ run (void *cls,
150 ret = -1; 145 ret = -1;
151 return; 146 return;
152 } 147 }
153 sched = s;
154 cfg = c; 148 cfg = c;
155 ctx = GNUNET_FS_start (sched, 149 ctx = GNUNET_FS_start (cfg,
156 cfg,
157 "gnunet-unindex", 150 "gnunet-unindex",
158 &progress_cb, 151 &progress_cb,
159 NULL, 152 NULL,
@@ -177,8 +170,7 @@ run (void *cls,
177 GNUNET_FS_stop (ctx); 170 GNUNET_FS_stop (ctx);
178 return; 171 return;
179 } 172 }
180 GNUNET_SCHEDULER_add_delayed (sched, 173 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
181 GNUNET_TIME_UNIT_FOREVER_REL,
182 &shutdown_task, 174 &shutdown_task,
183 NULL); 175 NULL);
184} 176}
diff --git a/src/fs/perf_gnunet_service_fs_p2p.c b/src/fs/perf_gnunet_service_fs_p2p.c
index 8b1c0ad24..8d5ad6587 100644
--- a/src/fs/perf_gnunet_service_fs_p2p.c
+++ b/src/fs/perf_gnunet_service_fs_p2p.c
@@ -45,8 +45,6 @@
45 45
46static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS]; 46static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS];
47 47
48static struct GNUNET_SCHEDULER_Handle *sched;
49
50static int ok; 48static int ok;
51 49
52static struct GNUNET_TIME_Absolute start_time; 50static struct GNUNET_TIME_Absolute start_time;
@@ -57,8 +55,7 @@ static void
57do_stop (void *cls, 55do_stop (void *cls,
58 const struct GNUNET_SCHEDULER_TaskContext *tc) 56 const struct GNUNET_SCHEDULER_TaskContext *tc)
59{ 57{
60 GNUNET_FS_TEST_daemons_stop (sched, 58 GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS,
61 NUM_DAEMONS,
62 daemons); 59 daemons);
63} 60}
64 61
@@ -152,7 +149,7 @@ get_done (void *cls,
152 struct StatMaster *sm = cls; 149 struct StatMaster *sm = cls;
153 GNUNET_break (GNUNET_OK == success); 150 GNUNET_break (GNUNET_OK == success);
154 sm->value++; 151 sm->value++;
155 GNUNET_SCHEDULER_add_now (sched, &stat_run, sm); 152 GNUNET_SCHEDULER_add_now (&stat_run, sm);
156} 153}
157 154
158 155
@@ -185,13 +182,13 @@ stat_run (void *cls,
185 if (sm->daemon == NUM_DAEMONS) 182 if (sm->daemon == NUM_DAEMONS)
186 { 183 {
187 GNUNET_free (sm); 184 GNUNET_free (sm);
188 GNUNET_SCHEDULER_add_now (sched, &do_stop, NULL); 185 GNUNET_SCHEDULER_add_now (&do_stop, NULL);
189 return; 186 return;
190 } 187 }
191 sm->stat = GNUNET_STATISTICS_create (sched, "<driver>", 188 sm->stat = GNUNET_STATISTICS_create ("<driver>",
192 GNUNET_FS_TEST_get_configuration (daemons, 189 GNUNET_FS_TEST_get_configuration (daemons,
193 sm->daemon)); 190 sm->daemon));
194 GNUNET_SCHEDULER_add_now (sched, &stat_run, sm); 191 GNUNET_SCHEDULER_add_now (&stat_run, sm);
195} 192}
196 193
197 194
@@ -217,17 +214,17 @@ do_report (void *cls,
217 "Finished download, shutting down\n", 214 "Finished download, shutting down\n",
218 (unsigned long long) FILESIZE); 215 (unsigned long long) FILESIZE);
219 sm = GNUNET_malloc (sizeof (struct StatMaster)); 216 sm = GNUNET_malloc (sizeof (struct StatMaster));
220 sm->stat = GNUNET_STATISTICS_create (sched, "<driver>", 217 sm->stat = GNUNET_STATISTICS_create ("<driver>",
221 GNUNET_FS_TEST_get_configuration (daemons, 218 GNUNET_FS_TEST_get_configuration (daemons,
222 sm->daemon)); 219 sm->daemon));
223 GNUNET_SCHEDULER_add_now (sched, &stat_run, sm); 220 GNUNET_SCHEDULER_add_now (&stat_run, sm);
224 } 221 }
225 else 222 else
226 { 223 {
227 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 224 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
228 "Timeout during download, shutting down with error\n"); 225 "Timeout during download, shutting down with error\n");
229 ok = 1; 226 ok = 1;
230 GNUNET_SCHEDULER_add_now (sched, &do_stop, NULL); 227 GNUNET_SCHEDULER_add_now (&do_stop, NULL);
231 } 228 }
232} 229}
233 230
@@ -240,8 +237,7 @@ do_download (void *cls,
240 237
241 if (NULL == uri) 238 if (NULL == uri)
242 { 239 {
243 GNUNET_FS_TEST_daemons_stop (sched, 240 GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS,
244 NUM_DAEMONS,
245 daemons); 241 daemons);
246 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 242 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
247 "Timeout during upload attempt, shutting down with error\n"); 243 "Timeout during upload attempt, shutting down with error\n");
@@ -256,8 +252,7 @@ do_download (void *cls,
256 anonymity = 0; 252 anonymity = 0;
257 else 253 else
258 anonymity = 1; 254 anonymity = 1;
259 GNUNET_FS_TEST_download (sched, 255 GNUNET_FS_TEST_download (daemons[0],
260 daemons[0],
261 TIMEOUT, 256 TIMEOUT,
262 anonymity, SEED, uri, 257 anonymity, SEED, uri,
263 VERBOSE, 258 VERBOSE,
@@ -274,8 +269,7 @@ do_publish (void *cls,
274 269
275 if (NULL != emsg) 270 if (NULL != emsg)
276 { 271 {
277 GNUNET_FS_TEST_daemons_stop (sched, 272 GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS,
278 NUM_DAEMONS,
279 daemons); 273 daemons);
280 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 274 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
281 "Error trying to connect: %s\n", 275 "Error trying to connect: %s\n",
@@ -295,8 +289,7 @@ do_publish (void *cls,
295 else 289 else
296 anonymity = 1; 290 anonymity = 1;
297 291
298 GNUNET_FS_TEST_publish (sched, 292 GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS-1],
299 daemons[NUM_DAEMONS-1],
300 TIMEOUT, 293 TIMEOUT,
301 anonymity, 294 anonymity,
302 do_index, FILESIZE, SEED, 295 do_index, FILESIZE, SEED,
@@ -331,14 +324,11 @@ do_connect (void *cls,
331 324
332static void 325static void
333run (void *cls, 326run (void *cls,
334 struct GNUNET_SCHEDULER_Handle *s,
335 char *const *args, 327 char *const *args,
336 const char *cfgfile, 328 const char *cfgfile,
337 const struct GNUNET_CONFIGURATION_Handle *cfg) 329 const struct GNUNET_CONFIGURATION_Handle *cfg)
338{ 330{
339 sched = s; 331 GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf",
340 GNUNET_FS_TEST_daemons_start (sched,
341 "fs_test_lib_data.conf",
342 TIMEOUT, 332 TIMEOUT,
343 NUM_DAEMONS, 333 NUM_DAEMONS,
344 daemons, 334 daemons,
diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c
index 4bcedcb4d..549a2eeed 100644
--- a/src/fs/test_fs_download.c
+++ b/src/fs/test_fs_download.c
@@ -60,8 +60,6 @@ static struct PeerContext p1;
60 60
61static struct GNUNET_TIME_Absolute start; 61static struct GNUNET_TIME_Absolute start;
62 62
63static struct GNUNET_SCHEDULER_Handle *sched;
64
65static struct GNUNET_FS_Handle *fs; 63static struct GNUNET_FS_Handle *fs;
66 64
67static struct GNUNET_FS_DownloadContext *download; 65static struct GNUNET_FS_DownloadContext *download;
@@ -127,7 +125,7 @@ abort_download_task (void *cls,
127 GNUNET_DISK_directory_remove (fn); 125 GNUNET_DISK_directory_remove (fn);
128 GNUNET_free (fn); 126 GNUNET_free (fn);
129 fn = NULL; 127 fn = NULL;
130 GNUNET_SCHEDULER_cancel (sched, timeout_kill); 128 GNUNET_SCHEDULER_cancel (timeout_kill);
131 timeout_kill = GNUNET_SCHEDULER_NO_TASK; 129 timeout_kill = GNUNET_SCHEDULER_NO_TASK;
132} 130}
133 131
@@ -168,8 +166,7 @@ progress_cb (void *cls,
168 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: 166 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
169 printf ("Download complete, %llu kbps.\n", 167 printf ("Download complete, %llu kbps.\n",
170 (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024LL)); 168 (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024LL));
171 GNUNET_SCHEDULER_add_now (sched, 169 GNUNET_SCHEDULER_add_now (&abort_download_task,
172 &abort_download_task,
173 NULL); 170 NULL);
174 break; 171 break;
175 case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: 172 case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
@@ -187,8 +184,7 @@ progress_cb (void *cls,
187 "Error publishing file: %s\n", 184 "Error publishing file: %s\n",
188 event->value.publish.specifics.error.message); 185 event->value.publish.specifics.error.message);
189 GNUNET_break (0); 186 GNUNET_break (0);
190 GNUNET_SCHEDULER_add_continuation (sched, 187 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
191 &abort_publish_task,
192 NULL, 188 NULL,
193 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 189 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
194 break; 190 break;
@@ -196,8 +192,7 @@ progress_cb (void *cls,
196 fprintf (stderr, 192 fprintf (stderr,
197 "Error downloading file: %s\n", 193 "Error downloading file: %s\n",
198 event->value.download.specifics.error.message); 194 event->value.download.specifics.error.message);
199 GNUNET_SCHEDULER_add_now (sched, 195 GNUNET_SCHEDULER_add_now (&abort_download_task,
200 &abort_download_task,
201 NULL); 196 NULL);
202 break; 197 break;
203 case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: 198 case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE:
@@ -214,8 +209,7 @@ progress_cb (void *cls,
214 GNUNET_assert (publish == event->value.publish.pc); 209 GNUNET_assert (publish == event->value.publish.pc);
215 GNUNET_assert (FILESIZE == event->value.publish.size); 210 GNUNET_assert (FILESIZE == event->value.publish.size);
216 GNUNET_assert (1 == event->value.publish.anonymity); 211 GNUNET_assert (1 == event->value.publish.anonymity);
217 GNUNET_SCHEDULER_add_now (sched, 212 GNUNET_SCHEDULER_add_now (&stop_fs_task,
218 &stop_fs_task,
219 NULL); 213 NULL);
220 break; 214 break;
221 case GNUNET_FS_STATUS_DOWNLOAD_START: 215 case GNUNET_FS_STATUS_DOWNLOAD_START:
@@ -230,8 +224,7 @@ progress_cb (void *cls,
230 break; 224 break;
231 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: 225 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
232 GNUNET_assert (download == event->value.download.dc); 226 GNUNET_assert (download == event->value.download.dc);
233 GNUNET_SCHEDULER_add_continuation (sched, 227 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
234 &abort_publish_task,
235 NULL, 228 NULL,
236 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 229 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
237 break; 230 break;
@@ -279,7 +272,6 @@ stop_arm (struct PeerContext *p)
279 272
280static void 273static void
281run (void *cls, 274run (void *cls,
282 struct GNUNET_SCHEDULER_Handle *s,
283 char *const *args, 275 char *const *args,
284 const char *cfgfile, 276 const char *cfgfile,
285 const struct GNUNET_CONFIGURATION_Handle *cfg) 277 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -294,10 +286,8 @@ run (void *cls,
294 struct GNUNET_FS_FileInformation *fi; 286 struct GNUNET_FS_FileInformation *fi;
295 size_t i; 287 size_t i;
296 288
297 sched = s;
298 setup_peer (&p1, "test_fs_download_data.conf"); 289 setup_peer (&p1, "test_fs_download_data.conf");
299 fs = GNUNET_FS_start (sched, 290 fs = GNUNET_FS_start (cfg,
300 cfg,
301 "test-fs-download", 291 "test-fs-download",
302 &progress_cb, 292 &progress_cb,
303 NULL, 293 NULL,
@@ -322,8 +312,7 @@ run (void *cls,
322 GNUNET_FS_uri_destroy (kuri); 312 GNUNET_FS_uri_destroy (kuri);
323 GNUNET_CONTAINER_meta_data_destroy (meta); 313 GNUNET_CONTAINER_meta_data_destroy (meta);
324 GNUNET_assert (NULL != fi); 314 GNUNET_assert (NULL != fi);
325 timeout_kill = GNUNET_SCHEDULER_add_delayed (sched, 315 timeout_kill = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
326 TIMEOUT,
327 &timeout_kill_task, 316 &timeout_kill_task,
328 NULL); 317 NULL);
329 start = GNUNET_TIME_absolute_get (); 318 start = GNUNET_TIME_absolute_get ();
diff --git a/src/fs/test_fs_download_indexed.c b/src/fs/test_fs_download_indexed.c
index 21d95d584..6e59f97cd 100644
--- a/src/fs/test_fs_download_indexed.c
+++ b/src/fs/test_fs_download_indexed.c
@@ -60,8 +60,6 @@ static struct PeerContext p1;
60 60
61static struct GNUNET_TIME_Absolute start; 61static struct GNUNET_TIME_Absolute start;
62 62
63static struct GNUNET_SCHEDULER_Handle *sched;
64
65static struct GNUNET_FS_Handle *fs; 63static struct GNUNET_FS_Handle *fs;
66 64
67static struct GNUNET_FS_DownloadContext *download; 65static struct GNUNET_FS_DownloadContext *download;
@@ -129,7 +127,7 @@ abort_download_task (void *cls,
129 GNUNET_DISK_directory_remove (fn); 127 GNUNET_DISK_directory_remove (fn);
130 GNUNET_free (fn); 128 GNUNET_free (fn);
131 fn = NULL; 129 fn = NULL;
132 GNUNET_SCHEDULER_cancel (sched, timeout_kill); 130 GNUNET_SCHEDULER_cancel (timeout_kill);
133 timeout_kill = GNUNET_SCHEDULER_NO_TASK; 131 timeout_kill = GNUNET_SCHEDULER_NO_TASK;
134} 132}
135 133
@@ -170,8 +168,7 @@ progress_cb (void *cls,
170 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: 168 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
171 printf ("Download complete, %llu kbps.\n", 169 printf ("Download complete, %llu kbps.\n",
172 (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024LL)); 170 (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024LL));
173 GNUNET_SCHEDULER_add_now (sched, 171 GNUNET_SCHEDULER_add_now (&abort_download_task,
174 &abort_download_task,
175 NULL); 172 NULL);
176 break; 173 break;
177 case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: 174 case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
@@ -189,8 +186,7 @@ progress_cb (void *cls,
189 "Error publishing file: %s\n", 186 "Error publishing file: %s\n",
190 event->value.publish.specifics.error.message); 187 event->value.publish.specifics.error.message);
191 GNUNET_break (0); 188 GNUNET_break (0);
192 GNUNET_SCHEDULER_add_continuation (sched, 189 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
193 &abort_publish_task,
194 NULL, 190 NULL,
195 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 191 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
196 break; 192 break;
@@ -198,8 +194,7 @@ progress_cb (void *cls,
198 fprintf (stderr, 194 fprintf (stderr,
199 "Error downloading file: %s\n", 195 "Error downloading file: %s\n",
200 event->value.download.specifics.error.message); 196 event->value.download.specifics.error.message);
201 GNUNET_SCHEDULER_add_now (sched, 197 GNUNET_SCHEDULER_add_now (&abort_download_task,
202 &abort_download_task,
203 NULL); 198 NULL);
204 break; 199 break;
205 case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: 200 case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE:
@@ -216,8 +211,7 @@ progress_cb (void *cls,
216 GNUNET_assert (publish == event->value.publish.pc); 211 GNUNET_assert (publish == event->value.publish.pc);
217 GNUNET_assert (FILESIZE == event->value.publish.size); 212 GNUNET_assert (FILESIZE == event->value.publish.size);
218 GNUNET_assert (1 == event->value.publish.anonymity); 213 GNUNET_assert (1 == event->value.publish.anonymity);
219 GNUNET_SCHEDULER_add_now (sched, 214 GNUNET_SCHEDULER_add_now (&stop_fs_task,
220 &stop_fs_task,
221 NULL); 215 NULL);
222 break; 216 break;
223 case GNUNET_FS_STATUS_DOWNLOAD_START: 217 case GNUNET_FS_STATUS_DOWNLOAD_START:
@@ -232,8 +226,7 @@ progress_cb (void *cls,
232 break; 226 break;
233 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: 227 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
234 GNUNET_assert (download == event->value.download.dc); 228 GNUNET_assert (download == event->value.download.dc);
235 GNUNET_SCHEDULER_add_continuation (sched, 229 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
236 &abort_publish_task,
237 NULL, 230 NULL,
238 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 231 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
239 break; 232 break;
@@ -281,7 +274,6 @@ stop_arm (struct PeerContext *p)
281 274
282static void 275static void
283run (void *cls, 276run (void *cls,
284 struct GNUNET_SCHEDULER_Handle *s,
285 char *const *args, 277 char *const *args,
286 const char *cfgfile, 278 const char *cfgfile,
287 const struct GNUNET_CONFIGURATION_Handle *cfg) 279 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -296,10 +288,8 @@ run (void *cls,
296 struct GNUNET_FS_FileInformation *fi; 288 struct GNUNET_FS_FileInformation *fi;
297 size_t i; 289 size_t i;
298 290
299 sched = s;
300 setup_peer (&p1, "test_fs_download_data.conf"); 291 setup_peer (&p1, "test_fs_download_data.conf");
301 fs = GNUNET_FS_start (sched, 292 fs = GNUNET_FS_start (cfg,
302 cfg,
303 "test-fs-download-indexed", 293 "test-fs-download-indexed",
304 &progress_cb, 294 &progress_cb,
305 NULL, 295 NULL,
@@ -331,8 +321,7 @@ run (void *cls,
331 GNUNET_FS_uri_destroy (kuri); 321 GNUNET_FS_uri_destroy (kuri);
332 GNUNET_CONTAINER_meta_data_destroy (meta); 322 GNUNET_CONTAINER_meta_data_destroy (meta);
333 GNUNET_assert (NULL != fi); 323 GNUNET_assert (NULL != fi);
334 timeout_kill = GNUNET_SCHEDULER_add_delayed (sched, 324 timeout_kill = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
335 TIMEOUT,
336 &timeout_kill_task, 325 &timeout_kill_task,
337 NULL); 326 NULL);
338 start = GNUNET_TIME_absolute_get (); 327 start = GNUNET_TIME_absolute_get ();
diff --git a/src/fs/test_fs_download_persistence.c b/src/fs/test_fs_download_persistence.c
index 966d52412..66d1199ca 100644
--- a/src/fs/test_fs_download_persistence.c
+++ b/src/fs/test_fs_download_persistence.c
@@ -60,8 +60,6 @@ static struct PeerContext p1;
60 60
61static struct GNUNET_TIME_Absolute start; 61static struct GNUNET_TIME_Absolute start;
62 62
63static struct GNUNET_SCHEDULER_Handle *sched;
64
65static const struct GNUNET_CONFIGURATION_Handle *cfg; 63static const struct GNUNET_CONFIGURATION_Handle *cfg;
66 64
67static struct GNUNET_FS_Handle *fs; 65static struct GNUNET_FS_Handle *fs;
@@ -122,7 +120,7 @@ abort_download_task (void *cls,
122 GNUNET_DISK_directory_remove (fn); 120 GNUNET_DISK_directory_remove (fn);
123 GNUNET_free (fn); 121 GNUNET_free (fn);
124 fn = NULL; 122 fn = NULL;
125 GNUNET_SCHEDULER_cancel (sched, timeout_kill); 123 GNUNET_SCHEDULER_cancel (timeout_kill);
126 timeout_kill = GNUNET_SCHEDULER_NO_TASK; 124 timeout_kill = GNUNET_SCHEDULER_NO_TASK;
127} 125}
128 126
@@ -137,8 +135,7 @@ restart_fs_task (void *cls,
137 const struct GNUNET_SCHEDULER_TaskContext *tc) 135 const struct GNUNET_SCHEDULER_TaskContext *tc)
138{ 136{
139 GNUNET_FS_stop (fs); 137 GNUNET_FS_stop (fs);
140 fs = GNUNET_FS_start (sched, 138 fs = GNUNET_FS_start (cfg,
141 cfg,
142 "test-fs-download-persistence", 139 "test-fs-download-persistence",
143 &progress_cb, 140 &progress_cb,
144 NULL, 141 NULL,
@@ -164,8 +161,7 @@ consider_restart (int ev)
164 if (prev[i] == ev) 161 if (prev[i] == ev)
165 return; 162 return;
166 prev[off++] = ev; 163 prev[off++] = ev;
167 GNUNET_SCHEDULER_add_with_priority (sched, 164 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_URGENT,
168 GNUNET_SCHEDULER_PRIORITY_URGENT,
169 &restart_fs_task, 165 &restart_fs_task,
170 NULL); 166 NULL);
171} 167}
@@ -207,8 +203,7 @@ progress_cb (void *cls,
207 consider_restart (event->status); 203 consider_restart (event->status);
208 printf ("Download complete, %llu kbps.\n", 204 printf ("Download complete, %llu kbps.\n",
209 (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024LL)); 205 (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024LL));
210 GNUNET_SCHEDULER_add_now (sched, 206 GNUNET_SCHEDULER_add_now (&abort_download_task,
211 &abort_download_task,
212 NULL); 207 NULL);
213 break; 208 break;
214 case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: 209 case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
@@ -227,8 +222,7 @@ progress_cb (void *cls,
227 "Error publishing file: %s\n", 222 "Error publishing file: %s\n",
228 event->value.publish.specifics.error.message); 223 event->value.publish.specifics.error.message);
229 GNUNET_break (0); 224 GNUNET_break (0);
230 GNUNET_SCHEDULER_add_continuation (sched, 225 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
231 &abort_publish_task,
232 NULL, 226 NULL,
233 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 227 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
234 break; 228 break;
@@ -236,8 +230,7 @@ progress_cb (void *cls,
236 fprintf (stderr, 230 fprintf (stderr,
237 "Error downloading file: %s\n", 231 "Error downloading file: %s\n",
238 event->value.download.specifics.error.message); 232 event->value.download.specifics.error.message);
239 GNUNET_SCHEDULER_add_now (sched, 233 GNUNET_SCHEDULER_add_now (&abort_download_task,
240 &abort_download_task,
241 NULL); 234 NULL);
242 break; 235 break;
243 case GNUNET_FS_STATUS_PUBLISH_SUSPEND: 236 case GNUNET_FS_STATUS_PUBLISH_SUSPEND:
@@ -290,8 +283,7 @@ progress_cb (void *cls,
290 break; 283 break;
291 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: 284 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
292 GNUNET_assert (download == event->value.download.dc); 285 GNUNET_assert (download == event->value.download.dc);
293 GNUNET_SCHEDULER_add_continuation (sched, 286 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
294 &abort_publish_task,
295 NULL, 287 NULL,
296 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 288 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
297 download = NULL; 289 download = NULL;
@@ -340,7 +332,6 @@ stop_arm (struct PeerContext *p)
340 332
341static void 333static void
342run (void *cls, 334run (void *cls,
343 struct GNUNET_SCHEDULER_Handle *s,
344 char *const *args, 335 char *const *args,
345 const char *cfgfile, 336 const char *cfgfile,
346 const struct GNUNET_CONFIGURATION_Handle *c) 337 const struct GNUNET_CONFIGURATION_Handle *c)
@@ -355,11 +346,9 @@ run (void *cls,
355 struct GNUNET_FS_FileInformation *fi; 346 struct GNUNET_FS_FileInformation *fi;
356 size_t i; 347 size_t i;
357 348
358 sched = s;
359 cfg = c; 349 cfg = c;
360 setup_peer (&p1, "test_fs_download_data.conf"); 350 setup_peer (&p1, "test_fs_download_data.conf");
361 fs = GNUNET_FS_start (sched, 351 fs = GNUNET_FS_start (cfg,
362 cfg,
363 "test-fs-download-persistence", 352 "test-fs-download-persistence",
364 &progress_cb, 353 &progress_cb,
365 NULL, 354 NULL,
@@ -384,8 +373,7 @@ run (void *cls,
384 GNUNET_FS_uri_destroy (kuri); 373 GNUNET_FS_uri_destroy (kuri);
385 GNUNET_CONTAINER_meta_data_destroy (meta); 374 GNUNET_CONTAINER_meta_data_destroy (meta);
386 GNUNET_assert (NULL != fi); 375 GNUNET_assert (NULL != fi);
387 timeout_kill = GNUNET_SCHEDULER_add_delayed (sched, 376 timeout_kill = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
388 TIMEOUT,
389 &timeout_kill_task, 377 &timeout_kill_task,
390 NULL); 378 NULL);
391 start = GNUNET_TIME_absolute_get (); 379 start = GNUNET_TIME_absolute_get ();
diff --git a/src/fs/test_fs_file_information.c b/src/fs/test_fs_file_information.c
index 57698165e..914dbad9f 100644
--- a/src/fs/test_fs_file_information.c
+++ b/src/fs/test_fs_file_information.c
@@ -67,7 +67,6 @@ mycleaner(void *cls,
67 67
68static void 68static void
69run (void *cls, 69run (void *cls,
70 struct GNUNET_SCHEDULER_Handle *s,
71 char *const *args, 70 char *const *args,
72 const char *cfgfile, 71 const char *cfgfile,
73 const struct GNUNET_CONFIGURATION_Handle *cfg) 72 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -87,7 +86,7 @@ run (void *cls,
87 struct GNUNET_FS_Handle *fs; 86 struct GNUNET_FS_Handle *fs;
88 size_t i; 87 size_t i;
89 88
90 fs = GNUNET_FS_start (s, cfg, "test-fs-file-information", NULL, NULL, 89 fs = GNUNET_FS_start (cfg, "test-fs-file-information", NULL, NULL,
91 GNUNET_FS_FLAGS_NONE, 90 GNUNET_FS_FLAGS_NONE,
92 GNUNET_FS_OPTIONS_END); 91 GNUNET_FS_OPTIONS_END);
93 fn1 = GNUNET_DISK_mktemp ("gnunet-file_information-test-dst"); 92 fn1 = GNUNET_DISK_mktemp ("gnunet-file_information-test-dst");
diff --git a/src/fs/test_fs_list_indexed.c b/src/fs/test_fs_list_indexed.c
index 0e46336df..206e58baf 100644
--- a/src/fs/test_fs_list_indexed.c
+++ b/src/fs/test_fs_list_indexed.c
@@ -64,8 +64,6 @@ static struct PeerContext p1;
64 64
65static struct GNUNET_TIME_Absolute start; 65static struct GNUNET_TIME_Absolute start;
66 66
67static struct GNUNET_SCHEDULER_Handle *sched;
68
69static struct GNUNET_FS_Handle *fs; 67static struct GNUNET_FS_Handle *fs;
70 68
71static struct GNUNET_FS_PublishContext *publish; 69static struct GNUNET_FS_PublishContext *publish;
@@ -96,8 +94,7 @@ list_indexed_task (void *cls,
96 const struct GNUNET_SCHEDULER_TaskContext *tc) 94 const struct GNUNET_SCHEDULER_TaskContext *tc)
97{ 95{
98 96
99 GNUNET_SCHEDULER_add_continuation (sched, 97 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
100 &abort_publish_task,
101 NULL, 98 NULL,
102 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 99 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
103} 100}
@@ -118,8 +115,7 @@ progress_cb (void *cls,
118 (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024)); 115 (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024));
119 if (0 == strcmp ("list_indexed-context-dir", 116 if (0 == strcmp ("list_indexed-context-dir",
120 event->value.publish.cctx)) 117 event->value.publish.cctx))
121 GNUNET_SCHEDULER_add_continuation (sched, 118 GNUNET_SCHEDULER_add_continuation (&list_indexed_task,
122 &list_indexed_task,
123 NULL, 119 NULL,
124 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 120 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
125 121
@@ -143,8 +139,7 @@ progress_cb (void *cls,
143 err = 1; 139 err = 1;
144 if (0 == strcmp ("list_indexed-context-dir", 140 if (0 == strcmp ("list_indexed-context-dir",
145 event->value.publish.cctx)) 141 event->value.publish.cctx))
146 GNUNET_SCHEDULER_add_continuation (sched, 142 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
147 &abort_publish_task,
148 NULL, 143 NULL,
149 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 144 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
150 break; 145 break;
@@ -229,7 +224,6 @@ stop_arm (struct PeerContext *p)
229 224
230static void 225static void
231run (void *cls, 226run (void *cls,
232 struct GNUNET_SCHEDULER_Handle *s,
233 char *const *args, 227 char *const *args,
234 const char *cfgfile, 228 const char *cfgfile,
235 const struct GNUNET_CONFIGURATION_Handle *cfg) 229 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -246,10 +240,8 @@ run (void *cls,
246 struct GNUNET_FS_FileInformation *fidir; 240 struct GNUNET_FS_FileInformation *fidir;
247 size_t i; 241 size_t i;
248 242
249 sched = s;
250 setup_peer (&p1, "test_fs_list_indexed_data.conf"); 243 setup_peer (&p1, "test_fs_list_indexed_data.conf");
251 fs = GNUNET_FS_start (sched, 244 fs = GNUNET_FS_start (cfg,
252 cfg,
253 "test-fs-list_indexed", 245 "test-fs-list_indexed",
254 &progress_cb, 246 &progress_cb,
255 NULL, 247 NULL,
diff --git a/src/fs/test_fs_namespace.c b/src/fs/test_fs_namespace.c
index b7641ab3b..0d37affa2 100644
--- a/src/fs/test_fs_namespace.c
+++ b/src/fs/test_fs_namespace.c
@@ -35,8 +35,6 @@
35 35
36#define START_ARM GNUNET_YES 36#define START_ARM GNUNET_YES
37 37
38static struct GNUNET_SCHEDULER_Handle *sched;
39
40static struct PeerContext p1; 38static struct PeerContext p1;
41 39
42static GNUNET_HashCode nsid; 40static GNUNET_HashCode nsid;
@@ -151,8 +149,7 @@ progress_cb (void *cls,
151 err = 1; 149 err = 1;
152 } 150 }
153 /* give system 1ms to initiate update search! */ 151 /* give system 1ms to initiate update search! */
154 GNUNET_SCHEDULER_add_delayed (sched, 152 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
155 GNUNET_TIME_UNIT_MILLISECONDS,
156 &abort_sks_search_task, 153 &abort_sks_search_task,
157 NULL); 154 NULL);
158 } 155 }
@@ -165,8 +162,7 @@ progress_cb (void *cls,
165 "Wrong result for ksk search!\n"); 162 "Wrong result for ksk search!\n");
166 err = 1; 163 err = 1;
167 } 164 }
168 GNUNET_SCHEDULER_add_continuation (sched, 165 GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task,
169 &abort_ksk_search_task,
170 NULL, 166 NULL,
171 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 167 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
172 } 168 }
@@ -182,13 +178,11 @@ progress_cb (void *cls,
182 "Error searching file: %s\n", 178 "Error searching file: %s\n",
183 event->value.search.specifics.error.message); 179 event->value.search.specifics.error.message);
184 if (sks_search == event->value.search.sc) 180 if (sks_search == event->value.search.sc)
185 GNUNET_SCHEDULER_add_continuation (sched, 181 GNUNET_SCHEDULER_add_continuation (&abort_sks_search_task,
186 &abort_sks_search_task,
187 NULL, 182 NULL,
188 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 183 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
189 else if (ksk_search == event->value.search.sc) 184 else if (ksk_search == event->value.search.sc)
190 GNUNET_SCHEDULER_add_continuation (sched, 185 GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task,
191 &abort_ksk_search_task,
192 NULL, 186 NULL,
193 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 187 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
194 else 188 else
@@ -384,15 +378,12 @@ testNamespace ()
384 378
385static void 379static void
386run (void *cls, 380run (void *cls,
387 struct GNUNET_SCHEDULER_Handle *s,
388 char *const *args, 381 char *const *args,
389 const char *cfgfile, 382 const char *cfgfile,
390 const struct GNUNET_CONFIGURATION_Handle *cfg) 383 const struct GNUNET_CONFIGURATION_Handle *cfg)
391{ 384{
392 sched = s;
393 setup_peer (&p1, "test_fs_namespace_data.conf"); 385 setup_peer (&p1, "test_fs_namespace_data.conf");
394 fs = GNUNET_FS_start (sched, 386 fs = GNUNET_FS_start (cfg,
395 cfg,
396 "test-fs-namespace", 387 "test-fs-namespace",
397 &progress_cb, 388 &progress_cb,
398 NULL, 389 NULL,
diff --git a/src/fs/test_fs_namespace_list_updateable.c b/src/fs/test_fs_namespace_list_updateable.c
index 2637b1665..359800f56 100644
--- a/src/fs/test_fs_namespace_list_updateable.c
+++ b/src/fs/test_fs_namespace_list_updateable.c
@@ -32,8 +32,6 @@
32 32
33#define START_ARM GNUNET_YES 33#define START_ARM GNUNET_YES
34 34
35static struct GNUNET_SCHEDULER_Handle *sched;
36
37static struct PeerContext p1; 35static struct PeerContext p1;
38 36
39static struct GNUNET_FS_Handle *fs; 37static struct GNUNET_FS_Handle *fs;
@@ -226,15 +224,12 @@ testNamespace ()
226 224
227static void 225static void
228run (void *cls, 226run (void *cls,
229 struct GNUNET_SCHEDULER_Handle *s,
230 char *const *args, 227 char *const *args,
231 const char *cfgfile, 228 const char *cfgfile,
232 const struct GNUNET_CONFIGURATION_Handle *cfg) 229 const struct GNUNET_CONFIGURATION_Handle *cfg)
233{ 230{
234 sched = s;
235 setup_peer (&p1, "test_fs_namespace_data.conf"); 231 setup_peer (&p1, "test_fs_namespace_data.conf");
236 fs = GNUNET_FS_start (sched, 232 fs = GNUNET_FS_start (cfg,
237 cfg,
238 "test-fs-namespace", 233 "test-fs-namespace",
239 &progress_cb, 234 &progress_cb,
240 NULL, 235 NULL,
diff --git a/src/fs/test_fs_publish.c b/src/fs/test_fs_publish.c
index b5472ca93..327fa5a69 100644
--- a/src/fs/test_fs_publish.c
+++ b/src/fs/test_fs_publish.c
@@ -61,8 +61,6 @@ static struct PeerContext p1;
61 61
62static struct GNUNET_TIME_Absolute start; 62static struct GNUNET_TIME_Absolute start;
63 63
64static struct GNUNET_SCHEDULER_Handle *sched;
65
66static struct GNUNET_FS_Handle *fs; 64static struct GNUNET_FS_Handle *fs;
67 65
68static struct GNUNET_FS_PublishContext *publish; 66static struct GNUNET_FS_PublishContext *publish;
@@ -103,8 +101,7 @@ progress_cb (void *cls,
103 (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024)); 101 (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024));
104 if (0 == strcmp ("publish-context-dir", 102 if (0 == strcmp ("publish-context-dir",
105 event->value.publish.cctx)) 103 event->value.publish.cctx))
106 GNUNET_SCHEDULER_add_continuation (sched, 104 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
107 &abort_publish_task,
108 NULL, 105 NULL,
109 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 106 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
110 break; 107 break;
@@ -130,8 +127,7 @@ progress_cb (void *cls,
130 { 127 {
131 fprintf (stderr, "Scheduling abort task for error on `%s'\n", 128 fprintf (stderr, "Scheduling abort task for error on `%s'\n",
132 (const char*) event->value.publish.cctx); 129 (const char*) event->value.publish.cctx);
133 GNUNET_SCHEDULER_add_continuation (sched, 130 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
134 &abort_publish_task,
135 NULL, 131 NULL,
136 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 132 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
137 } 133 }
@@ -214,7 +210,6 @@ stop_arm (struct PeerContext *p)
214 210
215static void 211static void
216run (void *cls, 212run (void *cls,
217 struct GNUNET_SCHEDULER_Handle *s,
218 char *const *args, 213 char *const *args,
219 const char *cfgfile, 214 const char *cfgfile,
220 const struct GNUNET_CONFIGURATION_Handle *cfg) 215 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -231,10 +226,8 @@ run (void *cls,
231 struct GNUNET_FS_FileInformation *fidir; 226 struct GNUNET_FS_FileInformation *fidir;
232 size_t i; 227 size_t i;
233 228
234 sched = s;
235 setup_peer (&p1, "test_fs_publish_data.conf"); 229 setup_peer (&p1, "test_fs_publish_data.conf");
236 fs = GNUNET_FS_start (sched, 230 fs = GNUNET_FS_start (cfg,
237 cfg,
238 "test-fs-publish", 231 "test-fs-publish",
239 &progress_cb, 232 &progress_cb,
240 NULL, 233 NULL,
diff --git a/src/fs/test_fs_publish_persistence.c b/src/fs/test_fs_publish_persistence.c
index b1260456b..52b2b270e 100644
--- a/src/fs/test_fs_publish_persistence.c
+++ b/src/fs/test_fs_publish_persistence.c
@@ -60,8 +60,6 @@ static struct PeerContext p1;
60 60
61static struct GNUNET_TIME_Absolute start; 61static struct GNUNET_TIME_Absolute start;
62 62
63static struct GNUNET_SCHEDULER_Handle *sched;
64
65static struct GNUNET_FS_Handle *fs; 63static struct GNUNET_FS_Handle *fs;
66 64
67static const struct GNUNET_CONFIGURATION_Handle *cfg; 65static const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -101,8 +99,7 @@ restart_fs_task (void *cls,
101 const struct GNUNET_SCHEDULER_TaskContext *tc) 99 const struct GNUNET_SCHEDULER_TaskContext *tc)
102{ 100{
103 GNUNET_FS_stop (fs); 101 GNUNET_FS_stop (fs);
104 fs = GNUNET_FS_start (sched, 102 fs = GNUNET_FS_start (cfg,
105 cfg,
106 "test-fs-publish-persistence", 103 "test-fs-publish-persistence",
107 &progress_cb, 104 &progress_cb,
108 NULL, 105 NULL,
@@ -128,8 +125,7 @@ consider_restart (int ev)
128 if (prev[i] == ev) 125 if (prev[i] == ev)
129 return; 126 return;
130 prev[off++] = ev; 127 prev[off++] = ev;
131 GNUNET_SCHEDULER_add_with_priority (sched, 128 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_URGENT,
132 GNUNET_SCHEDULER_PRIORITY_URGENT,
133 &restart_fs_task, 129 &restart_fs_task,
134 NULL); 130 NULL);
135} 131}
@@ -151,8 +147,7 @@ progress_cb (void *cls,
151 (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024)); 147 (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024));
152 if (0 == strcmp ("publish-context-dir", 148 if (0 == strcmp ("publish-context-dir",
153 event->value.publish.cctx)) 149 event->value.publish.cctx))
154 GNUNET_SCHEDULER_add_continuation (sched, 150 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
155 &abort_publish_task,
156 NULL, 151 NULL,
157 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 152 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
158 break; 153 break;
@@ -187,8 +182,7 @@ progress_cb (void *cls,
187 err = 1; 182 err = 1;
188 if (0 == strcmp ("publish-context-dir", 183 if (0 == strcmp ("publish-context-dir",
189 event->value.publish.cctx)) 184 event->value.publish.cctx))
190 GNUNET_SCHEDULER_add_continuation (sched, 185 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
191 &abort_publish_task,
192 NULL, 186 NULL,
193 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 187 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
194 break; 188 break;
@@ -273,7 +267,6 @@ stop_arm (struct PeerContext *p)
273 267
274static void 268static void
275run (void *cls, 269run (void *cls,
276 struct GNUNET_SCHEDULER_Handle *s,
277 char *const *args, 270 char *const *args,
278 const char *cfgfile, 271 const char *cfgfile,
279 const struct GNUNET_CONFIGURATION_Handle *c) 272 const struct GNUNET_CONFIGURATION_Handle *c)
@@ -290,11 +283,9 @@ run (void *cls,
290 struct GNUNET_FS_FileInformation *fidir; 283 struct GNUNET_FS_FileInformation *fidir;
291 size_t i; 284 size_t i;
292 285
293 sched = s;
294 cfg = c; 286 cfg = c;
295 setup_peer (&p1, "test_fs_publish_data.conf"); 287 setup_peer (&p1, "test_fs_publish_data.conf");
296 fs = GNUNET_FS_start (sched, 288 fs = GNUNET_FS_start (cfg,
297 cfg,
298 "test-fs-publish-persistence", 289 "test-fs-publish-persistence",
299 &progress_cb, 290 &progress_cb,
300 NULL, 291 NULL,
diff --git a/src/fs/test_fs_search.c b/src/fs/test_fs_search.c
index 1609cd8e3..b003b75e1 100644
--- a/src/fs/test_fs_search.c
+++ b/src/fs/test_fs_search.c
@@ -61,8 +61,6 @@ static struct PeerContext p1;
61 61
62static struct GNUNET_TIME_Absolute start; 62static struct GNUNET_TIME_Absolute start;
63 63
64static struct GNUNET_SCHEDULER_Handle *sched;
65
66static struct GNUNET_FS_Handle *fs; 64static struct GNUNET_FS_Handle *fs;
67 65
68static struct GNUNET_FS_SearchContext *search; 66static struct GNUNET_FS_SearchContext *search;
@@ -124,8 +122,7 @@ progress_cb (void *cls,
124#if VERBOSE 122#if VERBOSE
125 printf ("Search complete.\n"); 123 printf ("Search complete.\n");
126#endif 124#endif
127 GNUNET_SCHEDULER_add_continuation (sched, 125 GNUNET_SCHEDULER_add_continuation (&abort_search_task,
128 &abort_search_task,
129 NULL, 126 NULL,
130 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 127 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
131 break; 128 break;
@@ -134,8 +131,7 @@ progress_cb (void *cls,
134 "Error publishing file: %s\n", 131 "Error publishing file: %s\n",
135 event->value.publish.specifics.error.message); 132 event->value.publish.specifics.error.message);
136 GNUNET_break (0); 133 GNUNET_break (0);
137 GNUNET_SCHEDULER_add_continuation (sched, 134 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
138 &abort_publish_task,
139 NULL, 135 NULL,
140 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 136 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
141 break; 137 break;
@@ -143,8 +139,7 @@ progress_cb (void *cls,
143 fprintf (stderr, 139 fprintf (stderr,
144 "Error searching file: %s\n", 140 "Error searching file: %s\n",
145 event->value.search.specifics.error.message); 141 event->value.search.specifics.error.message);
146 GNUNET_SCHEDULER_add_continuation (sched, 142 GNUNET_SCHEDULER_add_continuation (&abort_search_task,
147 &abort_search_task,
148 NULL, 143 NULL,
149 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 144 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
150 break; 145 break;
@@ -171,8 +166,7 @@ progress_cb (void *cls,
171 break; 166 break;
172 case GNUNET_FS_STATUS_SEARCH_STOPPED: 167 case GNUNET_FS_STATUS_SEARCH_STOPPED:
173 GNUNET_assert (search == event->value.search.sc); 168 GNUNET_assert (search == event->value.search.sc);
174 GNUNET_SCHEDULER_add_continuation (sched, 169 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
175 &abort_publish_task,
176 NULL, 170 NULL,
177 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 171 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
178 break; 172 break;
@@ -221,7 +215,6 @@ stop_arm (struct PeerContext *p)
221 215
222static void 216static void
223run (void *cls, 217run (void *cls,
224 struct GNUNET_SCHEDULER_Handle *s,
225 char *const *args, 218 char *const *args,
226 const char *cfgfile, 219 const char *cfgfile,
227 const struct GNUNET_CONFIGURATION_Handle *cfg) 220 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -236,10 +229,8 @@ run (void *cls,
236 struct GNUNET_FS_FileInformation *fi; 229 struct GNUNET_FS_FileInformation *fi;
237 size_t i; 230 size_t i;
238 231
239 sched = s;
240 setup_peer (&p1, "test_fs_search_data.conf"); 232 setup_peer (&p1, "test_fs_search_data.conf");
241 fs = GNUNET_FS_start (sched, 233 fs = GNUNET_FS_start (cfg,
242 cfg,
243 "test-fs-search", 234 "test-fs-search",
244 &progress_cb, 235 &progress_cb,
245 NULL, 236 NULL,
diff --git a/src/fs/test_fs_search_persistence.c b/src/fs/test_fs_search_persistence.c
index d755a9582..4def3fe6a 100644
--- a/src/fs/test_fs_search_persistence.c
+++ b/src/fs/test_fs_search_persistence.c
@@ -61,8 +61,6 @@ static struct PeerContext p1;
61 61
62static struct GNUNET_TIME_Absolute start; 62static struct GNUNET_TIME_Absolute start;
63 63
64static struct GNUNET_SCHEDULER_Handle *sched;
65
66static struct GNUNET_FS_Handle *fs; 64static struct GNUNET_FS_Handle *fs;
67 65
68static struct GNUNET_FS_SearchContext *search; 66static struct GNUNET_FS_SearchContext *search;
@@ -100,8 +98,7 @@ restart_fs_task (void *cls,
100 const struct GNUNET_SCHEDULER_TaskContext *tc) 98 const struct GNUNET_SCHEDULER_TaskContext *tc)
101{ 99{
102 GNUNET_FS_stop (fs); 100 GNUNET_FS_stop (fs);
103 fs = GNUNET_FS_start (sched, 101 fs = GNUNET_FS_start (cfg,
104 cfg,
105 "test-fs-search-persistence", 102 "test-fs-search-persistence",
106 &progress_cb, 103 &progress_cb,
107 NULL, 104 NULL,
@@ -129,8 +126,7 @@ consider_restart (int ev)
129 if (prev[i] == ev) 126 if (prev[i] == ev)
130 return; 127 return;
131 prev[off++] = ev; 128 prev[off++] = ev;
132 GNUNET_SCHEDULER_add_with_priority (sched, 129 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_URGENT,
133 GNUNET_SCHEDULER_PRIORITY_URGENT,
134 &restart_fs_task, 130 &restart_fs_task,
135 NULL); 131 NULL);
136} 132}
@@ -181,8 +177,7 @@ progress_cb (void *cls,
181#if VERBOSE 177#if VERBOSE
182 printf ("Search complete.\n"); 178 printf ("Search complete.\n");
183#endif 179#endif
184 GNUNET_SCHEDULER_add_continuation (sched, 180 GNUNET_SCHEDULER_add_continuation (&abort_search_task,
185 &abort_search_task,
186 NULL, 181 NULL,
187 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 182 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
188 break; 183 break;
@@ -191,8 +186,7 @@ progress_cb (void *cls,
191 "Error publishing file: %s\n", 186 "Error publishing file: %s\n",
192 event->value.publish.specifics.error.message); 187 event->value.publish.specifics.error.message);
193 GNUNET_break (0); 188 GNUNET_break (0);
194 GNUNET_SCHEDULER_add_continuation (sched, 189 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
195 &abort_publish_task,
196 NULL, 190 NULL,
197 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 191 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
198 break; 192 break;
@@ -200,8 +194,7 @@ progress_cb (void *cls,
200 fprintf (stderr, 194 fprintf (stderr,
201 "Error searching file: %s\n", 195 "Error searching file: %s\n",
202 event->value.search.specifics.error.message); 196 event->value.search.specifics.error.message);
203 GNUNET_SCHEDULER_add_continuation (sched, 197 GNUNET_SCHEDULER_add_continuation (&abort_search_task,
204 &abort_search_task,
205 NULL, 198 NULL,
206 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 199 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
207 break; 200 break;
@@ -241,8 +234,7 @@ progress_cb (void *cls,
241 break; 234 break;
242 case GNUNET_FS_STATUS_SEARCH_STOPPED: 235 case GNUNET_FS_STATUS_SEARCH_STOPPED:
243 GNUNET_assert (search == event->value.search.sc); 236 GNUNET_assert (search == event->value.search.sc);
244 GNUNET_SCHEDULER_add_continuation (sched, 237 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
245 &abort_publish_task,
246 NULL, 238 NULL,
247 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 239 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
248 search = NULL; 240 search = NULL;
@@ -292,7 +284,6 @@ stop_arm (struct PeerContext *p)
292 284
293static void 285static void
294run (void *cls, 286run (void *cls,
295 struct GNUNET_SCHEDULER_Handle *s,
296 char *const *args, 287 char *const *args,
297 const char *cfgfile, 288 const char *cfgfile,
298 const struct GNUNET_CONFIGURATION_Handle *c) 289 const struct GNUNET_CONFIGURATION_Handle *c)
@@ -307,11 +298,9 @@ run (void *cls,
307 struct GNUNET_FS_FileInformation *fi; 298 struct GNUNET_FS_FileInformation *fi;
308 size_t i; 299 size_t i;
309 300
310 sched = s;
311 cfg = c; 301 cfg = c;
312 setup_peer (&p1, "test_fs_search_data.conf"); 302 setup_peer (&p1, "test_fs_search_data.conf");
313 fs = GNUNET_FS_start (sched, 303 fs = GNUNET_FS_start (cfg,
314 cfg,
315 "test-fs-search-persistence", 304 "test-fs-search-persistence",
316 &progress_cb, 305 &progress_cb,
317 NULL, 306 NULL,
diff --git a/src/fs/test_fs_start_stop.c b/src/fs/test_fs_start_stop.c
index f64596061..71043bf36 100644
--- a/src/fs/test_fs_start_stop.c
+++ b/src/fs/test_fs_start_stop.c
@@ -33,8 +33,6 @@
33 33
34#define START_ARM GNUNET_YES 34#define START_ARM GNUNET_YES
35 35
36static struct GNUNET_SCHEDULER_Handle *sched;
37
38static struct PeerContext p1; 36static struct PeerContext p1;
39 37
40struct PeerContext 38struct PeerContext
@@ -89,17 +87,14 @@ stop_arm (struct PeerContext *p)
89 87
90static void 88static void
91run (void *cls, 89run (void *cls,
92 struct GNUNET_SCHEDULER_Handle *s,
93 char *const *args, 90 char *const *args,
94 const char *cfgfile, 91 const char *cfgfile,
95 const struct GNUNET_CONFIGURATION_Handle *cfg) 92 const struct GNUNET_CONFIGURATION_Handle *cfg)
96{ 93{
97 struct GNUNET_FS_Handle *fs; 94 struct GNUNET_FS_Handle *fs;
98 95
99 sched = s;
100 setup_peer (&p1, "test_fs_data.conf"); 96 setup_peer (&p1, "test_fs_data.conf");
101 fs = GNUNET_FS_start (sched, 97 fs = GNUNET_FS_start (cfg,
102 cfg,
103 "test-fs-start-stop", 98 "test-fs-start-stop",
104 &progress_cb, 99 &progress_cb,
105 NULL, 100 NULL,
diff --git a/src/fs/test_fs_test_lib.c b/src/fs/test_fs_test_lib.c
index 930038da5..3c6826181 100644
--- a/src/fs/test_fs_test_lib.c
+++ b/src/fs/test_fs_test_lib.c
@@ -44,8 +44,6 @@
44 44
45static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS]; 45static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS];
46 46
47static struct GNUNET_SCHEDULER_Handle *sched;
48
49static int ret; 47static int ret;
50 48
51static void 49static void
@@ -63,8 +61,7 @@ do_stop (void *cls,
63 "Finished download, shutting down\n", 61 "Finished download, shutting down\n",
64 (unsigned long long) FILESIZE); 62 (unsigned long long) FILESIZE);
65 } 63 }
66 GNUNET_FS_TEST_daemons_stop (sched, 64 GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS,
67 NUM_DAEMONS,
68 daemons); 65 daemons);
69} 66}
70 67
@@ -76,8 +73,7 @@ do_download (void *cls,
76 if (NULL == uri) 73 if (NULL == uri)
77 { 74 {
78 GNUNET_break (0); 75 GNUNET_break (0);
79 GNUNET_SCHEDULER_add_now (sched, 76 GNUNET_SCHEDULER_add_now (&do_stop,
80 &do_stop,
81 NULL); 77 NULL);
82 ret = 1; 78 ret = 1;
83 return; 79 return;
@@ -85,8 +81,7 @@ do_download (void *cls,
85 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 81 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
86 "Downloading %llu bytes\n", 82 "Downloading %llu bytes\n",
87 (unsigned long long) FILESIZE); 83 (unsigned long long) FILESIZE);
88 GNUNET_FS_TEST_download (sched, 84 GNUNET_FS_TEST_download (daemons[0],
89 daemons[0],
90 TIMEOUT, 85 TIMEOUT,
91 1, SEED, uri, 86 1, SEED, uri,
92 VERBOSE, 87 VERBOSE,
@@ -102,16 +97,14 @@ do_publish (void *cls,
102 { 97 {
103 GNUNET_break (0); 98 GNUNET_break (0);
104 ret = 1; 99 ret = 1;
105 GNUNET_SCHEDULER_add_now (sched, 100 GNUNET_SCHEDULER_add_now (&do_stop,
106 &do_stop,
107 NULL); 101 NULL);
108 return; 102 return;
109 } 103 }
110 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 104 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
111 "Publishing %llu bytes\n", 105 "Publishing %llu bytes\n",
112 (unsigned long long) FILESIZE); 106 (unsigned long long) FILESIZE);
113 GNUNET_FS_TEST_publish (sched, 107 GNUNET_FS_TEST_publish (daemons[0],
114 daemons[0],
115 TIMEOUT, 108 TIMEOUT,
116 1, GNUNET_NO, FILESIZE, SEED, 109 1, GNUNET_NO, FILESIZE, SEED,
117 VERBOSE, 110 VERBOSE,
@@ -127,15 +120,13 @@ do_connect (void *cls,
127 { 120 {
128 GNUNET_break (0); 121 GNUNET_break (0);
129 ret = 1; 122 ret = 1;
130 GNUNET_SCHEDULER_add_now (sched, 123 GNUNET_SCHEDULER_add_now (&do_stop,
131 &do_stop,
132 NULL); 124 NULL);
133 return; 125 return;
134 } 126 }
135 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 127 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
136 "Daemons started, will now try to connect them\n"); 128 "Daemons started, will now try to connect them\n");
137 GNUNET_FS_TEST_daemons_connect (sched, 129 GNUNET_FS_TEST_daemons_connect (daemons[0],
138 daemons[0],
139 daemons[1], 130 daemons[1],
140 TIMEOUT, 131 TIMEOUT,
141 &do_publish, 132 &do_publish,
@@ -145,14 +136,11 @@ do_connect (void *cls,
145 136
146static void 137static void
147run (void *cls, 138run (void *cls,
148 struct GNUNET_SCHEDULER_Handle *s,
149 char *const *args, 139 char *const *args,
150 const char *cfgfile, 140 const char *cfgfile,
151 const struct GNUNET_CONFIGURATION_Handle *cfg) 141 const struct GNUNET_CONFIGURATION_Handle *cfg)
152{ 142{
153 sched = s; 143 GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf",
154 GNUNET_FS_TEST_daemons_start (sched,
155 "fs_test_lib_data.conf",
156 TIMEOUT, 144 TIMEOUT,
157 NUM_DAEMONS, 145 NUM_DAEMONS,
158 daemons, 146 daemons,
diff --git a/src/fs/test_fs_unindex.c b/src/fs/test_fs_unindex.c
index 7adc4d229..e2c0e86ee 100644
--- a/src/fs/test_fs_unindex.c
+++ b/src/fs/test_fs_unindex.c
@@ -60,8 +60,6 @@ static struct PeerContext p1;
60 60
61static struct GNUNET_TIME_Absolute start; 61static struct GNUNET_TIME_Absolute start;
62 62
63static struct GNUNET_SCHEDULER_Handle *sched;
64
65static struct GNUNET_FS_Handle *fs; 63static struct GNUNET_FS_Handle *fs;
66 64
67static struct GNUNET_FS_UnindexContext *unindex; 65static struct GNUNET_FS_UnindexContext *unindex;
@@ -120,8 +118,7 @@ progress_cb (void *cls,
120 case GNUNET_FS_STATUS_UNINDEX_COMPLETED: 118 case GNUNET_FS_STATUS_UNINDEX_COMPLETED:
121 printf ("Unindex complete, %llu kbps.\n", 119 printf ("Unindex complete, %llu kbps.\n",
122 (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024)); 120 (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024));
123 GNUNET_SCHEDULER_add_continuation (sched, 121 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task,
124 &abort_unindex_task,
125 NULL, 122 NULL,
126 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 123 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
127 break; 124 break;
@@ -140,8 +137,7 @@ progress_cb (void *cls,
140 "Error publishing file: %s\n", 137 "Error publishing file: %s\n",
141 event->value.publish.specifics.error.message); 138 event->value.publish.specifics.error.message);
142 GNUNET_break (0); 139 GNUNET_break (0);
143 GNUNET_SCHEDULER_add_continuation (sched, 140 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
144 &abort_publish_task,
145 NULL, 141 NULL,
146 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 142 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
147 break; 143 break;
@@ -149,8 +145,7 @@ progress_cb (void *cls,
149 fprintf (stderr, 145 fprintf (stderr,
150 "Error unindexing file: %s\n", 146 "Error unindexing file: %s\n",
151 event->value.unindex.specifics.error.message); 147 event->value.unindex.specifics.error.message);
152 GNUNET_SCHEDULER_add_continuation (sched, 148 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task,
153 &abort_unindex_task,
154 NULL, 149 NULL,
155 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 150 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
156 break; 151 break;
@@ -177,8 +172,7 @@ progress_cb (void *cls,
177 break; 172 break;
178 case GNUNET_FS_STATUS_UNINDEX_STOPPED: 173 case GNUNET_FS_STATUS_UNINDEX_STOPPED:
179 GNUNET_assert (unindex == event->value.unindex.uc); 174 GNUNET_assert (unindex == event->value.unindex.uc);
180 GNUNET_SCHEDULER_add_continuation (sched, 175 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
181 &abort_publish_task,
182 NULL, 176 NULL,
183 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 177 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
184 break; 178 break;
@@ -226,7 +220,6 @@ stop_arm (struct PeerContext *p)
226 220
227static void 221static void
228run (void *cls, 222run (void *cls,
229 struct GNUNET_SCHEDULER_Handle *s,
230 char *const *args, 223 char *const *args,
231 const char *cfgfile, 224 const char *cfgfile,
232 const struct GNUNET_CONFIGURATION_Handle *cfg) 225 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -241,11 +234,9 @@ run (void *cls,
241 struct GNUNET_FS_FileInformation *fi; 234 struct GNUNET_FS_FileInformation *fi;
242 size_t i; 235 size_t i;
243 236
244 sched = s;
245 setup_peer (&p1, "test_fs_unindex_data.conf"); 237 setup_peer (&p1, "test_fs_unindex_data.conf");
246 fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst"); 238 fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst");
247 fs = GNUNET_FS_start (sched, 239 fs = GNUNET_FS_start (cfg,
248 cfg,
249 "test-fs-unindex", 240 "test-fs-unindex",
250 &progress_cb, 241 &progress_cb,
251 NULL, 242 NULL,
diff --git a/src/fs/test_fs_unindex_persistence.c b/src/fs/test_fs_unindex_persistence.c
index 42f047b70..eec181544 100644
--- a/src/fs/test_fs_unindex_persistence.c
+++ b/src/fs/test_fs_unindex_persistence.c
@@ -59,8 +59,6 @@ static struct PeerContext p1;
59 59
60static struct GNUNET_TIME_Absolute start; 60static struct GNUNET_TIME_Absolute start;
61 61
62static struct GNUNET_SCHEDULER_Handle *sched;
63
64static struct GNUNET_FS_Handle *fs; 62static struct GNUNET_FS_Handle *fs;
65 63
66static struct GNUNET_FS_UnindexContext *unindex; 64static struct GNUNET_FS_UnindexContext *unindex;
@@ -108,8 +106,7 @@ restart_fs_task (void *cls,
108 const struct GNUNET_SCHEDULER_TaskContext *tc) 106 const struct GNUNET_SCHEDULER_TaskContext *tc)
109{ 107{
110 GNUNET_FS_stop (fs); 108 GNUNET_FS_stop (fs);
111 fs = GNUNET_FS_start (sched, 109 fs = GNUNET_FS_start (cfg,
112 cfg,
113 "test-fs-unindex-persistence", 110 "test-fs-unindex-persistence",
114 &progress_cb, 111 &progress_cb,
115 NULL, 112 NULL,
@@ -135,8 +132,7 @@ consider_restart (int ev)
135 if (prev[i] == ev) 132 if (prev[i] == ev)
136 return; 133 return;
137 prev[off++] = ev; 134 prev[off++] = ev;
138 GNUNET_SCHEDULER_add_with_priority (sched, 135 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_URGENT,
139 GNUNET_SCHEDULER_PRIORITY_URGENT,
140 &restart_fs_task, 136 &restart_fs_task,
141 NULL); 137 NULL);
142} 138}
@@ -169,8 +165,7 @@ progress_cb (void *cls,
169 case GNUNET_FS_STATUS_UNINDEX_COMPLETED: 165 case GNUNET_FS_STATUS_UNINDEX_COMPLETED:
170 printf ("Unindex complete, %llu kbps.\n", 166 printf ("Unindex complete, %llu kbps.\n",
171 (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024)); 167 (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024));
172 GNUNET_SCHEDULER_add_continuation (sched, 168 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task,
173 &abort_unindex_task,
174 NULL, 169 NULL,
175 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 170 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
176 break; 171 break;
@@ -209,8 +204,7 @@ progress_cb (void *cls,
209 "Error publishing file: %s\n", 204 "Error publishing file: %s\n",
210 event->value.publish.specifics.error.message); 205 event->value.publish.specifics.error.message);
211 GNUNET_break (0); 206 GNUNET_break (0);
212 GNUNET_SCHEDULER_add_continuation (sched, 207 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
213 &abort_publish_task,
214 NULL, 208 NULL,
215 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 209 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
216 break; 210 break;
@@ -218,8 +212,7 @@ progress_cb (void *cls,
218 fprintf (stderr, 212 fprintf (stderr,
219 "Error unindexing file: %s\n", 213 "Error unindexing file: %s\n",
220 event->value.unindex.specifics.error.message); 214 event->value.unindex.specifics.error.message);
221 GNUNET_SCHEDULER_add_continuation (sched, 215 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task,
222 &abort_unindex_task,
223 NULL, 216 NULL,
224 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 217 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
225 break; 218 break;
@@ -247,8 +240,7 @@ progress_cb (void *cls,
247 break; 240 break;
248 case GNUNET_FS_STATUS_UNINDEX_STOPPED: 241 case GNUNET_FS_STATUS_UNINDEX_STOPPED:
249 GNUNET_assert (unindex == event->value.unindex.uc); 242 GNUNET_assert (unindex == event->value.unindex.uc);
250 GNUNET_SCHEDULER_add_continuation (sched, 243 GNUNET_SCHEDULER_add_continuation (&abort_publish_task,
251 &abort_publish_task,
252 NULL, 244 NULL,
253 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 245 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
254 break; 246 break;
@@ -296,7 +288,6 @@ stop_arm (struct PeerContext *p)
296 288
297static void 289static void
298run (void *cls, 290run (void *cls,
299 struct GNUNET_SCHEDULER_Handle *s,
300 char *const *args, 291 char *const *args,
301 const char *cfgfile, 292 const char *cfgfile,
302 const struct GNUNET_CONFIGURATION_Handle *c) 293 const struct GNUNET_CONFIGURATION_Handle *c)
@@ -311,12 +302,10 @@ run (void *cls,
311 struct GNUNET_FS_FileInformation *fi; 302 struct GNUNET_FS_FileInformation *fi;
312 size_t i; 303 size_t i;
313 304
314 sched = s;
315 cfg = c; 305 cfg = c;
316 setup_peer (&p1, "test_fs_unindex_data.conf"); 306 setup_peer (&p1, "test_fs_unindex_data.conf");
317 fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst"); 307 fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst");
318 fs = GNUNET_FS_start (sched, 308 fs = GNUNET_FS_start (cfg,
319 cfg,
320 "test-fs-unindex-persistence", 309 "test-fs-unindex-persistence",
321 &progress_cb, 310 &progress_cb,
322 NULL, 311 NULL,
diff --git a/src/fs/test_gnunet_service_fs_migration.c b/src/fs/test_gnunet_service_fs_migration.c
index 3d6afbdc2..092cedfc2 100644
--- a/src/fs/test_gnunet_service_fs_migration.c
+++ b/src/fs/test_gnunet_service_fs_migration.c
@@ -48,8 +48,6 @@
48 48
49static struct GNUNET_FS_TestDaemon *daemons[2]; 49static struct GNUNET_FS_TestDaemon *daemons[2];
50 50
51static struct GNUNET_SCHEDULER_Handle *sched;
52
53static int ok; 51static int ok;
54 52
55static struct GNUNET_TIME_Absolute start_time; 53static struct GNUNET_TIME_Absolute start_time;
@@ -61,8 +59,7 @@ do_stop (void *cls,
61 struct GNUNET_TIME_Relative del; 59 struct GNUNET_TIME_Relative del;
62 char *fancy; 60 char *fancy;
63 61
64 GNUNET_FS_TEST_daemons_stop (sched, 62 GNUNET_FS_TEST_daemons_stop (2,
65 2,
66 daemons); 63 daemons);
67 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) 64 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
68 { 65 {
@@ -95,8 +92,7 @@ do_download (void *cls,
95 92
96 if (emsg != NULL) 93 if (emsg != NULL)
97 { 94 {
98 GNUNET_FS_TEST_daemons_stop (sched, 95 GNUNET_FS_TEST_daemons_stop (2,
99 2,
100 daemons); 96 daemons);
101 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 97 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
102 "Failed to stop source daemon: %s\n", 98 "Failed to stop source daemon: %s\n",
@@ -109,8 +105,7 @@ do_download (void *cls,
109 "Downloading %llu bytes\n", 105 "Downloading %llu bytes\n",
110 (unsigned long long) FILESIZE); 106 (unsigned long long) FILESIZE);
111 start_time = GNUNET_TIME_absolute_get (); 107 start_time = GNUNET_TIME_absolute_get ();
112 GNUNET_FS_TEST_download (sched, 108 GNUNET_FS_TEST_download (daemons[0],
113 daemons[0],
114 TIMEOUT, 109 TIMEOUT,
115 1, SEED, uri, 110 1, SEED, uri,
116 VERBOSE, 111 VERBOSE,
@@ -143,8 +138,7 @@ do_wait (void *cls,
143 138
144 if (NULL == uri) 139 if (NULL == uri)
145 { 140 {
146 GNUNET_FS_TEST_daemons_stop (sched, 141 GNUNET_FS_TEST_daemons_stop (2,
147 2,
148 daemons); 142 daemons);
149 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 143 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
150 "Timeout during upload attempt, shutting down with error\n"); 144 "Timeout during upload attempt, shutting down with error\n");
@@ -154,8 +148,7 @@ do_wait (void *cls,
154 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
155 "Waiting to allow content to migrate\n"); 149 "Waiting to allow content to migrate\n");
156 d = GNUNET_FS_uri_dup (uri); 150 d = GNUNET_FS_uri_dup (uri);
157 (void) GNUNET_SCHEDULER_add_delayed (sched, 151 (void) GNUNET_SCHEDULER_add_delayed (MIGRATION_DELAY,
158 MIGRATION_DELAY,
159 &stop_source_peer, 152 &stop_source_peer,
160 d); 153 d);
161} 154}
@@ -167,8 +160,7 @@ do_publish (void *cls,
167{ 160{
168 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) 161 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
169 { 162 {
170 GNUNET_FS_TEST_daemons_stop (sched, 163 GNUNET_FS_TEST_daemons_stop (2,
171 2,
172 daemons); 164 daemons);
173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 165 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
174 "Timeout during connect attempt, shutting down with error\n"); 166 "Timeout during connect attempt, shutting down with error\n");
@@ -178,8 +170,7 @@ do_publish (void *cls,
178 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 170 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
179 "Publishing %llu bytes\n", 171 "Publishing %llu bytes\n",
180 (unsigned long long) FILESIZE); 172 (unsigned long long) FILESIZE);
181 GNUNET_FS_TEST_publish (sched, 173 GNUNET_FS_TEST_publish (daemons[1],
182 daemons[1],
183 TIMEOUT, 174 TIMEOUT,
184 1, GNUNET_NO, FILESIZE, SEED, 175 1, GNUNET_NO, FILESIZE, SEED,
185 VERBOSE, 176 VERBOSE,
@@ -201,8 +192,7 @@ do_connect (void *cls,
201 } 192 }
202 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 193 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
203 "Daemons started, will now try to connect them\n"); 194 "Daemons started, will now try to connect them\n");
204 GNUNET_FS_TEST_daemons_connect (sched, 195 GNUNET_FS_TEST_daemons_connect (daemons[0],
205 daemons[0],
206 daemons[1], 196 daemons[1],
207 TIMEOUT, 197 TIMEOUT,
208 &do_publish, 198 &do_publish,
@@ -212,14 +202,11 @@ do_connect (void *cls,
212 202
213static void 203static void
214run (void *cls, 204run (void *cls,
215 struct GNUNET_SCHEDULER_Handle *s,
216 char *const *args, 205 char *const *args,
217 const char *cfgfile, 206 const char *cfgfile,
218 const struct GNUNET_CONFIGURATION_Handle *cfg) 207 const struct GNUNET_CONFIGURATION_Handle *cfg)
219{ 208{
220 sched = s; 209 GNUNET_FS_TEST_daemons_start ("test_gnunet_service_fs_migration_data.conf",
221 GNUNET_FS_TEST_daemons_start (sched,
222 "test_gnunet_service_fs_migration_data.conf",
223 TIMEOUT, 210 TIMEOUT,
224 2, 211 2,
225 daemons, 212 daemons,
diff --git a/src/fs/test_gnunet_service_fs_p2p.c b/src/fs/test_gnunet_service_fs_p2p.c
index f026baf6b..3bb808c48 100644
--- a/src/fs/test_gnunet_service_fs_p2p.c
+++ b/src/fs/test_gnunet_service_fs_p2p.c
@@ -44,8 +44,6 @@
44 44
45static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS]; 45static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS];
46 46
47static struct GNUNET_SCHEDULER_Handle *sched;
48
49static int ok; 47static int ok;
50 48
51static struct GNUNET_TIME_Absolute start_time; 49static struct GNUNET_TIME_Absolute start_time;
@@ -57,8 +55,7 @@ do_stop (void *cls,
57 struct GNUNET_TIME_Relative del; 55 struct GNUNET_TIME_Relative del;
58 char *fancy; 56 char *fancy;
59 57
60 GNUNET_FS_TEST_daemons_stop (sched, 58 GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS,
61 NUM_DAEMONS,
62 daemons); 59 daemons);
63 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) 60 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
64 { 61 {
@@ -89,8 +86,7 @@ do_download (void *cls,
89{ 86{
90 if (NULL == uri) 87 if (NULL == uri)
91 { 88 {
92 GNUNET_FS_TEST_daemons_stop (sched, 89 GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS,
93 NUM_DAEMONS,
94 daemons); 90 daemons);
95 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 91 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
96 "Timeout during upload attempt, shutting down with error\n"); 92 "Timeout during upload attempt, shutting down with error\n");
@@ -101,8 +97,7 @@ do_download (void *cls,
101 "Downloading %llu bytes\n", 97 "Downloading %llu bytes\n",
102 (unsigned long long) FILESIZE); 98 (unsigned long long) FILESIZE);
103 start_time = GNUNET_TIME_absolute_get (); 99 start_time = GNUNET_TIME_absolute_get ();
104 GNUNET_FS_TEST_download (sched, 100 GNUNET_FS_TEST_download (daemons[0],
105 daemons[0],
106 TIMEOUT, 101 TIMEOUT,
107 1, SEED, uri, 102 1, SEED, uri,
108 VERBOSE, 103 VERBOSE,
@@ -116,8 +111,7 @@ do_publish (void *cls,
116{ 111{
117 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) 112 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
118 { 113 {
119 GNUNET_FS_TEST_daemons_stop (sched, 114 GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS,
120 NUM_DAEMONS,
121 daemons); 115 daemons);
122 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 116 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
123 "Timeout during connect attempt, shutting down with error\n"); 117 "Timeout during connect attempt, shutting down with error\n");
@@ -127,8 +121,7 @@ do_publish (void *cls,
127 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 121 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
128 "Publishing %llu bytes\n", 122 "Publishing %llu bytes\n",
129 (unsigned long long) FILESIZE); 123 (unsigned long long) FILESIZE);
130 GNUNET_FS_TEST_publish (sched, 124 GNUNET_FS_TEST_publish (daemons[1],
131 daemons[1],
132 TIMEOUT, 125 TIMEOUT,
133 1, GNUNET_NO, FILESIZE, SEED, 126 1, GNUNET_NO, FILESIZE, SEED,
134 VERBOSE, 127 VERBOSE,
@@ -143,8 +136,7 @@ do_connect (void *cls,
143 GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); 136 GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE));
144 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 137 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
145 "Daemons started, will now try to connect them\n"); 138 "Daemons started, will now try to connect them\n");
146 GNUNET_FS_TEST_daemons_connect (sched, 139 GNUNET_FS_TEST_daemons_connect (daemons[0],
147 daemons[0],
148 daemons[1], 140 daemons[1],
149 TIMEOUT, 141 TIMEOUT,
150 &do_publish, 142 &do_publish,
@@ -154,14 +146,11 @@ do_connect (void *cls,
154 146
155static void 147static void
156run (void *cls, 148run (void *cls,
157 struct GNUNET_SCHEDULER_Handle *s,
158 char *const *args, 149 char *const *args,
159 const char *cfgfile, 150 const char *cfgfile,
160 const struct GNUNET_CONFIGURATION_Handle *cfg) 151 const struct GNUNET_CONFIGURATION_Handle *cfg)
161{ 152{
162 sched = s; 153 GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf",
163 GNUNET_FS_TEST_daemons_start (sched,
164 "fs_test_lib_data.conf",
165 TIMEOUT, 154 TIMEOUT,
166 NUM_DAEMONS, 155 NUM_DAEMONS,
167 daemons, 156 daemons,
diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c
index 52c996aed..f41f0add0 100644
--- a/src/hostlist/gnunet-daemon-hostlist.c
+++ b/src/hostlist/gnunet-daemon-hostlist.c
@@ -235,14 +235,12 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
235 * Main function that will be run. 235 * Main function that will be run.
236 * 236 *
237 * @param cls closure 237 * @param cls closure
238 * @param sched the scheduler to use
239 * @param args remaining command-line arguments 238 * @param args remaining command-line arguments
240 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 239 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
241 * @param cfg configuration 240 * @param cfg configuration
242 */ 241 */
243static void 242static void
244run (void *cls, 243run (void *cls,
245 struct GNUNET_SCHEDULER_Handle * sched,
246 char *const *args, 244 char *const *args,
247 const char *cfgfile, 245 const char *cfgfile,
248 const struct GNUNET_CONFIGURATION_Handle * cfg) 246 const struct GNUNET_CONFIGURATION_Handle * cfg)
@@ -268,9 +266,9 @@ run (void *cls,
268 266
269 267
270 268
271 stats = GNUNET_STATISTICS_create (sched, "hostlist", cfg); 269 stats = GNUNET_STATISTICS_create ("hostlist", cfg);
272 270
273 core = GNUNET_CORE_connect (sched, cfg, 271 core = GNUNET_CORE_connect (cfg,
274 GNUNET_TIME_UNIT_FOREVER_REL, 272 GNUNET_TIME_UNIT_FOREVER_REL,
275 NULL, 273 NULL,
276 &core_init, 274 &core_init,
@@ -281,18 +279,17 @@ run (void *cls,
281 279
282 if (bootstrapping) 280 if (bootstrapping)
283 { 281 {
284 GNUNET_HOSTLIST_client_start (cfg, sched, stats, 282 GNUNET_HOSTLIST_client_start (cfg, stats,
285 &client_ch, &client_dh, &client_adv_handler, learning); 283 &client_ch, &client_dh, &client_adv_handler, learning);
286 } 284 }
287 285
288 #if HAVE_MHD 286 #if HAVE_MHD
289 if (provide_hostlist) 287 if (provide_hostlist)
290 { 288 {
291 GNUNET_HOSTLIST_server_start (cfg, sched, stats, core, &server_ch, &server_dh, advertising ); 289 GNUNET_HOSTLIST_server_start (cfg, stats, core, &server_ch, &server_dh, advertising );
292 } 290 }
293#endif 291#endif
294 GNUNET_SCHEDULER_add_delayed (sched, 292 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
295 GNUNET_TIME_UNIT_FOREVER_REL,
296 &cleaning_task, NULL); 293 &cleaning_task, NULL);
297 294
298 if (NULL == core) 295 if (NULL == core)
@@ -300,7 +297,7 @@ run (void *cls,
300 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 297 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
301 _("Failed to connect to `%s' service.\n"), 298 _("Failed to connect to `%s' service.\n"),
302 "core"); 299 "core");
303 GNUNET_SCHEDULER_shutdown (sched); 300 GNUNET_SCHEDULER_shutdown ();
304 return; 301 return;
305 } 302 }
306} 303}
diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c
index e41c8ff18..47d625437 100644
--- a/src/hostlist/hostlist-client.c
+++ b/src/hostlist/hostlist-client.c
@@ -109,11 +109,6 @@ struct Hostlist
109static const struct GNUNET_CONFIGURATION_Handle *cfg; 109static const struct GNUNET_CONFIGURATION_Handle *cfg;
110 110
111/** 111/**
112 * Our scheduler.
113 */
114static struct GNUNET_SCHEDULER_Handle *sched;
115
116/**
117 * Statistics handle. 112 * Statistics handle.
118 */ 113 */
119static struct GNUNET_STATISTICS_Handle *stats; 114static struct GNUNET_STATISTICS_Handle *stats;
@@ -769,8 +764,7 @@ download_prepare ()
769 "Scheduling task for hostlist download using cURL\n"); 764 "Scheduling task for hostlist download using cURL\n");
770#endif 765#endif
771 ti_download 766 ti_download
772 = GNUNET_SCHEDULER_add_select (sched, 767 = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
773 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
774 GNUNET_SCHEDULER_NO_TASK, 768 GNUNET_SCHEDULER_NO_TASK,
775 rtime, 769 rtime,
776 grs, 770 grs,
@@ -1036,8 +1030,7 @@ task_download_dispatcher (void *cls,
1036 { 1030 {
1037 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1031 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1038 "Download in progess, have to wait...\n"); 1032 "Download in progess, have to wait...\n");
1039 ti_download_dispatcher_task = GNUNET_SCHEDULER_add_delayed (sched, 1033 ti_download_dispatcher_task = GNUNET_SCHEDULER_add_delayed (WAITING_INTERVALL,
1040 WAITING_INTERVALL,
1041 &task_download_dispatcher, 1034 &task_download_dispatcher,
1042 NULL); 1035 NULL);
1043 } 1036 }
@@ -1061,8 +1054,7 @@ task_check (void *cls,
1061 1054
1062 if (stat_connection_count < MIN_CONNECTIONS) 1055 if (stat_connection_count < MIN_CONNECTIONS)
1063 { 1056 {
1064 ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now ( sched, 1057 ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now (&task_download_dispatcher,
1065 &task_download_dispatcher,
1066 NULL); 1058 NULL);
1067 } 1059 }
1068 1060
@@ -1093,8 +1085,7 @@ task_check (void *cls,
1093 stat_connection_count, 1085 stat_connection_count,
1094 MIN_CONNECTIONS, 1086 MIN_CONNECTIONS,
1095 (unsigned long long) delay.rel_value); 1087 (unsigned long long) delay.rel_value);
1096 ti_check_download = GNUNET_SCHEDULER_add_delayed (sched, 1088 ti_check_download = GNUNET_SCHEDULER_add_delayed (delay,
1097 delay,
1098 &task_check, 1089 &task_check,
1099 NULL); 1090 NULL);
1100} 1091}
@@ -1136,8 +1127,7 @@ task_hostlist_saving (void *cls,
1136 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1127 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1137 _("Hostlists will be saved to file again in %llums\n"), 1128 _("Hostlists will be saved to file again in %llums\n"),
1138 (unsigned long long) SAVING_INTERVALL.rel_value); 1129 (unsigned long long) SAVING_INTERVALL.rel_value);
1139 ti_saving_task = GNUNET_SCHEDULER_add_delayed (sched, 1130 ti_saving_task = GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL,
1140 SAVING_INTERVALL,
1141 &task_hostlist_saving, 1131 &task_hostlist_saving,
1142 NULL); 1132 NULL);
1143} 1133}
@@ -1259,8 +1249,7 @@ handler_advertisement (void *cls,
1259 1249
1260 stat_testing_hostlist = GNUNET_YES; 1250 stat_testing_hostlist = GNUNET_YES;
1261 stat_testing_allowed = GNUNET_NO; 1251 stat_testing_allowed = GNUNET_NO;
1262 ti_testing_intervall_task = GNUNET_SCHEDULER_add_delayed (sched, 1252 ti_testing_intervall_task = GNUNET_SCHEDULER_add_delayed (TESTING_INTERVAL,
1263 TESTING_INTERVAL,
1264 &task_testing_intervall_reset, 1253 &task_testing_intervall_reset,
1265 NULL); 1254 NULL);
1266 1255
@@ -1268,8 +1257,7 @@ handler_advertisement (void *cls,
1268 "Testing new hostlist advertisements is locked for the next %u ms\n", 1257 "Testing new hostlist advertisements is locked for the next %u ms\n",
1269 TESTING_INTERVAL.rel_value); 1258 TESTING_INTERVAL.rel_value);
1270 1259
1271 ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now (sched, 1260 ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now (&task_download_dispatcher,
1272 &task_download_dispatcher,
1273 NULL); 1261 NULL);
1274 1262
1275 return GNUNET_OK; 1263 return GNUNET_OK;
@@ -1294,8 +1282,7 @@ primary_task (void *cls, int success)
1294 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1282 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1295 "Statistics request done, scheduling hostlist download\n"); 1283 "Statistics request done, scheduling hostlist download\n");
1296#endif 1284#endif
1297 ti_check_download = GNUNET_SCHEDULER_add_now (sched, 1285 ti_check_download = GNUNET_SCHEDULER_add_now (&task_check,
1298 &task_check,
1299 NULL); 1286 NULL);
1300} 1287}
1301 1288
@@ -1502,7 +1489,6 @@ static void save_hostlist_file ( int shutdown )
1502 */ 1489 */
1503int 1490int
1504GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, 1491GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c,
1505 struct GNUNET_SCHEDULER_Handle *s,
1506 struct GNUNET_STATISTICS_Handle *st, 1492 struct GNUNET_STATISTICS_Handle *st,
1507 GNUNET_CORE_ConnectEventHandler *ch, 1493 GNUNET_CORE_ConnectEventHandler *ch,
1508 GNUNET_CORE_DisconnectEventHandler *dh, 1494 GNUNET_CORE_DisconnectEventHandler *dh,
@@ -1517,14 +1503,13 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c,
1517 GNUNET_break (0); 1503 GNUNET_break (0);
1518 return GNUNET_SYSERR; 1504 return GNUNET_SYSERR;
1519 } 1505 }
1520 transport = GNUNET_TRANSPORT_connect (s, c, NULL, NULL, NULL, NULL, NULL); 1506 transport = GNUNET_TRANSPORT_connect (c, NULL, NULL, NULL, NULL, NULL);
1521 if (NULL == transport) 1507 if (NULL == transport)
1522 { 1508 {
1523 curl_global_cleanup (); 1509 curl_global_cleanup ();
1524 return GNUNET_SYSERR; 1510 return GNUNET_SYSERR;
1525 } 1511 }
1526 cfg = c; 1512 cfg = c;
1527 sched = s;
1528 stats = st; 1513 stats = st;
1529 if (GNUNET_OK != 1514 if (GNUNET_OK !=
1530 GNUNET_CONFIGURATION_get_value_string (cfg, 1515 GNUNET_CONFIGURATION_get_value_string (cfg,
@@ -1550,8 +1535,7 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c,
1550 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1535 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1551 _("Hostlists will be saved to file again in %llums\n"), 1536 _("Hostlists will be saved to file again in %llums\n"),
1552 (unsigned long long) SAVING_INTERVALL.rel_value); 1537 (unsigned long long) SAVING_INTERVALL.rel_value);
1553 ti_saving_task = GNUNET_SCHEDULER_add_delayed (sched, 1538 ti_saving_task = GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL,
1554 SAVING_INTERVALL,
1555 &task_hostlist_saving, 1539 &task_hostlist_saving,
1556 NULL); 1540 NULL);
1557 } 1541 }
@@ -1606,29 +1590,24 @@ GNUNET_HOSTLIST_client_stop ()
1606 1590
1607 if (ti_saving_task != GNUNET_SCHEDULER_NO_TASK) 1591 if (ti_saving_task != GNUNET_SCHEDULER_NO_TASK)
1608 { 1592 {
1609 GNUNET_SCHEDULER_cancel (sched, 1593 GNUNET_SCHEDULER_cancel (ti_saving_task);
1610 ti_saving_task);
1611 } 1594 }
1612 1595
1613 if (ti_download_dispatcher_task != GNUNET_SCHEDULER_NO_TASK) 1596 if (ti_download_dispatcher_task != GNUNET_SCHEDULER_NO_TASK)
1614 { 1597 {
1615 GNUNET_SCHEDULER_cancel (sched, 1598 GNUNET_SCHEDULER_cancel (ti_download_dispatcher_task);
1616 ti_download_dispatcher_task);
1617 } 1599 }
1618 if (ti_testing_intervall_task != GNUNET_SCHEDULER_NO_TASK) 1600 if (ti_testing_intervall_task != GNUNET_SCHEDULER_NO_TASK)
1619 { 1601 {
1620 GNUNET_SCHEDULER_cancel (sched, 1602 GNUNET_SCHEDULER_cancel (ti_testing_intervall_task);
1621 ti_testing_intervall_task);
1622 } 1603 }
1623 if (ti_download != GNUNET_SCHEDULER_NO_TASK) 1604 if (ti_download != GNUNET_SCHEDULER_NO_TASK)
1624 { 1605 {
1625 GNUNET_SCHEDULER_cancel (sched, 1606 GNUNET_SCHEDULER_cancel (ti_download);
1626 ti_download);
1627 } 1607 }
1628 if (ti_check_download != GNUNET_SCHEDULER_NO_TASK) 1608 if (ti_check_download != GNUNET_SCHEDULER_NO_TASK)
1629 { 1609 {
1630 GNUNET_SCHEDULER_cancel (sched, 1610 GNUNET_SCHEDULER_cancel (ti_check_download);
1631 ti_check_download);
1632 curl_global_cleanup (); 1611 curl_global_cleanup ();
1633 } 1612 }
1634 if (transport != NULL) 1613 if (transport != NULL)
@@ -1640,7 +1619,6 @@ GNUNET_HOSTLIST_client_stop ()
1640 GNUNET_free_non_null (proxy); 1619 GNUNET_free_non_null (proxy);
1641 proxy = NULL; 1620 proxy = NULL;
1642 cfg = NULL; 1621 cfg = NULL;
1643 sched = NULL;
1644} 1622}
1645 1623
1646/* end of hostlist-client.c */ 1624/* end of hostlist-client.c */
diff --git a/src/hostlist/hostlist-client.h b/src/hostlist/hostlist-client.h
index 04c3bb60f..b29b96a04 100644
--- a/src/hostlist/hostlist-client.h
+++ b/src/hostlist/hostlist-client.h
@@ -82,7 +82,6 @@
82 * Start downloading hostlists from hostlist servers as necessary. 82 * Start downloading hostlists from hostlist servers as necessary.
83 * 83 *
84 * @param c the configuration to use 84 * @param c the configuration to use
85 * @param s the scheduler to use
86 * @param st hande for publishing statistics 85 * @param st hande for publishing statistics
87 * @param ch set to handler for connect notifications 86 * @param ch set to handler for connect notifications
88 * @param dh set to handler for disconnect notifications 87 * @param dh set to handler for disconnect notifications
@@ -92,7 +91,6 @@
92 */ 91 */
93int 92int
94GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, 93GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c,
95 struct GNUNET_SCHEDULER_Handle *s,
96 struct GNUNET_STATISTICS_Handle *st, 94 struct GNUNET_STATISTICS_Handle *st,
97 GNUNET_CORE_ConnectEventHandler *ch, 95 GNUNET_CORE_ConnectEventHandler *ch,
98 GNUNET_CORE_DisconnectEventHandler *dh, 96 GNUNET_CORE_DisconnectEventHandler *dh,
diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c
index 8fdee5545..1c85f8f75 100644
--- a/src/hostlist/hostlist-server.c
+++ b/src/hostlist/hostlist-server.c
@@ -50,11 +50,6 @@ static struct MHD_Daemon *daemon_handle_v4;
50static const struct GNUNET_CONFIGURATION_Handle *cfg; 50static const struct GNUNET_CONFIGURATION_Handle *cfg;
51 51
52/** 52/**
53 * Our scheduler.
54 */
55static struct GNUNET_SCHEDULER_Handle *sched;
56
57/**
58 * For keeping statistics. 53 * For keeping statistics.
59 */ 54 */
60static struct GNUNET_STATISTICS_Handle *stats; 55static struct GNUNET_STATISTICS_Handle *stats;
@@ -539,8 +534,7 @@ prepare_daemon (struct MHD_Daemon *daemon_handle)
539 GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1); 534 GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1);
540 GNUNET_NETWORK_fdset_copy_native (wws, &ws, max + 1); 535 GNUNET_NETWORK_fdset_copy_native (wws, &ws, max + 1);
541 GNUNET_NETWORK_fdset_copy_native (wes, &es, max + 1); 536 GNUNET_NETWORK_fdset_copy_native (wes, &es, max + 1);
542 ret = GNUNET_SCHEDULER_add_select (sched, 537 ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH,
543 GNUNET_SCHEDULER_PRIORITY_HIGH,
544 GNUNET_SCHEDULER_NO_TASK, 538 GNUNET_SCHEDULER_NO_TASK,
545 tv, 539 tv,
546 wrs, 540 wrs,
@@ -562,7 +556,6 @@ prepare_daemon (struct MHD_Daemon *daemon_handle)
562 */ 556 */
563int 557int
564GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, 558GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c,
565 struct GNUNET_SCHEDULER_Handle *s,
566 struct GNUNET_STATISTICS_Handle *st, 559 struct GNUNET_STATISTICS_Handle *st,
567 struct GNUNET_CORE_Handle *co, 560 struct GNUNET_CORE_Handle *co,
568 GNUNET_CORE_ConnectEventHandler *server_ch, 561 GNUNET_CORE_ConnectEventHandler *server_ch,
@@ -580,10 +573,9 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c,
580 else 573 else
581 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 574 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
582 "Advertising enabled on this hostlist server\n"); 575 "Advertising enabled on this hostlist server\n");
583 sched = s;
584 cfg = c; 576 cfg = c;
585 stats = st; 577 stats = st;
586 peerinfo = GNUNET_PEERINFO_connect (sched, cfg); 578 peerinfo = GNUNET_PEERINFO_connect (cfg);
587 if (peerinfo == NULL) 579 if (peerinfo == NULL)
588 { 580 {
589 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 581 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -682,7 +674,7 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c,
682 if (daemon_handle_v6 != NULL) 674 if (daemon_handle_v6 != NULL)
683 hostlist_task_v6 = prepare_daemon (daemon_handle_v6); 675 hostlist_task_v6 = prepare_daemon (daemon_handle_v6);
684 676
685 notify = GNUNET_PEERINFO_notify ( cfg, sched, process_notify, NULL); 677 notify = GNUNET_PEERINFO_notify ( cfg, process_notify, NULL);
686 678
687 return GNUNET_OK; 679 return GNUNET_OK;
688} 680}
@@ -704,12 +696,12 @@ GNUNET_HOSTLIST_server_stop ()
704 } 696 }
705 if (GNUNET_SCHEDULER_NO_TASK != hostlist_task_v6) 697 if (GNUNET_SCHEDULER_NO_TASK != hostlist_task_v6)
706 { 698 {
707 GNUNET_SCHEDULER_cancel (sched, hostlist_task_v6); 699 GNUNET_SCHEDULER_cancel (hostlist_task_v6);
708 hostlist_task_v6 = GNUNET_SCHEDULER_NO_TASK; 700 hostlist_task_v6 = GNUNET_SCHEDULER_NO_TASK;
709 } 701 }
710 if (GNUNET_SCHEDULER_NO_TASK != hostlist_task_v4) 702 if (GNUNET_SCHEDULER_NO_TASK != hostlist_task_v4)
711 { 703 {
712 GNUNET_SCHEDULER_cancel (sched, hostlist_task_v4); 704 GNUNET_SCHEDULER_cancel (hostlist_task_v4);
713 hostlist_task_v4 = GNUNET_SCHEDULER_NO_TASK; 705 hostlist_task_v4 = GNUNET_SCHEDULER_NO_TASK;
714 } 706 }
715 if (pitr != NULL) 707 if (pitr != NULL)
@@ -738,7 +730,6 @@ GNUNET_HOSTLIST_server_stop ()
738 peerinfo = NULL; 730 peerinfo = NULL;
739 } 731 }
740 cfg = NULL; 732 cfg = NULL;
741 sched = NULL;
742 stats = NULL; 733 stats = NULL;
743 core = NULL; 734 core = NULL;
744} 735}
diff --git a/src/hostlist/hostlist-server.h b/src/hostlist/hostlist-server.h
index 187bdddf0..98ce2179b 100644
--- a/src/hostlist/hostlist-server.h
+++ b/src/hostlist/hostlist-server.h
@@ -40,7 +40,6 @@
40 */ 40 */
41int 41int
42GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, 42GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c,
43 struct GNUNET_SCHEDULER_Handle *s,
44 struct GNUNET_STATISTICS_Handle *st, 43 struct GNUNET_STATISTICS_Handle *st,
45 struct GNUNET_CORE_Handle *core, 44 struct GNUNET_CORE_Handle *core,
46 GNUNET_CORE_ConnectEventHandler *server_ch, 45 GNUNET_CORE_ConnectEventHandler *server_ch,
diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c
index 63ba53b69..28a8ddfcf 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist.c
@@ -39,8 +39,6 @@
39 39
40static int ok; 40static int ok;
41 41
42static struct GNUNET_SCHEDULER_Handle *sched;
43
44static GNUNET_SCHEDULER_TaskIdentifier timeout_task; 42static GNUNET_SCHEDULER_TaskIdentifier timeout_task;
45 43
46struct PeerContext 44struct PeerContext
@@ -71,7 +69,7 @@ clean_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
71 GNUNET_TRANSPORT_disconnect (p2.th); 69 GNUNET_TRANSPORT_disconnect (p2.th);
72 p2.th = NULL; 70 p2.th = NULL;
73 } 71 }
74 GNUNET_SCHEDULER_shutdown (sched); 72 GNUNET_SCHEDULER_shutdown ();
75} 73}
76 74
77/** 75/**
@@ -109,12 +107,10 @@ notify_connect (void *cls,
109 ok = 0; 107 ok = 0;
110 if (timeout_task != GNUNET_SCHEDULER_NO_TASK) 108 if (timeout_task != GNUNET_SCHEDULER_NO_TASK)
111 { 109 {
112 GNUNET_SCHEDULER_cancel (sched, 110 GNUNET_SCHEDULER_cancel (timeout_task);
113 timeout_task);
114 timeout_task = GNUNET_SCHEDULER_NO_TASK; 111 timeout_task = GNUNET_SCHEDULER_NO_TASK;
115 } 112 }
116 GNUNET_SCHEDULER_add_now (sched, 113 GNUNET_SCHEDULER_add_now (&clean_up, NULL);
117 &clean_up, NULL);
118} 114}
119 115
120 116
@@ -143,7 +139,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
143 "-c", cfgname, NULL); 139 "-c", cfgname, NULL);
144#endif 140#endif
145 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 141 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
146 p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, p, NULL, 142 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL,
147 &notify_connect, NULL); 143 &notify_connect, NULL);
148 GNUNET_assert (p->th != NULL); 144 GNUNET_assert (p->th != NULL);
149 GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); 145 GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
@@ -177,8 +173,7 @@ stop_arm (struct PeerContext *p)
177{ 173{
178 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 174 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
179 "Asking ARM to stop core service\n"); 175 "Asking ARM to stop core service\n");
180 GNUNET_SCHEDULER_add_delayed (sched, 176 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
181 GNUNET_TIME_UNIT_SECONDS,
182 &waitpid_task, p); 177 &waitpid_task, p);
183} 178}
184 179
@@ -196,20 +191,16 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
196 191
197static void 192static void
198run (void *cls, 193run (void *cls,
199 struct GNUNET_SCHEDULER_Handle *s,
200 char *const *args, 194 char *const *args,
201 const char *cfgfile, 195 const char *cfgfile,
202 const struct GNUNET_CONFIGURATION_Handle *cfg) 196 const struct GNUNET_CONFIGURATION_Handle *cfg)
203{ 197{
204 GNUNET_assert (ok == 1); 198 GNUNET_assert (ok == 1);
205 ok++; 199 ok++;
206 sched = s; 200 timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
207 timeout_task = GNUNET_SCHEDULER_add_delayed (sched,
208 TIMEOUT,
209 &timeout_error, 201 &timeout_error,
210 NULL); 202 NULL);
211 GNUNET_SCHEDULER_add_delayed (sched, 203 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
212 GNUNET_TIME_UNIT_FOREVER_REL,
213 &shutdown_task, 204 &shutdown_task,
214 NULL); 205 NULL);
215 setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf"); 206 setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf");
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c
index 16bd91d8b..7e2e2ac9e 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c
@@ -30,37 +30,29 @@
30#include "gnunet_resolver_service.h" 30#include "gnunet_resolver_service.h"
31#include "gnunet_statistics_service.h" 31#include "gnunet_statistics_service.h"
32 32
33#define VERBOSE GNUNET_NO 33#define VERBOSE GNUNET_YES
34 34
35#define START_ARM GNUNET_YES 35#define START_ARM GNUNET_YES
36
37#define MAX_URL_LEN 1000 36#define MAX_URL_LEN 1000
38 37
39/** 38/**
40 * How long until wait until testcases fails 39 * How long until wait until testcases fails
41 */ 40 */
42#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 180) 41#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 180)
43
44#define CHECK_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) 42#define CHECK_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
45 43
46static int timeout; 44static int timeout;
47
48static int adv_sent; 45static int adv_sent;
49
50static int adv_arrived; 46static int adv_arrived;
51 47
52static int learned_hostlist_saved; 48static int learned_hostlist_saved;
53
54static int learned_hostlist_downloaded; 49static int learned_hostlist_downloaded;
55 50
56static char * current_adv_uri; 51static char * current_adv_uri;
57 52
58static const struct GNUNET_CONFIGURATION_Handle *cfg; 53static const struct GNUNET_CONFIGURATION_Handle *cfg;
59 54
60static struct GNUNET_SCHEDULER_Handle *sched;
61
62static GNUNET_SCHEDULER_TaskIdentifier timeout_task; 55static GNUNET_SCHEDULER_TaskIdentifier timeout_task;
63
64static GNUNET_SCHEDULER_TaskIdentifier check_task; 56static GNUNET_SCHEDULER_TaskIdentifier check_task;
65 57
66struct PeerContext 58struct PeerContext
@@ -80,19 +72,16 @@ static struct PeerContext adv_peer;
80static struct PeerContext learn_peer; 72static struct PeerContext learn_peer;
81 73
82static struct GNUNET_STATISTICS_GetHandle * download_stats; 74static struct GNUNET_STATISTICS_GetHandle * download_stats;
83
84static struct GNUNET_STATISTICS_GetHandle * urisrecv_stat; 75static struct GNUNET_STATISTICS_GetHandle * urisrecv_stat;
85
86static struct GNUNET_STATISTICS_GetHandle * advsent_stat; 76static struct GNUNET_STATISTICS_GetHandle * advsent_stat;
87 77
88
89static void shutdown_testcase() 78static void shutdown_testcase()
90{ 79{
91 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown testcase....\n"); 80 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown testcase....\n");
92 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping Timeout Task.\n"); 81 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping Timeout Task.\n");
93 if (timeout_task != GNUNET_SCHEDULER_NO_TASK) 82 if (timeout_task != GNUNET_SCHEDULER_NO_TASK)
94 { 83 {
95 GNUNET_SCHEDULER_cancel (sched, timeout_task); 84 GNUNET_SCHEDULER_cancel (timeout_task);
96 timeout_task = GNUNET_SCHEDULER_NO_TASK; 85 timeout_task = GNUNET_SCHEDULER_NO_TASK;
97 } 86 }
98 87
@@ -106,9 +95,9 @@ static void shutdown_testcase()
106 GNUNET_STATISTICS_get_cancel (advsent_stat); 95 GNUNET_STATISTICS_get_cancel (advsent_stat);
107*/ 96*/
108 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping Statistics Check Task.\n"); 97 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping Statistics Check Task.\n");
109 if ((check_task != GNUNET_SCHEDULER_NO_TASK) && (sched !=NULL)) 98 if (check_task != GNUNET_SCHEDULER_NO_TASK)
110 { 99 {
111 GNUNET_SCHEDULER_cancel (sched, check_task); 100 GNUNET_SCHEDULER_cancel (check_task);
112 check_task = GNUNET_SCHEDULER_NO_TASK; 101 check_task = GNUNET_SCHEDULER_NO_TASK;
113 } 102 }
114 103
@@ -169,7 +158,7 @@ static void shutdown_testcase()
169#endif 158#endif
170 159
171 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down scheduler\n"); 160 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down scheduler\n");
172 GNUNET_SCHEDULER_shutdown (sched); 161 GNUNET_SCHEDULER_shutdown ();
173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown complete....\n"); 162 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown complete....\n");
174 163
175} 164}
@@ -286,8 +275,7 @@ check_statistics (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
286 &process_adv_sent, 275 &process_adv_sent,
287 NULL); 276 NULL);
288 } 277 }
289 check_task = GNUNET_SCHEDULER_add_delayed (sched, 278 check_task = GNUNET_SCHEDULER_add_delayed (CHECK_INTERVALL,
290 CHECK_INTERVALL,
291 &check_statistics, 279 &check_statistics,
292 NULL); 280 NULL);
293} 281}
@@ -381,7 +369,7 @@ setup_learn_peer (struct PeerContext *p, const char *cfgname)
381 } 369 }
382 if ( NULL != filename) GNUNET_free ( filename ); 370 if ( NULL != filename) GNUNET_free ( filename );
383 371
384 p->core = GNUNET_CORE_connect (sched, p->cfg, 372 p->core = GNUNET_CORE_connect (p->cfg,
385 GNUNET_TIME_UNIT_FOREVER_REL, 373 GNUNET_TIME_UNIT_FOREVER_REL,
386 NULL, 374 NULL,
387 NULL, 375 NULL,
@@ -390,7 +378,7 @@ setup_learn_peer (struct PeerContext *p, const char *cfgname)
390 NULL, GNUNET_NO, 378 NULL, GNUNET_NO,
391 learn_handlers ); 379 learn_handlers );
392 GNUNET_assert ( NULL != p->core ); 380 GNUNET_assert ( NULL != p->core );
393 p->stats = GNUNET_STATISTICS_create (sched, "hostlist", p->cfg); 381 p->stats = GNUNET_STATISTICS_create ("hostlist", p->cfg);
394 GNUNET_assert ( NULL != p->stats ); 382 GNUNET_assert ( NULL != p->stats );
395} 383}
396 384
@@ -409,14 +397,13 @@ setup_adv_peer (struct PeerContext *p, const char *cfgname)
409 "-c", cfgname, NULL); 397 "-c", cfgname, NULL);
410#endif 398#endif
411 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 399 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
412 p->stats = GNUNET_STATISTICS_create (sched, "hostlist", p->cfg); 400 p->stats = GNUNET_STATISTICS_create ("hostlist", p->cfg);
413 GNUNET_assert ( NULL != p->stats ); 401 GNUNET_assert ( NULL != p->stats );
414 402
415} 403}
416 404
417static void 405static void
418run (void *cls, 406run (void *cls,
419 struct GNUNET_SCHEDULER_Handle *s,
420 char *const *args, 407 char *const *args,
421 const char *cfgfile, 408 const char *cfgfile,
422 const struct GNUNET_CONFIGURATION_Handle *c) 409 const struct GNUNET_CONFIGURATION_Handle *c)
@@ -429,17 +416,14 @@ run (void *cls,
429 learned_hostlist_downloaded = GNUNET_NO; 416 learned_hostlist_downloaded = GNUNET_NO;
430 417
431 cfg = c; 418 cfg = c;
432 sched = s;
433 419
434 setup_adv_peer (&adv_peer, "test_learning_adv_peer.conf"); 420 setup_adv_peer (&adv_peer, "test_learning_adv_peer.conf");
435 setup_learn_peer (&learn_peer, "test_learning_learn_peer.conf"); 421 setup_learn_peer (&learn_peer, "test_learning_learn_peer.conf");
436 timeout_task = GNUNET_SCHEDULER_add_delayed (sched, 422 timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
437 TIMEOUT,
438 &timeout_error, 423 &timeout_error,
439 NULL); 424 NULL);
440 425
441 check_task = GNUNET_SCHEDULER_add_delayed (sched, 426 check_task = GNUNET_SCHEDULER_add_delayed (CHECK_INTERVALL,
442 CHECK_INTERVALL,
443 &check_statistics, 427 &check_statistics,
444 NULL); 428 NULL);
445} 429}
@@ -531,4 +515,4 @@ main (int argc, char *argv[])
531 return ret; 515 return ret;
532} 516}
533 517
534/* end of test_gnunet_daemon_hostlist_learning.c */ 518/* end of test_gnunet_daemon_hostlist.c */
diff --git a/src/include/gnunet_arm_service.h b/src/include/gnunet_arm_service.h
index 912db027b..317105520 100644
--- a/src/include/gnunet_arm_service.h
+++ b/src/include/gnunet_arm_service.h
@@ -70,13 +70,11 @@ struct GNUNET_ARM_Handle;
70 * @param cfg configuration to use (needed to contact ARM; 70 * @param cfg configuration to use (needed to contact ARM;
71 * the ARM service may internally use a different 71 * the ARM service may internally use a different
72 * configuration to determine how to start the service). 72 * configuration to determine how to start the service).
73 * @param sched scheduler to use
74 * @param service service that *this* process is implementing/providing, can be NULL 73 * @param service service that *this* process is implementing/providing, can be NULL
75 * @return context to use for further ARM operations, NULL on error 74 * @return context to use for further ARM operations, NULL on error
76 */ 75 */
77struct GNUNET_ARM_Handle * 76struct GNUNET_ARM_Handle *
78GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 77GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
79 struct GNUNET_SCHEDULER_Handle *sched,
80 const char *service); 78 const char *service);
81 79
82 80
diff --git a/src/include/gnunet_client_lib.h b/src/include/gnunet_client_lib.h
index 49ccc6c6b..41dbe4efc 100644
--- a/src/include/gnunet_client_lib.h
+++ b/src/include/gnunet_client_lib.h
@@ -49,15 +49,11 @@ struct GNUNET_CLIENT_Connection;
49/** 49/**
50 * Get a connection with a service. 50 * Get a connection with a service.
51 * 51 *
52 * @param sched scheduler to use
53 * @param service_name name of the service 52 * @param service_name name of the service
54 * @param cfg configuration to use 53 * @param cfg configuration to use
55 * @return NULL on error (service unknown to configuration) 54 * @return NULL on error (service unknown to configuration)
56 */ 55 */
57struct GNUNET_CLIENT_Connection *GNUNET_CLIENT_connect (struct 56struct GNUNET_CLIENT_Connection *GNUNET_CLIENT_connect (const char
58 GNUNET_SCHEDULER_Handle
59 *sched,
60 const char
61 *service_name, 57 *service_name,
62 const struct 58 const struct
63 GNUNET_CONFIGURATION_Handle 59 GNUNET_CONFIGURATION_Handle
@@ -210,7 +206,6 @@ GNUNET_CLIENT_transmit_and_get_response (struct GNUNET_CLIENT_Connection *sock,
210/** 206/**
211 * Wait until the service is running. 207 * Wait until the service is running.
212 * 208 *
213 * @param sched scheduler to use
214 * @param service name of the service to wait for 209 * @param service name of the service to wait for
215 * @param cfg configuration to use 210 * @param cfg configuration to use
216 * @param timeout how long to wait at most in ms 211 * @param timeout how long to wait at most in ms
@@ -219,8 +214,7 @@ GNUNET_CLIENT_transmit_and_get_response (struct GNUNET_CLIENT_Connection *sock,
219 * or "TIMEOUT" (service not known to be running)) 214 * or "TIMEOUT" (service not known to be running))
220 * @param task_cls closure for task 215 * @param task_cls closure for task
221 */ 216 */
222void GNUNET_CLIENT_service_test (struct GNUNET_SCHEDULER_Handle *sched, 217void GNUNET_CLIENT_service_test (const char *service,
223 const char *service,
224 const struct GNUNET_CONFIGURATION_Handle *cfg, 218 const struct GNUNET_CONFIGURATION_Handle *cfg,
225 struct GNUNET_TIME_Relative timeout, 219 struct GNUNET_TIME_Relative timeout,
226 GNUNET_SCHEDULER_Task task, void *task_cls); 220 GNUNET_SCHEDULER_Task task, void *task_cls);
diff --git a/src/include/gnunet_connection_lib.h b/src/include/gnunet_connection_lib.h
index d5942236b..33afb0386 100644
--- a/src/include/gnunet_connection_lib.h
+++ b/src/include/gnunet_connection_lib.h
@@ -99,15 +99,11 @@ GNUNET_CONNECTION_persist_(struct GNUNET_CONNECTION_Handle *sock);
99 * socket should henceforth be no longer used directly. 99 * socket should henceforth be no longer used directly.
100 * GNUNET_socket_destroy will close it. 100 * GNUNET_socket_destroy will close it.
101 * 101 *
102 * @param sched scheduler to use
103 * @param osSocket existing socket to box 102 * @param osSocket existing socket to box
104 * @return the boxed socket handle 103 * @return the boxed socket handle
105 */ 104 */
106struct GNUNET_CONNECTION_Handle 105struct GNUNET_CONNECTION_Handle
107 *GNUNET_CONNECTION_create_from_existing (struct 106 *GNUNET_CONNECTION_create_from_existing (struct
108 GNUNET_SCHEDULER_Handle
109 *sched,
110 struct
111 GNUNET_NETWORK_Handle 107 GNUNET_NETWORK_Handle
112 *osSocket); 108 *osSocket);
113 109
@@ -116,17 +112,13 @@ struct GNUNET_CONNECTION_Handle
116 * Create a socket handle by accepting on a listen socket. This 112 * Create a socket handle by accepting on a listen socket. This
117 * function may block if the listen socket has no connection ready. 113 * function may block if the listen socket has no connection ready.
118 * 114 *
119 * @param sched scheduler to use
120 * @param access function to use to check if access is allowed 115 * @param access function to use to check if access is allowed
121 * @param access_cls closure for access 116 * @param access_cls closure for access
122 * @param lsock listen socket 117 * @param lsock listen socket
123 * @return the socket handle, NULL on error (for example, access refused) 118 * @return the socket handle, NULL on error (for example, access refused)
124 */ 119 */
125struct GNUNET_CONNECTION_Handle 120struct GNUNET_CONNECTION_Handle
126 *GNUNET_CONNECTION_create_from_accept (struct 121 *GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck
127 GNUNET_SCHEDULER_Handle
128 *sched,
129 GNUNET_CONNECTION_AccessCheck
130 access, void *access_cls, 122 access, void *access_cls,
131 struct 123 struct
132 GNUNET_NETWORK_Handle 124 GNUNET_NETWORK_Handle
@@ -138,15 +130,13 @@ struct GNUNET_CONNECTION_Handle
138 * This function returns immediately, even if the connection has not 130 * This function returns immediately, even if the connection has not
139 * yet been established. This function only creates TCP connections. 131 * yet been established. This function only creates TCP connections.
140 * 132 *
141 * @param sched scheduler to use
142 * @param cfg configuration to use 133 * @param cfg configuration to use
143 * @param hostname name of the host to connect to 134 * @param hostname name of the host to connect to
144 * @param port port to connect to 135 * @param port port to connect to
145 * @return the socket handle 136 * @return the socket handle
146 */ 137 */
147struct GNUNET_CONNECTION_Handle 138struct GNUNET_CONNECTION_Handle
148 *GNUNET_CONNECTION_create_from_connect (struct GNUNET_SCHEDULER_Handle *sched, 139 *GNUNET_CONNECTION_create_from_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
149 const struct GNUNET_CONFIGURATION_Handle *cfg,
150 const char *hostname, 140 const char *hostname,
151 uint16_t port); 141 uint16_t port);
152 142
@@ -156,14 +146,12 @@ struct GNUNET_CONNECTION_Handle
156 * This function returns immediately, even if the connection has not 146 * This function returns immediately, even if the connection has not
157 * yet been established. This function only creates UNIX connections. 147 * yet been established. This function only creates UNIX connections.
158 * 148 *
159 * @param sched scheduler to use
160 * @param cfg configuration to use 149 * @param cfg configuration to use
161 * @param unixpath path to connect to) 150 * @param unixpath path to connect to)
162 * @return the socket handle, NULL on systems without UNIX support 151 * @return the socket handle, NULL on systems without UNIX support
163 */ 152 */
164struct GNUNET_CONNECTION_Handle * 153struct GNUNET_CONNECTION_Handle *
165GNUNET_CONNECTION_create_from_connect_to_unixpath (struct GNUNET_SCHEDULER_Handle *sched, 154GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct
166 const struct
167 GNUNET_CONFIGURATION_Handle *cfg, 155 GNUNET_CONFIGURATION_Handle *cfg,
168 const char *unixpath); 156 const char *unixpath);
169 157
@@ -175,16 +163,13 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (struct GNUNET_SCHEDULER_Handl
175 * This function returns immediately, even if the connection has not 163 * This function returns immediately, even if the connection has not
176 * yet been established. This function only creates TCP connections. 164 * yet been established. This function only creates TCP connections.
177 * 165 *
178 * @param sched scheduler to use
179 * @param af_family address family to use 166 * @param af_family address family to use
180 * @param serv_addr server address 167 * @param serv_addr server address
181 * @param addrlen length of server address 168 * @param addrlen length of server address
182 * @return the socket handle 169 * @return the socket handle
183 */ 170 */
184struct GNUNET_CONNECTION_Handle 171struct GNUNET_CONNECTION_Handle
185 *GNUNET_CONNECTION_create_from_sockaddr (struct 172 *GNUNET_CONNECTION_create_from_sockaddr (int af_family,
186 GNUNET_SCHEDULER_Handle
187 *sched, int af_family,
188 const struct sockaddr 173 const struct sockaddr
189 *serv_addr, 174 *serv_addr,
190 socklen_t addrlen); 175 socklen_t addrlen);
diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h
index caa02c6b2..7fe871741 100644
--- a/src/include/gnunet_core_service.h
+++ b/src/include/gnunet_core_service.h
@@ -178,7 +178,6 @@ typedef void
178 * Certain events (such as connect/disconnect notifications) are not 178 * Certain events (such as connect/disconnect notifications) are not
179 * subject to queue size limitations. 179 * subject to queue size limitations.
180 * 180 *
181 * @param sched scheduler to use
182 * @param cfg configuration to use 181 * @param cfg configuration to use
183 * @param timeout after how long should we give up trying to connect to the core service? 182 * @param timeout after how long should we give up trying to connect to the core service?
184 * @param cls closure for the various callbacks that follow (including handlers in the handlers array) 183 * @param cls closure for the various callbacks that follow (including handlers in the handlers array)
@@ -215,8 +214,7 @@ typedef void
215 * NULL on error (in this case, init is never called) 214 * NULL on error (in this case, init is never called)
216 */ 215 */
217struct GNUNET_CORE_Handle * 216struct GNUNET_CORE_Handle *
218GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, 217GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
219 const struct GNUNET_CONFIGURATION_Handle *cfg,
220 struct GNUNET_TIME_Relative timeout, 218 struct GNUNET_TIME_Relative timeout,
221 void *cls, 219 void *cls,
222 GNUNET_CORE_StartupCallback init, 220 GNUNET_CORE_StartupCallback init,
@@ -257,7 +255,6 @@ struct GNUNET_CORE_PeerRequestHandle;
257 * to our connection attempt within the given time frame, 'cont' will 255 * to our connection attempt within the given time frame, 'cont' will
258 * be called with the TIMEOUT reason code. 256 * be called with the TIMEOUT reason code.
259 * 257 *
260 * @param sched scheduler to use
261 * @param cfg configuration to use 258 * @param cfg configuration to use
262 * @param timeout how long to try to talk to core 259 * @param timeout how long to try to talk to core
263 * @param peer who should we connect to 260 * @param peer who should we connect to
@@ -266,8 +263,7 @@ struct GNUNET_CORE_PeerRequestHandle;
266 * @return NULL on error (cont will not be called), otherwise handle for cancellation 263 * @return NULL on error (cont will not be called), otherwise handle for cancellation
267 */ 264 */
268struct GNUNET_CORE_PeerRequestHandle * 265struct GNUNET_CORE_PeerRequestHandle *
269GNUNET_CORE_peer_request_connect (struct GNUNET_SCHEDULER_Handle *sched, 266GNUNET_CORE_peer_request_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
270 const struct GNUNET_CONFIGURATION_Handle *cfg,
271 struct GNUNET_TIME_Relative timeout, 267 struct GNUNET_TIME_Relative timeout,
272 const struct GNUNET_PeerIdentity * peer, 268 const struct GNUNET_PeerIdentity * peer,
273 GNUNET_SCHEDULER_Task cont, 269 GNUNET_SCHEDULER_Task cont,
@@ -317,7 +313,6 @@ struct GNUNET_CORE_InformationRequestContext;
317/** 313/**
318 * Obtain statistics and/or change preferences for the given peer. 314 * Obtain statistics and/or change preferences for the given peer.
319 * 315 *
320 * @param sched scheduler to use
321 * @param cfg configuration to use 316 * @param cfg configuration to use
322 * @param peer identifies the peer 317 * @param peer identifies the peer
323 * @param timeout after how long should we give up (and call "info" with NULL 318 * @param timeout after how long should we give up (and call "info" with NULL
@@ -340,8 +335,7 @@ struct GNUNET_CORE_InformationRequestContext;
340 * @return NULL on error 335 * @return NULL on error
341 */ 336 */
342struct GNUNET_CORE_InformationRequestContext * 337struct GNUNET_CORE_InformationRequestContext *
343GNUNET_CORE_peer_change_preference (struct GNUNET_SCHEDULER_Handle *sched, 338GNUNET_CORE_peer_change_preference (const struct GNUNET_CONFIGURATION_Handle *cfg,
344 const struct GNUNET_CONFIGURATION_Handle *cfg,
345 const struct GNUNET_PeerIdentity *peer, 339 const struct GNUNET_PeerIdentity *peer,
346 struct GNUNET_TIME_Relative timeout, 340 struct GNUNET_TIME_Relative timeout,
347 struct GNUNET_BANDWIDTH_Value32NBO bw_out, 341 struct GNUNET_BANDWIDTH_Value32NBO bw_out,
@@ -362,15 +356,13 @@ GNUNET_CORE_peer_change_preference_cancel (struct GNUNET_CORE_InformationRequest
362/** 356/**
363 * Obtain statistics and/or change preferences for the given peer. 357 * Obtain statistics and/or change preferences for the given peer.
364 * 358 *
365 * @param sched scheduler to use
366 * @param cfg configuration to use 359 * @param cfg configuration to use
367 * @param peer_cb function to call with the peer information 360 * @param peer_cb function to call with the peer information
368 * @param cb_cls closure for peer_cb 361 * @param cb_cls closure for peer_cb
369 * @return GNUNET_OK if iterating, GNUNET_SYSERR on error 362 * @return GNUNET_OK if iterating, GNUNET_SYSERR on error
370 */ 363 */
371int 364int
372GNUNET_CORE_iterate_peers (struct GNUNET_SCHEDULER_Handle *sched, 365GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
373 const struct GNUNET_CONFIGURATION_Handle *cfg,
374 GNUNET_CORE_ConnectEventHandler peer_cb, 366 GNUNET_CORE_ConnectEventHandler peer_cb,
375 void *cb_cls); 367 void *cb_cls);
376 368
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 8b1379e45..5d8b4ab8a 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -436,7 +436,6 @@ struct GNUNET_CRYPTO_FileHashContext;
436/** 436/**
437 * Compute the hash of an entire file. 437 * Compute the hash of an entire file.
438 * 438 *
439 * @param sched scheduler to use
440 * @param priority scheduling priority to use 439 * @param priority scheduling priority to use
441 * @param filename name of file to hash 440 * @param filename name of file to hash
442 * @param blocksize number of bytes to process in one task 441 * @param blocksize number of bytes to process in one task
@@ -445,8 +444,7 @@ struct GNUNET_CRYPTO_FileHashContext;
445 * @return NULL on (immediate) errror 444 * @return NULL on (immediate) errror
446 */ 445 */
447struct GNUNET_CRYPTO_FileHashContext * 446struct GNUNET_CRYPTO_FileHashContext *
448GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched, 447GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority,
449 enum GNUNET_SCHEDULER_Priority priority,
450 const char *filename, 448 const char *filename,
451 size_t blocksize, 449 size_t blocksize,
452 GNUNET_CRYPTO_HashCompletedCallback callback, 450 GNUNET_CRYPTO_HashCompletedCallback callback,
diff --git a/src/include/gnunet_datacache_lib.h b/src/include/gnunet_datacache_lib.h
index 74878f08b..5fcd99ad4 100644
--- a/src/include/gnunet_datacache_lib.h
+++ b/src/include/gnunet_datacache_lib.h
@@ -52,14 +52,12 @@ struct GNUNET_DATACACHE_Handle;
52/** 52/**
53 * Create a data cache. 53 * Create a data cache.
54 * 54 *
55 * @param sched scheduler to use
56 * @param cfg configuration to use 55 * @param cfg configuration to use
57 * @param section section in the configuration that contains our options 56 * @param section section in the configuration that contains our options
58 * @return handle to use to access the service 57 * @return handle to use to access the service
59 */ 58 */
60struct GNUNET_DATACACHE_Handle * 59struct GNUNET_DATACACHE_Handle *
61GNUNET_DATACACHE_create (struct GNUNET_SCHEDULER_Handle *sched, 60GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
62 const struct GNUNET_CONFIGURATION_Handle *cfg,
63 const char *section); 61 const char *section);
64 62
65 63
diff --git a/src/include/gnunet_datastore_service.h b/src/include/gnunet_datastore_service.h
index 8d35f7900..4c9fad965 100644
--- a/src/include/gnunet_datastore_service.h
+++ b/src/include/gnunet_datastore_service.h
@@ -57,15 +57,11 @@ struct GNUNET_DATASTORE_Handle;
57 * Connect to the datastore service. 57 * Connect to the datastore service.
58 * 58 *
59 * @param cfg configuration to use 59 * @param cfg configuration to use
60 * @param sched scheduler to use
61 * @return handle to use to access the service 60 * @return handle to use to access the service
62 */ 61 */
63struct GNUNET_DATASTORE_Handle *GNUNET_DATASTORE_connect (const struct 62struct GNUNET_DATASTORE_Handle *GNUNET_DATASTORE_connect (const struct
64 GNUNET_CONFIGURATION_Handle 63 GNUNET_CONFIGURATION_Handle
65 *cfg, 64 *cfg);
66 struct
67 GNUNET_SCHEDULER_Handle
68 *sched);
69 65
70 66
71/** 67/**
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h
index b3bf2b84b..7ab818de7 100644
--- a/src/include/gnunet_dht_service.h
+++ b/src/include/gnunet_dht_service.h
@@ -99,15 +99,13 @@ enum GNUNET_DHT_RouteOption
99/** 99/**
100 * Initialize the connection with the DHT service. 100 * Initialize the connection with the DHT service.
101 * 101 *
102 * @param sched scheduler to use
103 * @param cfg configuration to use 102 * @param cfg configuration to use
104 * @param ht_len size of the internal hash table to use for 103 * @param ht_len size of the internal hash table to use for
105 * processing multiple GET/FIND requests in parallel 104 * processing multiple GET/FIND requests in parallel
106 * @return NULL on error 105 * @return NULL on error
107 */ 106 */
108struct GNUNET_DHT_Handle * 107struct GNUNET_DHT_Handle *
109GNUNET_DHT_connect (struct GNUNET_SCHEDULER_Handle *sched, 108GNUNET_DHT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
110 const struct GNUNET_CONFIGURATION_Handle *cfg,
111 unsigned int ht_len); 109 unsigned int ht_len);
112 110
113 111
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h
index b8df9d7b6..6eb666049 100644
--- a/src/include/gnunet_disk_lib.h
+++ b/src/include/gnunet_disk_lib.h
@@ -496,15 +496,12 @@ int GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator
496 * If a scheduler does not need to be used, GNUNET_DISK_directory_scan 496 * If a scheduler does not need to be used, GNUNET_DISK_directory_scan
497 * may provide a simpler API. 497 * may provide a simpler API.
498 * 498 *
499 * @param sched scheduler to use
500 * @param prio priority to use 499 * @param prio priority to use
501 * @param dirName the name of the directory 500 * @param dirName the name of the directory
502 * @param callback the method to call for each file 501 * @param callback the method to call for each file
503 * @param callback_cls closure for callback 502 * @param callback_cls closure for callback
504 */ 503 */
505void GNUNET_DISK_directory_iterator_start (struct GNUNET_SCHEDULER_Handle 504void GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority
506 *sched,
507 enum GNUNET_SCHEDULER_Priority
508 prio, const char *dirName, 505 prio, const char *dirName,
509 GNUNET_DISK_DirectoryIteratorCallback 506 GNUNET_DISK_DirectoryIteratorCallback
510 callback, void *callback_cls); 507 callback, void *callback_cls);
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h
index 0e5dccc2d..68c250e97 100644
--- a/src/include/gnunet_fs_service.h
+++ b/src/include/gnunet_fs_service.h
@@ -1585,7 +1585,6 @@ struct GNUNET_FS_Handle;
1585/** 1585/**
1586 * Setup a connection to the file-sharing service. 1586 * Setup a connection to the file-sharing service.
1587 * 1587 *
1588 * @param sched scheduler to use
1589 * @param cfg configuration to use 1588 * @param cfg configuration to use
1590 * @param client_name unique identifier for this client 1589 * @param client_name unique identifier for this client
1591 * @param upcb function to call to notify about FS actions 1590 * @param upcb function to call to notify about FS actions
@@ -1595,8 +1594,7 @@ struct GNUNET_FS_Handle;
1595 * @return NULL on error 1594 * @return NULL on error
1596 */ 1595 */
1597struct GNUNET_FS_Handle * 1596struct GNUNET_FS_Handle *
1598GNUNET_FS_start (struct GNUNET_SCHEDULER_Handle *sched, 1597GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1599 const struct GNUNET_CONFIGURATION_Handle *cfg,
1600 const char *client_name, 1598 const char *client_name,
1601 GNUNET_FS_ProgressCallback upcb, 1599 GNUNET_FS_ProgressCallback upcb,
1602 void *upcb_cls, 1600 void *upcb_cls,
diff --git a/src/include/gnunet_nat_lib.h b/src/include/gnunet_nat_lib.h
index 9c6e171b6..c1080c586 100644
--- a/src/include/gnunet_nat_lib.h
+++ b/src/include/gnunet_nat_lib.h
@@ -57,7 +57,6 @@ struct GNUNET_NAT_Handle;
57 * of the local host's addresses should the external port be mapped. The port 57 * of the local host's addresses should the external port be mapped. The port
58 * is taken from the corresponding sockaddr_in[6] field. 58 * is taken from the corresponding sockaddr_in[6] field.
59 * 59 *
60 * @param sched the sheduler used in the program
61 * @param addr the local address packets should be redirected to 60 * @param addr the local address packets should be redirected to
62 * @param addrlen actual lenght of the address 61 * @param addrlen actual lenght of the address
63 * @param callback function to call everytime the public IP address changes 62 * @param callback function to call everytime the public IP address changes
@@ -65,8 +64,7 @@ struct GNUNET_NAT_Handle;
65 * @return NULL on error, otherwise handle that can be used to unregister 64 * @return NULL on error, otherwise handle that can be used to unregister
66 */ 65 */
67struct GNUNET_NAT_Handle * 66struct GNUNET_NAT_Handle *
68GNUNET_NAT_register (struct GNUNET_SCHEDULER_Handle *sched, 67GNUNET_NAT_register (const struct sockaddr *addr,
69 const struct sockaddr *addr,
70 socklen_t addrlen, 68 socklen_t addrlen,
71 GNUNET_NAT_AddressCallback callback, 69 GNUNET_NAT_AddressCallback callback,
72 void *callback_cls); 70 void *callback_cls);
diff --git a/src/include/gnunet_peerinfo_service.h b/src/include/gnunet_peerinfo_service.h
index d88c6fb41..228e698b3 100644
--- a/src/include/gnunet_peerinfo_service.h
+++ b/src/include/gnunet_peerinfo_service.h
@@ -50,14 +50,12 @@ struct GNUNET_PEERINFO_Handle;
50/** 50/**
51 * Connect to the peerinfo service. 51 * Connect to the peerinfo service.
52 * 52 *
53 * @param sched scheduler to use
54 * @param cfg configuration to use 53 * @param cfg configuration to use
55 * @return NULL on error (configuration related, actual connection 54 * @return NULL on error (configuration related, actual connection
56 * etablishment may happen asynchronously). 55 * etablishment may happen asynchronously).
57 */ 56 */
58struct GNUNET_PEERINFO_Handle * 57struct GNUNET_PEERINFO_Handle *
59GNUNET_PEERINFO_connect (struct GNUNET_SCHEDULER_Handle *sched, 58GNUNET_PEERINFO_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
60 const struct GNUNET_CONFIGURATION_Handle *cfg);
61 59
62 60
63 61
@@ -164,14 +162,12 @@ struct GNUNET_PEERINFO_NotifyContext;
164 * twice with the same peer information. 162 * twice with the same peer information.
165 * 163 *
166 * @param cfg configuration to use 164 * @param cfg configuration to use
167 * @param sched scheduler to use
168 * @param callback the method to call for each peer 165 * @param callback the method to call for each peer
169 * @param callback_cls closure for callback 166 * @param callback_cls closure for callback
170 * @return NULL on error 167 * @return NULL on error
171 */ 168 */
172struct GNUNET_PEERINFO_NotifyContext * 169struct GNUNET_PEERINFO_NotifyContext *
173GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg, 170GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg,
174 struct GNUNET_SCHEDULER_Handle *sched,
175 GNUNET_PEERINFO_Processor callback, 171 GNUNET_PEERINFO_Processor callback,
176 void *callback_cls); 172 void *callback_cls);
177 173
diff --git a/src/include/gnunet_program_lib.h b/src/include/gnunet_program_lib.h
index a44f4f11e..b01703f05 100644
--- a/src/include/gnunet_program_lib.h
+++ b/src/include/gnunet_program_lib.h
@@ -43,13 +43,11 @@ extern "C"
43 * Main function that will be run. 43 * Main function that will be run.
44 * 44 *
45 * @param cls closure 45 * @param cls closure
46 * @param sched the scheduler to use
47 * @param args remaining command-line arguments 46 * @param args remaining command-line arguments
48 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 47 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
49 * @param cfg configuration 48 * @param cfg configuration
50 */ 49 */
51typedef void (*GNUNET_PROGRAM_Main) (void *cls, 50typedef void (*GNUNET_PROGRAM_Main) (void *cls,
52 struct GNUNET_SCHEDULER_Handle * sched,
53 char *const *args, 51 char *const *args,
54 const char *cfgfile, 52 const char *cfgfile,
55 const struct GNUNET_CONFIGURATION_Handle * 53 const struct GNUNET_CONFIGURATION_Handle *
diff --git a/src/include/gnunet_resolver_service.h b/src/include/gnunet_resolver_service.h
index b55ca2f56..79f703553 100644
--- a/src/include/gnunet_resolver_service.h
+++ b/src/include/gnunet_resolver_service.h
@@ -62,7 +62,6 @@ struct GNUNET_RESOLVER_RequestHandle;
62/** 62/**
63 * Convert a string to one or more IP addresses. 63 * Convert a string to one or more IP addresses.
64 * 64 *
65 * @param sched scheduler to use
66 * @param cfg configuration to use 65 * @param cfg configuration to use
67 * @param hostname the hostname to resolve 66 * @param hostname the hostname to resolve
68 * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any" 67 * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any"
@@ -72,8 +71,7 @@ struct GNUNET_RESOLVER_RequestHandle;
72 * @return handle that can be used to cancel the request, NULL on error 71 * @return handle that can be used to cancel the request, NULL on error
73 */ 72 */
74struct GNUNET_RESOLVER_RequestHandle * 73struct GNUNET_RESOLVER_RequestHandle *
75GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, 74GNUNET_RESOLVER_ip_get (const struct GNUNET_CONFIGURATION_Handle *cfg,
76 const struct GNUNET_CONFIGURATION_Handle *cfg,
77 const char *hostname, 75 const char *hostname,
78 int domain, 76 int domain,
79 struct GNUNET_TIME_Relative timeout, 77 struct GNUNET_TIME_Relative timeout,
@@ -84,7 +82,6 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched,
84/** 82/**
85 * Resolve our hostname to an IP address. 83 * Resolve our hostname to an IP address.
86 * 84 *
87 * @param sched scheduler to use
88 * @param cfg configuration to use 85 * @param cfg configuration to use
89 * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any" 86 * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any"
90 * @param callback function to call with addresses 87 * @param callback function to call with addresses
@@ -93,8 +90,7 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched,
93 * @return handle that can be used to cancel the request, NULL on error 90 * @return handle that can be used to cancel the request, NULL on error
94 */ 91 */
95struct GNUNET_RESOLVER_RequestHandle * 92struct GNUNET_RESOLVER_RequestHandle *
96GNUNET_RESOLVER_hostname_resolve (struct GNUNET_SCHEDULER_Handle *sched, 93GNUNET_RESOLVER_hostname_resolve (const struct GNUNET_CONFIGURATION_Handle *cfg,
97 const struct GNUNET_CONFIGURATION_Handle *cfg,
98 int domain, 94 int domain,
99 struct GNUNET_TIME_Relative timeout, 95 struct GNUNET_TIME_Relative timeout,
100 GNUNET_RESOLVER_AddressCallback callback, 96 GNUNET_RESOLVER_AddressCallback callback,
@@ -123,7 +119,6 @@ GNUNET_RESOLVER_local_fqdn_get ( void );
123/** 119/**
124 * Perform a reverse DNS lookup. 120 * Perform a reverse DNS lookup.
125 * 121 *
126 * @param sched scheduler to use
127 * @param cfg configuration to use 122 * @param cfg configuration to use
128 * @param sa host address 123 * @param sa host address
129 * @param salen length of host address 124 * @param salen length of host address
@@ -134,8 +129,7 @@ GNUNET_RESOLVER_local_fqdn_get ( void );
134 * @return handle that can be used to cancel the request, NULL on error 129 * @return handle that can be used to cancel the request, NULL on error
135 */ 130 */
136struct GNUNET_RESOLVER_RequestHandle * 131struct GNUNET_RESOLVER_RequestHandle *
137GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, 132GNUNET_RESOLVER_hostname_get (const struct GNUNET_CONFIGURATION_Handle *cfg,
138 const struct GNUNET_CONFIGURATION_Handle *cfg,
139 const struct sockaddr *sa, 133 const struct sockaddr *sa,
140 socklen_t salen, 134 socklen_t salen,
141 int do_resolve, 135 int do_resolve,
diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h
index b39feb926..774f2f4bc 100644
--- a/src/include/gnunet_scheduler_lib.h
+++ b/src/include/gnunet_scheduler_lib.h
@@ -35,12 +35,6 @@ extern "C"
35#endif 35#endif
36#endif 36#endif
37 37
38
39/**
40 * Opaque handle for the scheduling service.
41 */
42struct GNUNET_SCHEDULER_Handle;
43
44/** 38/**
45 * Opaque reference to a task. 39 * Opaque reference to a task.
46 */ 40 */
@@ -167,12 +161,6 @@ enum GNUNET_SCHEDULER_Priority
167 */ 161 */
168struct GNUNET_SCHEDULER_TaskContext 162struct GNUNET_SCHEDULER_TaskContext
169{ 163{
170
171 /**
172 * Scheduler running the task
173 */
174 struct GNUNET_SCHEDULER_Handle *sched;
175
176 /** 164 /**
177 * Reason why the task is run now 165 * Reason why the task is run now
178 */ 166 */
@@ -229,10 +217,8 @@ void GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls);
229 * cause all tasks to run (as soon as possible, respecting 217 * cause all tasks to run (as soon as possible, respecting
230 * priorities and prerequisite tasks). Note that tasks 218 * priorities and prerequisite tasks). Note that tasks
231 * scheduled AFTER this call may still be delayed arbitrarily. 219 * scheduled AFTER this call may still be delayed arbitrarily.
232 *
233 * @param sched the scheduler
234 */ 220 */
235void GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched); 221void GNUNET_SCHEDULER_shutdown ();
236 222
237 223
238/** 224/**
@@ -241,14 +227,12 @@ void GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched);
241 * dropped (if the decision should be made based on the number of 227 * dropped (if the decision should be made based on the number of
242 * tasks ready to run). 228 * tasks ready to run).
243 * 229 *
244 * @param sched scheduler to query 230 * * @param p priority-level to query, use KEEP to query the level
245 * @param p priority-level to query, use KEEP to query the level
246 * of the current task, use COUNT to get the sum over 231 * of the current task, use COUNT to get the sum over
247 * all priority levels 232 * all priority levels
248 * @return number of tasks pending right now 233 * @return number of tasks pending right now
249 */ 234 */
250unsigned int GNUNET_SCHEDULER_get_load (struct GNUNET_SCHEDULER_Handle *sched, 235unsigned int GNUNET_SCHEDULER_get_load (enum GNUNET_SCHEDULER_Priority p);
251 enum GNUNET_SCHEDULER_Priority p);
252 236
253 237
254/** 238/**
@@ -256,23 +240,20 @@ unsigned int GNUNET_SCHEDULER_get_load (struct GNUNET_SCHEDULER_Handle *sched,
256 * started. Will return the same value as 240 * started. Will return the same value as
257 * the GNUNET_SCHEDULER_TaskContext's reason field. 241 * the GNUNET_SCHEDULER_TaskContext's reason field.
258 * 242 *
259 * @param sched scheduler to query 243 * * @return reason(s) why the current task is run
260 * @return reason(s) why the current task is run
261 */ 244 */
262enum GNUNET_SCHEDULER_Reason 245enum GNUNET_SCHEDULER_Reason
263GNUNET_SCHEDULER_get_reason (struct GNUNET_SCHEDULER_Handle *sched); 246GNUNET_SCHEDULER_get_reason ();
264 247
265 248
266/** 249/**
267 * Cancel the task with the specified identifier. 250 * Cancel the task with the specified identifier.
268 * The task must not yet have run. 251 * The task must not yet have run.
269 * 252 *
270 * @param sched scheduler to use 253 * * @param task id of the task to cancel
271 * @param task id of the task to cancel
272 * @return the closure of the callback of the cancelled task 254 * @return the closure of the callback of the cancelled task
273 */ 255 */
274void *GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched, 256void *GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_TaskIdentifier task);
275 GNUNET_SCHEDULER_TaskIdentifier task);
276 257
277 258
278/** 259/**
@@ -280,14 +261,12 @@ void *GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched,
280 * similar to the other "add" functions except that there is no delay 261 * similar to the other "add" functions except that there is no delay
281 * and the reason code can be specified. 262 * and the reason code can be specified.
282 * 263 *
283 * @param sched scheduler to use 264 * * @param task main function of the task
284 * @param task main function of the task
285 * @param task_cls closure of task 265 * @param task_cls closure of task
286 * @param reason reason for task invocation 266 * @param reason reason for task invocation
287 */ 267 */
288void 268void
289GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched, 269GNUNET_SCHEDULER_add_continuation (GNUNET_SCHEDULER_Task task,
290 GNUNET_SCHEDULER_Task task,
291 void *task_cls, 270 void *task_cls,
292 enum GNUNET_SCHEDULER_Reason reason); 271 enum GNUNET_SCHEDULER_Reason reason);
293 272
@@ -297,8 +276,7 @@ GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched,
297 * has completed. It will be run with the priority of the calling 276 * has completed. It will be run with the priority of the calling
298 * task. 277 * task.
299 * 278 *
300 * @param sched scheduler to use 279 * * @param prerequisite_task run this task after the task with the given
301 * @param prerequisite_task run this task after the task with the given
302 * task identifier completes (and any of our other 280 * task identifier completes (and any of our other
303 * conditions, such as delay, read or write-readiness 281 * conditions, such as delay, read or write-readiness
304 * 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
@@ -310,8 +288,7 @@ GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched,
310 * only valid until "task" is started! 288 * only valid until "task" is started!
311 */ 289 */
312GNUNET_SCHEDULER_TaskIdentifier 290GNUNET_SCHEDULER_TaskIdentifier
313GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched, 291GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_TaskIdentifier prerequisite_task,
314 GNUNET_SCHEDULER_TaskIdentifier prerequisite_task,
315 GNUNET_SCHEDULER_Task task, 292 GNUNET_SCHEDULER_Task task,
316 void *task_cls); 293 void *task_cls);
317 294
@@ -319,16 +296,14 @@ GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched,
319/** 296/**
320 * Schedule a new task to be run with a specified priority. 297 * Schedule a new task to be run with a specified priority.
321 * 298 *
322 * @param sched scheduler to use 299 * * @param prio how important is the new task?
323 * @param prio how important is the new task?
324 * @param task main function of the task 300 * @param task main function of the task
325 * @param task_cls closure of task 301 * @param task_cls closure of task
326 * @return unique task identifier for the job 302 * @return unique task identifier for the job
327 * only valid until "task" is started! 303 * only valid until "task" is started!
328 */ 304 */
329GNUNET_SCHEDULER_TaskIdentifier 305GNUNET_SCHEDULER_TaskIdentifier
330GNUNET_SCHEDULER_add_with_priority (struct GNUNET_SCHEDULER_Handle *sched, 306GNUNET_SCHEDULER_add_with_priority (enum GNUNET_SCHEDULER_Priority prio,
331 enum GNUNET_SCHEDULER_Priority prio,
332 GNUNET_SCHEDULER_Task task, 307 GNUNET_SCHEDULER_Task task,
333 void *task_cls); 308 void *task_cls);
334 309
@@ -337,15 +312,13 @@ GNUNET_SCHEDULER_add_with_priority (struct GNUNET_SCHEDULER_Handle *sched,
337 * Schedule a new task to be run as soon as possible. The task 312 * Schedule a new task to be run as soon as possible. The task
338 * will be run with the priority of the calling task. 313 * will be run with the priority of the calling task.
339 * 314 *
340 * @param sched scheduler to use 315 * * @param task main function of the task
341 * @param task main function of the task
342 * @param task_cls closure of task 316 * @param task_cls closure of task
343 * @return unique task identifier for the job 317 * @return unique task identifier for the job
344 * only valid until "task" is started! 318 * only valid until "task" is started!
345 */ 319 */
346GNUNET_SCHEDULER_TaskIdentifier 320GNUNET_SCHEDULER_TaskIdentifier
347GNUNET_SCHEDULER_add_now (struct GNUNET_SCHEDULER_Handle *sched, 321GNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_Task task,
348 GNUNET_SCHEDULER_Task task,
349 void *task_cls); 322 void *task_cls);
350 323
351 324
@@ -354,8 +327,7 @@ GNUNET_SCHEDULER_add_now (struct GNUNET_SCHEDULER_Handle *sched,
354 * will be scheduled for execution once the delay has expired. It 327 * will be scheduled for execution once the delay has expired. It
355 * will be run with the priority of the calling task. 328 * will be run with the priority of the calling task.
356 * 329 *
357 * @param sched scheduler to use 330 * * @param delay when should this operation time out? Use
358 * @param delay when should this operation time out? Use
359 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" 331 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
360 * @param task main function of the task 332 * @param task main function of the task
361 * @param task_cls closure of task 333 * @param task_cls closure of task
@@ -363,8 +335,7 @@ GNUNET_SCHEDULER_add_now (struct GNUNET_SCHEDULER_Handle *sched,
363 * only valid until "task" is started! 335 * only valid until "task" is started!
364 */ 336 */
365GNUNET_SCHEDULER_TaskIdentifier 337GNUNET_SCHEDULER_TaskIdentifier
366GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle *sched, 338GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay,
367 struct GNUNET_TIME_Relative delay,
368 GNUNET_SCHEDULER_Task task, 339 GNUNET_SCHEDULER_Task task,
369 void *task_cls); 340 void *task_cls);
370 341
@@ -377,8 +348,7 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle *sched,
377 * socket operation is ready. It will be run with the priority of 348 * socket operation is ready. It will be run with the priority of
378 * the calling task. 349 * the calling task.
379 * 350 *
380 * @param sched scheduler to use 351 * * @param delay when should this operation time out? Use
381 * @param delay when should this operation time out? Use
382 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" 352 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
383 * @param rfd read file-descriptor 353 * @param rfd read file-descriptor
384 * @param task main function of the task 354 * @param task main function of the task
@@ -387,8 +357,7 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle *sched,
387 * only valid until "task" is started! 357 * only valid until "task" is started!
388 */ 358 */
389GNUNET_SCHEDULER_TaskIdentifier 359GNUNET_SCHEDULER_TaskIdentifier
390GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle *sched, 360GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay,
391 struct GNUNET_TIME_Relative delay,
392 struct GNUNET_NETWORK_Handle *rfd, 361 struct GNUNET_NETWORK_Handle *rfd,
393 GNUNET_SCHEDULER_Task task, 362 GNUNET_SCHEDULER_Task task,
394 void *task_cls); 363 void *task_cls);
@@ -402,8 +371,7 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle *sched,
402 * socket operation is ready. It will be run with the priority of 371 * socket operation is ready. It will be run with the priority of
403 * the calling task. 372 * the calling task.
404 * 373 *
405 * @param sched scheduler to use 374 * * @param delay when should this operation time out? Use
406 * @param delay when should this operation time out? Use
407 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" 375 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
408 * @param wfd write file-descriptor 376 * @param wfd write file-descriptor
409 * @param task main function of the task 377 * @param task main function of the task
@@ -412,8 +380,7 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle *sched,
412 * only valid until "task" is started! 380 * only valid until "task" is started!
413 */ 381 */
414GNUNET_SCHEDULER_TaskIdentifier 382GNUNET_SCHEDULER_TaskIdentifier
415GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle *sched, 383GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay,
416 struct GNUNET_TIME_Relative delay,
417 struct GNUNET_NETWORK_Handle *wfd, 384 struct GNUNET_NETWORK_Handle *wfd,
418 GNUNET_SCHEDULER_Task task, 385 GNUNET_SCHEDULER_Task task,
419 void *task_cls); 386 void *task_cls);
@@ -427,8 +394,7 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle *sched,
427 * socket operation is ready. It will be run with the priority of 394 * socket operation is ready. It will be run with the priority of
428 * the calling task. 395 * the calling task.
429 * 396 *
430 * @param sched scheduler to use 397 * * @param delay when should this operation time out? Use
431 * @param delay when should this operation time out? Use
432 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" 398 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
433 * @param rfd read file-descriptor 399 * @param rfd read file-descriptor
434 * @param task main function of the task 400 * @param task main function of the task
@@ -437,8 +403,7 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle *sched,
437 * only valid until "task" is started! 403 * only valid until "task" is started!
438 */ 404 */
439GNUNET_SCHEDULER_TaskIdentifier 405GNUNET_SCHEDULER_TaskIdentifier
440GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle *sched, 406GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay,
441 struct GNUNET_TIME_Relative delay,
442 const struct GNUNET_DISK_FileHandle *rfd, 407 const struct GNUNET_DISK_FileHandle *rfd,
443 GNUNET_SCHEDULER_Task task, 408 GNUNET_SCHEDULER_Task task,
444 void *task_cls); 409 void *task_cls);
@@ -452,8 +417,7 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle *sched,
452 * socket operation is ready. It will be run with the priority of 417 * socket operation is ready. It will be run with the priority of
453 * the calling task. 418 * the calling task.
454 * 419 *
455 * @param sched scheduler to use 420 * * @param delay when should this operation time out? Use
456 * @param delay when should this operation time out? Use
457 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" 421 * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
458 * @param wfd write file-descriptor 422 * @param wfd write file-descriptor
459 * @param task main function of the task 423 * @param task main function of the task
@@ -462,8 +426,7 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle *sched,
462 * only valid until "task" is started! 426 * only valid until "task" is started!
463 */ 427 */
464GNUNET_SCHEDULER_TaskIdentifier 428GNUNET_SCHEDULER_TaskIdentifier
465GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle *sched, 429GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay,
466 struct GNUNET_TIME_Relative delay,
467 const struct GNUNET_DISK_FileHandle *wfd, 430 const struct GNUNET_DISK_FileHandle *wfd,
468 GNUNET_SCHEDULER_Task task, 431 GNUNET_SCHEDULER_Task task,
469 void *task_cls); 432 void *task_cls);
@@ -486,8 +449,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle *sched,
486 * || shutdown-active) 449 * || shutdown-active)
487 * </code> 450 * </code>
488 * 451 *
489 * @param sched scheduler to use 452 * * @param prio how important is this task?
490 * @param prio how important is this task?
491 * @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
492 * task identifier completes (and any of our other 454 * task identifier completes (and any of our other
493 * conditions, such as delay, read or write-readiness 455 * conditions, such as delay, read or write-readiness
@@ -503,8 +465,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle *sched,
503 * only valid until "task" is started! 465 * only valid until "task" is started!
504 */ 466 */
505GNUNET_SCHEDULER_TaskIdentifier 467GNUNET_SCHEDULER_TaskIdentifier
506GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle *sched, 468GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio,
507 enum GNUNET_SCHEDULER_Priority prio,
508 GNUNET_SCHEDULER_TaskIdentifier 469 GNUNET_SCHEDULER_TaskIdentifier
509 prerequisite_task, 470 prerequisite_task,
510 struct GNUNET_TIME_Relative delay, 471 struct GNUNET_TIME_Relative delay,
diff --git a/src/include/gnunet_server_lib.h b/src/include/gnunet_server_lib.h
index 20ed78bab..6f671754d 100644
--- a/src/include/gnunet_server_lib.h
+++ b/src/include/gnunet_server_lib.h
@@ -115,7 +115,6 @@ struct GNUNET_SERVER_MessageHandler
115/** 115/**
116 * Create a new server. 116 * Create a new server.
117 * 117 *
118 * @param sched scheduler to use
119 * @param access function for access control 118 * @param access function for access control
120 * @param access_cls closure for access 119 * @param access_cls closure for access
121 * @param lsocks NULL-terminated array of listen sockets 120 * @param lsocks NULL-terminated array of listen sockets
@@ -126,8 +125,7 @@ struct GNUNET_SERVER_MessageHandler
126 * (typically, "port" already in use) 125 * (typically, "port" already in use)
127 */ 126 */
128struct GNUNET_SERVER_Handle * 127struct GNUNET_SERVER_Handle *
129GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched, 128GNUNET_SERVER_create_with_sockets (GNUNET_CONNECTION_AccessCheck access, void *access_cls,
130 GNUNET_CONNECTION_AccessCheck access, void *access_cls,
131 struct GNUNET_NETWORK_Handle **lsocks, 129 struct GNUNET_NETWORK_Handle **lsocks,
132 struct GNUNET_TIME_Relative 130 struct GNUNET_TIME_Relative
133 idle_timeout, 131 idle_timeout,
@@ -136,7 +134,6 @@ GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched,
136/** 134/**
137 * Create a new server. 135 * Create a new server.
138 * 136 *
139 * @param sched scheduler to use
140 * @param access function for access control 137 * @param access function for access control
141 * @param access_cls closure for access 138 * @param access_cls closure for access
142 * @param serverAddr address toes listen on (including port), NULL terminated array 139 * @param serverAddr address toes listen on (including port), NULL terminated array
@@ -147,10 +144,7 @@ GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched,
147 * @return handle for the new server, NULL on error 144 * @return handle for the new server, NULL on error
148 * (typically, "port" already in use) 145 * (typically, "port" already in use)
149 */ 146 */
150struct GNUNET_SERVER_Handle *GNUNET_SERVER_create (struct 147struct GNUNET_SERVER_Handle *GNUNET_SERVER_create (GNUNET_CONNECTION_AccessCheck
151 GNUNET_SCHEDULER_Handle
152 *sched,
153 GNUNET_CONNECTION_AccessCheck
154 access, void *access_cls, 148 access, void *access_cls,
155 struct sockaddr *const*serverAddr, 149 struct sockaddr *const*serverAddr,
156 const socklen_t *socklen, 150 const socklen_t *socklen,
diff --git a/src/include/gnunet_service_lib.h b/src/include/gnunet_service_lib.h
index c17af065f..883ad462f 100644
--- a/src/include/gnunet_service_lib.h
+++ b/src/include/gnunet_service_lib.h
@@ -71,12 +71,10 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName,
71 * method to run service-specific setup code. 71 * method to run service-specific setup code.
72 * 72 *
73 * @param cls closure 73 * @param cls closure
74 * @param sched scheduler to use
75 * @param server the initialized server 74 * @param server the initialized server
76 * @param cfg configuration to use 75 * @param cfg configuration to use
77 */ 76 */
78typedef void (*GNUNET_SERVICE_Main) (void *cls, 77typedef void (*GNUNET_SERVICE_Main) (void *cls,
79 struct GNUNET_SCHEDULER_Handle * sched,
80 struct GNUNET_SERVER_Handle * server, 78 struct GNUNET_SERVER_Handle * server,
81 const struct GNUNET_CONFIGURATION_Handle * 79 const struct GNUNET_CONFIGURATION_Handle *
82 cfg); 80 cfg);
@@ -128,14 +126,10 @@ struct GNUNET_SERVICE_Context;
128 * initialized system. 126 * initialized system.
129 * 127 *
130 * @param serviceName our service name 128 * @param serviceName our service name
131 * @param sched scheduler to use
132 * @param cfg configuration to use 129 * @param cfg configuration to use
133 * @return NULL on error, service handle 130 * @return NULL on error, service handle
134 */ 131 */
135struct GNUNET_SERVICE_Context *GNUNET_SERVICE_start (const char *serviceName, 132struct GNUNET_SERVICE_Context *GNUNET_SERVICE_start (const char *serviceName,
136 struct
137 GNUNET_SCHEDULER_Handle
138 *sched,
139 const struct 133 const struct
140 GNUNET_CONFIGURATION_Handle 134 GNUNET_CONFIGURATION_Handle
141 *cfg); 135 *cfg);
diff --git a/src/include/gnunet_statistics_service.h b/src/include/gnunet_statistics_service.h
index 71c834f2a..e22fe16d4 100644
--- a/src/include/gnunet_statistics_service.h
+++ b/src/include/gnunet_statistics_service.h
@@ -70,14 +70,12 @@ typedef int (*GNUNET_STATISTICS_Iterator) (void *cls,
70/** 70/**
71 * Get handle for the statistics service. 71 * Get handle for the statistics service.
72 * 72 *
73 * @param sched scheduler to use
74 * @param subsystem name of subsystem using the service 73 * @param subsystem name of subsystem using the service
75 * @param cfg services configuration in use 74 * @param cfg services configuration in use
76 * @return handle to use 75 * @return handle to use
77 */ 76 */
78struct GNUNET_STATISTICS_Handle 77struct GNUNET_STATISTICS_Handle
79 *GNUNET_STATISTICS_create (struct GNUNET_SCHEDULER_Handle *sched, 78 *GNUNET_STATISTICS_create (const char *subsystem,
80 const char *subsystem,
81 const struct GNUNET_CONFIGURATION_Handle *cfg); 79 const struct GNUNET_CONFIGURATION_Handle *cfg);
82 80
83 81
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h
index a00e59976..97bc36a79 100644
--- a/src/include/gnunet_testing_lib.h
+++ b/src/include/gnunet_testing_lib.h
@@ -205,11 +205,6 @@ typedef void (*GNUNET_TESTING_NotifyConnections)(void *cls,
205struct GNUNET_TESTING_Daemon 205struct GNUNET_TESTING_Daemon
206{ 206{
207 /** 207 /**
208 * Our scheduler.
209 */
210 struct GNUNET_SCHEDULER_Handle *sched;
211
212 /**
213 * Our configuration. 208 * Our configuration.
214 */ 209 */
215 struct GNUNET_CONFIGURATION_Handle *cfg; 210 struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -410,7 +405,6 @@ typedef void (*GNUNET_TESTING_NotifyTopology)(void *cls,
410 * reachable via "ssh" (unless the hostname is "NULL") without the 405 * reachable via "ssh" (unless the hostname is "NULL") without the
411 * need to enter a password. 406 * need to enter a password.
412 * 407 *
413 * @param sched scheduler to use
414 * @param cfg configuration to use 408 * @param cfg configuration to use
415 * @param timeout how long to wait starting up peers 409 * @param timeout how long to wait starting up peers
416 * @param hostname name of the machine where to run GNUnet 410 * @param hostname name of the machine where to run GNUnet
@@ -426,8 +420,7 @@ typedef void (*GNUNET_TESTING_NotifyTopology)(void *cls,
426 * @return handle to the daemon (actual start will be completed asynchronously) 420 * @return handle to the daemon (actual start will be completed asynchronously)
427 */ 421 */
428struct GNUNET_TESTING_Daemon * 422struct GNUNET_TESTING_Daemon *
429GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, 423GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
430 const struct GNUNET_CONFIGURATION_Handle *cfg,
431 struct GNUNET_TIME_Relative timeout, 424 struct GNUNET_TIME_Relative timeout,
432 const char *hostname, 425 const char *hostname,
433 const char *ssh_username, 426 const char *ssh_username,
@@ -569,7 +562,6 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
569 * adjusted to ensure that no two peers running on the same system 562 * adjusted to ensure that no two peers running on the same system
570 * have the same port(s) in their respective configurations. 563 * have the same port(s) in their respective configurations.
571 * 564 *
572 * @param sched scheduler to use
573 * @param cfg configuration template to use 565 * @param cfg configuration template to use
574 * @param total number of daemons to start 566 * @param total number of daemons to start
575 * @param timeout total time allowed for peers to start 567 * @param timeout total time allowed for peers to start
@@ -587,8 +579,7 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
587 * @return NULL on error, otherwise handle to control peer group 579 * @return NULL on error, otherwise handle to control peer group
588 */ 580 */
589struct GNUNET_TESTING_PeerGroup * 581struct GNUNET_TESTING_PeerGroup *
590GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, 582GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
591 const struct GNUNET_CONFIGURATION_Handle *cfg,
592 unsigned int total, 583 unsigned int total,
593 struct GNUNET_TIME_Relative timeout, 584 struct GNUNET_TIME_Relative timeout,
594 GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback, 585 GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback,
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h
index 2ee9fb718..eddd8f8af 100644
--- a/src/include/gnunet_transport_service.h
+++ b/src/include/gnunet_transport_service.h
@@ -118,7 +118,6 @@ typedef void
118 * Connect to the transport service. Note that the connection may 118 * Connect to the transport service. Note that the connection may
119 * complete (or fail) asynchronously. 119 * complete (or fail) asynchronously.
120 * 120 *
121 * @param sched scheduler to use
122 * @param cfg configuration to use 121 * @param cfg configuration to use
123 * @param self our own identity (API should check that it matches 122 * @param self our own identity (API should check that it matches
124 * the identity found by transport), or NULL (no check) 123 * the identity found by transport), or NULL (no check)
@@ -128,10 +127,7 @@ typedef void
128 * @param nd function to call on disconnect events 127 * @param nd function to call on disconnect events
129 * @return NULL on error 128 * @return NULL on error
130 */ 129 */
131struct GNUNET_TRANSPORT_Handle *GNUNET_TRANSPORT_connect (struct 130struct GNUNET_TRANSPORT_Handle *GNUNET_TRANSPORT_connect (const struct
132 GNUNET_SCHEDULER_Handle
133 *sched,
134 const struct
135 GNUNET_CONFIGURATION_Handle 131 GNUNET_CONFIGURATION_Handle
136 *cfg, 132 *cfg,
137 const struct GNUNET_PeerIdentity *self, 133 const struct GNUNET_PeerIdentity *self,
@@ -278,7 +274,6 @@ GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
278/** 274/**
279 * Convert a binary address into a human readable address. 275 * Convert a binary address into a human readable address.
280 * 276 *
281 * @param sched scheduler to use
282 * @param cfg configuration to use 277 * @param cfg configuration to use
283 * @param address address to convert (binary format) 278 * @param address address to convert (binary format)
284 * @param addressLen number of bytes in address 279 * @param addressLen number of bytes in address
@@ -290,8 +285,7 @@ GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
290 * @param aluc_cls closure for aluc 285 * @param aluc_cls closure for aluc
291 */ 286 */
292void 287void
293GNUNET_TRANSPORT_address_lookup (struct GNUNET_SCHEDULER_Handle *sched, 288GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg,
294 const struct GNUNET_CONFIGURATION_Handle *cfg,
295 const char * address, 289 const char * address,
296 size_t addressLen, 290 size_t addressLen,
297 int numeric, 291 int numeric,
@@ -328,15 +322,13 @@ typedef int (*GNUNET_TRANSPORT_BlacklistCallback)(void *cls,
328 * only way to re-enable connections from peers that were previously 322 * only way to re-enable connections from peers that were previously
329 * blacklisted. 323 * blacklisted.
330 * 324 *
331 * @param sched scheduler to use
332 * @param cfg configuration to use 325 * @param cfg configuration to use
333 * @param cb callback to invoke to check if connections are allowed 326 * @param cb callback to invoke to check if connections are allowed
334 * @param cb_cls closure for cb 327 * @param cb_cls closure for cb
335 * @return NULL on error, otherwise handle for cancellation 328 * @return NULL on error, otherwise handle for cancellation
336 */ 329 */
337struct GNUNET_TRANSPORT_Blacklist * 330struct GNUNET_TRANSPORT_Blacklist *
338GNUNET_TRANSPORT_blacklist (struct GNUNET_SCHEDULER_Handle *sched, 331GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg,
339 const struct GNUNET_CONFIGURATION_Handle *cfg,
340 GNUNET_TRANSPORT_BlacklistCallback cb, 332 GNUNET_TRANSPORT_BlacklistCallback cb,
341 void *cb_cls); 333 void *cb_cls);
342 334
diff --git a/src/include/gnunet_upnp_service.h b/src/include/gnunet_upnp_service.h
index b57f76697..7e6ea5180 100644
--- a/src/include/gnunet_upnp_service.h
+++ b/src/include/gnunet_upnp_service.h
@@ -43,7 +43,6 @@ extern "C"
43 * install a port mapping if possible. The external port 43 * install a port mapping if possible. The external port
44 * will be returned as part of the address. 44 * will be returned as part of the address.
45 * 45 *
46 * @param sched scheduler to use
47 * @param cfg configuration to use 46 * @param cfg configuration to use
48 * @param domain communication domain (i.e. PF_INET or PF_INET6) 47 * @param domain communication domain (i.e. PF_INET or PF_INET6)
49 * @param type communication semantics (SOCK_STREAM, SOCK_DGRAM) 48 * @param type communication semantics (SOCK_STREAM, SOCK_DGRAM)
@@ -55,8 +54,7 @@ extern "C"
55 * function will be called with NULL on error 54 * function will be called with NULL on error
56 * @param cls closure for callback 55 * @param cls closure for callback
57 */ 56 */
58int GNUNET_UPNP_get_ip (struct GNUNET_SCHEDULER_Handle *sched, 57int GNUNET_UPNP_get_ip (struct GNUNET_CONFIGURATION_Handle *cfg,
59 struct GNUNET_CONFIGURATION_Handle *cfg,
60 int domain, 58 int domain,
61 int type, 59 int type,
62 int protocol, 60 int protocol,
diff --git a/src/monkey/gnunet-monkey.c b/src/monkey/gnunet-monkey.c
index d3018cf3e..f3dc238c8 100644
--- a/src/monkey/gnunet-monkey.c
+++ b/src/monkey/gnunet-monkey.c
@@ -115,14 +115,12 @@ int wait_for_stop(mi_h *h)
115 * Main function that will be run by the scheduler. 115 * Main function that will be run by the scheduler.
116 * 116 *
117 * @param cls closure 117 * @param cls closure
118 * @param s the scheduler to use
119 * @param args remaining command-line arguments 118 * @param args remaining command-line arguments
120 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 119 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
121 * @param c configuration 120 * @param c configuration
122 */ 121 */
123static void 122static void
124run (void *cls, 123run (void *cls,
125 struct GNUNET_SCHEDULER_Handle *s,
126 char *const *args, 124 char *const *args,
127 const char *cfgfile, 125 const char *cfgfile,
128 const struct GNUNET_CONFIGURATION_Handle *c) 126 const struct GNUNET_CONFIGURATION_Handle *c)
diff --git a/src/nat/nat.c b/src/nat/nat.c
index 74d08bd6f..eb203265c 100644
--- a/src/nat/nat.c
+++ b/src/nat/nat.c
@@ -54,11 +54,6 @@ struct GNUNET_NAT_Handle
54 struct GNUNET_NAT_NATPMP_Handle *natpmp; 54 struct GNUNET_NAT_NATPMP_Handle *natpmp;
55 55
56 /** 56 /**
57 * Scheduler.
58 */
59 struct GNUNET_SCHEDULER_Handle *sched;
60
61 /**
62 * LAN address as passed by the caller 57 * LAN address as passed by the caller
63 */ 58 */
64 struct sockaddr *local_addr; 59 struct sockaddr *local_addr;
@@ -296,8 +291,7 @@ pulse_cb (struct GNUNET_NAT_Handle *h)
296 notify_change (h, h->ext_addr_natpmp, addrlen, port_mapped); 291 notify_change (h, h->ext_addr_natpmp, addrlen, port_mapped);
297 } 292 }
298 293
299 h->pulse_timer = GNUNET_SCHEDULER_add_delayed (h->sched, 294 h->pulse_timer = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
300 GNUNET_TIME_UNIT_SECONDS,
301 &nat_pulse, h); 295 &nat_pulse, h);
302} 296}
303 297
@@ -372,7 +366,6 @@ nat_pulse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
372 * of the local host's addresses should the external port be mapped. The port 366 * of the local host's addresses should the external port be mapped. The port
373 * is taken from the corresponding sockaddr_in[6] field. 367 * is taken from the corresponding sockaddr_in[6] field.
374 * 368 *
375 * @param sched the sheduler used in the program
376 * @param addr the local address packets should be redirected to 369 * @param addr the local address packets should be redirected to
377 * @param addrlen actual lenght of the address 370 * @param addrlen actual lenght of the address
378 * @param callback function to call everytime the public IP address changes 371 * @param callback function to call everytime the public IP address changes
@@ -380,9 +373,7 @@ nat_pulse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
380 * @return NULL on error, otherwise handle that can be used to unregister 373 * @return NULL on error, otherwise handle that can be used to unregister
381 */ 374 */
382struct GNUNET_NAT_Handle * 375struct GNUNET_NAT_Handle *
383GNUNET_NAT_register (struct GNUNET_SCHEDULER_Handle 376GNUNET_NAT_register (const struct sockaddr *addr,
384 *sched,
385 const struct sockaddr *addr,
386 socklen_t addrlen, 377 socklen_t addrlen,
387 GNUNET_NAT_AddressCallback callback, void *callback_cls) 378 GNUNET_NAT_AddressCallback callback, void *callback_cls)
388{ 379{
@@ -408,22 +399,20 @@ GNUNET_NAT_register (struct GNUNET_SCHEDULER_Handle
408 } 399 }
409 } 400 }
410 h->should_change = GNUNET_YES; 401 h->should_change = GNUNET_YES;
411 h->sched = sched;
412 h->is_enabled = GNUNET_YES; 402 h->is_enabled = GNUNET_YES;
413 h->upnp_status = GNUNET_NAT_PORT_UNMAPPED; 403 h->upnp_status = GNUNET_NAT_PORT_UNMAPPED;
414 h->natpmp_status = GNUNET_NAT_PORT_UNMAPPED; 404 h->natpmp_status = GNUNET_NAT_PORT_UNMAPPED;
415 h->callback = callback; 405 h->callback = callback;
416 h->callback_cls = callback_cls; 406 h->callback_cls = callback_cls;
417 h->upnp = 407 h->upnp =
418 GNUNET_NAT_UPNP_init (h->sched, h->local_addr, addrlen, h->public_port, 408 GNUNET_NAT_UPNP_init (h->local_addr, addrlen, h->public_port,
419 &upnp_pulse_cb, h); 409 &upnp_pulse_cb, h);
420#if 0 410#if 0
421 h->natpmp = 411 h->natpmp =
422 GNUNET_NAT_NATPMP_init (h->sched, h->local_addr, addrlen, h->public_port, 412 GNUNET_NAT_NATPMP_init (h->local_addr, addrlen, h->public_port,
423 &natpmp_pulse_cb, h); 413 &natpmp_pulse_cb, h);
424#endif 414#endif
425 h->pulse_timer = GNUNET_SCHEDULER_add_delayed (sched, 415 h->pulse_timer = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
426 GNUNET_TIME_UNIT_SECONDS,
427 &nat_pulse, h); 416 &nat_pulse, h);
428 return h; 417 return h;
429} 418}
@@ -447,7 +436,7 @@ GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h)
447#endif 436#endif
448 437
449 if (GNUNET_SCHEDULER_NO_TASK != h->pulse_timer) 438 if (GNUNET_SCHEDULER_NO_TASK != h->pulse_timer)
450 GNUNET_SCHEDULER_cancel (h->sched, h->pulse_timer); 439 GNUNET_SCHEDULER_cancel (h->pulse_timer);
451 440
452 GNUNET_free_non_null (h->local_addr); 441 GNUNET_free_non_null (h->local_addr);
453 GNUNET_free_non_null (h->ext_addr); 442 GNUNET_free_non_null (h->ext_addr);
diff --git a/src/nat/natpmp.c b/src/nat/natpmp.c
index 79a6bfd33..c6a5604d8 100644
--- a/src/nat/natpmp.c
+++ b/src/nat/natpmp.c
@@ -74,7 +74,6 @@ struct GNUNET_NAT_NATPMP_Handle
74 time_t command_time; 74 time_t command_time;
75 enum NATPMP_state state; 75 enum NATPMP_state state;
76 struct natpmp_t natpmp; 76 struct natpmp_t natpmp;
77 struct GNUNET_SCHEDULER_Handle *sched;
78}; 77};
79 78
80 79
@@ -97,14 +96,12 @@ log_val (const char *func, int ret)
97} 96}
98 97
99struct GNUNET_NAT_NATPMP_Handle * 98struct GNUNET_NAT_NATPMP_Handle *
100GNUNET_NAT_NATPMP_init (struct GNUNET_SCHEDULER_Handle *sched, 99GNUNET_NAT_NATPMP_init (const struct sockaddr *addr, socklen_t addrlen,
101 const struct sockaddr *addr, socklen_t addrlen,
102 u_short port) 100 u_short port)
103{ 101{
104 struct GNUNET_NAT_NATPMP_Handle *nat; 102 struct GNUNET_NAT_NATPMP_Handle *nat;
105 103
106 nat = GNUNET_malloc (sizeof (struct GNUNET_NAT_NATPMP_Handle)); 104 nat = GNUNET_malloc (sizeof (struct GNUNET_NAT_NATPMP_Handle));
107 nat->sched = sched;
108 nat->state = NATPMP_DISCOVER; 105 nat->state = NATPMP_DISCOVER;
109 nat->port = port; 106 nat->port = port;
110 nat->addr = addr; 107 nat->addr = addr;
diff --git a/src/nat/natpmp.h b/src/nat/natpmp.h
index 0c198e203..56d5f0034 100644
--- a/src/nat/natpmp.h
+++ b/src/nat/natpmp.h
@@ -32,10 +32,7 @@
32 32
33struct GNUNET_NAT_NATPMP_Handle; 33struct GNUNET_NAT_NATPMP_Handle;
34 34
35struct GNUNET_NAT_NATPMP_Handle *GNUNET_NAT_NATPMP_init (struct 35struct GNUNET_NAT_NATPMP_Handle *GNUNET_NAT_NATPMP_init (const struct sockaddr
36 GNUNET_SCHEDULER_Handle
37 *sched,
38 const struct sockaddr
39 *addr, 36 *addr,
40 socklen_t addrlen, 37 socklen_t addrlen,
41 unsigned short port); 38 unsigned short port);
diff --git a/src/nat/test_nat.c b/src/nat/test_nat.c
index e42d76b7f..6f2226929 100644
--- a/src/nat/test_nat.c
+++ b/src/nat/test_nat.c
@@ -96,7 +96,6 @@ process_if (void *cls,
96 96
97static void 97static void
98run (void *cls, 98run (void *cls,
99 struct GNUNET_SCHEDULER_Handle *sched,
100 char *const *args, 99 char *const *args,
101 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 100 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
102{ 101{
@@ -128,11 +127,10 @@ run (void *cls,
128 "Requesting NAT redirection from address %s...\n", 127 "Requesting NAT redirection from address %s...\n",
129 GNUNET_a2s (addr, data.addrlen)); 128 GNUNET_a2s (addr, data.addrlen));
130 129
131 nat = GNUNET_NAT_register (sched, addr, data.addrlen, addr_callback, NULL); 130 nat = GNUNET_NAT_register (addr, data.addrlen, addr_callback, NULL);
132 GNUNET_free (addr); 131 GNUNET_free (addr);
133 132
134 GNUNET_SCHEDULER_add_delayed (sched, 133 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
135 GNUNET_TIME_relative_multiply
136 (GNUNET_TIME_UNIT_SECONDS, TIMEOUT), stop, 134 (GNUNET_TIME_UNIT_SECONDS, TIMEOUT), stop,
137 nat); 135 nat);
138} 136}
diff --git a/src/nat/upnp-commands.c b/src/nat/upnp-commands.c
index 09b004968..d9962117d 100644
--- a/src/nat/upnp-commands.c
+++ b/src/nat/upnp-commands.c
@@ -344,7 +344,6 @@ parse_url (const char *url, char *hostname, unsigned short *port, char **path)
344/** 344/**
345 * Send UPnP command to the device identified by url and service. 345 * Send UPnP command to the device identified by url and service.
346 * 346 *
347 * @param sched scheduler to use for network tasks
348 * @param url control URL of the device 347 * @param url control URL of the device
349 * @param service type of the service corresponding to the command 348 * @param service type of the service corresponding to the command
350 * @param action action to send 349 * @param action action to send
@@ -353,8 +352,7 @@ parse_url (const char *url, char *hostname, unsigned short *port, char **path)
353 * @param caller_cls closure to pass to caller_cb 352 * @param caller_cls closure to pass to caller_cb
354 */ 353 */
355void 354void
356UPNP_command_ (struct GNUNET_SCHEDULER_Handle *sched, 355UPNP_command_ (const char *url, const char *service,
357 const char *url, const char *service,
358 const char *action, struct UPNP_Arg_ *args, 356 const char *action, struct UPNP_Arg_ *args,
359 char *buffer, size_t buf_size, 357 char *buffer, size_t buf_size,
360 UPNP_command_cb_ caller_cb, void *caller_cls) 358 UPNP_command_cb_ caller_cb, void *caller_cls)
@@ -470,7 +468,7 @@ UPNP_command_ (struct GNUNET_SCHEDULER_Handle *sched,
470 dest.sin_len = sizeof (dest); 468 dest.sin_len = sizeof (dest);
471#endif 469#endif
472 470
473 s = GNUNET_CONNECTION_create_from_sockaddr (sched, PF_INET, 471 s = GNUNET_CONNECTION_create_from_sockaddr (PF_INET,
474 (struct sockaddr *) &dest, 472 (struct sockaddr *) &dest,
475 sizeof (dest)); 473 sizeof (dest));
476 } 474 }
@@ -482,7 +480,7 @@ UPNP_command_ (struct GNUNET_SCHEDULER_Handle *sched,
482 dest6.sin6_len = sizeof (dest6); 480 dest6.sin6_len = sizeof (dest6);
483#endif 481#endif
484 482
485 s = GNUNET_CONNECTION_create_from_sockaddr (sched, PF_INET6, 483 s = GNUNET_CONNECTION_create_from_sockaddr (PF_INET6,
486 (struct sockaddr *) &dest6, 484 (struct sockaddr *) &dest6,
487 sizeof (dest6)); 485 sizeof (dest6));
488 } 486 }
@@ -602,8 +600,7 @@ get_external_ip_address_receiver (char *response, size_t received, void *data)
602 * 501 Action Failed - See UPnP Device Architecture section on Control. 600 * 501 Action Failed - See UPnP Device Architecture section on Control.
603 */ 601 */
604void 602void
605UPNP_get_external_ip_address_ (struct GNUNET_SCHEDULER_Handle *sched, 603UPNP_get_external_ip_address_ (const char *control_url,
606 const char *control_url,
607 const char *service_type, 604 const char *service_type,
608 UPNP_get_external_ip_address_cb_ caller_cb, 605 UPNP_get_external_ip_address_cb_ caller_cb,
609 void *caller_cls) 606 void *caller_cls)
@@ -620,7 +617,7 @@ UPNP_get_external_ip_address_ (struct GNUNET_SCHEDULER_Handle *sched,
620 617
621 buffer = GNUNET_malloc (UPNP_COMMAND_BUFSIZE); 618 buffer = GNUNET_malloc (UPNP_COMMAND_BUFSIZE);
622 619
623 UPNP_command_ (sched, control_url, service_type, "GetExternalIPAddress", 620 UPNP_command_ (control_url, service_type, "GetExternalIPAddress",
624 NULL, buffer, UPNP_COMMAND_BUFSIZE, 621 NULL, buffer, UPNP_COMMAND_BUFSIZE,
625 (UPNP_command_cb_) get_external_ip_address_receiver, cls); 622 (UPNP_command_cb_) get_external_ip_address_receiver, cls);
626} 623}
@@ -667,8 +664,7 @@ add_delete_port_mapping_receiver (char *response, size_t received, void *data)
667} 664}
668 665
669void 666void
670UPNP_add_port_mapping_ (struct GNUNET_SCHEDULER_Handle *sched, 667UPNP_add_port_mapping_ (const char *control_url, const char *service_type,
671 const char *control_url, const char *service_type,
672 const char *ext_port, 668 const char *ext_port,
673 const char *in_port, 669 const char *in_port,
674 const char *inClient, 670 const char *inClient,
@@ -718,14 +714,13 @@ UPNP_add_port_mapping_ (struct GNUNET_SCHEDULER_Handle *sched,
718 714
719 buffer = GNUNET_malloc (UPNP_COMMAND_BUFSIZE); 715 buffer = GNUNET_malloc (UPNP_COMMAND_BUFSIZE);
720 716
721 UPNP_command_ (sched, control_url, service_type, "AddPortMapping", 717 UPNP_command_ (control_url, service_type, "AddPortMapping",
722 args, buffer, UPNP_COMMAND_BUFSIZE, 718 args, buffer, UPNP_COMMAND_BUFSIZE,
723 add_delete_port_mapping_receiver, cls); 719 add_delete_port_mapping_receiver, cls);
724} 720}
725 721
726void 722void
727UPNP_delete_port_mapping_ (struct GNUNET_SCHEDULER_Handle *sched, 723UPNP_delete_port_mapping_ (const char *control_url, const char *service_type,
728 const char *control_url, const char *service_type,
729 const char *ext_port, const char *proto, 724 const char *ext_port, const char *proto,
730 const char *remoteHost, 725 const char *remoteHost,
731 UPNP_port_mapping_cb_ caller_cb, void *caller_cls) 726 UPNP_port_mapping_cb_ caller_cb, void *caller_cls)
@@ -762,7 +757,7 @@ UPNP_delete_port_mapping_ (struct GNUNET_SCHEDULER_Handle *sched,
762 757
763 buffer = GNUNET_malloc (UPNP_COMMAND_BUFSIZE); 758 buffer = GNUNET_malloc (UPNP_COMMAND_BUFSIZE);
764 759
765 UPNP_command_ (sched, control_url, service_type, 760 UPNP_command_ (control_url, service_type,
766 "DeletePortMapping", 761 "DeletePortMapping",
767 args, buffer, UPNP_COMMAND_BUFSIZE, 762 args, buffer, UPNP_COMMAND_BUFSIZE,
768 add_delete_port_mapping_receiver, cls); 763 add_delete_port_mapping_receiver, cls);
@@ -836,8 +831,7 @@ get_specific_port_mapping_entry_receiver (char *response, size_t received,
836 * the result is returned in the in_client and in_port strings 831 * the result is returned in the in_client and in_port strings
837 * please provide 128 and 6 bytes of data */ 832 * please provide 128 and 6 bytes of data */
838void 833void
839UPNP_get_specific_port_mapping_entry_ (struct GNUNET_SCHEDULER_Handle *sched, 834UPNP_get_specific_port_mapping_entry_ (const char *control_url,
840 const char *control_url,
841 const char *service_type, 835 const char *service_type,
842 const char *ext_port, 836 const char *ext_port,
843 const char *proto, 837 const char *proto,
@@ -874,7 +868,7 @@ UPNP_get_specific_port_mapping_entry_ (struct GNUNET_SCHEDULER_Handle *sched,
874 868
875 buffer = GNUNET_malloc (UPNP_COMMAND_BUFSIZE); 869 buffer = GNUNET_malloc (UPNP_COMMAND_BUFSIZE);
876 870
877 UPNP_command_ (sched, control_url, service_type, 871 UPNP_command_ (control_url, service_type,
878 "GetSpecificPortMappingEntry", 872 "GetSpecificPortMappingEntry",
879 args, buffer, UPNP_COMMAND_BUFSIZE, 873 args, buffer, UPNP_COMMAND_BUFSIZE,
880 get_specific_port_mapping_entry_receiver, cls); 874 get_specific_port_mapping_entry_receiver, cls);
diff --git a/src/nat/upnp-commands.h b/src/nat/upnp-commands.h
index 8e7510dbf..4f3cdc33c 100644
--- a/src/nat/upnp-commands.h
+++ b/src/nat/upnp-commands.h
@@ -94,7 +94,6 @@ typedef void (*UPNP_command_cb_) (char *response, size_t received, void *cls);
94/** 94/**
95 * Send UPnP command to the device identified by url and service. 95 * Send UPnP command to the device identified by url and service.
96 * 96 *
97 * @param sched scheduler to use for network tasks
98 * @param url control URL of the device 97 * @param url control URL of the device
99 * @param service type of the service corresponding to the command 98 * @param service type of the service corresponding to the command
100 * @param action action to send 99 * @param action action to send
@@ -102,8 +101,7 @@ typedef void (*UPNP_command_cb_) (char *response, size_t received, void *cls);
102 * @param caller_cb user callback to trigger when done 101 * @param caller_cb user callback to trigger when done
103 * @param caller_cls closure to pass to caller_cb 102 * @param caller_cls closure to pass to caller_cb
104 */ 103 */
105void UPNP_command_ (struct GNUNET_SCHEDULER_Handle *sched, 104void UPNP_command_ (const char *url, const char *service,
106 const char *url, const char *service,
107 const char *action, struct UPNP_Arg_ *args, 105 const char *action, struct UPNP_Arg_ *args,
108 char *buffer, size_t buf_size, 106 char *buffer, size_t buf_size,
109 UPNP_command_cb_ caller_cb, void *caller_cls); 107 UPNP_command_cb_ caller_cb, void *caller_cls);
@@ -127,15 +125,13 @@ typedef void (*UPNP_get_external_ip_address_cb_) (int error,
127 * Get the IP address associated with the WAN connection of the device. 125 * Get the IP address associated with the WAN connection of the device.
128 * See UPNP_get_external_ip_address_cb_. 126 * See UPNP_get_external_ip_address_cb_.
129 * 127 *
130 * @param sched the scheduler to use for networking
131 * @param control_url the control URL corresponding to service_type on the device 128 * @param control_url the control URL corresponding to service_type on the device
132 * @param service_type service type to call the command on 129 * @param service_type service type to call the command on
133 * @param caller_cb function to call when done 130 * @param caller_cb function to call when done
134 * @param cls closure passed to caller_cb 131 * @param cls closure passed to caller_cb
135 */ 132 */
136void 133void
137UPNP_get_external_ip_address_ (struct GNUNET_SCHEDULER_Handle *sched, 134UPNP_get_external_ip_address_ (const char *control_url,
138 const char *control_url,
139 const char *service_type, 135 const char *service_type,
140 UPNP_get_external_ip_address_cb_ caller_cb, 136 UPNP_get_external_ip_address_cb_ caller_cb,
141 void *caller_cls); 137 void *caller_cls);
@@ -185,7 +181,6 @@ typedef void (*UPNP_port_mapping_cb_) (int error,
185 * Request opening a port on the IGD device. 181 * Request opening a port on the IGD device.
186 * (remote_host is usually NULL because IGDs don't support it.) 182 * (remote_host is usually NULL because IGDs don't support it.)
187 * 183 *
188 * @param sched the scheduler to use for networking
189 * @param control_url the control URL corresponding to service_type on the device 184 * @param control_url the control URL corresponding to service_type on the device
190 * @param service_type service type to call the command on 185 * @param service_type service type to call the command on
191 * @param ext_port port that should be opened on the WAN side 186 * @param ext_port port that should be opened on the WAN side
@@ -197,8 +192,7 @@ typedef void (*UPNP_port_mapping_cb_) (int error,
197 * @param cls closure passed to caller_cb 192 * @param cls closure passed to caller_cb
198 */ 193 */
199void 194void
200UPNP_add_port_mapping_ (struct GNUNET_SCHEDULER_Handle *sched, 195UPNP_add_port_mapping_ (const char *control_url, const char *service_type,
201 const char *control_url, const char *service_type,
202 const char *ext_port, 196 const char *ext_port,
203 const char *in_port, 197 const char *in_port,
204 const char *in_client, 198 const char *in_client,
@@ -212,7 +206,6 @@ UPNP_add_port_mapping_ (struct GNUNET_SCHEDULER_Handle *sched,
212 * used when opening the port. 206 * used when opening the port.
213 * (remote_host is usually NULL because IGDs don't support it.) 207 * (remote_host is usually NULL because IGDs don't support it.)
214 * 208 *
215 * @param sched the scheduler to use for networking
216 * @param control_url the control URL the command was called on 209 * @param control_url the control URL the command was called on
217 * @param service_type service the command was called on 210 * @param service_type service the command was called on
218 * @param in_port port on the gateway on the LAN side which was requested 211 * @param in_port port on the gateway on the LAN side which was requested
@@ -223,8 +216,7 @@ UPNP_add_port_mapping_ (struct GNUNET_SCHEDULER_Handle *sched,
223 * @param cls closure passed to caller_cb 216 * @param cls closure passed to caller_cb
224 */ 217 */
225void 218void
226UPNP_delete_port_mapping_ (struct GNUNET_SCHEDULER_Handle *sched, 219UPNP_delete_port_mapping_ (const char *control_url, const char *service_type,
227 const char *control_url, const char *service_type,
228 const char *ext_port, const char *proto, 220 const char *ext_port, const char *proto,
229 const char *remote_host, 221 const char *remote_host,
230 UPNP_port_mapping_cb_ caller_cb, void *caller_cls); 222 UPNP_port_mapping_cb_ caller_cb, void *caller_cls);
@@ -259,7 +251,6 @@ typedef void (*UPNP_get_specific_port_mapping_entry_cb_) (int error,
259 * Check that a port mapping set up with UPNP_add_port_mapping_() 251 * Check that a port mapping set up with UPNP_add_port_mapping_()
260 * is alive. 252 * is alive.
261 * 253 *
262 * @param sched the scheduler to use for networking
263 * @param control_url the control URL the command was called on 254 * @param control_url the control URL the command was called on
264 * @param service_type service the command was called on 255 * @param service_type service the command was called on
265 * @param in_port port on the gateway on the LAN side which was requested 256 * @param in_port port on the gateway on the LAN side which was requested
@@ -270,8 +261,7 @@ typedef void (*UPNP_get_specific_port_mapping_entry_cb_) (int error,
270 * @param cls closure passed to caller_cb 261 * @param cls closure passed to caller_cb
271 */ 262 */
272void 263void
273UPNP_get_specific_port_mapping_entry_ (struct GNUNET_SCHEDULER_Handle *sched, 264UPNP_get_specific_port_mapping_entry_ (const char *control_url,
274 const char *control_url,
275 const char *service_type, 265 const char *service_type,
276 const char *ext_port, 266 const char *ext_port,
277 const char *proto, 267 const char *proto,
diff --git a/src/nat/upnp-discover.c b/src/nat/upnp-discover.c
index ba9594462..d915fb622 100644
--- a/src/nat/upnp-discover.c
+++ b/src/nat/upnp-discover.c
@@ -86,11 +86,6 @@ typedef void (*download_cb) (char *data, void *cls);
86struct download_cls 86struct download_cls
87{ 87{
88 /** 88 /**
89 * Scheduler used for the download task.
90 */
91 struct GNUNET_SCHEDULER_Handle *sched;
92
93 /**
94 * curl_easy handle. 89 * curl_easy handle.
95 */ 90 */
96 CURL *curl; 91 CURL *curl;
@@ -243,8 +238,7 @@ download_prepare (struct download_cls *cls)
243 GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1); 238 GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1);
244 GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1); 239 GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1);
245 240
246 GNUNET_SCHEDULER_add_select (cls->sched, 241 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
247 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
248 GNUNET_SCHEDULER_NO_TASK, 242 GNUNET_SCHEDULER_NO_TASK,
249 rtime, 243 rtime,
250 grs, 244 grs,
@@ -352,14 +346,12 @@ task_download (struct download_cls *cls,
352/** 346/**
353 * Download description from devices. 347 * Download description from devices.
354 * 348 *
355 * @param sched the scheduler to use for the download task
356 * @param url URL of the file to download 349 * @param url URL of the file to download
357 * @param caller_cb user function to call when done 350 * @param caller_cb user function to call when done
358 * @caller_cls closure to pass to caller_cb 351 * @caller_cls closure to pass to caller_cb
359 */ 352 */
360void 353void
361download_device_description (struct GNUNET_SCHEDULER_Handle *sched, 354download_device_description (char *url, download_cb caller_cb,
362 char *url, download_cb caller_cb,
363 void *caller_cls) 355 void *caller_cls)
364{ 356{
365 CURL *curl; 357 CURL *curl;
@@ -425,7 +417,6 @@ download_device_description (struct GNUNET_SCHEDULER_Handle *sched,
425 url); 417 url);
426#endif 418#endif
427 419
428 cls->sched = sched;
429 cls->curl = curl; 420 cls->curl = curl;
430 cls->multi = multi; 421 cls->multi = multi;
431 cls->url = url; 422 cls->url = url;
@@ -588,11 +579,6 @@ struct UPNP_Dev_
588struct UPNP_discover_cls 579struct UPNP_discover_cls
589{ 580{
590 /** 581 /**
591 * Scheduler to use for networking tasks.
592 */
593 struct GNUNET_SCHEDULER_Handle *sched;
594
595 /**
596 * Remote address used for multicast emission and reception. 582 * Remote address used for multicast emission and reception.
597 */ 583 */
598 struct sockaddr *multicast_addr; 584 struct sockaddr *multicast_addr;
@@ -818,8 +804,7 @@ get_valid_igd_receive (char *desc, void *data)
818 804
819 /* Check whether device is connected */ 805 /* Check whether device is connected */
820 buffer = GNUNET_malloc (UPNP_COMMAND_BUFSIZE); 806 buffer = GNUNET_malloc (UPNP_COMMAND_BUFSIZE);
821 UPNP_command_ (cls->sched, 807 UPNP_command_ (cls->current_dev->control_url,
822 cls->current_dev->control_url,
823 cls->current_dev->data->service_type, 808 cls->current_dev->data->service_type,
824 "GetStatusInfo", NULL, buffer, UPNP_COMMAND_BUFSIZE, 809 "GetStatusInfo", NULL, buffer, UPNP_COMMAND_BUFSIZE,
825 get_valid_igd_connected_cb, cls); 810 get_valid_igd_connected_cb, cls);
@@ -900,7 +885,7 @@ get_valid_igd (struct UPNP_discover_cls *cls)
900 } 885 }
901 886
902 /* There are still devices to ask, go on */ 887 /* There are still devices to ask, go on */
903 download_device_description (cls->sched, cls->current_dev->desc_url, 888 download_device_description (cls->current_dev->desc_url,
904 get_valid_igd_receive, cls); 889 get_valid_igd_receive, cls);
905} 890}
906 891
@@ -999,16 +984,14 @@ discover_recv (void *data, const struct GNUNET_SCHEDULER_TaskContext *tc)
999 GNUNET_NETWORK_fdset_zero (cls->fdset); 984 GNUNET_NETWORK_fdset_zero (cls->fdset);
1000 GNUNET_NETWORK_fdset_set (cls->fdset, cls->sudp); 985 GNUNET_NETWORK_fdset_set (cls->fdset, cls->sudp);
1001 986
1002 task_w = GNUNET_SCHEDULER_add_select (cls->sched, 987 task_w = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1003 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1004 GNUNET_SCHEDULER_NO_TASK, 988 GNUNET_SCHEDULER_NO_TASK,
1005 GNUNET_TIME_relative_multiply 989 GNUNET_TIME_relative_multiply
1006 (GNUNET_TIME_UNIT_SECONDS, 15), 990 (GNUNET_TIME_UNIT_SECONDS, 15),
1007 NULL, cls->fdset, &discover_send, 991 NULL, cls->fdset, &discover_send,
1008 cls); 992 cls);
1009 993
1010 GNUNET_SCHEDULER_add_select (cls->sched, 994 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1011 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1012 task_w, 995 task_w,
1013 GNUNET_TIME_relative_multiply 996 GNUNET_TIME_relative_multiply
1014 (GNUNET_TIME_UNIT_SECONDS, 5), cls->fdset, 997 (GNUNET_TIME_UNIT_SECONDS, 5), cls->fdset,
@@ -1079,15 +1062,13 @@ discover_send (void *data, const struct GNUNET_SCHEDULER_TaskContext *tc)
1079 * If several devices are found, a device that is connected to the WAN 1062 * If several devices are found, a device that is connected to the WAN
1080 * is returned first (if any). 1063 * is returned first (if any).
1081 * 1064 *
1082 * @param sched scheduler to use for network tasks
1083 * @param multicastif network interface to send discovery messages, or NULL 1065 * @param multicastif network interface to send discovery messages, or NULL
1084 * @param addr address used to send messages on multicastif, or NULL 1066 * @param addr address used to send messages on multicastif, or NULL
1085 * @param caller_cb user function to call when done 1067 * @param caller_cb user function to call when done
1086 * @param caller_cls closure to pass to caller_cb 1068 * @param caller_cls closure to pass to caller_cb
1087 */ 1069 */
1088void 1070void
1089UPNP_discover_ (struct GNUNET_SCHEDULER_Handle *sched, 1071UPNP_discover_ (const char *multicastif,
1090 const char *multicastif,
1091 const struct sockaddr *addr, 1072 const struct sockaddr *addr,
1092 UPNP_discover_cb_ caller_cb, void *caller_cls) 1073 UPNP_discover_cb_ caller_cb, void *caller_cls)
1093{ 1074{
@@ -1129,7 +1110,6 @@ UPNP_discover_ (struct GNUNET_SCHEDULER_Handle *sched,
1129 1110
1130 1111
1131 cls = GNUNET_malloc (sizeof (struct UPNP_discover_cls)); 1112 cls = GNUNET_malloc (sizeof (struct UPNP_discover_cls));
1132 cls->sched = sched;
1133 cls->sudp = sudp; 1113 cls->sudp = sudp;
1134 cls->type_index = 0; 1114 cls->type_index = 0;
1135 cls->dev_list = NULL; 1115 cls->dev_list = NULL;
@@ -1270,15 +1250,13 @@ UPNP_discover_ (struct GNUNET_SCHEDULER_Handle *sched,
1270 GNUNET_NETWORK_fdset_zero (cls->fdset); 1250 GNUNET_NETWORK_fdset_zero (cls->fdset);
1271 GNUNET_NETWORK_fdset_set (cls->fdset, sudp); 1251 GNUNET_NETWORK_fdset_set (cls->fdset, sudp);
1272 1252
1273 task_w = GNUNET_SCHEDULER_add_select (sched, 1253 task_w = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1274 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1275 GNUNET_SCHEDULER_NO_TASK, 1254 GNUNET_SCHEDULER_NO_TASK,
1276 GNUNET_TIME_relative_multiply 1255 GNUNET_TIME_relative_multiply
1277 (GNUNET_TIME_UNIT_SECONDS, 15), NULL, 1256 (GNUNET_TIME_UNIT_SECONDS, 15), NULL,
1278 cls->fdset, &discover_send, cls); 1257 cls->fdset, &discover_send, cls);
1279 1258
1280 GNUNET_SCHEDULER_add_select (sched, 1259 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1281 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1282 task_w, 1260 task_w,
1283 GNUNET_TIME_relative_multiply 1261 GNUNET_TIME_relative_multiply
1284 (GNUNET_TIME_UNIT_SECONDS, 15), cls->fdset, 1262 (GNUNET_TIME_UNIT_SECONDS, 15), cls->fdset,
diff --git a/src/nat/upnp-discover.h b/src/nat/upnp-discover.h
index 2e996cd88..39b704bcf 100644
--- a/src/nat/upnp-discover.h
+++ b/src/nat/upnp-discover.h
@@ -70,14 +70,12 @@ typedef void (*UPNP_discover_cb_) (const char *control_urls,
70 * If several devices are found, a device that is connected to the WAN 70 * If several devices are found, a device that is connected to the WAN
71 * is returned first (if any). 71 * is returned first (if any).
72 * 72 *
73 * @param sched scheduler to use for network tasks
74 * @param multicastif network interface to send discovery messages, or NULL 73 * @param multicastif network interface to send discovery messages, or NULL
75 * @param addr address used to send messages on multicastif, or NULL 74 * @param addr address used to send messages on multicastif, or NULL
76 * @param caller_cb user function to call when done 75 * @param caller_cb user function to call when done
77 * @param caller_cls closure to pass to caller_cb 76 * @param caller_cls closure to pass to caller_cb
78 */ 77 */
79void UPNP_discover_ (struct GNUNET_SCHEDULER_Handle *sched, 78void UPNP_discover_ (const char *multicastif,
80 const char *multicastif,
81 const struct sockaddr *addr, 79 const struct sockaddr *addr,
82 UPNP_discover_cb_ caller_cb, void *caller_cls); 80 UPNP_discover_cb_ caller_cb, void *caller_cls);
83 81
diff --git a/src/nat/upnp.c b/src/nat/upnp.c
index e383055b5..8dd7d626c 100644
--- a/src/nat/upnp.c
+++ b/src/nat/upnp.c
@@ -57,7 +57,6 @@ enum UPNP_State
57 57
58struct GNUNET_NAT_UPNP_Handle 58struct GNUNET_NAT_UPNP_Handle
59{ 59{
60 struct GNUNET_SCHEDULER_Handle *sched;
61 int hasDiscovered; 60 int hasDiscovered;
62 char *control_url; 61 char *control_url;
63 char *service_type; 62 char *service_type;
@@ -91,8 +90,7 @@ process_if (void *cls,
91 90
92 91
93struct GNUNET_NAT_UPNP_Handle * 92struct GNUNET_NAT_UPNP_Handle *
94GNUNET_NAT_UPNP_init (struct GNUNET_SCHEDULER_Handle *sched, 93GNUNET_NAT_UPNP_init (const struct sockaddr *addr,
95 const struct sockaddr *addr,
96 socklen_t addrlen, 94 socklen_t addrlen,
97 u_short port, 95 u_short port,
98 GNUNET_NAT_UPNP_pulse_cb pulse_cb, void *pulse_cls) 96 GNUNET_NAT_UPNP_pulse_cb pulse_cb, void *pulse_cls)
@@ -100,7 +98,6 @@ GNUNET_NAT_UPNP_init (struct GNUNET_SCHEDULER_Handle *sched,
100 struct GNUNET_NAT_UPNP_Handle *handle; 98 struct GNUNET_NAT_UPNP_Handle *handle;
101 99
102 handle = GNUNET_malloc (sizeof (struct GNUNET_NAT_UPNP_Handle)); 100 handle = GNUNET_malloc (sizeof (struct GNUNET_NAT_UPNP_Handle));
103 handle->sched = sched;
104 handle->processing = GNUNET_NO; 101 handle->processing = GNUNET_NO;
105 handle->state = UPNP_DISCOVER; 102 handle->state = UPNP_DISCOVER;
106 handle->addr = addr; 103 handle->addr = addr;
@@ -350,7 +347,7 @@ GNUNET_NAT_UPNP_pulse (struct GNUNET_NAT_UPNP_Handle *handle,
350 if (is_enabled && (handle->state == UPNP_DISCOVER)) 347 if (is_enabled && (handle->state == UPNP_DISCOVER))
351 { 348 {
352 handle->processing = GNUNET_YES; 349 handle->processing = GNUNET_YES;
353 UPNP_discover_ (handle->sched, handle->iface, handle->addr, discover_cb, 350 UPNP_discover_ (handle->iface, handle->addr, discover_cb,
354 handle); 351 handle);
355 } 352 }
356 353
@@ -367,8 +364,7 @@ GNUNET_NAT_UPNP_pulse (struct GNUNET_NAT_UPNP_Handle *handle,
367 GNUNET_snprintf (portStr, sizeof (portStr), "%d", handle->port); 364 GNUNET_snprintf (portStr, sizeof (portStr), "%d", handle->port);
368 365
369 handle->processing = GNUNET_YES; 366 handle->processing = GNUNET_YES;
370 UPNP_get_specific_port_mapping_entry_ (handle->sched, 367 UPNP_get_specific_port_mapping_entry_ (handle->control_url,
371 handle->control_url,
372 handle->service_type, portStr, 368 handle->service_type, portStr,
373 "TCP", check_port_mapping_cb, 369 "TCP", check_port_mapping_cb,
374 handle); 370 handle);
@@ -380,7 +376,7 @@ GNUNET_NAT_UPNP_pulse (struct GNUNET_NAT_UPNP_Handle *handle,
380 GNUNET_snprintf (portStr, sizeof (portStr), "%d", handle->port); 376 GNUNET_snprintf (portStr, sizeof (portStr), "%d", handle->port);
381 377
382 handle->processing = GNUNET_YES; 378 handle->processing = GNUNET_YES;
383 UPNP_delete_port_mapping_ (handle->sched, handle->control_url, 379 UPNP_delete_port_mapping_ (handle->control_url,
384 handle->service_type, portStr, "TCP", NULL, 380 handle->service_type, portStr, "TCP", NULL,
385 delete_port_mapping_cb, handle); 381 delete_port_mapping_cb, handle);
386 } 382 }
@@ -403,7 +399,7 @@ GNUNET_NAT_UPNP_pulse (struct GNUNET_NAT_UPNP_Handle *handle,
403 GNUNET_snprintf (desc, sizeof (desc), "GNUnet at %d", handle->port); 399 GNUNET_snprintf (desc, sizeof (desc), "GNUnet at %d", handle->port);
404 400
405 handle->processing = GNUNET_YES; 401 handle->processing = GNUNET_YES;
406 UPNP_add_port_mapping_ (handle->sched, handle->control_url, 402 UPNP_add_port_mapping_ (handle->control_url,
407 handle->service_type, 403 handle->service_type,
408 portStr, portStr, GNUNET_a2s (handle->addr, 404 portStr, portStr, GNUNET_a2s (handle->addr,
409 handle->addrlen), 405 handle->addrlen),
@@ -415,7 +411,7 @@ GNUNET_NAT_UPNP_pulse (struct GNUNET_NAT_UPNP_Handle *handle,
415 if (handle->state != UPNP_DISCOVER) 411 if (handle->state != UPNP_DISCOVER)
416 { 412 {
417 handle->processing = GNUNET_YES; 413 handle->processing = GNUNET_YES;
418 UPNP_get_external_ip_address_ (handle->sched, handle->control_url, 414 UPNP_get_external_ip_address_ (handle->control_url,
419 handle->service_type, 415 handle->service_type,
420 get_ip_address_cb, handle); 416 get_ip_address_cb, handle);
421 } 417 }
diff --git a/src/nat/upnp.h b/src/nat/upnp.h
index da95106a0..dc6ba0d45 100644
--- a/src/nat/upnp.h
+++ b/src/nat/upnp.h
@@ -36,10 +36,7 @@ typedef void (*GNUNET_NAT_UPNP_pulse_cb) (int status,
36 struct sockaddr * ext_addr, 36 struct sockaddr * ext_addr,
37 void *cls); 37 void *cls);
38 38
39struct GNUNET_NAT_UPNP_Handle *GNUNET_NAT_UPNP_init (struct 39struct GNUNET_NAT_UPNP_Handle *GNUNET_NAT_UPNP_init (const struct sockaddr
40 GNUNET_SCHEDULER_Handle
41 *sched,
42 const struct sockaddr
43 *addr, socklen_t addrlen, 40 *addr, socklen_t addrlen,
44 unsigned short port, 41 unsigned short port,
45 GNUNET_NAT_UPNP_pulse_cb 42 GNUNET_NAT_UPNP_pulse_cb
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c
index 28f2284ce..1963d6a98 100644
--- a/src/peerinfo-tool/gnunet-peerinfo.c
+++ b/src/peerinfo-tool/gnunet-peerinfo.c
@@ -37,8 +37,6 @@ static int be_quiet;
37 37
38static int get_self; 38static int get_self;
39 39
40static struct GNUNET_SCHEDULER_Handle *sched;
41
42static struct GNUNET_PEERINFO_Handle *peerinfo; 40static struct GNUNET_PEERINFO_Handle *peerinfo;
43 41
44static const struct GNUNET_CONFIGURATION_Handle *cfg; 42static const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -139,8 +137,7 @@ print_address (void *cls,
139 const void *addr, uint16_t addrlen) 137 const void *addr, uint16_t addrlen)
140{ 138{
141 struct PrintContext *pc = cls; 139 struct PrintContext *pc = cls;
142 GNUNET_TRANSPORT_address_lookup (sched, 140 GNUNET_TRANSPORT_address_lookup (cfg,
143 cfg,
144 addr, 141 addr,
145 addrlen, 142 addrlen,
146 no_resolve, 143 no_resolve,
@@ -194,14 +191,12 @@ print_peer_info (void *cls,
194 * Main function that will be run by the scheduler. 191 * Main function that will be run by the scheduler.
195 * 192 *
196 * @param cls closure 193 * @param cls closure
197 * @param s the scheduler to use
198 * @param args remaining command-line arguments 194 * @param args remaining command-line arguments
199 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 195 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
200 * @param c configuration 196 * @param c configuration
201 */ 197 */
202static void 198static void
203run (void *cls, 199run (void *cls,
204 struct GNUNET_SCHEDULER_Handle *s,
205 char *const *args, 200 char *const *args,
206 const char *cfgfile, 201 const char *cfgfile,
207 const struct GNUNET_CONFIGURATION_Handle *c) 202 const struct GNUNET_CONFIGURATION_Handle *c)
@@ -212,7 +207,6 @@ run (void *cls,
212 struct GNUNET_CRYPTO_HashAsciiEncoded enc; 207 struct GNUNET_CRYPTO_HashAsciiEncoded enc;
213 char *fn; 208 char *fn;
214 209
215 sched = s;
216 cfg = c; 210 cfg = c;
217 if (args[0] != NULL) 211 if (args[0] != NULL)
218 { 212 {
@@ -223,7 +217,7 @@ run (void *cls,
223 } 217 }
224 if (get_self != GNUNET_YES) 218 if (get_self != GNUNET_YES)
225 { 219 {
226 peerinfo = GNUNET_PEERINFO_connect (sched, cfg); 220 peerinfo = GNUNET_PEERINFO_connect (cfg);
227 if (peerinfo == NULL) 221 if (peerinfo == NULL)
228 { 222 {
229 fprintf (stderr, 223 fprintf (stderr,
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c
index 698c7dc30..31b0199f4 100644
--- a/src/peerinfo/gnunet-service-peerinfo.c
+++ b/src/peerinfo/gnunet-service-peerinfo.c
@@ -311,8 +311,7 @@ cron_scan_directory_data_hosts (void *cls,
311 GNUNET_log (GNUNET_ERROR_TYPE_WARNING | 311 GNUNET_log (GNUNET_ERROR_TYPE_WARNING |
312 GNUNET_ERROR_TYPE_BULK, 312 GNUNET_ERROR_TYPE_BULK,
313 _("Still no peers found in `%s'!\n"), networkIdDirectory); 313 _("Still no peers found in `%s'!\n"), networkIdDirectory);
314 GNUNET_SCHEDULER_add_delayed (tc->sched, 314 GNUNET_SCHEDULER_add_delayed (DATA_HOST_FREQ,
315 DATA_HOST_FREQ,
316 &cron_scan_directory_data_hosts, NULL); 315 &cron_scan_directory_data_hosts, NULL);
317} 316}
318 317
@@ -464,8 +463,7 @@ cron_clean_data_hosts (void *cls,
464 now = GNUNET_TIME_absolute_get (); 463 now = GNUNET_TIME_absolute_get ();
465 GNUNET_DISK_directory_scan (networkIdDirectory, 464 GNUNET_DISK_directory_scan (networkIdDirectory,
466 &discard_hosts_helper, &now); 465 &discard_hosts_helper, &now);
467 GNUNET_SCHEDULER_add_delayed (tc->sched, 466 GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ,
468 DATA_HOST_CLEAN_FREQ,
469 &cron_clean_data_hosts, NULL); 467 &cron_clean_data_hosts, NULL);
470} 468}
471 469
@@ -650,13 +648,11 @@ shutdown_task (void *cls,
650 * Process statistics requests. 648 * Process statistics requests.
651 * 649 *
652 * @param cls closure 650 * @param cls closure
653 * @param sched scheduler to use
654 * @param server the initialized server 651 * @param server the initialized server
655 * @param cfg configuration to use 652 * @param cfg configuration to use
656 */ 653 */
657static void 654static void
658run (void *cls, 655run (void *cls,
659 struct GNUNET_SCHEDULER_Handle *sched,
660 struct GNUNET_SERVER_Handle *server, 656 struct GNUNET_SERVER_Handle *server,
661 const struct GNUNET_CONFIGURATION_Handle *cfg) 657 const struct GNUNET_CONFIGURATION_Handle *cfg)
662{ 658{
@@ -672,7 +668,7 @@ run (void *cls,
672 }; 668 };
673 669
674 hostmap = GNUNET_CONTAINER_multihashmap_create (1024); 670 hostmap = GNUNET_CONTAINER_multihashmap_create (1024);
675 stats = GNUNET_STATISTICS_create (sched, "peerinfo", cfg); 671 stats = GNUNET_STATISTICS_create ("peerinfo", cfg);
676 notify_list = GNUNET_SERVER_notification_context_create (server, 0); 672 notify_list = GNUNET_SERVER_notification_context_create (server, 0);
677 GNUNET_assert (GNUNET_OK == 673 GNUNET_assert (GNUNET_OK ==
678 GNUNET_CONFIGURATION_get_value_filename (cfg, 674 GNUNET_CONFIGURATION_get_value_filename (cfg,
@@ -680,14 +676,11 @@ run (void *cls,
680 "HOSTS", 676 "HOSTS",
681 &networkIdDirectory)); 677 &networkIdDirectory));
682 GNUNET_DISK_directory_create (networkIdDirectory); 678 GNUNET_DISK_directory_create (networkIdDirectory);
683 GNUNET_SCHEDULER_add_with_priority (sched, 679 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
684 GNUNET_SCHEDULER_PRIORITY_IDLE,
685 &cron_scan_directory_data_hosts, NULL); 680 &cron_scan_directory_data_hosts, NULL);
686 GNUNET_SCHEDULER_add_with_priority (sched, 681 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
687 GNUNET_SCHEDULER_PRIORITY_IDLE,
688 &cron_clean_data_hosts, NULL); 682 &cron_clean_data_hosts, NULL);
689 GNUNET_SCHEDULER_add_delayed (sched, 683 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
690 GNUNET_TIME_UNIT_FOREVER_REL,
691 &shutdown_task, NULL); 684 &shutdown_task, NULL);
692 GNUNET_SERVER_add_handlers (server, handlers); 685 GNUNET_SERVER_add_handlers (server, handlers);
693} 686}
diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c
index 5803b076a..e7f095eac 100644
--- a/src/peerinfo/peerinfo_api.c
+++ b/src/peerinfo/peerinfo_api.c
@@ -91,11 +91,6 @@ struct GNUNET_PEERINFO_Handle
91 const struct GNUNET_CONFIGURATION_Handle *cfg; 91 const struct GNUNET_CONFIGURATION_Handle *cfg;
92 92
93 /** 93 /**
94 * Our scheduler.
95 */
96 struct GNUNET_SCHEDULER_Handle *sched;
97
98 /**
99 * Connection to the service. 94 * Connection to the service.
100 */ 95 */
101 struct GNUNET_CLIENT_Connection *client; 96 struct GNUNET_CLIENT_Connection *client;
@@ -127,25 +122,22 @@ struct GNUNET_PEERINFO_Handle
127/** 122/**
128 * Connect to the peerinfo service. 123 * Connect to the peerinfo service.
129 * 124 *
130 * @param sched scheduler to use
131 * @param cfg configuration to use 125 * @param cfg configuration to use
132 * @return NULL on error (configuration related, actual connection 126 * @return NULL on error (configuration related, actual connection
133 * establishment may happen asynchronously). 127 * establishment may happen asynchronously).
134 */ 128 */
135struct GNUNET_PEERINFO_Handle * 129struct GNUNET_PEERINFO_Handle *
136GNUNET_PEERINFO_connect (struct GNUNET_SCHEDULER_Handle *sched, 130GNUNET_PEERINFO_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
137 const struct GNUNET_CONFIGURATION_Handle *cfg)
138{ 131{
139 struct GNUNET_CLIENT_Connection *client; 132 struct GNUNET_CLIENT_Connection *client;
140 struct GNUNET_PEERINFO_Handle *ret; 133 struct GNUNET_PEERINFO_Handle *ret;
141 134
142 client = GNUNET_CLIENT_connect (sched, "peerinfo", cfg); 135 client = GNUNET_CLIENT_connect ("peerinfo", cfg);
143 if (client == NULL) 136 if (client == NULL)
144 return NULL; 137 return NULL;
145 ret = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_Handle)); 138 ret = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_Handle));
146 ret->client = client; 139 ret->client = client;
147 ret->cfg = cfg; 140 ret->cfg = cfg;
148 ret->sched = sched;
149 return ret; 141 return ret;
150} 142}
151 143
@@ -203,7 +195,7 @@ reconnect (struct GNUNET_PEERINFO_Handle *h)
203{ 195{
204 GNUNET_CLIENT_disconnect (h->client, GNUNET_SYSERR); 196 GNUNET_CLIENT_disconnect (h->client, GNUNET_SYSERR);
205 h->th = NULL; 197 h->th = NULL;
206 h->client = GNUNET_CLIENT_connect (h->sched, "peerinfo", h->cfg); 198 h->client = GNUNET_CLIENT_connect ("peerinfo", h->cfg);
207 GNUNET_assert (h->client != NULL); 199 GNUNET_assert (h->client != NULL);
208} 200}
209 201
@@ -395,8 +387,7 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg)
395 reconnect (ic->h); 387 reconnect (ic->h);
396 trigger_transmit (ic->h); 388 trigger_transmit (ic->h);
397 if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) 389 if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK)
398 GNUNET_SCHEDULER_cancel (ic->h->sched, 390 GNUNET_SCHEDULER_cancel (ic->timeout_task);
399 ic->timeout_task);
400 if (ic->callback != NULL) 391 if (ic->callback != NULL)
401 ic->callback (ic->callback_cls, NULL, NULL); 392 ic->callback (ic->callback_cls, NULL, NULL);
402 GNUNET_free (ic); 393 GNUNET_free (ic);
@@ -411,8 +402,7 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg)
411#endif 402#endif
412 trigger_transmit (ic->h); 403 trigger_transmit (ic->h);
413 if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) 404 if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK)
414 GNUNET_SCHEDULER_cancel (ic->h->sched, 405 GNUNET_SCHEDULER_cancel (ic->timeout_task);
415 ic->timeout_task);
416 if (ic->callback != NULL) 406 if (ic->callback != NULL)
417 ic->callback (ic->callback_cls, NULL, NULL); 407 ic->callback (ic->callback_cls, NULL, NULL);
418 GNUNET_free (ic); 408 GNUNET_free (ic);
@@ -426,8 +416,7 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg)
426 reconnect (ic->h); 416 reconnect (ic->h);
427 trigger_transmit (ic->h); 417 trigger_transmit (ic->h);
428 if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) 418 if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK)
429 GNUNET_SCHEDULER_cancel (ic->h->sched, 419 GNUNET_SCHEDULER_cancel (ic->timeout_task);
430 ic->timeout_task);
431 if (ic->callback != NULL) 420 if (ic->callback != NULL)
432 ic->callback (ic->callback_cls, NULL, NULL); 421 ic->callback (ic->callback_cls, NULL, NULL);
433 GNUNET_free (ic); 422 GNUNET_free (ic);
@@ -445,8 +434,7 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg)
445 reconnect (ic->h); 434 reconnect (ic->h);
446 trigger_transmit (ic->h); 435 trigger_transmit (ic->h);
447 if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) 436 if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK)
448 GNUNET_SCHEDULER_cancel (ic->h->sched, 437 GNUNET_SCHEDULER_cancel (ic->timeout_task);
449 ic->timeout_task);
450 if (ic->callback != NULL) 438 if (ic->callback != NULL)
451 ic->callback (ic->callback_cls, NULL, NULL); 439 ic->callback (ic->callback_cls, NULL, NULL);
452 GNUNET_free (ic); 440 GNUNET_free (ic);
@@ -492,8 +480,7 @@ iterator_start_receive (void *cls,
492 transmit_success); 480 transmit_success);
493 if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) 481 if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK)
494 { 482 {
495 GNUNET_SCHEDULER_cancel (ic->h->sched, 483 GNUNET_SCHEDULER_cancel (ic->timeout_task);
496 ic->timeout_task);
497 ic->timeout_task = GNUNET_SCHEDULER_NO_TASK; 484 ic->timeout_task = GNUNET_SCHEDULER_NO_TASK;
498 } 485 }
499 reconnect (ic->h); 486 reconnect (ic->h);
@@ -609,8 +596,7 @@ GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h,
609 ic->callback = callback; 596 ic->callback = callback;
610 ic->callback_cls = callback_cls; 597 ic->callback_cls = callback_cls;
611 ic->timeout = GNUNET_TIME_relative_to_absolute (timeout); 598 ic->timeout = GNUNET_TIME_relative_to_absolute (timeout);
612 ic->timeout_task = GNUNET_SCHEDULER_add_delayed (h->sched, 599 ic->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout,
613 timeout,
614 &signal_timeout, 600 &signal_timeout,
615 ic); 601 ic);
616 tqe->timeout = ic->timeout; 602 tqe->timeout = ic->timeout;
@@ -637,8 +623,7 @@ GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic)
637{ 623{
638 if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) 624 if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK)
639 { 625 {
640 GNUNET_SCHEDULER_cancel (ic->h->sched, 626 GNUNET_SCHEDULER_cancel (ic->timeout_task);
641 ic->timeout_task);
642 ic->timeout_task = GNUNET_SCHEDULER_NO_TASK; 627 ic->timeout_task = GNUNET_SCHEDULER_NO_TASK;
643 } 628 }
644 ic->callback = NULL; 629 ic->callback = NULL;
diff --git a/src/peerinfo/peerinfo_api_notify.c b/src/peerinfo/peerinfo_api_notify.c
index c7a9c6145..25f2b9d5e 100644
--- a/src/peerinfo/peerinfo_api_notify.c
+++ b/src/peerinfo/peerinfo_api_notify.c
@@ -62,10 +62,6 @@ struct GNUNET_PEERINFO_NotifyContext
62 */ 62 */
63 const struct GNUNET_CONFIGURATION_Handle *cfg; 63 const struct GNUNET_CONFIGURATION_Handle *cfg;
64 64
65 /**
66 * Scheduler.
67 */
68 struct GNUNET_SCHEDULER_Handle *sched;
69}; 65};
70 66
71 67
@@ -109,7 +105,7 @@ process_notification (void *cls,
109 if (msg == NULL) 105 if (msg == NULL)
110 { 106 {
111 GNUNET_CLIENT_disconnect (nc->client, GNUNET_NO); 107 GNUNET_CLIENT_disconnect (nc->client, GNUNET_NO);
112 nc->client = GNUNET_CLIENT_connect (nc->sched, "peerinfo", nc->cfg); 108 nc->client = GNUNET_CLIENT_connect ("peerinfo", nc->cfg);
113 request_notifications (nc); 109 request_notifications (nc);
114 return; 110 return;
115 } 111 }
@@ -119,7 +115,7 @@ process_notification (void *cls,
119 { 115 {
120 GNUNET_break (0); 116 GNUNET_break (0);
121 GNUNET_CLIENT_disconnect (nc->client, GNUNET_NO); 117 GNUNET_CLIENT_disconnect (nc->client, GNUNET_NO);
122 nc->client = GNUNET_CLIENT_connect (nc->sched, "peerinfo", nc->cfg); 118 nc->client = GNUNET_CLIENT_connect ("peerinfo", nc->cfg);
123 request_notifications (nc); 119 request_notifications (nc);
124 return; 120 return;
125 } 121 }
@@ -132,7 +128,7 @@ process_notification (void *cls,
132 { 128 {
133 GNUNET_break (0); 129 GNUNET_break (0);
134 GNUNET_CLIENT_disconnect (nc->client, GNUNET_NO); 130 GNUNET_CLIENT_disconnect (nc->client, GNUNET_NO);
135 nc->client = GNUNET_CLIENT_connect (nc->sched, "peerinfo", nc->cfg); 131 nc->client = GNUNET_CLIENT_connect ("peerinfo", nc->cfg);
136 request_notifications (nc); 132 request_notifications (nc);
137 return; 133 return;
138 } 134 }
@@ -183,7 +179,7 @@ transmit_notify_request (void *cls,
183 if (buf == NULL) 179 if (buf == NULL)
184 { 180 {
185 GNUNET_CLIENT_disconnect (nc->client, GNUNET_NO); 181 GNUNET_CLIENT_disconnect (nc->client, GNUNET_NO);
186 nc->client = GNUNET_CLIENT_connect (nc->sched, "peerinfo", nc->cfg); 182 nc->client = GNUNET_CLIENT_connect ("peerinfo", nc->cfg);
187 request_notifications (nc); 183 request_notifications (nc);
188 return 0; 184 return 0;
189 } 185 }
@@ -221,21 +217,19 @@ request_notifications (struct GNUNET_PEERINFO_NotifyContext *nc)
221 * peers and then only signals changes. 217 * peers and then only signals changes.
222 * 218 *
223 * @param cfg configuration to use 219 * @param cfg configuration to use
224 * @param sched scheduler to use
225 * @param callback the method to call for each peer 220 * @param callback the method to call for each peer
226 * @param callback_cls closure for callback 221 * @param callback_cls closure for callback
227 * @return NULL on error 222 * @return NULL on error
228 */ 223 */
229struct GNUNET_PEERINFO_NotifyContext * 224struct GNUNET_PEERINFO_NotifyContext *
230GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg, 225GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg,
231 struct GNUNET_SCHEDULER_Handle *sched,
232 GNUNET_PEERINFO_Processor callback, 226 GNUNET_PEERINFO_Processor callback,
233 void *callback_cls) 227 void *callback_cls)
234{ 228{
235 struct GNUNET_PEERINFO_NotifyContext *nc; 229 struct GNUNET_PEERINFO_NotifyContext *nc;
236 struct GNUNET_CLIENT_Connection *client; 230 struct GNUNET_CLIENT_Connection *client;
237 231
238 client = GNUNET_CLIENT_connect (sched, "peerinfo", cfg); 232 client = GNUNET_CLIENT_connect ("peerinfo", cfg);
239 if (client == NULL) 233 if (client == NULL)
240 { 234 {
241 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 235 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -243,7 +237,6 @@ GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg,
243 return NULL; 237 return NULL;
244 } 238 }
245 nc = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_NotifyContext)); 239 nc = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_NotifyContext));
246 nc->sched = sched;
247 nc->cfg = cfg; 240 nc->cfg = cfg;
248 nc->client = client; 241 nc->client = client;
249 nc->callback = callback; 242 nc->callback = callback;
diff --git a/src/peerinfo/perf_peerinfo_api.c b/src/peerinfo/perf_peerinfo_api.c
index 2c3d54109..1c2f81d76 100755
--- a/src/peerinfo/perf_peerinfo_api.c
+++ b/src/peerinfo/perf_peerinfo_api.c
@@ -37,8 +37,6 @@
37 37
38#define NUM_REQUESTS 5000 38#define NUM_REQUESTS 5000
39 39
40static struct GNUNET_SCHEDULER_Handle *sched;
41
42static const struct GNUNET_CONFIGURATION_Handle *cfg; 40static const struct GNUNET_CONFIGURATION_Handle *cfg;
43 41
44static struct GNUNET_PEERINFO_IteratorContext *ic[NUM_REQUESTS]; 42static struct GNUNET_PEERINFO_IteratorContext *ic[NUM_REQUESTS];
@@ -132,15 +130,13 @@ process (void *cls,
132 130
133static void 131static void
134run (void *cls, 132run (void *cls,
135 struct GNUNET_SCHEDULER_Handle *s,
136 char *const *args, 133 char *const *args,
137 const char *cfgfile, 134 const char *cfgfile,
138 const struct GNUNET_CONFIGURATION_Handle *c) 135 const struct GNUNET_CONFIGURATION_Handle *c)
139{ 136{
140 size_t i; 137 size_t i;
141 sched = s;
142 cfg = c; 138 cfg = c;
143 h = GNUNET_PEERINFO_connect (sched, cfg); 139 h = GNUNET_PEERINFO_connect (cfg);
144 GNUNET_assert (h != NULL); 140 GNUNET_assert (h != NULL);
145 for (i = 0; i < NUM_REQUESTS; i++) 141 for (i = 0; i < NUM_REQUESTS; i++)
146 { 142 {
diff --git a/src/peerinfo/test_peerinfo_api.c b/src/peerinfo/test_peerinfo_api.c
index eae448bbf..fdd0dc460 100644
--- a/src/peerinfo/test_peerinfo_api.c
+++ b/src/peerinfo/test_peerinfo_api.c
@@ -36,8 +36,6 @@
36#include "gnunet_time_lib.h" 36#include "gnunet_time_lib.h"
37#include "peerinfo.h" 37#include "peerinfo.h"
38 38
39static struct GNUNET_SCHEDULER_Handle *sched;
40
41static const struct GNUNET_CONFIGURATION_Handle *cfg; 39static const struct GNUNET_CONFIGURATION_Handle *cfg;
42 40
43static struct GNUNET_PEERINFO_IteratorContext *ic; 41static struct GNUNET_PEERINFO_IteratorContext *ic;
@@ -143,14 +141,12 @@ process (void *cls,
143 141
144static void 142static void
145run (void *cls, 143run (void *cls,
146 struct GNUNET_SCHEDULER_Handle *s,
147 char *const *args, 144 char *const *args,
148 const char *cfgfile, 145 const char *cfgfile,
149 const struct GNUNET_CONFIGURATION_Handle *c) 146 const struct GNUNET_CONFIGURATION_Handle *c)
150{ 147{
151 sched = s;
152 cfg = c; 148 cfg = c;
153 h = GNUNET_PEERINFO_connect (sched, cfg); 149 h = GNUNET_PEERINFO_connect (cfg);
154 GNUNET_assert (h != NULL); 150 GNUNET_assert (h != NULL);
155 add_peer (); 151 add_peer ();
156 ic = GNUNET_PEERINFO_iterate (h, 152 ic = GNUNET_PEERINFO_iterate (h,
diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c
index 92f79cc91..c506dee7b 100644
--- a/src/statistics/gnunet-service-statistics.c
+++ b/src/statistics/gnunet-service-statistics.c
@@ -730,13 +730,11 @@ handle_client_disconnect (void *cls,
730 * Process statistics requests. 730 * Process statistics requests.
731 * 731 *
732 * @param cls closure 732 * @param cls closure
733 * @param sched scheduler to use
734 * @param server the initialized server 733 * @param server the initialized server
735 * @param c configuration to use 734 * @param c configuration to use
736 */ 735 */
737static void 736static void
738run (void *cls, 737run (void *cls,
739 struct GNUNET_SCHEDULER_Handle *sched,
740 struct GNUNET_SERVER_Handle *server, 738 struct GNUNET_SERVER_Handle *server,
741 const struct GNUNET_CONFIGURATION_Handle *c) 739 const struct GNUNET_CONFIGURATION_Handle *c)
742{ 740{
@@ -753,8 +751,7 @@ run (void *cls,
753 &handle_client_disconnect, 751 &handle_client_disconnect,
754 NULL); 752 NULL);
755 load (server); 753 load (server);
756 GNUNET_SCHEDULER_add_delayed (sched, 754 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
757 GNUNET_TIME_UNIT_FOREVER_REL,
758 &shutdown_task, 755 &shutdown_task,
759 NULL); 756 NULL);
760} 757}
diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c
index 3742a496d..0cbafa68f 100644
--- a/src/statistics/gnunet-statistics.c
+++ b/src/statistics/gnunet-statistics.c
@@ -104,14 +104,12 @@ cleanup (void *cls, int success)
104 * Main function that will be run by the scheduler. 104 * Main function that will be run by the scheduler.
105 * 105 *
106 * @param cls closure 106 * @param cls closure
107 * @param sched the scheduler to use
108 * @param args remaining command-line arguments 107 * @param args remaining command-line arguments
109 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 108 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
110 * @param cfg configuration 109 * @param cfg configuration
111 */ 110 */
112static void 111static void
113run (void *cls, 112run (void *cls,
114 struct GNUNET_SCHEDULER_Handle *sched,
115 char *const *args, 113 char *const *args,
116 const char *cfgfile, 114 const char *cfgfile,
117 const struct GNUNET_CONFIGURATION_Handle *cfg) 115 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -128,7 +126,7 @@ run (void *cls,
128 ret = 1; 126 ret = 1;
129 return; 127 return;
130 } 128 }
131 h = GNUNET_STATISTICS_create (sched, subsystem, cfg); 129 h = GNUNET_STATISTICS_create (subsystem, cfg);
132 if (h == NULL) 130 if (h == NULL)
133 { 131 {
134 ret = 1; 132 ret = 1;
@@ -138,7 +136,7 @@ run (void *cls,
138 GNUNET_STATISTICS_destroy (h, GNUNET_YES); 136 GNUNET_STATISTICS_destroy (h, GNUNET_YES);
139 return; 137 return;
140 } 138 }
141 h = GNUNET_STATISTICS_create (sched, "gnunet-statistics", cfg); 139 h = GNUNET_STATISTICS_create ("gnunet-statistics", cfg);
142 if (h == NULL) 140 if (h == NULL)
143 { 141 {
144 ret = 1; 142 ret = 1;
diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c
index ef9865e02..5bca6c786 100644
--- a/src/statistics/statistics_api.c
+++ b/src/statistics/statistics_api.c
@@ -167,11 +167,6 @@ struct GNUNET_STATISTICS_GetHandle
167struct GNUNET_STATISTICS_Handle 167struct GNUNET_STATISTICS_Handle
168{ 168{
169 /** 169 /**
170 * Our scheduler.
171 */
172 struct GNUNET_SCHEDULER_Handle *sched;
173
174 /**
175 * Name of our subsystem. 170 * Name of our subsystem.
176 */ 171 */
177 char *subsystem; 172 char *subsystem;
@@ -318,7 +313,7 @@ try_connect (struct GNUNET_STATISTICS_Handle *ret)
318 unsigned int i; 313 unsigned int i;
319 if (ret->client != NULL) 314 if (ret->client != NULL)
320 return GNUNET_YES; 315 return GNUNET_YES;
321 ret->client = GNUNET_CLIENT_connect (ret->sched, "statistics", ret->cfg); 316 ret->client = GNUNET_CLIENT_connect ("statistics", ret->cfg);
322 if (ret->client != NULL) 317 if (ret->client != NULL)
323 { 318 {
324 for (i=0;i<ret->watches_size;i++) 319 for (i=0;i<ret->watches_size;i++)
@@ -727,23 +722,19 @@ transmit_action (void *cls, size_t size, void *buf)
727/** 722/**
728 * Get handle for the statistics service. 723 * Get handle for the statistics service.
729 * 724 *
730 * @param sched scheduler to use
731 * @param subsystem name of subsystem using the service 725 * @param subsystem name of subsystem using the service
732 * @param cfg services configuration in use 726 * @param cfg services configuration in use
733 * @return handle to use 727 * @return handle to use
734 */ 728 */
735struct GNUNET_STATISTICS_Handle * 729struct GNUNET_STATISTICS_Handle *
736GNUNET_STATISTICS_create (struct GNUNET_SCHEDULER_Handle *sched, 730GNUNET_STATISTICS_create (const char *subsystem,
737 const char *subsystem,
738 const struct GNUNET_CONFIGURATION_Handle *cfg) 731 const struct GNUNET_CONFIGURATION_Handle *cfg)
739{ 732{
740 struct GNUNET_STATISTICS_Handle *ret; 733 struct GNUNET_STATISTICS_Handle *ret;
741 734
742 GNUNET_assert (subsystem != NULL); 735 GNUNET_assert (subsystem != NULL);
743 GNUNET_assert (sched != NULL);
744 GNUNET_assert (cfg != NULL); 736 GNUNET_assert (cfg != NULL);
745 ret = GNUNET_malloc (sizeof (struct GNUNET_STATISTICS_Handle)); 737 ret = GNUNET_malloc (sizeof (struct GNUNET_STATISTICS_Handle));
746 ret->sched = sched;
747 ret->cfg = cfg; 738 ret->cfg = cfg;
748 ret->subsystem = GNUNET_strdup (subsystem); 739 ret->subsystem = GNUNET_strdup (subsystem);
749 ret->backoff = GNUNET_TIME_UNIT_MILLISECONDS; 740 ret->backoff = GNUNET_TIME_UNIT_MILLISECONDS;
@@ -771,8 +762,7 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h,
771 int i; 762 int i;
772 763
773 if (GNUNET_SCHEDULER_NO_TASK != h->backoff_task) 764 if (GNUNET_SCHEDULER_NO_TASK != h->backoff_task)
774 GNUNET_SCHEDULER_cancel (h->sched, 765 GNUNET_SCHEDULER_cancel (h->backoff_task);
775 h->backoff_task);
776 if (sync_first) 766 if (sync_first)
777 { 767 {
778 if (h->current != NULL) 768 if (h->current != NULL)
@@ -884,8 +874,7 @@ schedule_action (struct GNUNET_STATISTICS_Handle *h)
884 return; /* action already pending */ 874 return; /* action already pending */
885 if (GNUNET_YES != try_connect (h)) 875 if (GNUNET_YES != try_connect (h))
886 { 876 {
887 h->backoff_task = GNUNET_SCHEDULER_add_delayed (h->sched, 877 h->backoff_task = GNUNET_SCHEDULER_add_delayed (h->backoff,
888 h->backoff,
889 &finish_task, 878 &finish_task,
890 h); 879 h);
891 h->backoff = GNUNET_TIME_relative_multiply (h->backoff, 2); 880 h->backoff = GNUNET_TIME_relative_multiply (h->backoff, 2);
diff --git a/src/statistics/test_statistics_api.c b/src/statistics/test_statistics_api.c
index cce90146c..7b01ff00f 100644
--- a/src/statistics/test_statistics_api.c
+++ b/src/statistics/test_statistics_api.c
@@ -109,12 +109,11 @@ next (void *cls, int success)
109 109
110static void 110static void
111run (void *cls, 111run (void *cls,
112 struct GNUNET_SCHEDULER_Handle *sched,
113 char *const *args, 112 char *const *args,
114 const char *cfgfile, 113 const char *cfgfile,
115 const struct GNUNET_CONFIGURATION_Handle *cfg) 114 const struct GNUNET_CONFIGURATION_Handle *cfg)
116{ 115{
117 h = GNUNET_STATISTICS_create (sched, "test-statistics-api", cfg); 116 h = GNUNET_STATISTICS_create ("test-statistics-api", cfg);
118 GNUNET_STATISTICS_set (h, "test-1", 1, GNUNET_NO); 117 GNUNET_STATISTICS_set (h, "test-1", 1, GNUNET_NO);
119 GNUNET_STATISTICS_set (h, "test-2", 2, GNUNET_NO); 118 GNUNET_STATISTICS_set (h, "test-2", 2, GNUNET_NO);
120 GNUNET_STATISTICS_set (h, "test-3", 2, GNUNET_NO); 119 GNUNET_STATISTICS_set (h, "test-3", 2, GNUNET_NO);
@@ -128,12 +127,11 @@ run (void *cls,
128 127
129static void 128static void
130run_more (void *cls, 129run_more (void *cls,
131 struct GNUNET_SCHEDULER_Handle *sched,
132 char *const *args, 130 char *const *args,
133 const char *cfgfile, 131 const char *cfgfile,
134 const struct GNUNET_CONFIGURATION_Handle *cfg) 132 const struct GNUNET_CONFIGURATION_Handle *cfg)
135{ 133{
136 h = GNUNET_STATISTICS_create (sched, "test-statistics-api", cfg); 134 h = GNUNET_STATISTICS_create ("test-statistics-api", cfg);
137 GNUNET_break (NULL != 135 GNUNET_break (NULL !=
138 GNUNET_STATISTICS_get (h, NULL, "test-3", 136 GNUNET_STATISTICS_get (h, NULL, "test-3",
139 GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_3, cls)); 137 GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_3, cls));
diff --git a/src/statistics/test_statistics_api_loop.c b/src/statistics/test_statistics_api_loop.c
index 7eaa9d27b..02f4aca44 100644
--- a/src/statistics/test_statistics_api_loop.c
+++ b/src/statistics/test_statistics_api_loop.c
@@ -60,7 +60,6 @@ next (void *cls, int success)
60 60
61static void 61static void
62run (void *cls, 62run (void *cls,
63 struct GNUNET_SCHEDULER_Handle *sched,
64 char *const *args, 63 char *const *args,
65 const char *cfgfile, 64 const char *cfgfile,
66 const struct GNUNET_CONFIGURATION_Handle *cfg) 65 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -68,7 +67,7 @@ run (void *cls,
68 int i; 67 int i;
69 char name[128]; 68 char name[128];
70 69
71 h = GNUNET_STATISTICS_create (sched, "test-statistics-api-loop", cfg); 70 h = GNUNET_STATISTICS_create ("test-statistics-api-loop", cfg);
72 for (i=0;i<ROUNDS;i++) 71 for (i=0;i<ROUNDS;i++)
73 { 72 {
74 GNUNET_snprintf (name, sizeof (name), "test-%d", i % 256); 73 GNUNET_snprintf (name, sizeof (name), "test-%d", i % 256);
diff --git a/src/template/gnunet-service-template.c b/src/template/gnunet-service-template.c
index 7270da160..96eb11e61 100644
--- a/src/template/gnunet-service-template.c
+++ b/src/template/gnunet-service-template.c
@@ -46,13 +46,11 @@ cleanup_task (void *cls,
46 * Process template requests. 46 * Process template requests.
47 * 47 *
48 * @param cls closure 48 * @param cls closure
49 * @param sched scheduler to use
50 * @param server the initialized server 49 * @param server the initialized server
51 * @param cfg configuration to use 50 * @param cfg configuration to use
52 */ 51 */
53static void 52static void
54run (void *cls, 53run (void *cls,
55 struct GNUNET_SCHEDULER_Handle *sched,
56 struct GNUNET_SERVER_Handle *server, 54 struct GNUNET_SERVER_Handle *server,
57 const struct GNUNET_CONFIGURATION_Handle *cfg) 55 const struct GNUNET_CONFIGURATION_Handle *cfg)
58{ 56{
@@ -62,8 +60,7 @@ run (void *cls,
62 }; 60 };
63 /* FIXME: do setup here */ 61 /* FIXME: do setup here */
64 GNUNET_SERVER_add_handlers (server, handlers); 62 GNUNET_SERVER_add_handlers (server, handlers);
65 GNUNET_SCHEDULER_add_delayed (sched, 63 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
66 GNUNET_TIME_UNIT_FOREVER_REL,
67 &cleanup_task, 64 &cleanup_task,
68 NULL); 65 NULL);
69} 66}
diff --git a/src/template/gnunet-template.c b/src/template/gnunet-template.c
index cfc854016..cd4687fb7 100644
--- a/src/template/gnunet-template.c
+++ b/src/template/gnunet-template.c
@@ -37,14 +37,12 @@ static int ret;
37 * Main function that will be run by the scheduler. 37 * Main function that will be run by the scheduler.
38 * 38 *
39 * @param cls closure 39 * @param cls closure
40 * @param sched the scheduler to use
41 * @param args remaining command-line arguments 40 * @param args remaining command-line arguments
42 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 41 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
43 * @param cfg configuration 42 * @param cfg configuration
44 */ 43 */
45static void 44static void
46run (void *cls, 45run (void *cls,
47 struct GNUNET_SCHEDULER_Handle *sched,
48 char *const *args, 46 char *const *args,
49 const char *cfgfile, 47 const char *cfgfile,
50 const struct GNUNET_CONFIGURATION_Handle *cfg) 48 const struct GNUNET_CONFIGURATION_Handle *cfg)
diff --git a/src/testing/test_testing.c b/src/testing/test_testing.c
index 519ccc31f..079ccb6db 100644
--- a/src/testing/test_testing.c
+++ b/src/testing/test_testing.c
@@ -64,7 +64,6 @@ my_cb (void *cls,
64 64
65static void 65static void
66run (void *cls, 66run (void *cls,
67 struct GNUNET_SCHEDULER_Handle *sched,
68 char *const *args, 67 char *const *args,
69 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 68 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
70{ 69{
@@ -74,7 +73,7 @@ run (void *cls,
74#if VERBOSE 73#if VERBOSE
75 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemon.\n"); 74 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemon.\n");
76#endif 75#endif
77 d = GNUNET_TESTING_daemon_start (sched, cfg, TIMEOUT, NULL, NULL, 0, NULL, NULL, &my_cb, NULL); 76 d = GNUNET_TESTING_daemon_start (cfg, TIMEOUT, NULL, NULL, 0, NULL, NULL, &my_cb, NULL);
78 GNUNET_assert (d != NULL); 77 GNUNET_assert (d != NULL);
79} 78}
80 79
diff --git a/src/testing/test_testing_connect.c b/src/testing/test_testing_connect.c
index 145989204..8da9b05d8 100644
--- a/src/testing/test_testing_connect.c
+++ b/src/testing/test_testing_connect.c
@@ -43,8 +43,6 @@ static struct GNUNET_CONFIGURATION_Handle *c1;
43 43
44static struct GNUNET_CONFIGURATION_Handle *c2; 44static struct GNUNET_CONFIGURATION_Handle *c2;
45 45
46static struct GNUNET_SCHEDULER_Handle *sched;
47
48static void 46static void
49end2_cb (void *cls, const char *emsg) 47end2_cb (void *cls, const char *emsg)
50{ 48{
@@ -99,7 +97,7 @@ my_connect_complete (void *cls,
99 struct GNUNET_TESTING_Daemon *second_daemon, 97 struct GNUNET_TESTING_Daemon *second_daemon,
100 const char *emsg) 98 const char *emsg)
101{ 99{
102 GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); 100 GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
103} 101}
104 102
105 103
@@ -130,7 +128,7 @@ my_cb1 (void *cls,
130 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 128 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
131 "Daemon `%s' started.\n", GNUNET_i2s (id)); 129 "Daemon `%s' started.\n", GNUNET_i2s (id));
132#endif 130#endif
133 d2 = GNUNET_TESTING_daemon_start (sched, c2, TIMEOUT, NULL, NULL, 0, NULL, NULL, &my_cb2, NULL); 131 d2 = GNUNET_TESTING_daemon_start (c2, TIMEOUT, NULL, NULL, 0, NULL, NULL, &my_cb2, NULL);
134 GNUNET_assert (d2 != NULL); 132 GNUNET_assert (d2 != NULL);
135 133
136} 134}
@@ -138,11 +136,9 @@ my_cb1 (void *cls,
138 136
139static void 137static void
140run (void *cls, 138run (void *cls,
141 struct GNUNET_SCHEDULER_Handle *s,
142 char *const *args, 139 char *const *args,
143 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 140 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
144{ 141{
145 sched = s;
146 ok = 1; 142 ok = 1;
147#if VERBOSE 143#if VERBOSE
148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemon.\n"); 144 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemon.\n");
@@ -151,7 +147,7 @@ run (void *cls,
151 GNUNET_CONFIGURATION_parse (c1, "test_testing_connect_peer1.conf"); 147 GNUNET_CONFIGURATION_parse (c1, "test_testing_connect_peer1.conf");
152 c2 = GNUNET_CONFIGURATION_create (); 148 c2 = GNUNET_CONFIGURATION_create ();
153 GNUNET_CONFIGURATION_parse (c2, "test_testing_connect_peer2.conf"); 149 GNUNET_CONFIGURATION_parse (c2, "test_testing_connect_peer2.conf");
154 d1 = GNUNET_TESTING_daemon_start (sched, c1, TIMEOUT, NULL, NULL, 0, NULL, NULL, &my_cb1, NULL); 150 d1 = GNUNET_TESTING_daemon_start (c1, TIMEOUT, NULL, NULL, 0, NULL, NULL, &my_cb1, NULL);
155 GNUNET_assert (d1 != NULL); 151 GNUNET_assert (d1 != NULL);
156} 152}
157 153
diff --git a/src/testing/test_testing_group.c b/src/testing/test_testing_group.c
index 6eacaca45..b1e6be395 100644
--- a/src/testing/test_testing_group.c
+++ b/src/testing/test_testing_group.c
@@ -41,8 +41,6 @@ static int failed_peers;
41 41
42static struct GNUNET_TESTING_PeerGroup *pg; 42static struct GNUNET_TESTING_PeerGroup *pg;
43 43
44static struct GNUNET_SCHEDULER_Handle *sched;
45
46/** 44/**
47 * Check whether peers successfully shut down. 45 * Check whether peers successfully shut down.
48 */ 46 */
@@ -106,17 +104,15 @@ my_cb (void *cls,
106 104
107static void 105static void
108run (void *cls, 106run (void *cls,
109 struct GNUNET_SCHEDULER_Handle *s,
110 char *const *args, 107 char *const *args,
111 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 108 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
112{ 109{
113 sched = s;
114 ok = 1; 110 ok = 1;
115#if VERBOSE 111#if VERBOSE
116 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); 112 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n");
117#endif 113#endif
118 peers_left = NUM_PEERS; 114 peers_left = NUM_PEERS;
119 pg = GNUNET_TESTING_daemons_start (sched, cfg, 115 pg = GNUNET_TESTING_daemons_start (cfg,
120 peers_left, 116 peers_left,
121 TIMEOUT, 117 TIMEOUT,
122 NULL, NULL, 118 NULL, NULL,
diff --git a/src/testing/test_testing_group_remote.c b/src/testing/test_testing_group_remote.c
index a0ef63847..e0338f534 100644
--- a/src/testing/test_testing_group_remote.c
+++ b/src/testing/test_testing_group_remote.c
@@ -44,8 +44,6 @@ static int peers_failed;
44 44
45static struct GNUNET_TESTING_PeerGroup *pg; 45static struct GNUNET_TESTING_PeerGroup *pg;
46 46
47static struct GNUNET_SCHEDULER_Handle *sched;
48
49static unsigned long long num_peers; 47static unsigned long long num_peers;
50 48
51 49
@@ -101,7 +99,6 @@ my_cb (void *cls,
101 99
102static void 100static void
103run (void *cls, 101run (void *cls,
104 struct GNUNET_SCHEDULER_Handle *s,
105 char *const *args, 102 char *const *args,
106 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 103 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
107{ 104{
@@ -114,7 +111,6 @@ run (void *cls,
114 char *data; 111 char *data;
115 int count; 112 int count;
116 int ret; 113 int ret;
117 sched = s;
118 ok = 1; 114 ok = 1;
119#if VERBOSE 115#if VERBOSE
120 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); 116 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n");
@@ -197,8 +193,7 @@ run (void *cls,
197 } 193 }
198 194
199 peers_left = num_peers; 195 peers_left = num_peers;
200 pg = GNUNET_TESTING_daemons_start (sched, 196 pg = GNUNET_TESTING_daemons_start (cfg,
201 cfg,
202 peers_left, 197 peers_left,
203 TIMEOUT, 198 TIMEOUT,
204 NULL, 199 NULL,
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c
index 7ca58faf1..adb5211fe 100644
--- a/src/testing/test_testing_topology.c
+++ b/src/testing/test_testing_topology.c
@@ -70,8 +70,6 @@ static unsigned long long peers_left;
70 70
71static struct GNUNET_TESTING_PeerGroup *pg; 71static struct GNUNET_TESTING_PeerGroup *pg;
72 72
73static struct GNUNET_SCHEDULER_Handle *sched;
74
75const struct GNUNET_CONFIGURATION_Handle *main_cfg; 73const struct GNUNET_CONFIGURATION_Handle *main_cfg;
76 74
77GNUNET_SCHEDULER_TaskIdentifier die_task; 75GNUNET_SCHEDULER_TaskIdentifier die_task;
@@ -219,7 +217,7 @@ finish_testing ()
219 pos = pos->next; 217 pos = pos->next;
220 if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK) 218 if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
221 { 219 {
222 GNUNET_SCHEDULER_cancel(sched, free_pos->disconnect_task); 220 GNUNET_SCHEDULER_cancel(free_pos->disconnect_task);
223 } 221 }
224 GNUNET_free(free_pos); 222 GNUNET_free(free_pos);
225 } 223 }
@@ -272,7 +270,7 @@ disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
272 270
273static void stats_finished (void *cls, int result) 271static void stats_finished (void *cls, int result)
274{ 272{
275 GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); 273 GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
276} 274}
277 275
278/** 276/**
@@ -323,7 +321,7 @@ static void topology_cb (void *cls,
323 fprintf(outfile, "}\n"); 321 fprintf(outfile, "}\n");
324 fclose(outfile); 322 fclose(outfile);
325 GNUNET_TESTING_get_statistics(pg, &stats_finished, &stats_print, NULL); 323 GNUNET_TESTING_get_statistics(pg, &stats_finished, &stats_print, NULL);
326 //GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); 324 //GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
327 } 325 }
328 } 326 }
329} 327}
@@ -373,7 +371,7 @@ process_mtype (void *cls,
373#if VERBOSE 371#if VERBOSE
374 fprintf(stdout, "100%%]\n"); 372 fprintf(stdout, "100%%]\n");
375#endif 373#endif
376 GNUNET_SCHEDULER_cancel (sched, die_task); 374 GNUNET_SCHEDULER_cancel (die_task);
377 GNUNET_asprintf(&dotOutFileNameFinished, "%s.dot", "final_topology"); 375 GNUNET_asprintf(&dotOutFileNameFinished, "%s.dot", "final_topology");
378 dotOutFileFinished = fopen (dotOutFileNameFinished, "w"); 376 dotOutFileFinished = fopen (dotOutFileNameFinished, "w");
379 GNUNET_free(dotOutFileNameFinished); 377 GNUNET_free(dotOutFileNameFinished);
@@ -383,11 +381,11 @@ process_mtype (void *cls,
383 } 381 }
384 topology_connections = 0; 382 topology_connections = 0;
385 GNUNET_TESTING_get_topology (pg, &topology_cb, dotOutFileFinished); 383 GNUNET_TESTING_get_topology (pg, &topology_cb, dotOutFileFinished);
386 //GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); 384 //GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
387 } 385 }
388 else 386 else
389 { 387 {
390 pos->disconnect_task = GNUNET_SCHEDULER_add_now(sched, &disconnect_cores, pos); 388 pos->disconnect_task = GNUNET_SCHEDULER_add_now(&disconnect_cores, pos);
391 } 389 }
392 390
393 return GNUNET_OK; 391 return GNUNET_OK;
@@ -523,8 +521,7 @@ init_notify_peer1 (void *cls,
523 /* 521 /*
524 * Connect to the receiving peer 522 * Connect to the receiving peer
525 */ 523 */
526 pos->peer2handle = GNUNET_CORE_connect (sched, 524 pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg,
527 pos->peer2->cfg,
528 TIMEOUT, 525 TIMEOUT,
529 pos, 526 pos,
530 &init_notify_peer2, 527 &init_notify_peer2,
@@ -551,14 +548,13 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
551 548
552 if (die_task == GNUNET_SCHEDULER_NO_TASK) 549 if (die_task == GNUNET_SCHEDULER_NO_TASK)
553 { 550 {
554 die_task = GNUNET_SCHEDULER_add_delayed (sched, 551 die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT,
555 TEST_TIMEOUT,
556 &end_badly, "from send test messages (timeout)"); 552 &end_badly, "from send test messages (timeout)");
557 } 553 }
558 554
559 if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) 555 if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS)
560 { 556 {
561 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), 557 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1),
562 &send_test_messages, pos); 558 &send_test_messages, pos);
563 return; /* Otherwise we'll double schedule messages here! */ 559 return; /* Otherwise we'll double schedule messages here! */
564 } 560 }
@@ -566,8 +562,7 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
566 /* 562 /*
567 * Connect to the sending peer 563 * Connect to the sending peer
568 */ 564 */
569 pos->peer1handle = GNUNET_CORE_connect (sched, 565 pos->peer1handle = GNUNET_CORE_connect (pos->peer1->cfg,
570 pos->peer1->cfg,
571 TIMEOUT, 566 TIMEOUT,
572 pos, 567 pos,
573 &init_notify_peer1, 568 &init_notify_peer1,
@@ -580,12 +575,11 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
580 575
581 if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS) 576 if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS)
582 { 577 {
583 GNUNET_SCHEDULER_add_now (sched, 578 GNUNET_SCHEDULER_add_now (&send_test_messages, pos->next);
584 &send_test_messages, pos->next);
585 } 579 }
586 else 580 else
587 { 581 {
588 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), 582 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1),
589 &send_test_messages, pos->next); 583 &send_test_messages, pos->next);
590 } 584 }
591} 585}
@@ -662,12 +656,11 @@ topology_callback (void *cls,
662#endif 656#endif
663 modnum = expected_messages / 4; 657 modnum = expected_messages / 4;
664 dotnum = (expected_messages / 50) + 1; 658 dotnum = (expected_messages / 50) + 1;
665 GNUNET_SCHEDULER_cancel (sched, die_task); 659 GNUNET_SCHEDULER_cancel (die_task);
666 die_task = GNUNET_SCHEDULER_NO_TASK; 660 die_task = GNUNET_SCHEDULER_NO_TASK;
667#if DELAY_FOR_LOGGING 661#if DELAY_FOR_LOGGING
668 fprintf(stdout, "Sending test messages in 10 seconds.\n"); 662 fprintf(stdout, "Sending test messages in 10 seconds.\n");
669 GNUNET_SCHEDULER_add_delayed (sched, 663 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
670 GNUNET_TIME_relative_multiply
671 (GNUNET_TIME_UNIT_SECONDS, 10), 664 (GNUNET_TIME_UNIT_SECONDS, 10),
672 &send_test_messages, test_messages); 665 &send_test_messages, test_messages);
673 gather_log_data(); 666 gather_log_data();
@@ -676,7 +669,7 @@ topology_callback (void *cls,
676 { 669 {
677 GNUNET_TESTING_get_topology (pg, &topology_cb, NULL); 670 GNUNET_TESTING_get_topology (pg, &topology_cb, NULL);
678 } 671 }
679 GNUNET_SCHEDULER_add_delayed (sched, settle_time, &send_test_messages, test_messages); 672 GNUNET_SCHEDULER_add_delayed (settle_time, &send_test_messages, test_messages);
680#endif 673#endif
681#if VERBOSE 674#if VERBOSE
682 fprintf(stdout, "Test message progress: ["); 675 fprintf(stdout, "Test message progress: [");
@@ -687,15 +680,14 @@ topology_callback (void *cls,
687 { 680 {
688 if (failed_connections < (unsigned int)(fail_percentage * total_connections)) 681 if (failed_connections < (unsigned int)(fail_percentage * total_connections))
689 { 682 {
690 GNUNET_SCHEDULER_cancel (sched, die_task); 683 GNUNET_SCHEDULER_cancel (die_task);
691 die_task = GNUNET_SCHEDULER_NO_TASK; 684 die_task = GNUNET_SCHEDULER_NO_TASK;
692 GNUNET_SCHEDULER_add_now (sched, &send_test_messages, test_messages); 685 GNUNET_SCHEDULER_add_now (&send_test_messages, test_messages);
693 } 686 }
694 else 687 else
695 { 688 {
696 GNUNET_SCHEDULER_cancel (sched, die_task); 689 GNUNET_SCHEDULER_cancel (die_task);
697 die_task = GNUNET_SCHEDULER_add_now (sched, 690 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many failed connections)");
698 &end_badly, "from topology_callback (too many failed connections)");
699 } 691 }
700 } 692 }
701 else 693 else
@@ -730,15 +722,13 @@ connect_topology ()
730#endif 722#endif
731 } 723 }
732 724
733 GNUNET_SCHEDULER_cancel (sched, die_task); 725 GNUNET_SCHEDULER_cancel (die_task);
734 if (expected_connections == GNUNET_SYSERR) 726 if (expected_connections == GNUNET_SYSERR)
735 { 727 {
736 die_task = GNUNET_SCHEDULER_add_now (sched, 728 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)");
737 &end_badly, "from connect topology (bad return)");
738 } 729 }
739 730
740 die_task = GNUNET_SCHEDULER_add_delayed (sched, 731 die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT,
741 TEST_TIMEOUT,
742 &end_badly, "from connect topology (timeout)"); 732 &end_badly, "from connect topology (timeout)");
743 modnum = expected_connections / 4; 733 modnum = expected_connections / 4;
744 dotnum = (expected_connections / 50) + 1; 734 dotnum = (expected_connections / 50) + 1;
@@ -762,13 +752,11 @@ create_topology ()
762 } 752 }
763 else 753 else
764 { 754 {
765 GNUNET_SCHEDULER_cancel (sched, die_task); 755 GNUNET_SCHEDULER_cancel (die_task);
766 die_task = GNUNET_SCHEDULER_add_now (sched, 756 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from create topology (bad return)");
767 &end_badly, "from create topology (bad return)");
768 } 757 }
769 GNUNET_SCHEDULER_cancel (sched, die_task); 758 GNUNET_SCHEDULER_cancel (die_task);
770 die_task = GNUNET_SCHEDULER_add_delayed (sched, 759 die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT,
771 TEST_TIMEOUT,
772 &end_badly, "from continue startup (timeout)"); 760 &end_badly, "from continue startup (timeout)");
773} 761}
774 762
@@ -818,18 +806,16 @@ peers_started_callback (void *cls,
818 "All %d daemons started, now connecting peers!\n", 806 "All %d daemons started, now connecting peers!\n",
819 num_peers); 807 num_peers);
820#endif 808#endif
821 GNUNET_SCHEDULER_cancel (sched, die_task); 809 GNUNET_SCHEDULER_cancel (die_task);
822 /* Set up task in case topology creation doesn't finish 810 /* Set up task in case topology creation doesn't finish
823 * within a reasonable amount of time */ 811 * within a reasonable amount of time */
824 die_task = GNUNET_SCHEDULER_add_delayed (sched, 812 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
825 GNUNET_TIME_relative_multiply
826 (GNUNET_TIME_UNIT_MINUTES, 8), 813 (GNUNET_TIME_UNIT_MINUTES, 8),
827 &end_badly, "from peers_started_callback"); 814 &end_badly, "from peers_started_callback");
828#if DELAY_FOR_LOGGING 815#if DELAY_FOR_LOGGING
829 fprintf(stdout, "Connecting topology in 10 seconds\n"); 816 fprintf(stdout, "Connecting topology in 10 seconds\n");
830 gather_log_data(); 817 gather_log_data();
831 GNUNET_SCHEDULER_add_delayed (sched, 818 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
832 GNUNET_TIME_relative_multiply
833 (GNUNET_TIME_UNIT_SECONDS, 10), 819 (GNUNET_TIME_UNIT_SECONDS, 10),
834 &connect_topology, NULL); 820 &connect_topology, NULL);
835#else 821#else
@@ -889,20 +875,18 @@ void hostkey_callback (void *cls,
889 "All %d hostkeys created, now creating topology!\n", 875 "All %d hostkeys created, now creating topology!\n",
890 num_peers); 876 num_peers);
891#endif 877#endif
892 GNUNET_SCHEDULER_cancel (sched, die_task); 878 GNUNET_SCHEDULER_cancel (die_task);
893 /* Set up task in case topology creation doesn't finish 879 /* Set up task in case topology creation doesn't finish
894 * within a reasonable amount of time */ 880 * within a reasonable amount of time */
895 die_task = GNUNET_SCHEDULER_add_delayed (sched, 881 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
896 TIMEOUT,
897 &end_badly, "from create_topology"); 882 &end_badly, "from create_topology");
898 GNUNET_SCHEDULER_add_now(sched, &create_topology, NULL); 883 GNUNET_SCHEDULER_add_now(&create_topology, NULL);
899 ok = 0; 884 ok = 0;
900 } 885 }
901} 886}
902 887
903static void 888static void
904run (void *cls, 889run (void *cls,
905 struct GNUNET_SCHEDULER_Handle *s,
906 char *const *args, 890 char *const *args,
907 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 891 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
908{ 892{
@@ -912,7 +896,6 @@ run (void *cls,
912 char * connect_topology_option_str; 896 char * connect_topology_option_str;
913 char * connect_topology_option_modifier_string; 897 char * connect_topology_option_modifier_string;
914 unsigned long long temp_settle; 898 unsigned long long temp_settle;
915 sched = s;
916 ok = 1; 899 ok = 1;
917 900
918 dotOutFile = fopen (dotOutFileName, "w"); 901 dotOutFile = fopen (dotOutFileName, "w");
@@ -1006,12 +989,11 @@ run (void *cls,
1006 fprintf (stdout, "Hostkey generation progress: ["); 989 fprintf (stdout, "Hostkey generation progress: [");
1007#endif 990#endif
1008 /* Set up a task to end testing if peer start fails */ 991 /* Set up a task to end testing if peer start fails */
1009 die_task = GNUNET_SCHEDULER_add_delayed (sched, 992 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers),
1010 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers),
1011 &end_badly, "didn't generate all hostkeys within a reasonable amount of time!!!"); 993 &end_badly, "didn't generate all hostkeys within a reasonable amount of time!!!");
1012 994
1013 GNUNET_assert(num_peers > 0 && num_peers < (unsigned int)-1); 995 GNUNET_assert(num_peers > 0 && num_peers < (unsigned int)-1);
1014 pg = GNUNET_TESTING_daemons_start (sched, cfg, 996 pg = GNUNET_TESTING_daemons_start (cfg,
1015 peers_left, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), &hostkey_callback, NULL, &peers_started_callback, NULL, 997 peers_left, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), &hostkey_callback, NULL, &peers_started_callback, NULL,
1016 &topology_callback, NULL, NULL); 998 &topology_callback, NULL, NULL);
1017 999
diff --git a/src/testing/test_testing_topology_blacklist.c b/src/testing/test_testing_topology_blacklist.c
index 8f9a469e5..13df683e9 100644
--- a/src/testing/test_testing_topology_blacklist.c
+++ b/src/testing/test_testing_topology_blacklist.c
@@ -57,8 +57,6 @@ static unsigned long long peers_left;
57 57
58static struct GNUNET_TESTING_PeerGroup *pg; 58static struct GNUNET_TESTING_PeerGroup *pg;
59 59
60static struct GNUNET_SCHEDULER_Handle *sched;
61
62const struct GNUNET_CONFIGURATION_Handle *main_cfg; 60const struct GNUNET_CONFIGURATION_Handle *main_cfg;
63 61
64GNUNET_SCHEDULER_TaskIdentifier die_task; 62GNUNET_SCHEDULER_TaskIdentifier die_task;
@@ -213,25 +211,22 @@ topology_callback (void *cls,
213 total_connections); 211 total_connections);
214#endif 212#endif
215 213
216 GNUNET_SCHEDULER_cancel (sched, die_task); 214 GNUNET_SCHEDULER_cancel (die_task);
217 die_task = GNUNET_SCHEDULER_NO_TASK; 215 die_task = GNUNET_SCHEDULER_NO_TASK;
218 die_task = GNUNET_SCHEDULER_add_now (sched, 216 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many successful connections)");
219 &end_badly, "from topology_callback (too many successful connections)");
220 } 217 }
221 else if (total_connections + failed_connections == expected_connections) 218 else if (total_connections + failed_connections == expected_connections)
222 { 219 {
223 if ((failed_connections == expected_failed_connections) && (total_connections == expected_connections - expected_failed_connections)) 220 if ((failed_connections == expected_failed_connections) && (total_connections == expected_connections - expected_failed_connections))
224 { 221 {
225 GNUNET_SCHEDULER_cancel (sched, die_task); 222 GNUNET_SCHEDULER_cancel (die_task);
226 die_task = GNUNET_SCHEDULER_NO_TASK; 223 die_task = GNUNET_SCHEDULER_NO_TASK;
227 die_task = GNUNET_SCHEDULER_add_now (sched, 224 die_task = GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
228 &finish_testing, NULL);
229 } 225 }
230 else 226 else
231 { 227 {
232 GNUNET_SCHEDULER_cancel (sched, die_task); 228 GNUNET_SCHEDULER_cancel (die_task);
233 die_task = GNUNET_SCHEDULER_add_now (sched, 229 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (wrong number of failed connections)");
234 &end_badly, "from topology_callback (wrong number of failed connections)");
235 } 230 }
236 } 231 }
237 else 232 else
@@ -257,15 +252,13 @@ connect_topology ()
257#endif 252#endif
258 } 253 }
259 254
260 GNUNET_SCHEDULER_cancel (sched, die_task); 255 GNUNET_SCHEDULER_cancel (die_task);
261 if (expected_connections == GNUNET_SYSERR) 256 if (expected_connections == GNUNET_SYSERR)
262 { 257 {
263 die_task = GNUNET_SCHEDULER_add_now (sched, 258 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)");
264 &end_badly, "from connect topology (bad return)");
265 } 259 }
266 260
267 die_task = GNUNET_SCHEDULER_add_delayed (sched, 261 die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT,
268 TEST_TIMEOUT,
269 &end_badly, "from connect topology (timeout)"); 262 &end_badly, "from connect topology (timeout)");
270} 263}
271 264
@@ -283,13 +276,11 @@ create_topology ()
283 } 276 }
284 else 277 else
285 { 278 {
286 GNUNET_SCHEDULER_cancel (sched, die_task); 279 GNUNET_SCHEDULER_cancel (die_task);
287 die_task = GNUNET_SCHEDULER_add_now (sched, 280 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from create topology (bad return)");
288 &end_badly, "from create topology (bad return)");
289 } 281 }
290 GNUNET_SCHEDULER_cancel (sched, die_task); 282 GNUNET_SCHEDULER_cancel (die_task);
291 die_task = GNUNET_SCHEDULER_add_delayed (sched, 283 die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT,
292 TEST_TIMEOUT,
293 &end_badly, "from continue startup (timeout)"); 284 &end_badly, "from continue startup (timeout)");
294} 285}
295 286
@@ -319,11 +310,10 @@ peers_started_callback (void *cls,
319 "All %d daemons started, now creating topology!\n", 310 "All %d daemons started, now creating topology!\n",
320 num_peers); 311 num_peers);
321#endif 312#endif
322 GNUNET_SCHEDULER_cancel (sched, die_task); 313 GNUNET_SCHEDULER_cancel (die_task);
323 /* Set up task in case topology creation doesn't finish 314 /* Set up task in case topology creation doesn't finish
324 * within a reasonable amount of time */ 315 * within a reasonable amount of time */
325 die_task = GNUNET_SCHEDULER_add_delayed (sched, 316 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
326 GNUNET_TIME_relative_multiply
327 (GNUNET_TIME_UNIT_MINUTES, 5), 317 (GNUNET_TIME_UNIT_MINUTES, 5),
328 &end_badly, "from peers_started_callback"); 318 &end_badly, "from peers_started_callback");
329 connect_topology (); 319 connect_topology ();
@@ -362,21 +352,19 @@ void hostkey_callback (void *cls,
362 "All %d hostkeys created, now creating topology!\n", 352 "All %d hostkeys created, now creating topology!\n",
363 num_peers); 353 num_peers);
364#endif 354#endif
365 GNUNET_SCHEDULER_cancel (sched, die_task); 355 GNUNET_SCHEDULER_cancel (die_task);
366 /* Set up task in case topology creation doesn't finish 356 /* Set up task in case topology creation doesn't finish
367 * within a reasonable amount of time */ 357 * within a reasonable amount of time */
368 die_task = GNUNET_SCHEDULER_add_delayed (sched, 358 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
369 GNUNET_TIME_relative_multiply
370 (GNUNET_TIME_UNIT_MINUTES, 5), 359 (GNUNET_TIME_UNIT_MINUTES, 5),
371 &end_badly, "from hostkey_callback"); 360 &end_badly, "from hostkey_callback");
372 GNUNET_SCHEDULER_add_now(sched, &create_topology, NULL); 361 GNUNET_SCHEDULER_add_now(&create_topology, NULL);
373 ok = 0; 362 ok = 0;
374 } 363 }
375} 364}
376 365
377static void 366static void
378run (void *cls, 367run (void *cls,
379 struct GNUNET_SCHEDULER_Handle *s,
380 char *const *args, 368 char *const *args,
381 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 369 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
382{ 370{
@@ -385,7 +373,6 @@ run (void *cls,
385 unsigned long long blacklist_topology_num; 373 unsigned long long blacklist_topology_num;
386 unsigned long long connect_topology_option_num; 374 unsigned long long connect_topology_option_num;
387 char *connect_topology_option_modifier_string; 375 char *connect_topology_option_modifier_string;
388 sched = s;
389 ok = 1; 376 ok = 1;
390 377
391 dotOutFile = fopen (dotOutFileName, "w"); 378 dotOutFile = fopen (dotOutFileName, "w");
@@ -483,12 +470,11 @@ run (void *cls,
483 470
484 471
485 /* Set up a task to end testing if peer start fails */ 472 /* Set up a task to end testing if peer start fails */
486 die_task = GNUNET_SCHEDULER_add_delayed (sched, 473 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
487 GNUNET_TIME_relative_multiply
488 (GNUNET_TIME_UNIT_MINUTES, 5), 474 (GNUNET_TIME_UNIT_MINUTES, 5),
489 &end_badly, "didn't start all daemons in reasonable amount of time!!!"); 475 &end_badly, "didn't start all daemons in reasonable amount of time!!!");
490 476
491 pg = GNUNET_TESTING_daemons_start (sched, cfg, 477 pg = GNUNET_TESTING_daemons_start (cfg,
492 peers_left, TIMEOUT, &hostkey_callback, NULL, &peers_started_callback, NULL, 478 peers_left, TIMEOUT, &hostkey_callback, NULL, &peers_started_callback, NULL,
493 &topology_callback, NULL, NULL); 479 &topology_callback, NULL, NULL);
494 480
diff --git a/src/testing/test_testing_topology_churn.c b/src/testing/test_testing_topology_churn.c
index a4b80e4a4..0e3647015 100644
--- a/src/testing/test_testing_topology_churn.c
+++ b/src/testing/test_testing_topology_churn.c
@@ -51,8 +51,6 @@ static unsigned long long peers_left;
51 51
52static struct GNUNET_TESTING_PeerGroup *pg; 52static struct GNUNET_TESTING_PeerGroup *pg;
53 53
54static struct GNUNET_SCHEDULER_Handle *sched;
55
56const struct GNUNET_CONFIGURATION_Handle *main_cfg; 54const struct GNUNET_CONFIGURATION_Handle *main_cfg;
57 55
58GNUNET_SCHEDULER_TaskIdentifier die_task; 56GNUNET_SCHEDULER_TaskIdentifier die_task;
@@ -104,7 +102,7 @@ finish_testing ()
104 GNUNET_assert (pg != NULL); 102 GNUNET_assert (pg != NULL);
105 103
106 if (die_task != GNUNET_SCHEDULER_NO_TASK) 104 if (die_task != GNUNET_SCHEDULER_NO_TASK)
107 GNUNET_SCHEDULER_cancel(sched, die_task); 105 GNUNET_SCHEDULER_cancel(die_task);
108 106
109#if VERBOSE 107#if VERBOSE
110 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 108 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -161,13 +159,13 @@ void churn_callback(void *cls,
161 if (emsg == NULL) 159 if (emsg == NULL)
162 { 160 {
163 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Successfully churned peers!\n", emsg); 161 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Successfully churned peers!\n", emsg);
164 GNUNET_SCHEDULER_add_now(sched, churn_ctx.next_task, NULL); 162 GNUNET_SCHEDULER_add_now(churn_ctx.next_task, NULL);
165 } 163 }
166 else 164 else
167 { 165 {
168 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Failed to churn peers with error `%s'\n", emsg); 166 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Failed to churn peers with error `%s'\n", emsg);
169 GNUNET_SCHEDULER_cancel(sched, die_task); 167 GNUNET_SCHEDULER_cancel(die_task);
170 die_task = GNUNET_SCHEDULER_add_now(sched, &end_badly, NULL); 168 die_task = GNUNET_SCHEDULER_add_now(&end_badly, NULL);
171 } 169 }
172} 170}
173 171
@@ -225,11 +223,10 @@ peers_started_callback (void *cls,
225 "All %d daemons started, now testing churn!\n", 223 "All %d daemons started, now testing churn!\n",
226 num_peers); 224 num_peers);
227#endif 225#endif
228 GNUNET_SCHEDULER_cancel (sched, die_task); 226 GNUNET_SCHEDULER_cancel (die_task);
229 /* Set up task in case topology creation doesn't finish 227 /* Set up task in case topology creation doesn't finish
230 * within a reasonable amount of time */ 228 * within a reasonable amount of time */
231 die_task = GNUNET_SCHEDULER_add_delayed (sched, 229 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
232 GNUNET_TIME_relative_multiply
233 (GNUNET_TIME_UNIT_MINUTES, 5), 230 (GNUNET_TIME_UNIT_MINUTES, 5),
234 &end_badly, "from peers_started_callback"); 231 &end_badly, "from peers_started_callback");
235 churn_peers_off (); 232 churn_peers_off ();
@@ -240,11 +237,9 @@ peers_started_callback (void *cls,
240 237
241static void 238static void
242run (void *cls, 239run (void *cls,
243 struct GNUNET_SCHEDULER_Handle *s,
244 char *const *args, 240 char *const *args,
245 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 241 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
246{ 242{
247 sched = s;
248 ok = 1; 243 ok = 1;
249 244
250#if VERBOSE 245#if VERBOSE
@@ -278,12 +273,11 @@ run (void *cls,
278 273
279 274
280 /* Set up a task to end testing if peer start fails */ 275 /* Set up a task to end testing if peer start fails */
281 die_task = GNUNET_SCHEDULER_add_delayed (sched, 276 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
282 GNUNET_TIME_relative_multiply
283 (GNUNET_TIME_UNIT_MINUTES, 5), 277 (GNUNET_TIME_UNIT_MINUTES, 5),
284 &end_badly, "didn't start all daemons in reasonable amount of time!!!"); 278 &end_badly, "didn't start all daemons in reasonable amount of time!!!");
285 279
286 pg = GNUNET_TESTING_daemons_start (sched, cfg, 280 pg = GNUNET_TESTING_daemons_start (cfg,
287 peers_left, TIMEOUT, NULL, NULL, &peers_started_callback, NULL, 281 peers_left, TIMEOUT, NULL, NULL, &peers_started_callback, NULL,
288 NULL, NULL, NULL); 282 NULL, NULL, NULL);
289 283
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 89272f3c2..d5b585a62 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -160,8 +160,7 @@ testing_init (void *cls,
160#endif 160#endif
161 161
162 162
163 d->th = GNUNET_TRANSPORT_connect (d->sched, 163 d->th = GNUNET_TRANSPORT_connect (d->cfg,
164 d->cfg,
165 &d->id, 164 &d->id,
166 d, NULL, NULL, NULL); 165 d, NULL, NULL, NULL);
167 if (d->th == NULL) 166 if (d->th == NULL)
@@ -219,8 +218,7 @@ start_fsm (void *cls,
219 } 218 }
220 /* wait some more */ 219 /* wait some more */
221 d->task 220 d->task
222 = GNUNET_SCHEDULER_add_delayed (d->sched, 221 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT,
223 GNUNET_CONSTANTS_EXEC_WAIT,
224 &start_fsm, d); 222 &start_fsm, d);
225 return; 223 return;
226 } 224 }
@@ -333,8 +331,7 @@ start_fsm (void *cls,
333#endif 331#endif
334 d->phase = SP_HOSTKEY_CREATE; 332 d->phase = SP_HOSTKEY_CREATE;
335 d->task 333 d->task
336 = GNUNET_SCHEDULER_add_read_file (d->sched, 334 = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining(d->max_timeout),
337 GNUNET_TIME_absolute_get_remaining(d->max_timeout),
338 GNUNET_DISK_pipe_handle(d->pipe_stdout, 335 GNUNET_DISK_pipe_handle(d->pipe_stdout,
339 GNUNET_DISK_PIPE_END_READ), 336 GNUNET_DISK_PIPE_END_READ),
340 &start_fsm, 337 &start_fsm,
@@ -353,8 +350,7 @@ start_fsm (void *cls,
353 { 350 {
354 /* keep reading */ 351 /* keep reading */
355 d->task 352 d->task
356 = GNUNET_SCHEDULER_add_read_file (d->sched, 353 = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining(d->max_timeout),
357 GNUNET_TIME_absolute_get_remaining(d->max_timeout),
358 GNUNET_DISK_pipe_handle(d->pipe_stdout, 354 GNUNET_DISK_pipe_handle(d->pipe_stdout,
359 GNUNET_DISK_PIPE_END_READ), 355 GNUNET_DISK_PIPE_END_READ),
360 &start_fsm, 356 &start_fsm,
@@ -426,8 +422,7 @@ start_fsm (void *cls,
426 } 422 }
427 423
428 d->task 424 d->task
429 = GNUNET_SCHEDULER_add_delayed (d->sched, 425 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT,
430 GNUNET_CONSTANTS_EXEC_WAIT,
431 &start_fsm, d); 426 &start_fsm, d);
432 break; 427 break;
433 case SP_TOPOLOGY_SETUP: 428 case SP_TOPOLOGY_SETUP:
@@ -517,8 +512,7 @@ start_fsm (void *cls,
517#endif 512#endif
518 d->phase = SP_START_ARMING; 513 d->phase = SP_START_ARMING;
519 d->task 514 d->task
520 = GNUNET_SCHEDULER_add_delayed (d->sched, 515 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT,
521 GNUNET_CONSTANTS_EXEC_WAIT,
522 &start_fsm, d); 516 &start_fsm, d);
523 break; 517 break;
524 case SP_START_ARMING: 518 case SP_START_ARMING:
@@ -540,8 +534,7 @@ start_fsm (void *cls,
540 } 534 }
541 /* wait some more */ 535 /* wait some more */
542 d->task 536 d->task
543 = GNUNET_SCHEDULER_add_delayed (d->sched, 537 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT,
544 GNUNET_CONSTANTS_EXEC_WAIT,
545 &start_fsm, d); 538 &start_fsm, d);
546 return; 539 return;
547 } 540 }
@@ -550,8 +543,7 @@ start_fsm (void *cls,
550 "Successfully started `%s'.\n", "gnunet-arm"); 543 "Successfully started `%s'.\n", "gnunet-arm");
551#endif 544#endif
552 d->phase = SP_START_CORE; 545 d->phase = SP_START_CORE;
553 d->server = GNUNET_CORE_connect (d->sched, 546 d->server = GNUNET_CORE_connect (d->cfg,
554 d->cfg,
555 ARM_START_WAIT, 547 ARM_START_WAIT,
556 d, 548 d,
557 &testing_init, 549 &testing_init,
@@ -591,8 +583,7 @@ start_fsm (void *cls,
591 } 583 }
592 /* wait some more */ 584 /* wait some more */
593 d->task 585 d->task
594 = GNUNET_SCHEDULER_add_delayed (d->sched, 586 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT,
595 GNUNET_CONSTANTS_EXEC_WAIT,
596 &start_fsm, d); 587 &start_fsm, d);
597 return; 588 return;
598 } 589 }
@@ -661,8 +652,7 @@ start_fsm (void *cls,
661 } 652 }
662 /* wait some more */ 653 /* wait some more */
663 d->task 654 d->task
664 = GNUNET_SCHEDULER_add_delayed (d->sched, 655 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT,
665 GNUNET_CONSTANTS_EXEC_WAIT,
666 &start_fsm, d); 656 &start_fsm, d);
667 return; 657 return;
668 } 658 }
@@ -744,8 +734,7 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon,
744 daemon->phase = SP_TOPOLOGY_SETUP; 734 daemon->phase = SP_TOPOLOGY_SETUP;
745 daemon->max_timeout = GNUNET_TIME_relative_to_absolute(timeout); 735 daemon->max_timeout = GNUNET_TIME_relative_to_absolute(timeout);
746 736
747 GNUNET_SCHEDULER_add_continuation (daemon->sched, 737 GNUNET_SCHEDULER_add_continuation (&start_fsm,
748 &start_fsm,
749 daemon, 738 daemon,
750 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 739 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
751} 740}
@@ -756,7 +745,6 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon,
756 * reachable via "ssh" (unless the hostname is "NULL") without the 745 * reachable via "ssh" (unless the hostname is "NULL") without the
757 * need to enter a password. 746 * need to enter a password.
758 * 747 *
759 * @param sched scheduler to use
760 * @param cfg configuration to use 748 * @param cfg configuration to use
761 * @param timeout how long to wait starting up peers 749 * @param timeout how long to wait starting up peers
762 * @param hostname name of the machine where to run GNUnet 750 * @param hostname name of the machine where to run GNUnet
@@ -772,8 +760,7 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon,
772 * @return handle to the daemon (actual start will be completed asynchronously) 760 * @return handle to the daemon (actual start will be completed asynchronously)
773 */ 761 */
774struct GNUNET_TESTING_Daemon * 762struct GNUNET_TESTING_Daemon *
775GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, 763GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
776 const struct GNUNET_CONFIGURATION_Handle *cfg,
777 struct GNUNET_TIME_Relative timeout, 764 struct GNUNET_TIME_Relative timeout,
778 const char *hostname, 765 const char *hostname,
779 const char *ssh_username, 766 const char *ssh_username,
@@ -788,7 +775,6 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched,
788 char *username; 775 char *username;
789 776
790 ret = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Daemon)); 777 ret = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Daemon));
791 ret->sched = sched;
792 ret->hostname = (hostname == NULL) ? NULL : GNUNET_strdup (hostname); 778 ret->hostname = (hostname == NULL) ? NULL : GNUNET_strdup (hostname);
793 if (sshport != 0) 779 if (sshport != 0)
794 { 780 {
@@ -892,8 +878,7 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched,
892 return NULL; 878 return NULL;
893 } 879 }
894 ret->task 880 ret->task
895 = GNUNET_SCHEDULER_add_delayed (sched, 881 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT,
896 GNUNET_CONSTANTS_EXEC_WAIT,
897 &start_fsm, ret); 882 &start_fsm, ret);
898 return ret; 883 return ret;
899 } 884 }
@@ -902,8 +887,7 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched,
902 "No need to copy configuration file since we are running locally.\n"); 887 "No need to copy configuration file since we are running locally.\n");
903#endif 888#endif
904 ret->phase = SP_COPIED; 889 ret->phase = SP_COPIED;
905 GNUNET_SCHEDULER_add_continuation (sched, 890 GNUNET_SCHEDULER_add_continuation (&start_fsm,
906 &start_fsm,
907 ret, 891 ret,
908 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 892 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
909 return ret; 893 return ret;
@@ -936,7 +920,7 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d,
936 920
937 if (d->phase == SP_CONFIG_UPDATE) 921 if (d->phase == SP_CONFIG_UPDATE)
938 { 922 {
939 GNUNET_SCHEDULER_cancel (d->sched, d->task); 923 GNUNET_SCHEDULER_cancel (d->task);
940 d->phase = SP_START_DONE; 924 d->phase = SP_START_DONE;
941 } 925 }
942 if (d->server != NULL) 926 if (d->server != NULL)
@@ -1003,8 +987,7 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d,
1003 987
1004 GNUNET_free_non_null(del_arg); 988 GNUNET_free_non_null(del_arg);
1005 d->task 989 d->task
1006 = GNUNET_SCHEDULER_add_delayed (d->sched, 990 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT,
1007 GNUNET_CONSTANTS_EXEC_WAIT,
1008 &start_fsm, d); 991 &start_fsm, d);
1009 992
1010} 993}
@@ -1073,7 +1056,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
1073 1056
1074 if (d->phase == SP_CONFIG_UPDATE) 1057 if (d->phase == SP_CONFIG_UPDATE)
1075 { 1058 {
1076 GNUNET_SCHEDULER_cancel (d->sched, d->task); 1059 GNUNET_SCHEDULER_cancel (d->task);
1077 d->phase = SP_START_DONE; 1060 d->phase = SP_START_DONE;
1078 } 1061 }
1079 if (d->server != NULL) 1062 if (d->server != NULL)
@@ -1140,8 +1123,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
1140 GNUNET_free_non_null(del_arg); 1123 GNUNET_free_non_null(del_arg);
1141 d->max_timeout = GNUNET_TIME_relative_to_absolute(timeout); 1124 d->max_timeout = GNUNET_TIME_relative_to_absolute(timeout);
1142 d->task 1125 d->task
1143 = GNUNET_SCHEDULER_add_now (d->sched, 1126 = GNUNET_SCHEDULER_add_now (&start_fsm, d);
1144 &start_fsm, d);
1145} 1127}
1146 1128
1147 1129
@@ -1216,8 +1198,7 @@ GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d,
1216 d->update_cb = cb; 1198 d->update_cb = cb;
1217 d->update_cb_cls = cb_cls; 1199 d->update_cb_cls = cb_cls;
1218 d->task 1200 d->task
1219 = GNUNET_SCHEDULER_add_delayed (d->sched, 1201 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT,
1220 GNUNET_CONSTANTS_EXEC_WAIT,
1221 &start_fsm, d); 1202 &start_fsm, d);
1222} 1203}
1223 1204
@@ -1331,7 +1312,7 @@ notify_connect_result (void *cls,
1331 ctx->timeout_task = GNUNET_SCHEDULER_NO_TASK; 1312 ctx->timeout_task = GNUNET_SCHEDULER_NO_TASK;
1332 if (ctx->hello_send_task != GNUNET_SCHEDULER_NO_TASK) 1313 if (ctx->hello_send_task != GNUNET_SCHEDULER_NO_TASK)
1333 { 1314 {
1334 GNUNET_SCHEDULER_cancel(ctx->d1->sched, ctx->hello_send_task); 1315 GNUNET_SCHEDULER_cancel(ctx->hello_send_task);
1335 ctx->hello_send_task = GNUNET_SCHEDULER_NO_TASK; 1316 ctx->hello_send_task = GNUNET_SCHEDULER_NO_TASK;
1336 } 1317 }
1337 1318
@@ -1388,7 +1369,7 @@ notify_connect_result (void *cls,
1388 GNUNET_TRANSPORT_disconnect(ctx->d2th); 1369 GNUNET_TRANSPORT_disconnect(ctx->d2th);
1389 ctx->d2th = NULL; 1370 ctx->d2th = NULL;
1390 } 1371 }
1391 GNUNET_SCHEDULER_add_now(ctx->d1->sched, &reattempt_daemons_connect, ctx); 1372 GNUNET_SCHEDULER_add_now(&reattempt_daemons_connect, ctx);
1392 return; 1373 return;
1393 } 1374 }
1394 else 1375 else
@@ -1428,9 +1409,8 @@ connect_notify (void *cls, const struct GNUNET_PeerIdentity * peer, struct GNUNE
1428 { 1409 {
1429 ctx->connected = GNUNET_YES; 1410 ctx->connected = GNUNET_YES;
1430 ctx->distance = distance; 1411 ctx->distance = distance;
1431 GNUNET_SCHEDULER_cancel(ctx->d1->sched, ctx->timeout_task); 1412 GNUNET_SCHEDULER_cancel(ctx->timeout_task);
1432 ctx->timeout_task = GNUNET_SCHEDULER_add_now (ctx->d1->sched, 1413 ctx->timeout_task = GNUNET_SCHEDULER_add_now (&notify_connect_result,
1433 &notify_connect_result,
1434 ctx); 1414 ctx);
1435 } 1415 }
1436 1416
@@ -1456,9 +1436,8 @@ connect_notify_core2 (void *cls, const struct GNUNET_PeerIdentity * peer, struct
1456 { 1436 {
1457 ctx->connected = GNUNET_YES; 1437 ctx->connected = GNUNET_YES;
1458 ctx->distance = distance; 1438 ctx->distance = distance;
1459 GNUNET_SCHEDULER_cancel(ctx->d1->sched, ctx->timeout_task); 1439 GNUNET_SCHEDULER_cancel(ctx->timeout_task);
1460 ctx->timeout_task = GNUNET_SCHEDULER_add_now (ctx->d1->sched, 1440 ctx->timeout_task = GNUNET_SCHEDULER_add_now (&notify_connect_result,
1461 &notify_connect_result,
1462 ctx); 1441 ctx);
1463 } 1442 }
1464 1443
@@ -1496,8 +1475,7 @@ send_hello(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1496 GNUNET_assert(hello != NULL); 1475 GNUNET_assert(hello != NULL);
1497 GNUNET_TRANSPORT_offer_hello (ctx->d2th, hello); 1476 GNUNET_TRANSPORT_offer_hello (ctx->d2th, hello);
1498 1477
1499 ctx->connect_request_handle = GNUNET_CORE_peer_request_connect (ctx->d1->sched, 1478 ctx->connect_request_handle = GNUNET_CORE_peer_request_connect (ctx->d2->cfg,
1500 ctx->d2->cfg,
1501 GNUNET_TIME_relative_divide(ctx->relative_timeout, 1479 GNUNET_TIME_relative_divide(ctx->relative_timeout,
1502 ctx->max_connect_attempts + 1), 1480 ctx->max_connect_attempts + 1),
1503 &ctx->d1->id, 1481 &ctx->d1->id,
@@ -1508,8 +1486,7 @@ send_hello(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1508 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 1486 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS,
1509 500)); 1487 500));
1510 } 1488 }
1511 ctx->hello_send_task = GNUNET_SCHEDULER_add_delayed(ctx->d1->sched, 1489 ctx->hello_send_task = GNUNET_SCHEDULER_add_delayed(ctx->timeout_hello,
1512 ctx->timeout_hello,
1513 &send_hello, ctx); 1490 &send_hello, ctx);
1514} 1491}
1515 1492
@@ -1558,8 +1535,7 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
1558 d1->shortname, d2->shortname); 1535 d1->shortname, d2->shortname);
1559#endif 1536#endif
1560 1537
1561 ctx->d1core = GNUNET_CORE_connect (d1->sched, 1538 ctx->d1core = GNUNET_CORE_connect (d1->cfg,
1562 d1->cfg,
1563 timeout, 1539 timeout,
1564 ctx, 1540 ctx,
1565 NULL, 1541 NULL,
@@ -1576,8 +1552,7 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
1576 } 1552 }
1577 1553
1578#if CONNECT_CORE2 1554#if CONNECT_CORE2
1579 ctx->d2core = GNUNET_CORE_connect (d2->sched, 1555 ctx->d2core = GNUNET_CORE_connect (d2->cfg,
1580 d2->cfg,
1581 timeout, 1556 timeout,
1582 ctx, 1557 ctx,
1583 NULL, 1558 NULL,
@@ -1603,8 +1578,7 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
1603 1578
1604#endif 1579#endif
1605 1580
1606 ctx->d2th = GNUNET_TRANSPORT_connect (d2->sched, 1581 ctx->d2th = GNUNET_TRANSPORT_connect (d2->cfg,
1607 d2->cfg,
1608 &d2->id, 1582 &d2->id,
1609 d2, NULL, NULL, NULL); 1583 d2, NULL, NULL, NULL);
1610 if (ctx->d2th == NULL) 1584 if (ctx->d2th == NULL)
@@ -1617,12 +1591,11 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
1617 return; 1591 return;
1618 } 1592 }
1619 1593
1620 ctx->timeout_task = GNUNET_SCHEDULER_add_delayed (d1->sched, 1594 ctx->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide(ctx->relative_timeout,
1621 GNUNET_TIME_relative_divide(ctx->relative_timeout,
1622 ctx->max_connect_attempts), 1595 ctx->max_connect_attempts),
1623 &notify_connect_result, ctx); 1596 &notify_connect_result, ctx);
1624 1597
1625 ctx->hello_send_task = GNUNET_SCHEDULER_add_now(ctx->d1->sched, &send_hello, ctx); 1598 ctx->hello_send_task = GNUNET_SCHEDULER_add_now(&send_hello, ctx);
1626} 1599}
1627 1600
1628static void 1601static void
@@ -1641,8 +1614,7 @@ reattempt_daemons_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext
1641 1614
1642 GNUNET_assert(ctx->d1core == NULL); 1615 GNUNET_assert(ctx->d1core == NULL);
1643 1616
1644 ctx->d1core = GNUNET_CORE_connect (ctx->d1->sched, 1617 ctx->d1core = GNUNET_CORE_connect (ctx->d1->cfg,
1645 ctx->d1->cfg,
1646 GNUNET_TIME_absolute_get_remaining(ctx->timeout), 1618 GNUNET_TIME_absolute_get_remaining(ctx->timeout),
1647 ctx, 1619 ctx,
1648 NULL, 1620 NULL,
@@ -1658,8 +1630,7 @@ reattempt_daemons_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext
1658 return; 1630 return;
1659 } 1631 }
1660 1632
1661 ctx->d2th = GNUNET_TRANSPORT_connect (ctx->d2->sched, 1633 ctx->d2th = GNUNET_TRANSPORT_connect (ctx->d2->cfg,
1662 ctx->d2->cfg,
1663 &ctx->d2->id, 1634 &ctx->d2->id,
1664 ctx->d2, NULL, NULL, NULL); 1635 ctx->d2, NULL, NULL, NULL);
1665 if (ctx->d2th == NULL) 1636 if (ctx->d2th == NULL)
@@ -1672,11 +1643,10 @@ reattempt_daemons_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext
1672 return; 1643 return;
1673 } 1644 }
1674 1645
1675 ctx->timeout_task = GNUNET_SCHEDULER_add_delayed (ctx->d1->sched, 1646 ctx->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide(ctx->relative_timeout, ctx->max_connect_attempts),
1676 GNUNET_TIME_relative_divide(ctx->relative_timeout, ctx->max_connect_attempts),
1677 &notify_connect_result, ctx); 1647 &notify_connect_result, ctx);
1678 1648
1679 ctx->hello_send_task = GNUNET_SCHEDULER_add_now(ctx->d1->sched, &send_hello, ctx); 1649 ctx->hello_send_task = GNUNET_SCHEDULER_add_now(&send_hello, ctx);
1680} 1650}
1681 1651
1682/* end of testing.c */ 1652/* end of testing.c */
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index 7322fc44a..8697044e3 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -481,11 +481,6 @@ struct StatsCoreContext
481struct GNUNET_TESTING_PeerGroup 481struct GNUNET_TESTING_PeerGroup
482{ 482{
483 /** 483 /**
484 * Our scheduler.
485 */
486 struct GNUNET_SCHEDULER_Handle *sched;
487
488 /**
489 * Configuration template. 484 * Configuration template.
490 */ 485 */
491 const struct GNUNET_CONFIGURATION_Handle *cfg; 486 const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -2252,7 +2247,7 @@ static void schedule_connect(void *cls, const struct GNUNET_SCHEDULER_TaskContex
2252 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2247 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2253 _("Delaying connect, we have too many outstanding connections!\n")); 2248 _("Delaying connect, we have too many outstanding connections!\n"));
2254#endif 2249#endif
2255 GNUNET_SCHEDULER_add_delayed(connect_context->ct_ctx->pg->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_connect, connect_context); 2250 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_connect, connect_context);
2256 } 2251 }
2257 else 2252 else
2258 { 2253 {
@@ -2296,7 +2291,7 @@ connect_iterator (void *cls,
2296 connect_context->first = first->daemon; 2291 connect_context->first = first->daemon;
2297 connect_context->second = second; 2292 connect_context->second = second;
2298 connect_context->ct_ctx = ct_ctx; 2293 connect_context->ct_ctx = ct_ctx;
2299 GNUNET_SCHEDULER_add_now(first->pg->sched, &schedule_connect, connect_context); 2294 GNUNET_SCHEDULER_add_now(&schedule_connect, connect_context);
2300 2295
2301 return GNUNET_YES; 2296 return GNUNET_YES;
2302} 2297}
@@ -2404,7 +2399,7 @@ connect_topology (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_NotifyComp
2404 connect_context->pg = pg; 2399 connect_context->pg = pg;
2405 connect_context->first = FIXME; 2400 connect_context->first = FIXME;
2406 connect_context->second = connection_iter->daemon; 2401 connect_context->second = connection_iter->daemon;
2407 GNUNET_SCHEDULER_add_now(pg->sched, &schedule_connect, connect_context); 2402 GNUNET_SCHEDULER_add_now(&schedule_connect, connect_context);
2408 connection_iter = connection_iter->next; 2403 connection_iter = connection_iter->next;
2409 } 2404 }
2410#endif 2405#endif
@@ -3156,7 +3151,7 @@ schedule_get_topology(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3156 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3151 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3157 _("Delaying connect, we have too many outstanding connections!\n")); 3152 _("Delaying connect, we have too many outstanding connections!\n"));
3158#endif 3153#endif
3159 GNUNET_SCHEDULER_add_delayed(core_context->daemon->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_get_topology, core_context); 3154 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_get_topology, core_context);
3160 } 3155 }
3161 else 3156 else
3162 { 3157 {
@@ -3165,7 +3160,7 @@ schedule_get_topology(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3165 _("Creating connection, outstanding_connections is %d\n"), outstanding_connects); 3160 _("Creating connection, outstanding_connections is %d\n"), outstanding_connects);
3166#endif 3161#endif
3167 topology_context->connected++; 3162 topology_context->connected++;
3168 if (GNUNET_OK != GNUNET_CORE_iterate_peers (core_context->daemon->sched, core_context->daemon->cfg, &internal_topology_callback, core_context)) 3163 if (GNUNET_OK != GNUNET_CORE_iterate_peers (core_context->daemon->cfg, &internal_topology_callback, core_context))
3169 internal_topology_callback(core_context, NULL, GNUNET_TIME_relative_get_zero(), 0); 3164 internal_topology_callback(core_context, NULL, GNUNET_TIME_relative_get_zero(), 0);
3170 3165
3171 } 3166 }
@@ -3197,7 +3192,7 @@ GNUNET_TESTING_get_topology (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING
3197 core_ctx->daemon = pg->peers[i].daemon; 3192 core_ctx->daemon = pg->peers[i].daemon;
3198 /* Set back pointer to topology iteration context */ 3193 /* Set back pointer to topology iteration context */
3199 core_ctx->iter_context = topology_context; 3194 core_ctx->iter_context = topology_context;
3200 GNUNET_SCHEDULER_add_now(pg->sched, &schedule_get_topology, core_ctx); 3195 GNUNET_SCHEDULER_add_now(&schedule_get_topology, core_ctx);
3201 total_count++; 3196 total_count++;
3202 } 3197 }
3203 } 3198 }
@@ -3276,7 +3271,7 @@ schedule_get_statistics(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc
3276 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3271 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3277 _("Delaying connect, we have too many outstanding connections!\n")); 3272 _("Delaying connect, we have too many outstanding connections!\n"));
3278#endif 3273#endif
3279 GNUNET_SCHEDULER_add_delayed(core_context->daemon->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_get_statistics, core_context); 3274 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_get_statistics, core_context);
3280 } 3275 }
3281 else 3276 else
3282 { 3277 {
@@ -3286,7 +3281,7 @@ schedule_get_statistics(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc
3286#endif 3281#endif
3287 3282
3288 stats_context->connected++; 3283 stats_context->connected++;
3289 core_context->stats_handle = GNUNET_STATISTICS_create(core_context->daemon->sched, "testing", core_context->daemon->cfg); 3284 core_context->stats_handle = GNUNET_STATISTICS_create("testing", core_context->daemon->cfg);
3290 if (core_context->stats_handle == NULL) 3285 if (core_context->stats_handle == NULL)
3291 { 3286 {
3292 internal_stats_cont (core_context, GNUNET_NO); 3287 internal_stats_cont (core_context, GNUNET_NO);
@@ -3394,7 +3389,7 @@ GNUNET_TESTING_get_statistics (struct GNUNET_TESTING_PeerGroup *pg,
3394 core_ctx->daemon = pg->peers[i].daemon; 3389 core_ctx->daemon = pg->peers[i].daemon;
3395 /* Set back pointer to topology iteration context */ 3390 /* Set back pointer to topology iteration context */
3396 core_ctx->iter_context = stats_context; 3391 core_ctx->iter_context = stats_context;
3397 GNUNET_SCHEDULER_add_now(pg->sched, &schedule_get_statistics, core_ctx); 3392 GNUNET_SCHEDULER_add_now(&schedule_get_statistics, core_ctx);
3398 total_count++; 3393 total_count++;
3399 } 3394 }
3400 } 3395 }
@@ -3626,7 +3621,7 @@ internal_continue_startup (void *cls, const struct GNUNET_SCHEDULER_TaskContext
3626 } 3621 }
3627 else 3622 else
3628 { 3623 {
3629 GNUNET_SCHEDULER_add_delayed(internal_context->peer->pg->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &internal_continue_startup, internal_context); 3624 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &internal_continue_startup, internal_context);
3630 } 3625 }
3631} 3626}
3632 3627
@@ -3697,7 +3692,7 @@ static void schedule_churn_restart(void *cls, const struct GNUNET_SCHEDULER_Task
3697 struct ChurnRestartContext *startup_ctx = peer_restart_ctx->churn_restart_ctx; 3692 struct ChurnRestartContext *startup_ctx = peer_restart_ctx->churn_restart_ctx;
3698 3693
3699 if (startup_ctx->outstanding > MAX_CONCURRENT_STARTING) 3694 if (startup_ctx->outstanding > MAX_CONCURRENT_STARTING)
3700 GNUNET_SCHEDULER_add_delayed(peer_restart_ctx->daemon->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_churn_restart, peer_restart_ctx); 3695 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_churn_restart, peer_restart_ctx);
3701 else 3696 else
3702 { 3697 {
3703 GNUNET_TESTING_daemon_start_stopped(peer_restart_ctx->daemon, 3698 GNUNET_TESTING_daemon_start_stopped(peer_restart_ctx->daemon,
@@ -3721,8 +3716,7 @@ internal_start (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
3721 if (internal_context->peer->pg->starting < MAX_CONCURRENT_HOSTKEYS) 3716 if (internal_context->peer->pg->starting < MAX_CONCURRENT_HOSTKEYS)
3722 { 3717 {
3723 internal_context->peer->pg->starting++; 3718 internal_context->peer->pg->starting++;
3724 internal_context->peer->daemon = GNUNET_TESTING_daemon_start (internal_context->peer->pg->sched, 3719 internal_context->peer->daemon = GNUNET_TESTING_daemon_start (internal_context->peer->cfg,
3725 internal_context->peer->cfg,
3726 internal_context->timeout, 3720 internal_context->timeout,
3727 internal_context->hostname, 3721 internal_context->hostname,
3728 internal_context->username, 3722 internal_context->username,
@@ -3734,7 +3728,7 @@ internal_start (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
3734 } 3728 }
3735 else 3729 else
3736 { 3730 {
3737 GNUNET_SCHEDULER_add_delayed(internal_context->peer->pg->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &internal_start, internal_context); 3731 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &internal_start, internal_context);
3738 } 3732 }
3739} 3733}
3740 3734
@@ -3753,7 +3747,7 @@ GNUNET_TESTING_daemons_continue_startup(struct GNUNET_TESTING_PeerGroup *pg)
3753 pg->starting = 0; 3747 pg->starting = 0;
3754 for (i = 0; i < pg->total; i++) 3748 for (i = 0; i < pg->total; i++)
3755 { 3749 {
3756 GNUNET_SCHEDULER_add_now (pg->sched, &internal_continue_startup, &pg->peers[i].internal_context); 3750 GNUNET_SCHEDULER_add_now (&internal_continue_startup, &pg->peers[i].internal_context);
3757 //GNUNET_TESTING_daemon_continue_startup(pg->peers[i].daemon); 3751 //GNUNET_TESTING_daemon_continue_startup(pg->peers[i].daemon);
3758 } 3752 }
3759} 3753}
@@ -3764,7 +3758,6 @@ GNUNET_TESTING_daemons_continue_startup(struct GNUNET_TESTING_PeerGroup *pg)
3764 * adjusted to ensure that no two peers running on the same system 3758 * adjusted to ensure that no two peers running on the same system
3765 * have the same port(s) in their respective configurations. 3759 * have the same port(s) in their respective configurations.
3766 * 3760 *
3767 * @param sched scheduler to use
3768 * @param cfg configuration template to use 3761 * @param cfg configuration template to use
3769 * @param total number of daemons to start 3762 * @param total number of daemons to start
3770 * @param timeout total time allowed for peers to start 3763 * @param timeout total time allowed for peers to start
@@ -3782,8 +3775,7 @@ GNUNET_TESTING_daemons_continue_startup(struct GNUNET_TESTING_PeerGroup *pg)
3782 * @return NULL on error, otherwise handle to control peer group 3775 * @return NULL on error, otherwise handle to control peer group
3783 */ 3776 */
3784struct GNUNET_TESTING_PeerGroup * 3777struct GNUNET_TESTING_PeerGroup *
3785GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, 3778GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
3786 const struct GNUNET_CONFIGURATION_Handle *cfg,
3787 unsigned int total, 3779 unsigned int total,
3788 struct GNUNET_TIME_Relative timeout, 3780 struct GNUNET_TIME_Relative timeout,
3789 GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback, 3781 GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback,
@@ -3822,7 +3814,6 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
3822 upnum = 0; 3814 upnum = 0;
3823 fdnum = 0; 3815 fdnum = 0;
3824 pg = GNUNET_malloc (sizeof (struct GNUNET_TESTING_PeerGroup)); 3816 pg = GNUNET_malloc (sizeof (struct GNUNET_TESTING_PeerGroup));
3825 pg->sched = sched;
3826 pg->cfg = cfg; 3817 pg->cfg = cfg;
3827 pg->notify_connection = connect_callback; 3818 pg->notify_connection = connect_callback;
3828 pg->notify_connection_cls = connect_callback_cls; 3819 pg->notify_connection_cls = connect_callback_cls;
@@ -3980,7 +3971,7 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
3980 pg->peers[off].internal_context.start_cb = cb; 3971 pg->peers[off].internal_context.start_cb = cb;
3981 pg->peers[off].internal_context.start_cb_cls = cb_cls; 3972 pg->peers[off].internal_context.start_cb_cls = cb_cls;
3982 3973
3983 GNUNET_SCHEDULER_add_now (sched, &internal_start, &pg->peers[off].internal_context); 3974 GNUNET_SCHEDULER_add_now (&internal_start, &pg->peers[off].internal_context);
3984 3975
3985 } 3976 }
3986 return pg; 3977 return pg;
@@ -4156,7 +4147,7 @@ schedule_churn_shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskConte
4156 GNUNET_assert(shutdown_ctx != NULL); 4147 GNUNET_assert(shutdown_ctx != NULL);
4157 4148
4158 if (shutdown_ctx->outstanding > MAX_CONCURRENT_SHUTDOWN) 4149 if (shutdown_ctx->outstanding > MAX_CONCURRENT_SHUTDOWN)
4159 GNUNET_SCHEDULER_add_delayed(peer_shutdown_ctx->daemon->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_churn_shutdown_task, peer_shutdown_ctx); 4150 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_churn_shutdown_task, peer_shutdown_ctx);
4160 else 4151 else
4161 { 4152 {
4162 shutdown_ctx->outstanding++; 4153 shutdown_ctx->outstanding++;
@@ -4309,7 +4300,7 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg,
4309 peer_shutdown_ctx = GNUNET_malloc(sizeof(struct PeerShutdownContext)); 4300 peer_shutdown_ctx = GNUNET_malloc(sizeof(struct PeerShutdownContext));
4310 peer_shutdown_ctx->daemon = pg->peers[running_arr[running_permute[i]]].daemon; 4301 peer_shutdown_ctx->daemon = pg->peers[running_arr[running_permute[i]]].daemon;
4311 peer_shutdown_ctx->shutdown_ctx = shutdown_ctx; 4302 peer_shutdown_ctx->shutdown_ctx = shutdown_ctx;
4312 GNUNET_SCHEDULER_add_now(peer_shutdown_ctx->daemon->sched, &schedule_churn_shutdown_task, peer_shutdown_ctx); 4303 GNUNET_SCHEDULER_add_now(&schedule_churn_shutdown_task, peer_shutdown_ctx);
4313 4304
4314 /* 4305 /*
4315 GNUNET_TESTING_daemon_stop (pg->peers[running_arr[running_permute[i]]].daemon, 4306 GNUNET_TESTING_daemon_stop (pg->peers[running_arr[running_permute[i]]].daemon,
@@ -4334,7 +4325,7 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg,
4334 peer_restart_ctx = GNUNET_malloc(sizeof(struct PeerRestartContext)); 4325 peer_restart_ctx = GNUNET_malloc(sizeof(struct PeerRestartContext));
4335 peer_restart_ctx->churn_restart_ctx = churn_startup_ctx; 4326 peer_restart_ctx->churn_restart_ctx = churn_startup_ctx;
4336 peer_restart_ctx->daemon = pg->peers[stopped_arr[stopped_permute[i]]].daemon; 4327 peer_restart_ctx->daemon = pg->peers[stopped_arr[stopped_permute[i]]].daemon;
4337 GNUNET_SCHEDULER_add_now(peer_restart_ctx->daemon->sched, &schedule_churn_restart, peer_restart_ctx); 4328 GNUNET_SCHEDULER_add_now(&schedule_churn_restart, peer_restart_ctx);
4338 /* 4329 /*
4339 GNUNET_TESTING_daemon_start_stopped(pg->peers[stopped_arr[stopped_permute[i]]].daemon, 4330 GNUNET_TESTING_daemon_start_stopped(pg->peers[stopped_arr[stopped_permute[i]]].daemon,
4340 timeout, &churn_start_callback, churn_ctx);*/ 4331 timeout, &churn_start_callback, churn_ctx);*/
@@ -4485,7 +4476,7 @@ schedule_shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * t
4485 GNUNET_assert(shutdown_ctx != NULL); 4476 GNUNET_assert(shutdown_ctx != NULL);
4486 4477
4487 if (shutdown_ctx->outstanding > MAX_CONCURRENT_SHUTDOWN) 4478 if (shutdown_ctx->outstanding > MAX_CONCURRENT_SHUTDOWN)
4488 GNUNET_SCHEDULER_add_delayed(peer_shutdown_ctx->daemon->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_shutdown_task, peer_shutdown_ctx); 4479 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_shutdown_task, peer_shutdown_ctx);
4489 else 4480 else
4490 { 4481 {
4491 shutdown_ctx->outstanding++; 4482 shutdown_ctx->outstanding++;
@@ -4527,7 +4518,7 @@ GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg,
4527 peer_shutdown_ctx = GNUNET_malloc(sizeof(struct PeerShutdownContext)); 4518 peer_shutdown_ctx = GNUNET_malloc(sizeof(struct PeerShutdownContext));
4528 peer_shutdown_ctx->daemon = pg->peers[off].daemon; 4519 peer_shutdown_ctx->daemon = pg->peers[off].daemon;
4529 peer_shutdown_ctx->shutdown_ctx = shutdown_ctx; 4520 peer_shutdown_ctx->shutdown_ctx = shutdown_ctx;
4530 GNUNET_SCHEDULER_add_now(pg->peers[off].daemon->sched, &schedule_shutdown_task, peer_shutdown_ctx); 4521 GNUNET_SCHEDULER_add_now(&schedule_shutdown_task, peer_shutdown_ctx);
4531 //GNUNET_TESTING_daemon_stop (pg->peers[off].daemon, timeout, shutdown_cb, shutdown_ctx, GNUNET_YES, GNUNET_NO); 4522 //GNUNET_TESTING_daemon_stop (pg->peers[off].daemon, timeout, shutdown_cb, shutdown_ctx, GNUNET_YES, GNUNET_NO);
4532 if (NULL != pg->peers[off].cfg) 4523 if (NULL != pg->peers[off].cfg)
4533 GNUNET_CONFIGURATION_destroy (pg->peers[off].cfg); 4524 GNUNET_CONFIGURATION_destroy (pg->peers[off].cfg);
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c
index dc7face2d..b8bad46a6 100644
--- a/src/topology/gnunet-daemon-topology.c
+++ b/src/topology/gnunet-daemon-topology.c
@@ -157,11 +157,6 @@ struct Peer
157static struct GNUNET_PEERINFO_NotifyContext *peerinfo_notify; 157static struct GNUNET_PEERINFO_NotifyContext *peerinfo_notify;
158 158
159/** 159/**
160 * Our scheduler.
161 */
162static struct GNUNET_SCHEDULER_Handle *sched;
163
164/**
165 * Our configuration. 160 * Our configuration.
166 */ 161 */
167static const struct GNUNET_CONFIGURATION_Handle *cfg; 162static const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -347,11 +342,9 @@ free_peer (void *cls,
347 if (pos->connect_req != NULL) 342 if (pos->connect_req != NULL)
348 GNUNET_CORE_peer_request_connect_cancel (pos->connect_req); 343 GNUNET_CORE_peer_request_connect_cancel (pos->connect_req);
349 if (pos->hello_delay_task != GNUNET_SCHEDULER_NO_TASK) 344 if (pos->hello_delay_task != GNUNET_SCHEDULER_NO_TASK)
350 GNUNET_SCHEDULER_cancel (sched, 345 GNUNET_SCHEDULER_cancel (pos->hello_delay_task);
351 pos->hello_delay_task);
352 if (pos->greylist_clean_task != GNUNET_SCHEDULER_NO_TASK) 346 if (pos->greylist_clean_task != GNUNET_SCHEDULER_NO_TASK)
353 GNUNET_SCHEDULER_cancel (sched, 347 GNUNET_SCHEDULER_cancel (pos->greylist_clean_task);
354 pos->greylist_clean_task);
355 GNUNET_free_non_null (pos->hello); 348 GNUNET_free_non_null (pos->hello);
356 if (pos->filter != NULL) 349 if (pos->filter != NULL)
357 GNUNET_CONTAINER_bloomfilter_free (pos->filter); 350 GNUNET_CONTAINER_bloomfilter_free (pos->filter);
@@ -406,11 +399,9 @@ attempt_connect (struct Peer *pos)
406 GREYLIST_AFTER_ATTEMPT_MAX); 399 GREYLIST_AFTER_ATTEMPT_MAX);
407 pos->greylisted_until = GNUNET_TIME_relative_to_absolute (rem); 400 pos->greylisted_until = GNUNET_TIME_relative_to_absolute (rem);
408 if (pos->greylist_clean_task != GNUNET_SCHEDULER_NO_TASK) 401 if (pos->greylist_clean_task != GNUNET_SCHEDULER_NO_TASK)
409 GNUNET_SCHEDULER_cancel (sched, 402 GNUNET_SCHEDULER_cancel (pos->greylist_clean_task);
410 pos->greylist_clean_task);
411 pos->greylist_clean_task 403 pos->greylist_clean_task
412 = GNUNET_SCHEDULER_add_delayed (sched, 404 = GNUNET_SCHEDULER_add_delayed (rem,
413 rem,
414 &remove_from_greylist, 405 &remove_from_greylist,
415 pos); 406 pos);
416#if DEBUG_TOPOLOGY 407#if DEBUG_TOPOLOGY
@@ -422,7 +413,7 @@ attempt_connect (struct Peer *pos)
422 gettext_noop ("# connect requests issued to core"), 413 gettext_noop ("# connect requests issued to core"),
423 1, 414 1,
424 GNUNET_NO); 415 GNUNET_NO);
425 pos->connect_req = GNUNET_CORE_peer_request_connect (sched, cfg, 416 pos->connect_req = GNUNET_CORE_peer_request_connect (cfg,
426 GNUNET_TIME_UNIT_MINUTES, 417 GNUNET_TIME_UNIT_MINUTES,
427 &pos->pid, 418 &pos->pid,
428 &connect_completed_callback, 419 &connect_completed_callback,
@@ -453,8 +444,7 @@ remove_from_greylist (void *cls,
453 else 444 else
454 { 445 {
455 pos->greylist_clean_task 446 pos->greylist_clean_task
456 = GNUNET_SCHEDULER_add_delayed (sched, 447 = GNUNET_SCHEDULER_add_delayed (rem,
457 rem,
458 &remove_from_greylist, 448 &remove_from_greylist,
459 pos); 449 pos);
460 } 450 }
@@ -635,8 +625,7 @@ schedule_next_hello (void *cls,
635 &find_advertisable_hello, 625 &find_advertisable_hello,
636 &fah); 626 &fah);
637 pl->hello_delay_task 627 pl->hello_delay_task
638 = GNUNET_SCHEDULER_add_delayed (sched, 628 = GNUNET_SCHEDULER_add_delayed (fah.next_adv,
639 fah.next_adv,
640 &schedule_next_hello, 629 &schedule_next_hello,
641 pl); 630 pl);
642 if (fah.result == NULL) 631 if (fah.result == NULL)
@@ -685,13 +674,11 @@ reschedule_hellos (void *cls,
685 } 674 }
686 if (peer->hello_delay_task != GNUNET_SCHEDULER_NO_TASK) 675 if (peer->hello_delay_task != GNUNET_SCHEDULER_NO_TASK)
687 { 676 {
688 GNUNET_SCHEDULER_cancel (sched, 677 GNUNET_SCHEDULER_cancel (peer->hello_delay_task);
689 peer->hello_delay_task);
690 peer->hello_delay_task = GNUNET_SCHEDULER_NO_TASK; 678 peer->hello_delay_task = GNUNET_SCHEDULER_NO_TASK;
691 } 679 }
692 peer->hello_delay_task 680 peer->hello_delay_task
693 = GNUNET_SCHEDULER_add_now (sched, 681 = GNUNET_SCHEDULER_add_now (&schedule_next_hello,
694 &schedule_next_hello,
695 peer); 682 peer);
696 return GNUNET_YES; 683 return GNUNET_YES;
697} 684}
@@ -822,7 +809,7 @@ disconnect_notify (void *cls,
822 NULL); 809 NULL);
823 if ( (friend_count < minimum_friend_count) && 810 if ( (friend_count < minimum_friend_count) &&
824 (blacklist == NULL) ) 811 (blacklist == NULL) )
825 blacklist = GNUNET_TRANSPORT_blacklist (sched, cfg, 812 blacklist = GNUNET_TRANSPORT_blacklist (cfg,
826 &blacklist_check, NULL); 813 &blacklist_check, NULL);
827} 814}
828 815
@@ -1021,7 +1008,7 @@ core_init (void *cls,
1021 { 1008 {
1022 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1009 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1023 _("Failed to connect to core service, can not manage topology!\n")); 1010 _("Failed to connect to core service, can not manage topology!\n"));
1024 GNUNET_SCHEDULER_shutdown (sched); 1011 GNUNET_SCHEDULER_shutdown ();
1025 return; 1012 return;
1026 } 1013 }
1027 handle = server; 1014 handle = server;
@@ -1031,8 +1018,7 @@ core_init (void *cls,
1031 "I am peer `%s'\n", 1018 "I am peer `%s'\n",
1032 GNUNET_i2s (my_id)); 1019 GNUNET_i2s (my_id));
1033#endif 1020#endif
1034 peerinfo_notify = GNUNET_PEERINFO_notify (cfg, sched, 1021 peerinfo_notify = GNUNET_PEERINFO_notify (cfg, &process_peer,
1035 &process_peer,
1036 NULL); 1022 NULL);
1037} 1023}
1038 1024
@@ -1285,8 +1271,7 @@ hello_advertising_ready (void *cls,
1285 } 1271 }
1286 pl->next_hello_allowed = GNUNET_TIME_relative_to_absolute (HELLO_ADVERTISEMENT_MIN_FREQUENCY); 1272 pl->next_hello_allowed = GNUNET_TIME_relative_to_absolute (HELLO_ADVERTISEMENT_MIN_FREQUENCY);
1287 pl->hello_delay_task 1273 pl->hello_delay_task
1288 = GNUNET_SCHEDULER_add_now (sched, 1274 = GNUNET_SCHEDULER_add_now (&schedule_next_hello,
1289 &schedule_next_hello,
1290 pl); 1275 pl);
1291 return want; 1276 return want;
1292} 1277}
@@ -1332,14 +1317,12 @@ cleaning_task (void *cls,
1332 * Main function that will be run. 1317 * Main function that will be run.
1333 * 1318 *
1334 * @param cls closure 1319 * @param cls closure
1335 * @param s the scheduler to use
1336 * @param args remaining command-line arguments 1320 * @param args remaining command-line arguments
1337 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 1321 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
1338 * @param c configuration 1322 * @param c configuration
1339 */ 1323 */
1340static void 1324static void
1341run (void *cls, 1325run (void *cls,
1342 struct GNUNET_SCHEDULER_Handle * s,
1343 char *const *args, 1326 char *const *args,
1344 const char *cfgfile, 1327 const char *cfgfile,
1345 const struct GNUNET_CONFIGURATION_Handle * c) 1328 const struct GNUNET_CONFIGURATION_Handle * c)
@@ -1351,9 +1334,8 @@ run (void *cls,
1351 }; 1334 };
1352 unsigned long long opt; 1335 unsigned long long opt;
1353 1336
1354 sched = s;
1355 cfg = c; 1337 cfg = c;
1356 stats = GNUNET_STATISTICS_create (sched, "topology", cfg); 1338 stats = GNUNET_STATISTICS_create ("topology", cfg);
1357 autoconnect = GNUNET_CONFIGURATION_get_value_yesno (cfg, 1339 autoconnect = GNUNET_CONFIGURATION_get_value_yesno (cfg,
1358 "TOPOLOGY", 1340 "TOPOLOGY",
1359 "AUTOCONNECT"); 1341 "AUTOCONNECT");
@@ -1387,17 +1369,15 @@ run (void *cls,
1387 autoconnect ? "autoconnect enabled" : "autoconnect disabled"); 1369 autoconnect ? "autoconnect enabled" : "autoconnect disabled");
1388#endif 1370#endif
1389 if (friend_count < minimum_friend_count) 1371 if (friend_count < minimum_friend_count)
1390 blacklist = GNUNET_TRANSPORT_blacklist (sched, cfg, 1372 blacklist = GNUNET_TRANSPORT_blacklist (cfg,
1391 &blacklist_check, NULL); 1373 &blacklist_check, NULL);
1392 transport = GNUNET_TRANSPORT_connect (sched, 1374 transport = GNUNET_TRANSPORT_connect (cfg,
1393 cfg,
1394 NULL, 1375 NULL,
1395 NULL, 1376 NULL,
1396 NULL, 1377 NULL,
1397 NULL, 1378 NULL,
1398 NULL); 1379 NULL);
1399 handle = GNUNET_CORE_connect (sched, 1380 handle = GNUNET_CORE_connect (cfg,
1400 cfg,
1401 GNUNET_TIME_UNIT_FOREVER_REL, 1381 GNUNET_TIME_UNIT_FOREVER_REL,
1402 NULL, 1382 NULL,
1403 &core_init, 1383 &core_init,
@@ -1407,15 +1387,14 @@ run (void *cls,
1407 NULL, GNUNET_NO, 1387 NULL, GNUNET_NO,
1408 NULL, GNUNET_NO, 1388 NULL, GNUNET_NO,
1409 handlers); 1389 handlers);
1410 GNUNET_SCHEDULER_add_delayed (sched, 1390 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
1411 GNUNET_TIME_UNIT_FOREVER_REL,
1412 &cleaning_task, NULL); 1391 &cleaning_task, NULL);
1413 if (NULL == transport) 1392 if (NULL == transport)
1414 { 1393 {
1415 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1394 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1416 _("Failed to connect to `%s' service.\n"), 1395 _("Failed to connect to `%s' service.\n"),
1417 "transport"); 1396 "transport");
1418 GNUNET_SCHEDULER_shutdown (sched); 1397 GNUNET_SCHEDULER_shutdown ();
1419 return; 1398 return;
1420 } 1399 }
1421 if (NULL == handle) 1400 if (NULL == handle)
@@ -1423,7 +1402,7 @@ run (void *cls,
1423 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1402 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1424 _("Failed to connect to `%s' service.\n"), 1403 _("Failed to connect to `%s' service.\n"),
1425 "core"); 1404 "core");
1426 GNUNET_SCHEDULER_shutdown (sched); 1405 GNUNET_SCHEDULER_shutdown ();
1427 return; 1406 return;
1428 } 1407 }
1429} 1408}
diff --git a/src/topology/test_gnunet_daemon_topology.c b/src/topology/test_gnunet_daemon_topology.c
index f6b671dc0..529496f11 100644
--- a/src/topology/test_gnunet_daemon_topology.c
+++ b/src/topology/test_gnunet_daemon_topology.c
@@ -48,8 +48,6 @@ static struct GNUNET_TESTING_Daemon *first;
48 48
49static struct GNUNET_TESTING_Daemon *last; 49static struct GNUNET_TESTING_Daemon *last;
50 50
51static struct GNUNET_SCHEDULER_Handle *sched;
52
53/** 51/**
54 * Check whether peers successfully shut down. 52 * Check whether peers successfully shut down.
55 */ 53 */
@@ -108,8 +106,7 @@ notify_connect_complete(void *cls,
108 { 106 {
109 /* FIXME: check that topology adds a few more links 107 /* FIXME: check that topology adds a few more links
110 in addition to those that were seeded */ 108 in addition to those that were seeded */
111 GNUNET_SCHEDULER_add_now (sched, 109 GNUNET_SCHEDULER_add_now (&clean_up_task,
112 &clean_up_task,
113 NULL); 110 NULL);
114 } 111 }
115} 112}
@@ -145,19 +142,17 @@ static void my_cb(void *cls,
145 142
146static void 143static void
147run (void *cls, 144run (void *cls,
148 struct GNUNET_SCHEDULER_Handle *s,
149 char *const *args, 145 char *const *args,
150 const char *cfgfile, 146 const char *cfgfile,
151 const struct GNUNET_CONFIGURATION_Handle *cfg) 147 const struct GNUNET_CONFIGURATION_Handle *cfg)
152{ 148{
153 sched = s;
154 ok = 1; 149 ok = 1;
155#if VERBOSE 150#if VERBOSE
156 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 151 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
157 "Starting daemons.\n"); 152 "Starting daemons.\n");
158#endif 153#endif
159 peers_left = NUM_PEERS; 154 peers_left = NUM_PEERS;
160 pg = GNUNET_TESTING_daemons_start (sched, cfg, 155 pg = GNUNET_TESTING_daemons_start (cfg,
161 peers_left, 156 peers_left,
162 TIMEOUT, 157 TIMEOUT,
163 NULL, NULL, 158 NULL, NULL,
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 87d73baf4..0ade42512 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -843,11 +843,6 @@ static struct GNUNET_PeerIdentity my_identity;
843static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key; 843static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key;
844 844
845/** 845/**
846 * Our scheduler.
847 */
848struct GNUNET_SCHEDULER_Handle *sched;
849
850/**
851 * Our configuration. 846 * Our configuration.
852 */ 847 */
853const struct GNUNET_CONFIGURATION_Handle *cfg; 848const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -1656,10 +1651,8 @@ try_transmission_to_peer (struct NeighbourList *neighbour)
1656 1, 1651 1,
1657 GNUNET_NO); 1652 GNUNET_NO);
1658 if (neighbour->retry_task != GNUNET_SCHEDULER_NO_TASK) 1653 if (neighbour->retry_task != GNUNET_SCHEDULER_NO_TASK)
1659 GNUNET_SCHEDULER_cancel (sched, 1654 GNUNET_SCHEDULER_cancel (neighbour->retry_task);
1660 neighbour->retry_task); 1655 neighbour->retry_task = GNUNET_SCHEDULER_add_delayed (timeout,
1661 neighbour->retry_task = GNUNET_SCHEDULER_add_delayed (sched,
1662 timeout,
1663 &retry_transmission_task, 1656 &retry_transmission_task,
1664 neighbour); 1657 neighbour);
1665#if DEBUG_TRANSPORT 1658#if DEBUG_TRANSPORT
@@ -1924,7 +1917,7 @@ update_addresses (struct TransportPlugin *plugin, int fresh)
1924 int expired; 1917 int expired;
1925 1918
1926 if (plugin->address_update_task != GNUNET_SCHEDULER_NO_TASK) 1919 if (plugin->address_update_task != GNUNET_SCHEDULER_NO_TASK)
1927 GNUNET_SCHEDULER_cancel (plugin->env.sched, plugin->address_update_task); 1920 GNUNET_SCHEDULER_cancel (plugin->address_update_task);
1928 plugin->address_update_task = GNUNET_SCHEDULER_NO_TASK; 1921 plugin->address_update_task = GNUNET_SCHEDULER_NO_TASK;
1929 now = GNUNET_TIME_absolute_get (); 1922 now = GNUNET_TIME_absolute_get ();
1930 min_remaining = GNUNET_TIME_UNIT_FOREVER_REL; 1923 min_remaining = GNUNET_TIME_UNIT_FOREVER_REL;
@@ -1962,8 +1955,7 @@ update_addresses (struct TransportPlugin *plugin, int fresh)
1962 GNUNET_TIME_relative_divide (HELLO_ADDRESS_EXPIRATION, 1955 GNUNET_TIME_relative_divide (HELLO_ADDRESS_EXPIRATION,
1963 2)); 1956 2));
1964 plugin->address_update_task 1957 plugin->address_update_task
1965 = GNUNET_SCHEDULER_add_delayed (plugin->env.sched, 1958 = GNUNET_SCHEDULER_add_delayed (min_remaining,
1966 min_remaining,
1967 &expire_address_task, plugin); 1959 &expire_address_task, plugin);
1968} 1960}
1969 1961
@@ -2126,8 +2118,7 @@ plugin_env_session_end (void *cls,
2126 prev->next = pos->next; 2118 prev->next = pos->next;
2127 if (GNUNET_SCHEDULER_NO_TASK != pos->revalidate_task) 2119 if (GNUNET_SCHEDULER_NO_TASK != pos->revalidate_task)
2128 { 2120 {
2129 GNUNET_SCHEDULER_cancel (sched, 2121 GNUNET_SCHEDULER_cancel (pos->revalidate_task);
2130 pos->revalidate_task);
2131 pos->revalidate_task = GNUNET_SCHEDULER_NO_TASK; 2122 pos->revalidate_task = GNUNET_SCHEDULER_NO_TASK;
2132 } 2123 }
2133 GNUNET_free (pos); 2124 GNUNET_free (pos);
@@ -2518,7 +2509,7 @@ abort_validation (void *cls,
2518 struct ValidationEntry *va = value; 2509 struct ValidationEntry *va = value;
2519 2510
2520 if (GNUNET_SCHEDULER_NO_TASK != va->timeout_task) 2511 if (GNUNET_SCHEDULER_NO_TASK != va->timeout_task)
2521 GNUNET_SCHEDULER_cancel (sched, va->timeout_task); 2512 GNUNET_SCHEDULER_cancel (va->timeout_task);
2522 GNUNET_free (va->transport_name); 2513 GNUNET_free (va->transport_name);
2523 if (va->chvc != NULL) 2514 if (va->chvc != NULL)
2524 { 2515 {
@@ -2776,8 +2767,7 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer,
2776 } 2767 }
2777 n->latency = GNUNET_TIME_UNIT_FOREVER_REL; 2768 n->latency = GNUNET_TIME_UNIT_FOREVER_REL;
2778 n->distance = -1; 2769 n->distance = -1;
2779 n->timeout_task = GNUNET_SCHEDULER_add_delayed (sched, 2770 n->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
2780 GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
2781 &neighbour_timeout_task, n); 2771 &neighbour_timeout_task, n);
2782 if (do_hello) 2772 if (do_hello)
2783 { 2773 {
@@ -2954,8 +2944,7 @@ transmit_blacklist_message (void *cls,
2954 if (size == 0) 2944 if (size == 0)
2955 { 2945 {
2956 GNUNET_assert (bc->task == GNUNET_SCHEDULER_NO_TASK); 2946 GNUNET_assert (bc->task == GNUNET_SCHEDULER_NO_TASK);
2957 bc->task = GNUNET_SCHEDULER_add_now (sched, 2947 bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check,
2958 &do_blacklist_check,
2959 bc); 2948 bc);
2960 return 0; 2949 return 0;
2961 } 2950 }
@@ -3047,8 +3036,7 @@ setup_peer_check_blacklist (const struct GNUNET_PeerIdentity *peer,
3047 bc->cont = cont; 3036 bc->cont = cont;
3048 bc->cont_cls = cont_cls; 3037 bc->cont_cls = cont_cls;
3049 bc->bl_pos = bl_head; 3038 bc->bl_pos = bl_head;
3050 bc->task = GNUNET_SCHEDULER_add_now (sched, 3039 bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check,
3051 &do_blacklist_check,
3052 bc); 3040 bc);
3053} 3041}
3054 3042
@@ -3120,8 +3108,7 @@ handle_blacklist_init (void *cls,
3120 bc->bl_pos = bl; 3108 bc->bl_pos = bl;
3121 if (n == neighbours) /* all would wait for the same client, no need to 3109 if (n == neighbours) /* all would wait for the same client, no need to
3122 create more than just the first task right now */ 3110 create more than just the first task right now */
3123 bc->task = GNUNET_SCHEDULER_add_now (sched, 3111 bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check,
3124 &do_blacklist_check,
3125 bc); 3112 bc);
3126 n = n->next; 3113 n = n->next;
3127 } 3114 }
@@ -3164,8 +3151,7 @@ handle_blacklist_reply (void *cls,
3164 else 3151 else
3165 { 3152 {
3166 bc->bl_pos = bc->bl_pos->next; 3153 bc->bl_pos = bc->bl_pos->next;
3167 bc->task = GNUNET_SCHEDULER_add_now (sched, 3154 bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check,
3168 &do_blacklist_check,
3169 bc); 3155 bc);
3170 } 3156 }
3171 /* check if any other bc's are waiting for this blacklister */ 3157 /* check if any other bc's are waiting for this blacklister */
@@ -3174,8 +3160,7 @@ handle_blacklist_reply (void *cls,
3174 { 3160 {
3175 if ( (bc->bl_pos == bl) && 3161 if ( (bc->bl_pos == bl) &&
3176 (GNUNET_SCHEDULER_NO_TASK == bc->task) ) 3162 (GNUNET_SCHEDULER_NO_TASK == bc->task) )
3177 bc->task = GNUNET_SCHEDULER_add_now (sched, 3163 bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check,
3178 &do_blacklist_check,
3179 bc); 3164 bc);
3180 bc = bc->next; 3165 bc = bc->next;
3181 } 3166 }
@@ -3258,8 +3243,7 @@ send_periodic_ping (void *cls,
3258 &neighbour->publicKey, 3243 &neighbour->publicKey,
3259 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); 3244 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded));
3260 3245
3261 va->timeout_task = GNUNET_SCHEDULER_add_delayed (sched, 3246 va->timeout_task = GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT,
3262 HELLO_VERIFICATION_TIMEOUT,
3263 &timeout_hello_validation, 3247 &timeout_hello_validation,
3264 va); 3248 va);
3265 GNUNET_CONTAINER_multihashmap_put (validation_map, 3249 GNUNET_CONTAINER_multihashmap_put (validation_map,
@@ -3384,8 +3368,7 @@ schedule_next_ping (struct ForeignAddressList *fal)
3384 GNUNET_TIME_UNIT_SECONDS); 3368 GNUNET_TIME_UNIT_SECONDS);
3385 /* randomize a bit (to avoid doing all at the same time) */ 3369 /* randomize a bit (to avoid doing all at the same time) */
3386 delay.rel_value += GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000); 3370 delay.rel_value += GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000);
3387 fal->revalidate_task = GNUNET_SCHEDULER_add_delayed(sched, 3371 fal->revalidate_task = GNUNET_SCHEDULER_add_delayed(delay,
3388 delay,
3389 &send_periodic_ping, 3372 &send_periodic_ping,
3390 fal); 3373 fal);
3391} 3374}
@@ -3691,8 +3674,7 @@ check_pending_validation (void *cls,
3691 } 3674 }
3692 if (n->retry_task != GNUNET_SCHEDULER_NO_TASK) 3675 if (n->retry_task != GNUNET_SCHEDULER_NO_TASK)
3693 { 3676 {
3694 GNUNET_SCHEDULER_cancel (sched, 3677 GNUNET_SCHEDULER_cancel (n->retry_task);
3695 n->retry_task);
3696 n->retry_task = GNUNET_SCHEDULER_NO_TASK; 3678 n->retry_task = GNUNET_SCHEDULER_NO_TASK;
3697 try_transmission_to_peer (n); 3679 try_transmission_to_peer (n);
3698 } 3680 }
@@ -3981,8 +3963,7 @@ run_validation (void *cls,
3981 va->addrlen = addrlen; 3963 va->addrlen = addrlen;
3982 GNUNET_HELLO_get_key (chvc->hello, 3964 GNUNET_HELLO_get_key (chvc->hello,
3983 &va->publicKey); 3965 &va->publicKey);
3984 va->timeout_task = GNUNET_SCHEDULER_add_delayed (sched, 3966 va->timeout_task = GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT,
3985 HELLO_VERIFICATION_TIMEOUT,
3986 &timeout_hello_validation, 3967 &timeout_hello_validation,
3987 va); 3968 va);
3988 GNUNET_CONTAINER_multihashmap_put (validation_map, 3969 GNUNET_CONTAINER_multihashmap_put (validation_map,
@@ -4146,8 +4127,7 @@ process_hello (struct TransportPlugin *plugin,
4146 GNUNET_NO); 4127 GNUNET_NO);
4147 4128
4148 /* first, check if load is too high */ 4129 /* first, check if load is too high */
4149 if (GNUNET_SCHEDULER_get_load (sched, 4130 if (GNUNET_SCHEDULER_get_load (GNUNET_SCHEDULER_PRIORITY_BACKGROUND) > MAX_HELLO_LOAD)
4150 GNUNET_SCHEDULER_PRIORITY_BACKGROUND) > MAX_HELLO_LOAD)
4151 { 4131 {
4152 GNUNET_STATISTICS_update (stats, 4132 GNUNET_STATISTICS_update (stats,
4153 gettext_noop ("# HELLOs ignored due to high load"), 4133 gettext_noop ("# HELLOs ignored due to high load"),
@@ -4351,8 +4331,7 @@ disconnect_neighbour (struct NeighbourList *n, int check)
4351 GNUNET_NO); 4331 GNUNET_NO);
4352 if (GNUNET_SCHEDULER_NO_TASK != peer_pos->revalidate_task) 4332 if (GNUNET_SCHEDULER_NO_TASK != peer_pos->revalidate_task)
4353 { 4333 {
4354 GNUNET_SCHEDULER_cancel (sched, 4334 GNUNET_SCHEDULER_cancel (peer_pos->revalidate_task);
4355 peer_pos->revalidate_task);
4356 peer_pos->revalidate_task = GNUNET_SCHEDULER_NO_TASK; 4335 peer_pos->revalidate_task = GNUNET_SCHEDULER_NO_TASK;
4357 } 4336 }
4358 GNUNET_free(peer_pos); 4337 GNUNET_free(peer_pos);
@@ -4381,12 +4360,12 @@ disconnect_neighbour (struct NeighbourList *n, int check)
4381 } 4360 }
4382 if (n->timeout_task != GNUNET_SCHEDULER_NO_TASK) 4361 if (n->timeout_task != GNUNET_SCHEDULER_NO_TASK)
4383 { 4362 {
4384 GNUNET_SCHEDULER_cancel (sched, n->timeout_task); 4363 GNUNET_SCHEDULER_cancel (n->timeout_task);
4385 n->timeout_task = GNUNET_SCHEDULER_NO_TASK; 4364 n->timeout_task = GNUNET_SCHEDULER_NO_TASK;
4386 } 4365 }
4387 if (n->retry_task != GNUNET_SCHEDULER_NO_TASK) 4366 if (n->retry_task != GNUNET_SCHEDULER_NO_TASK)
4388 { 4367 {
4389 GNUNET_SCHEDULER_cancel (sched, n->retry_task); 4368 GNUNET_SCHEDULER_cancel (n->retry_task);
4390 n->retry_task = GNUNET_SCHEDULER_NO_TASK; 4369 n->retry_task = GNUNET_SCHEDULER_NO_TASK;
4391 } 4370 }
4392 if (n->piter != NULL) 4371 if (n->piter != NULL)
@@ -4736,11 +4715,9 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
4736 n->peer_timeout = 4715 n->peer_timeout =
4737 GNUNET_TIME_relative_to_absolute 4716 GNUNET_TIME_relative_to_absolute
4738 (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 4717 (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
4739 GNUNET_SCHEDULER_cancel (sched, 4718 GNUNET_SCHEDULER_cancel (n->timeout_task);
4740 n->timeout_task);
4741 n->timeout_task = 4719 n->timeout_task =
4742 GNUNET_SCHEDULER_add_delayed (sched, 4720 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
4743 GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
4744 &neighbour_timeout_task, n); 4721 &neighbour_timeout_task, n);
4745 if (n->quota_violation_count > QUOTA_VIOLATION_DROP_THRESHOLD) 4722 if (n->quota_violation_count > QUOTA_VIOLATION_DROP_THRESHOLD)
4746 { 4723 {
@@ -5191,7 +5168,6 @@ static void
5191create_environment (struct TransportPlugin *plug) 5168create_environment (struct TransportPlugin *plug)
5192{ 5169{
5193 plug->env.cfg = cfg; 5170 plug->env.cfg = cfg;
5194 plug->env.sched = sched;
5195 plug->env.my_identity = &my_identity; 5171 plug->env.my_identity = &my_identity;
5196 plug->env.our_hello = &our_hello; 5172 plug->env.our_hello = &our_hello;
5197 plug->env.cls = plug; 5173 plug->env.cls = plug;
@@ -5276,8 +5252,7 @@ client_disconnect_notification (void *cls,
5276 bc->th = NULL; 5252 bc->th = NULL;
5277 } 5253 }
5278 if (bc->task == GNUNET_SCHEDULER_NO_TASK) 5254 if (bc->task == GNUNET_SCHEDULER_NO_TASK)
5279 bc->task = GNUNET_SCHEDULER_add_now (sched, 5255 bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check,
5280 &do_blacklist_check,
5281 bc); 5256 bc);
5282 break; 5257 break;
5283 } 5258 }
@@ -5359,8 +5334,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
5359 plugins = plug->next; 5334 plugins = plug->next;
5360 if (plug->address_update_task != GNUNET_SCHEDULER_NO_TASK) 5335 if (plug->address_update_task != GNUNET_SCHEDULER_NO_TASK)
5361 { 5336 {
5362 GNUNET_SCHEDULER_cancel (plug->env.sched, 5337 GNUNET_SCHEDULER_cancel (plug->address_update_task);
5363 plug->address_update_task);
5364 plug->address_update_task = GNUNET_SCHEDULER_NO_TASK; 5338 plug->address_update_task = GNUNET_SCHEDULER_NO_TASK;
5365 } 5339 }
5366 GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api)); 5340 GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api));
@@ -5423,13 +5397,11 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
5423 * Initiate transport service. 5397 * Initiate transport service.
5424 * 5398 *
5425 * @param cls closure 5399 * @param cls closure
5426 * @param s scheduler to use
5427 * @param server the initialized server 5400 * @param server the initialized server
5428 * @param c configuration to use 5401 * @param c configuration to use
5429 */ 5402 */
5430static void 5403static void
5431run (void *cls, 5404run (void *cls,
5432 struct GNUNET_SCHEDULER_Handle *s,
5433 struct GNUNET_SERVER_Handle *server, 5405 struct GNUNET_SERVER_Handle *server,
5434 const struct GNUNET_CONFIGURATION_Handle *c) 5406 const struct GNUNET_CONFIGURATION_Handle *c)
5435{ 5407{
@@ -5459,9 +5431,8 @@ run (void *cls,
5459 unsigned long long tneigh; 5431 unsigned long long tneigh;
5460 char *keyfile; 5432 char *keyfile;
5461 5433
5462 sched = s;
5463 cfg = c; 5434 cfg = c;
5464 stats = GNUNET_STATISTICS_create (sched, "transport", cfg); 5435 stats = GNUNET_STATISTICS_create ("transport", cfg);
5465 validation_map = GNUNET_CONTAINER_multihashmap_create (64); 5436 validation_map = GNUNET_CONTAINER_multihashmap_create (64);
5466 /* parse configuration */ 5437 /* parse configuration */
5467 if ((GNUNET_OK != 5438 if ((GNUNET_OK !=
@@ -5477,7 +5448,7 @@ run (void *cls,
5477 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 5448 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
5478 _ 5449 _
5479 ("Transport service is lacking key configuration settings. Exiting.\n")); 5450 ("Transport service is lacking key configuration settings. Exiting.\n"));
5480 GNUNET_SCHEDULER_shutdown (s); 5451 GNUNET_SCHEDULER_shutdown ();
5481 if (stats != NULL) 5452 if (stats != NULL)
5482 { 5453 {
5483 GNUNET_STATISTICS_destroy (stats, GNUNET_NO); 5454 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
@@ -5488,12 +5459,12 @@ run (void *cls,
5488 return; 5459 return;
5489 } 5460 }
5490 max_connect_per_transport = (uint32_t) tneigh; 5461 max_connect_per_transport = (uint32_t) tneigh;
5491 peerinfo = GNUNET_PEERINFO_connect (sched, cfg); 5462 peerinfo = GNUNET_PEERINFO_connect (cfg);
5492 if (peerinfo == NULL) 5463 if (peerinfo == NULL)
5493 { 5464 {
5494 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 5465 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
5495 _("Could not access PEERINFO service. Exiting.\n")); 5466 _("Could not access PEERINFO service. Exiting.\n"));
5496 GNUNET_SCHEDULER_shutdown (s); 5467 GNUNET_SCHEDULER_shutdown ();
5497 if (stats != NULL) 5468 if (stats != NULL)
5498 { 5469 {
5499 GNUNET_STATISTICS_destroy (stats, GNUNET_NO); 5470 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
@@ -5511,7 +5482,7 @@ run (void *cls,
5511 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 5482 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
5512 _ 5483 _
5513 ("Transport service could not access hostkey. Exiting.\n")); 5484 ("Transport service could not access hostkey. Exiting.\n"));
5514 GNUNET_SCHEDULER_shutdown (s); 5485 GNUNET_SCHEDULER_shutdown ();
5515 if (stats != NULL) 5486 if (stats != NULL)
5516 { 5487 {
5517 GNUNET_STATISTICS_destroy (stats, GNUNET_NO); 5488 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
@@ -5544,8 +5515,7 @@ run (void *cls,
5544 } 5515 }
5545 GNUNET_free (plugs); 5516 GNUNET_free (plugs);
5546 } 5517 }
5547 GNUNET_SCHEDULER_add_delayed (sched, 5518 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
5548 GNUNET_TIME_UNIT_FOREVER_REL,
5549 &shutdown_task, NULL); 5519 &shutdown_task, NULL);
5550 if (no_transports) 5520 if (no_transports)
5551 refresh_hello (); 5521 refresh_hello ();
diff --git a/src/transport/plugin_transport.h b/src/transport/plugin_transport.h
index a8e15ac8a..5f6d6fcfb 100644
--- a/src/transport/plugin_transport.h
+++ b/src/transport/plugin_transport.h
@@ -190,11 +190,6 @@ struct GNUNET_TRANSPORT_PluginEnvironment
190 const struct GNUNET_CONFIGURATION_Handle *cfg; 190 const struct GNUNET_CONFIGURATION_Handle *cfg;
191 191
192 /** 192 /**
193 * Scheduler to use.
194 */
195 struct GNUNET_SCHEDULER_Handle *sched;
196
197 /**
198 * Identity of this peer. 193 * Identity of this peer.
199 */ 194 */
200 const struct GNUNET_PeerIdentity *my_identity; 195 const struct GNUNET_PeerIdentity *my_identity;
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index e4c88903f..ad8ced567 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -880,14 +880,14 @@ static void mhd_write_mst_cb (void *cls,
880 0); 880 0);
881 pc->delay = delay; 881 pc->delay = delay;
882 if (pc->reset_task != GNUNET_SCHEDULER_NO_TASK) 882 if (pc->reset_task != GNUNET_SCHEDULER_NO_TASK)
883 GNUNET_SCHEDULER_cancel (pc->plugin->env->sched, pc->reset_task); 883 GNUNET_SCHEDULER_cancel (pc->reset_task);
884 884
885 if (delay.rel_value > 0) 885 if (delay.rel_value > 0)
886 { 886 {
887#if DEBUG_HTTP 887#if DEBUG_HTTP
888 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: Inbound quota management: delay next read for %llu ms \n", ps, delay.rel_value); 888 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: Inbound quota management: delay next read for %llu ms \n", ps, delay.rel_value);
889#endif 889#endif
890 pc->reset_task = GNUNET_SCHEDULER_add_delayed (pc->plugin->env->sched, delay, &reset_inbound_quota_delay, pc); 890 pc->reset_task = GNUNET_SCHEDULER_add_delayed (delay, &reset_inbound_quota_delay, pc);
891 } 891 }
892} 892}
893 893
@@ -1274,12 +1274,11 @@ http_server_daemon_prepare (struct Plugin *plugin , struct MHD_Daemon *daemon_ha
1274 { 1274 {
1275 if (plugin->http_server_task_v4 != GNUNET_SCHEDULER_NO_TASK) 1275 if (plugin->http_server_task_v4 != GNUNET_SCHEDULER_NO_TASK)
1276 { 1276 {
1277 GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_server_task_v4); 1277 GNUNET_SCHEDULER_cancel(plugin->http_server_task_v4);
1278 plugin->http_server_daemon_v4 = GNUNET_SCHEDULER_NO_TASK; 1278 plugin->http_server_daemon_v4 = GNUNET_SCHEDULER_NO_TASK;
1279 } 1279 }
1280 1280
1281 ret = GNUNET_SCHEDULER_add_select (plugin->env->sched, 1281 ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1282 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1283 GNUNET_SCHEDULER_NO_TASK, 1282 GNUNET_SCHEDULER_NO_TASK,
1284 tv, 1283 tv,
1285 wrs, 1284 wrs,
@@ -1291,12 +1290,11 @@ http_server_daemon_prepare (struct Plugin *plugin , struct MHD_Daemon *daemon_ha
1291 { 1290 {
1292 if (plugin->http_server_task_v6 != GNUNET_SCHEDULER_NO_TASK) 1291 if (plugin->http_server_task_v6 != GNUNET_SCHEDULER_NO_TASK)
1293 { 1292 {
1294 GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_server_task_v6); 1293 GNUNET_SCHEDULER_cancel(plugin->http_server_task_v6);
1295 plugin->http_server_task_v6 = GNUNET_SCHEDULER_NO_TASK; 1294 plugin->http_server_task_v6 = GNUNET_SCHEDULER_NO_TASK;
1296 } 1295 }
1297 1296
1298 ret = GNUNET_SCHEDULER_add_select (plugin->env->sched, 1297 ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1299 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1300 GNUNET_SCHEDULER_NO_TASK, 1298 GNUNET_SCHEDULER_NO_TASK,
1301 tv, 1299 tv,
1302 wrs, 1300 wrs,
@@ -1586,14 +1584,14 @@ static void curl_receive_mst_cb (void *cls,
1586 1584
1587 pc->delay = delay; 1585 pc->delay = delay;
1588 if (pc->reset_task != GNUNET_SCHEDULER_NO_TASK) 1586 if (pc->reset_task != GNUNET_SCHEDULER_NO_TASK)
1589 GNUNET_SCHEDULER_cancel (pc->plugin->env->sched, pc->reset_task); 1587 GNUNET_SCHEDULER_cancel (pc->reset_task);
1590 1588
1591 if (delay.rel_value > 0) 1589 if (delay.rel_value > 0)
1592 { 1590 {
1593#if DEBUG_HTTP 1591#if DEBUG_HTTP
1594 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: Inbound quota management: delay next read for %llu ms \n", ps, delay.abs_value); 1592 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: Inbound quota management: delay next read for %llu ms \n", ps, delay.abs_value);
1595#endif 1593#endif
1596 pc->reset_task = GNUNET_SCHEDULER_add_delayed (pc->plugin->env->sched, delay, &reset_inbound_quota_delay, pc); 1594 pc->reset_task = GNUNET_SCHEDULER_add_delayed (delay, &reset_inbound_quota_delay, pc);
1597 } 1595 }
1598} 1596}
1599 1597
@@ -1820,7 +1818,7 @@ static int curl_schedule(struct Plugin *plugin)
1820 /* Cancel previous scheduled task */ 1818 /* Cancel previous scheduled task */
1821 if (plugin->http_curl_task != GNUNET_SCHEDULER_NO_TASK) 1819 if (plugin->http_curl_task != GNUNET_SCHEDULER_NO_TASK)
1822 { 1820 {
1823 GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_curl_task); 1821 GNUNET_SCHEDULER_cancel(plugin->http_curl_task);
1824 plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK; 1822 plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK;
1825 } 1823 }
1826 1824
@@ -1851,8 +1849,7 @@ static int curl_schedule(struct Plugin *plugin)
1851 gws = GNUNET_NETWORK_fdset_create (); 1849 gws = GNUNET_NETWORK_fdset_create ();
1852 GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1); 1850 GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1);
1853 GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1); 1851 GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1);
1854 plugin->http_curl_task = GNUNET_SCHEDULER_add_select (plugin->env->sched, 1852 plugin->http_curl_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1855 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1856 GNUNET_SCHEDULER_NO_TASK, 1853 GNUNET_SCHEDULER_NO_TASK,
1857 (to == -1) ? GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) : GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, to), 1854 (to == -1) ? GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) : GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, to),
1858 grs, 1855 grs,
@@ -1958,10 +1955,10 @@ static int send_check_connections (struct Plugin *plugin, struct Session *ps)
1958 } 1955 }
1959 if (plugin->http_curl_task != GNUNET_SCHEDULER_NO_TASK) 1956 if (plugin->http_curl_task != GNUNET_SCHEDULER_NO_TASK)
1960 { 1957 {
1961 GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_curl_task); 1958 GNUNET_SCHEDULER_cancel(plugin->http_curl_task);
1962 plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK; 1959 plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK;
1963 } 1960 }
1964 plugin->http_curl_task = GNUNET_SCHEDULER_add_now (plugin->env->sched, &curl_perform, plugin); 1961 plugin->http_curl_task = GNUNET_SCHEDULER_add_now (&curl_perform, plugin);
1965 } 1962 }
1966 1963
1967 /* waiting for receive direction */ 1964 /* waiting for receive direction */
@@ -1989,10 +1986,10 @@ static int send_check_connections (struct Plugin *plugin, struct Session *ps)
1989 ps->send_active=GNUNET_YES; 1986 ps->send_active=GNUNET_YES;
1990 if (plugin->http_curl_task != GNUNET_SCHEDULER_NO_TASK) 1987 if (plugin->http_curl_task != GNUNET_SCHEDULER_NO_TASK)
1991 { 1988 {
1992 GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_curl_task); 1989 GNUNET_SCHEDULER_cancel(plugin->http_curl_task);
1993 plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK; 1990 plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK;
1994 } 1991 }
1995 plugin->http_curl_task = GNUNET_SCHEDULER_add_now (plugin->env->sched, &curl_perform, plugin); 1992 plugin->http_curl_task = GNUNET_SCHEDULER_add_now (&curl_perform, plugin);
1996 return GNUNET_YES; 1993 return GNUNET_YES;
1997 } 1994 }
1998 else 1995 else
@@ -2058,10 +2055,10 @@ static int send_check_connections (struct Plugin *plugin, struct Session *ps)
2058 } 2055 }
2059 if (plugin->http_curl_task != GNUNET_SCHEDULER_NO_TASK) 2056 if (plugin->http_curl_task != GNUNET_SCHEDULER_NO_TASK)
2060 { 2057 {
2061 GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_curl_task); 2058 GNUNET_SCHEDULER_cancel(plugin->http_curl_task);
2062 plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK; 2059 plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK;
2063 } 2060 }
2064 plugin->http_curl_task = GNUNET_SCHEDULER_add_now (plugin->env->sched, &curl_perform, plugin); 2061 plugin->http_curl_task = GNUNET_SCHEDULER_add_now (&curl_perform, plugin);
2065 return GNUNET_YES; 2062 return GNUNET_YES;
2066 } 2063 }
2067 if (ps->direction == INBOUND) 2064 if (ps->direction == INBOUND)
@@ -2658,13 +2655,13 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls)
2658 2655
2659 if ( plugin->http_server_task_v4 != GNUNET_SCHEDULER_NO_TASK) 2656 if ( plugin->http_server_task_v4 != GNUNET_SCHEDULER_NO_TASK)
2660 { 2657 {
2661 GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_server_task_v4); 2658 GNUNET_SCHEDULER_cancel(plugin->http_server_task_v4);
2662 plugin->http_server_task_v4 = GNUNET_SCHEDULER_NO_TASK; 2659 plugin->http_server_task_v4 = GNUNET_SCHEDULER_NO_TASK;
2663 } 2660 }
2664 2661
2665 if ( plugin->http_server_task_v6 != GNUNET_SCHEDULER_NO_TASK) 2662 if ( plugin->http_server_task_v6 != GNUNET_SCHEDULER_NO_TASK)
2666 { 2663 {
2667 GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_server_task_v6); 2664 GNUNET_SCHEDULER_cancel(plugin->http_server_task_v6);
2668 plugin->http_server_task_v6 = GNUNET_SCHEDULER_NO_TASK; 2665 plugin->http_server_task_v6 = GNUNET_SCHEDULER_NO_TASK;
2669 } 2666 }
2670 2667
@@ -2703,7 +2700,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls)
2703 2700
2704 if ( plugin->http_curl_task != GNUNET_SCHEDULER_NO_TASK) 2701 if ( plugin->http_curl_task != GNUNET_SCHEDULER_NO_TASK)
2705 { 2702 {
2706 GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_curl_task); 2703 GNUNET_SCHEDULER_cancel(plugin->http_curl_task);
2707 plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK; 2704 plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK;
2708 } 2705 }
2709 2706
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index 1073b24b7..b4d332d48 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -892,8 +892,7 @@ disconnect_session (struct Session *session)
892 GNUNET_break (session->client != NULL); 892 GNUNET_break (session->client != NULL);
893 if (session->receive_delay_task != GNUNET_SCHEDULER_NO_TASK) 893 if (session->receive_delay_task != GNUNET_SCHEDULER_NO_TASK)
894 { 894 {
895 GNUNET_SCHEDULER_cancel (session->plugin->env->sched, 895 GNUNET_SCHEDULER_cancel (session->receive_delay_task);
896 session->receive_delay_task);
897 if (session->client != NULL) 896 if (session->client != NULL)
898 GNUNET_SERVER_receive_done (session->client, 897 GNUNET_SERVER_receive_done (session->client,
899 GNUNET_SYSERR); 898 GNUNET_SYSERR);
@@ -1228,8 +1227,7 @@ tcp_plugin_send (void *cls,
1228 /* Only do one NAT punch attempt per peer identity */ 1227 /* Only do one NAT punch attempt per peer identity */
1229 return -1; 1228 return -1;
1230 } 1229 }
1231 sa = GNUNET_CONNECTION_create_from_sockaddr (plugin->env->sched, 1230 sa = GNUNET_CONNECTION_create_from_sockaddr (af, sb, sbs);
1232 af, sb, sbs);
1233 if (sa == NULL) 1231 if (sa == NULL)
1234 { 1232 {
1235#if DEBUG_TCP 1233#if DEBUG_TCP
@@ -1456,8 +1454,7 @@ tcp_plugin_address_pretty_printer (void *cls,
1456 ppc->asc = asc; 1454 ppc->asc = asc;
1457 ppc->asc_cls = asc_cls; 1455 ppc->asc_cls = asc_cls;
1458 ppc->port = port; 1456 ppc->port = port;
1459 GNUNET_RESOLVER_hostname_get (plugin->env->sched, 1457 GNUNET_RESOLVER_hostname_get (plugin->env->cfg,
1460 plugin->env->cfg,
1461 sb, 1458 sb,
1462 sbs, 1459 sbs,
1463 !numeric, timeout, &append_port, ppc); 1460 !numeric, timeout, &append_port, ppc);
@@ -1812,8 +1809,7 @@ delayed_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1812 GNUNET_SERVER_receive_done (session->client, GNUNET_OK); 1809 GNUNET_SERVER_receive_done (session->client, GNUNET_OK);
1813 else 1810 else
1814 session->receive_delay_task = 1811 session->receive_delay_task =
1815 GNUNET_SCHEDULER_add_delayed (session->plugin->env->sched, 1812 GNUNET_SCHEDULER_add_delayed (delay, &delayed_done, session);
1816 delay, &delayed_done, session);
1817} 1813}
1818 1814
1819 1815
@@ -1866,8 +1862,7 @@ handle_tcp_data (void *cls,
1866 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1862 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1867 else 1863 else
1868 session->receive_delay_task = 1864 session->receive_delay_task =
1869 GNUNET_SCHEDULER_add_delayed (session->plugin->env->sched, 1865 GNUNET_SCHEDULER_add_delayed (delay, &delayed_done, session);
1870 delay, &delayed_done, session);
1871} 1866}
1872 1867
1873 1868
@@ -2115,8 +2110,7 @@ tcp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc
2115 else 2110 else
2116 { 2111 {
2117 plugin->server_read_task = 2112 plugin->server_read_task =
2118 GNUNET_SCHEDULER_add_read_file (plugin->env->sched, 2113 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
2119 GNUNET_TIME_UNIT_FOREVER_REL,
2120 plugin->server_stdout_handle, &tcp_plugin_server_read, plugin); 2114 plugin->server_stdout_handle, &tcp_plugin_server_read, plugin);
2121 return; 2115 return;
2122 } 2116 }
@@ -2134,8 +2128,7 @@ tcp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc
2134 _("nat-server-read malformed address\n"), &mybuf, port); 2128 _("nat-server-read malformed address\n"), &mybuf, port);
2135 2129
2136 plugin->server_read_task = 2130 plugin->server_read_task =
2137 GNUNET_SCHEDULER_add_read_file (plugin->env->sched, 2131 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
2138 GNUNET_TIME_UNIT_FOREVER_REL,
2139 plugin->server_stdout_handle, &tcp_plugin_server_read, plugin); 2132 plugin->server_stdout_handle, &tcp_plugin_server_read, plugin);
2140 return; 2133 return;
2141 } 2134 }
@@ -2146,15 +2139,14 @@ tcp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc
2146 * We have received an ICMP response, ostensibly from a non-NAT'd peer 2139 * We have received an ICMP response, ostensibly from a non-NAT'd peer
2147 * that wants to connect to us! Send a message to establish a connection. 2140 * that wants to connect to us! Send a message to establish a connection.
2148 */ 2141 */
2149 sock = GNUNET_CONNECTION_create_from_sockaddr (plugin->env->sched, AF_INET, (struct sockaddr *)&in_addr, 2142 sock = GNUNET_CONNECTION_create_from_sockaddr (AF_INET, (struct sockaddr *)&in_addr,
2150 sizeof(in_addr)); 2143 sizeof(in_addr));
2151 2144
2152 2145
2153 if (sock == NULL) 2146 if (sock == NULL)
2154 { 2147 {
2155 plugin->server_read_task = 2148 plugin->server_read_task =
2156 GNUNET_SCHEDULER_add_read_file (plugin->env->sched, 2149 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
2157 GNUNET_TIME_UNIT_FOREVER_REL,
2158 plugin->server_stdout_handle, &tcp_plugin_server_read, plugin); 2150 plugin->server_stdout_handle, &tcp_plugin_server_read, plugin);
2159 return; 2151 return;
2160 } 2152 }
@@ -2178,8 +2170,7 @@ tcp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc
2178 2170
2179 /*GNUNET_SERVER_connect_socket(plugin->server, sock);*/ 2171 /*GNUNET_SERVER_connect_socket(plugin->server, sock);*/
2180 plugin->server_read_task = 2172 plugin->server_read_task =
2181 GNUNET_SCHEDULER_add_read_file (plugin->env->sched, 2173 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
2182 GNUNET_TIME_UNIT_FOREVER_REL,
2183 plugin->server_stdout_handle, &tcp_plugin_server_read, plugin); 2174 plugin->server_stdout_handle, &tcp_plugin_server_read, plugin);
2184} 2175}
2185 2176
@@ -2217,8 +2208,7 @@ tcp_transport_start_nat_server(struct Plugin *plugin)
2217 2208
2218 plugin->server_stdout_handle = GNUNET_DISK_pipe_handle(plugin->server_stdout, GNUNET_DISK_PIPE_END_READ); 2209 plugin->server_stdout_handle = GNUNET_DISK_pipe_handle(plugin->server_stdout, GNUNET_DISK_PIPE_END_READ);
2219 plugin->server_read_task = 2210 plugin->server_read_task =
2220 GNUNET_SCHEDULER_add_read_file (plugin->env->sched, 2211 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
2221 GNUNET_TIME_UNIT_FOREVER_REL,
2222 plugin->server_stdout_handle, &tcp_plugin_server_read, plugin); 2212 plugin->server_stdout_handle, &tcp_plugin_server_read, plugin);
2223 return GNUNET_YES; 2213 return GNUNET_YES;
2224} 2214}
@@ -2363,7 +2353,7 @@ libgnunet_plugin_transport_tcp_init (void *cls)
2363 struct sockaddr_in in_addr; 2353 struct sockaddr_in in_addr;
2364 struct IPv4TcpAddress t4; 2354 struct IPv4TcpAddress t4;
2365 2355
2366 service = GNUNET_SERVICE_start ("transport-tcp", env->sched, env->cfg); 2356 service = GNUNET_SERVICE_start ("transport-tcp", env->cfg);
2367 if (service == NULL) 2357 if (service == NULL)
2368 { 2358 {
2369 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2359 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -2545,8 +2535,7 @@ libgnunet_plugin_transport_tcp_init (void *cls)
2545 GNUNET_OS_network_interfaces_list (&process_interfaces, plugin); 2535 GNUNET_OS_network_interfaces_list (&process_interfaces, plugin);
2546 } 2536 }
2547 2537
2548 plugin->hostname_dns = GNUNET_RESOLVER_hostname_resolve (env->sched, 2538 plugin->hostname_dns = GNUNET_RESOLVER_hostname_resolve (env->cfg,
2549 env->cfg,
2550 AF_UNSPEC, 2539 AF_UNSPEC,
2551 HOSTNAME_RESOLVE_TIMEOUT, 2540 HOSTNAME_RESOLVE_TIMEOUT,
2552 &process_hostname_ips, 2541 &process_hostname_ips,
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index 4bd8c36d3..5c3682e2a 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -513,7 +513,7 @@ udp_transport_server_stop (void *cls)
513 513
514 if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK) 514 if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK)
515 { 515 {
516 GNUNET_SCHEDULER_cancel (plugin->env->sched, plugin->select_task); 516 GNUNET_SCHEDULER_cancel (plugin->select_task);
517 plugin->select_task = GNUNET_SCHEDULER_NO_TASK; 517 plugin->select_task = GNUNET_SCHEDULER_NO_TASK;
518 } 518 }
519 if (plugin->udp_sockv4.desc != NULL) 519 if (plugin->udp_sockv4.desc != NULL)
@@ -1107,7 +1107,7 @@ void
1107udp_probe_continuation (void *cls, const struct GNUNET_PeerIdentity *target, int result) 1107udp_probe_continuation (void *cls, const struct GNUNET_PeerIdentity *target, int result)
1108{ 1108{
1109 struct UDP_NAT_Probes *probe = cls; 1109 struct UDP_NAT_Probes *probe = cls;
1110 struct Plugin *plugin = probe->plugin; 1110 /*struct Plugin *plugin = probe->plugin;*/
1111 1111
1112 if ((result == GNUNET_OK) && (probe->count < MAX_PROBES)) 1112 if ((result == GNUNET_OK) && (probe->count < MAX_PROBES))
1113 { 1113 {
@@ -1115,7 +1115,7 @@ udp_probe_continuation (void *cls, const struct GNUNET_PeerIdentity *target, int
1115 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1115 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1116 _("Scheduling next probe for 10000 milliseconds\n")); 1116 _("Scheduling next probe for 10000 milliseconds\n"));
1117#endif 1117#endif
1118 probe->task = GNUNET_SCHEDULER_add_delayed(plugin->env->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 10000), &send_udp_probe_message, probe); 1118 probe->task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 10000), &send_udp_probe_message, probe);
1119 } 1119 }
1120 else /* Destroy the probe context. */ 1120 else /* Destroy the probe context. */
1121 { 1121 {
@@ -1200,8 +1200,7 @@ udp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc
1200 else 1200 else
1201 { 1201 {
1202 plugin->server_read_task = 1202 plugin->server_read_task =
1203 GNUNET_SCHEDULER_add_read_file (plugin->env->sched, 1203 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
1204 GNUNET_TIME_UNIT_FOREVER_REL,
1205 plugin->server_stdout_handle, &udp_plugin_server_read, plugin); 1204 plugin->server_stdout_handle, &udp_plugin_server_read, plugin);
1206 return; 1205 return;
1207 } 1206 }
@@ -1222,8 +1221,7 @@ udp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc
1222 _("nat-server-read malformed address\n"), &mybuf, port); 1221 _("nat-server-read malformed address\n"), &mybuf, port);
1223 1222
1224 plugin->server_read_task = 1223 plugin->server_read_task =
1225 GNUNET_SCHEDULER_add_read_file (plugin->env->sched, 1224 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
1226 GNUNET_TIME_UNIT_FOREVER_REL,
1227 plugin->server_stdout_handle, &udp_plugin_server_read, plugin); 1225 plugin->server_stdout_handle, &udp_plugin_server_read, plugin);
1228 return; 1226 return;
1229 } 1227 }
@@ -1238,13 +1236,12 @@ udp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc
1238 temp_probe->addr.u_port = htons(port); 1236 temp_probe->addr.u_port = htons(port);
1239 temp_probe->next = plugin->probes; 1237 temp_probe->next = plugin->probes;
1240 temp_probe->plugin = plugin; 1238 temp_probe->plugin = plugin;
1241 temp_probe->task = GNUNET_SCHEDULER_add_delayed(plugin->env->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 500), &send_udp_probe_message, temp_probe); 1239 temp_probe->task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 500), &send_udp_probe_message, temp_probe);
1242 plugin->probes = temp_probe; 1240 plugin->probes = temp_probe;
1243 } 1241 }
1244 1242
1245 plugin->server_read_task = 1243 plugin->server_read_task =
1246 GNUNET_SCHEDULER_add_read_file (plugin->env->sched, 1244 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
1247 GNUNET_TIME_UNIT_FOREVER_REL,
1248 plugin->server_stdout_handle, &udp_plugin_server_read, plugin); 1245 plugin->server_stdout_handle, &udp_plugin_server_read, plugin);
1249 1246
1250} 1247}
@@ -1358,7 +1355,7 @@ udp_demultiplexer(struct Plugin *plugin, struct GNUNET_PeerIdentity *sender,
1358 1355
1359 if (outgoing_probe->task != GNUNET_SCHEDULER_NO_TASK) 1356 if (outgoing_probe->task != GNUNET_SCHEDULER_NO_TASK)
1360 { 1357 {
1361 GNUNET_SCHEDULER_cancel(plugin->env->sched, outgoing_probe->task); 1358 GNUNET_SCHEDULER_cancel(outgoing_probe->task);
1362 outgoing_probe->task = GNUNET_SCHEDULER_NO_TASK; 1359 outgoing_probe->task = GNUNET_SCHEDULER_NO_TASK;
1363 /* Schedule task to timeout and remove probe if confirmation not received */ 1360 /* Schedule task to timeout and remove probe if confirmation not received */
1364 } 1361 }
@@ -1569,8 +1566,7 @@ udp_plugin_select (void *cls,
1569 { 1566 {
1570 GNUNET_break_op (0); 1567 GNUNET_break_op (0);
1571 plugin->select_task = 1568 plugin->select_task =
1572 GNUNET_SCHEDULER_add_select (plugin->env->sched, 1569 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1573 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1574 GNUNET_SCHEDULER_NO_TASK, 1570 GNUNET_SCHEDULER_NO_TASK,
1575 GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, 1571 GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs,
1576 NULL, &udp_plugin_select, plugin); 1572 NULL, &udp_plugin_select, plugin);
@@ -1581,8 +1577,7 @@ udp_plugin_select (void *cls,
1581 { 1577 {
1582 GNUNET_break_op (0); 1578 GNUNET_break_op (0);
1583 plugin->select_task = 1579 plugin->select_task =
1584 GNUNET_SCHEDULER_add_select (plugin->env->sched, 1580 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1585 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1586 GNUNET_SCHEDULER_NO_TASK, 1581 GNUNET_SCHEDULER_NO_TASK,
1587 GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, 1582 GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs,
1588 NULL, &udp_plugin_select, plugin); 1583 NULL, &udp_plugin_select, plugin);
@@ -1601,8 +1596,7 @@ udp_plugin_select (void *cls,
1601 count++; 1596 count++;
1602 } 1597 }
1603 plugin->select_task = 1598 plugin->select_task =
1604 GNUNET_SCHEDULER_add_select (plugin->env->sched, 1599 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1605 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1606 GNUNET_SCHEDULER_NO_TASK, 1600 GNUNET_SCHEDULER_NO_TASK,
1607 GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, 1601 GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs,
1608 NULL, &udp_plugin_select, plugin); 1602 NULL, &udp_plugin_select, plugin);
@@ -1659,8 +1653,7 @@ udp_transport_server_start (void *cls)
1659 1653
1660 plugin->server_stdout_handle = GNUNET_DISK_pipe_handle(plugin->server_stdout, GNUNET_DISK_PIPE_END_READ); 1654 plugin->server_stdout_handle = GNUNET_DISK_pipe_handle(plugin->server_stdout, GNUNET_DISK_PIPE_END_READ);
1661 plugin->server_read_task = 1655 plugin->server_read_task =
1662 GNUNET_SCHEDULER_add_read_file (plugin->env->sched, 1656 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
1663 GNUNET_TIME_UNIT_FOREVER_REL,
1664 plugin->server_stdout_handle, &udp_plugin_server_read, plugin); 1657 plugin->server_stdout_handle, &udp_plugin_server_read, plugin);
1665 } 1658 }
1666 1659
@@ -1783,8 +1776,7 @@ udp_transport_server_start (void *cls)
1783 plugin->udp_sockv6.desc); 1776 plugin->udp_sockv6.desc);
1784 1777
1785 plugin->select_task = 1778 plugin->select_task =
1786 GNUNET_SCHEDULER_add_select (plugin->env->sched, 1779 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1787 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1788 GNUNET_SCHEDULER_NO_TASK, 1780 GNUNET_SCHEDULER_NO_TASK,
1789 GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, 1781 GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs,
1790 NULL, &udp_plugin_select, plugin); 1782 NULL, &udp_plugin_select, plugin);
@@ -1992,8 +1984,7 @@ udp_plugin_address_pretty_printer (void *cls,
1992 ppc->asc = asc; 1984 ppc->asc = asc;
1993 ppc->asc_cls = asc_cls; 1985 ppc->asc_cls = asc_cls;
1994 ppc->port = port; 1986 ppc->port = port;
1995 GNUNET_RESOLVER_hostname_get (plugin->env->sched, 1987 GNUNET_RESOLVER_hostname_get (plugin->env->cfg,
1996 plugin->env->cfg,
1997 sb, 1988 sb,
1998 sbs, 1989 sbs,
1999 !numeric, timeout, &append_port, ppc); 1990 !numeric, timeout, &append_port, ppc);
@@ -2167,7 +2158,7 @@ libgnunet_plugin_transport_udp_init (void *cls)
2167 char *external_address; 2158 char *external_address;
2168 struct IPv4UdpAddress v4_address; 2159 struct IPv4UdpAddress v4_address;
2169 2160
2170 service = GNUNET_SERVICE_start ("transport-udp", env->sched, env->cfg); 2161 service = GNUNET_SERVICE_start ("transport-udp", env->cfg);
2171 if (service == NULL) 2162 if (service == NULL)
2172 { 2163 {
2173 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ 2164 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _
@@ -2308,8 +2299,7 @@ libgnunet_plugin_transport_udp_init (void *cls)
2308 GNUNET_OS_network_interfaces_list (&process_interfaces, plugin); 2299 GNUNET_OS_network_interfaces_list (&process_interfaces, plugin);
2309 } 2300 }
2310 2301
2311 plugin->hostname_dns = GNUNET_RESOLVER_hostname_resolve (env->sched, 2302 plugin->hostname_dns = GNUNET_RESOLVER_hostname_resolve (env->cfg,
2312 env->cfg,
2313 AF_UNSPEC, 2303 AF_UNSPEC,
2314 HOSTNAME_RESOLVE_TIMEOUT, 2304 HOSTNAME_RESOLVE_TIMEOUT,
2315 &process_hostname_ips, 2305 &process_hostname_ips,
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index 0f95f48c7..41f2958a2 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -682,8 +682,7 @@ do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
682 } else { 682 } else {
683 //nothing to send at the moment 683 //nothing to send at the moment
684 plugin->server_read_task = 684 plugin->server_read_task =
685 GNUNET_SCHEDULER_add_delayed (plugin->env->sched, 685 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining(nextsend),
686 GNUNET_TIME_absolute_get_remaining(nextsend),
687 &do_transmit, plugin); 686 &do_transmit, plugin);
688 687
689 } 688 }
@@ -804,8 +803,7 @@ do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
804 } 803 }
805 804
806 //plugin->server_read_task = 805 //plugin->server_read_task =
807 //GNUNET_SCHEDULER_add_read_file (plugin->env->sched, 806 //GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
808 // GNUNET_TIME_UNIT_FOREVER_REL,
809 // plugin->server_stdout_handle, &wlan_plugin_helper_read, plugin); 807 // plugin->server_stdout_handle, &wlan_plugin_helper_read, plugin);
810 808
811} 809}
@@ -837,8 +835,7 @@ process_pending_messages (struct Plugin * plugin)
837 835
838 // GNUNET_TIME_UNIT_FOREVER_REL is needed to clean up old msg 836 // GNUNET_TIME_UNIT_FOREVER_REL is needed to clean up old msg
839 plugin->server_write_task 837 plugin->server_write_task
840 = GNUNET_SCHEDULER_add_write_file(plugin->env->sched, 838 = GNUNET_SCHEDULER_add_write_file(GNUNET_TIME_UNIT_FOREVER_REL,
841 GNUNET_TIME_UNIT_FOREVER_REL,
842 plugin->server_stdin_handle, 839 plugin->server_stdin_handle,
843 &do_transmit, 840 &do_transmit,
844 plugin); 841 plugin);
@@ -1264,8 +1261,7 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
1264 plugin->server_stdin_handle = GNUNET_DISK_pipe_handle(plugin->server_stdin, GNUNET_DISK_PIPE_END_WRITE); 1261 plugin->server_stdin_handle = GNUNET_DISK_pipe_handle(plugin->server_stdin, GNUNET_DISK_PIPE_END_WRITE);
1265 1262
1266 plugin->server_read_task = 1263 plugin->server_read_task =
1267 GNUNET_SCHEDULER_add_read_file (plugin->env->sched, 1264 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
1268 GNUNET_TIME_UNIT_FOREVER_REL,
1269 plugin->server_stdout_handle, &wlan_plugin_helper_read, plugin); 1265 plugin->server_stdout_handle, &wlan_plugin_helper_read, plugin);
1270 return GNUNET_YES; 1266 return GNUNET_YES;
1271} 1267}
@@ -1288,7 +1284,7 @@ gnunet_plugin_transport_wlan_init (void *cls)
1288 1284
1289 GNUNET_assert(cls !=NULL); 1285 GNUNET_assert(cls !=NULL);
1290 1286
1291 service = GNUNET_SERVICE_start ("transport-wlan", env->sched, env->cfg); 1287 service = GNUNET_SERVICE_start ("transport-wlan", env->cfg);
1292 if (service == NULL){ 1288 if (service == NULL){
1293 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1289 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1294 _("Failed to start service for `%s' transport plugin.\n"), 1290 _("Failed to start service for `%s' transport plugin.\n"),
diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c
index 398dcf92b..11e00b80e 100644
--- a/src/transport/test_plugin_transport.c
+++ b/src/transport/test_plugin_transport.c
@@ -60,11 +60,6 @@ static struct GNUNET_PeerIdentity my_identity;
60static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key; 60static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key;
61 61
62/** 62/**
63 * Our scheduler.
64 */
65struct GNUNET_SCHEDULER_Handle *sched;
66
67/**
68 * Our configuration. 63 * Our configuration.
69 */ 64 */
70const struct GNUNET_CONFIGURATION_Handle *cfg; 65const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -168,8 +163,7 @@ test_validation ()
168 api->check_address (api->cls, 163 api->check_address (api->cls,
169 &soaddr, sizeof (soaddr))); 164 &soaddr, sizeof (soaddr)));
170 ok = 0; 165 ok = 0;
171 GNUNET_SCHEDULER_add_continuation (sched, 166 GNUNET_SCHEDULER_add_continuation (&unload_task,
172 &unload_task,
173 (void *) cfg, 167 (void *) cfg,
174 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 168 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
175} 169}
@@ -179,7 +173,6 @@ static void
179setup_plugin_environment () 173setup_plugin_environment ()
180{ 174{
181 env.cfg = cfg; 175 env.cfg = cfg;
182 env.sched = sched;
183 env.my_identity = &my_identity; 176 env.my_identity = &my_identity;
184 env.cls = &env; 177 env.cls = &env;
185 env.receive = &receive; 178 env.receive = &receive;
@@ -192,12 +185,10 @@ setup_plugin_environment ()
192 * Runs the test. 185 * Runs the test.
193 * 186 *
194 * @param cls closure 187 * @param cls closure
195 * @param s scheduler to use
196 * @param c configuration to use 188 * @param c configuration to use
197 */ 189 */
198static void 190static void
199run (void *cls, 191run (void *cls,
200 struct GNUNET_SCHEDULER_Handle *s,
201 char *const *args, 192 char *const *args,
202 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) 193 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
203{ 194{
@@ -205,7 +196,6 @@ run (void *cls,
205 char *keyfile; 196 char *keyfile;
206 char *libname; 197 char *libname;
207 198
208 sched = s;
209 cfg = c; 199 cfg = c;
210 /* parse configuration */ 200 /* parse configuration */
211 if ((GNUNET_OK != 201 if ((GNUNET_OK !=
diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c
index a178f16a0..7da64e295 100644
--- a/src/transport/test_plugin_transport_http.c
+++ b/src/transport/test_plugin_transport_http.c
@@ -232,11 +232,6 @@ static long long unsigned int port;
232static char * test_addr; 232static char * test_addr;
233 233
234/** 234/**
235 * Our scheduler.
236 */
237struct GNUNET_SCHEDULER_Handle *sched;
238
239/**
240 * Our statistics handle. 235 * Our statistics handle.
241 */ 236 */
242struct GNUNET_STATISTICS_Handle *stats; 237struct GNUNET_STATISTICS_Handle *stats;
@@ -446,19 +441,19 @@ shutdown_clean ()
446 441
447 if (ti_send != GNUNET_SCHEDULER_NO_TASK) 442 if (ti_send != GNUNET_SCHEDULER_NO_TASK)
448 { 443 {
449 GNUNET_SCHEDULER_cancel(sched,ti_send); 444 GNUNET_SCHEDULER_cancel(ti_send);
450 ti_send = GNUNET_SCHEDULER_NO_TASK; 445 ti_send = GNUNET_SCHEDULER_NO_TASK;
451 } 446 }
452 447
453 if (http_task_send != GNUNET_SCHEDULER_NO_TASK) 448 if (http_task_send != GNUNET_SCHEDULER_NO_TASK)
454 { 449 {
455 GNUNET_SCHEDULER_cancel(sched,http_task_send); 450 GNUNET_SCHEDULER_cancel(http_task_send);
456 http_task_send = GNUNET_SCHEDULER_NO_TASK; 451 http_task_send = GNUNET_SCHEDULER_NO_TASK;
457 } 452 }
458 453
459 if (ti_timeout != GNUNET_SCHEDULER_NO_TASK) 454 if (ti_timeout != GNUNET_SCHEDULER_NO_TASK)
460 { 455 {
461 GNUNET_SCHEDULER_cancel(sched,ti_timeout); 456 GNUNET_SCHEDULER_cancel(ti_timeout);
462 ti_timeout = GNUNET_SCHEDULER_NO_TASK; 457 ti_timeout = GNUNET_SCHEDULER_NO_TASK;
463 } 458 }
464 459
@@ -466,7 +461,7 @@ shutdown_clean ()
466 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unloading http plugin\n"); 461 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unloading http plugin\n");
467 GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_plugin_transport_http", api)); 462 GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_plugin_transport_http", api));
468 463
469 GNUNET_SCHEDULER_shutdown(sched); 464 GNUNET_SCHEDULER_shutdown();
470 GNUNET_DISK_directory_remove ("/tmp/test_plugin_transport_http"); 465 GNUNET_DISK_directory_remove ("/tmp/test_plugin_transport_http");
471 466
472 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Exiting testcase\n"); 467 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Exiting testcase\n");
@@ -781,8 +776,7 @@ static size_t send_prepare( struct HTTP_Transfer * result)
781 gws = GNUNET_NETWORK_fdset_create (); 776 gws = GNUNET_NETWORK_fdset_create ();
782 GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1); 777 GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1);
783 GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1); 778 GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1);
784 http_task_send = GNUNET_SCHEDULER_add_select (sched, 779 http_task_send = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
785 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
786 GNUNET_SCHEDULER_NO_TASK, 780 GNUNET_SCHEDULER_NO_TASK,
787 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 0), 781 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 0),
788 grs, 782 grs,
@@ -907,7 +901,6 @@ static void
907setup_plugin_environment () 901setup_plugin_environment ()
908{ 902{
909 env.cfg = cfg; 903 env.cfg = cfg;
910 env.sched = sched;
911 env.stats = stats; 904 env.stats = stats;
912 env.my_identity = &my_identity; 905 env.my_identity = &my_identity;
913 env.cls = &env; 906 env.cls = &env;
@@ -1123,17 +1116,14 @@ static void run_connection_tests( int phase , void * cls)
1123 * Runs the test. 1116 * Runs the test.
1124 * 1117 *
1125 * @param cls closure 1118 * @param cls closure
1126 * @param s scheduler to use
1127 * @param c configuration to use 1119 * @param c configuration to use
1128 */ 1120 */
1129static void 1121static void
1130run (void *cls, 1122run (void *cls,
1131 struct GNUNET_SCHEDULER_Handle *s,
1132 char *const *args, 1123 char *const *args,
1133 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) 1124 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
1134{ 1125{
1135 char * libname; 1126 char * libname;
1136 sched = s;
1137 cfg = c; 1127 cfg = c;
1138 char *keyfile; 1128 char *keyfile;
1139 unsigned long long tneigh; 1129 unsigned long long tneigh;
@@ -1223,7 +1213,7 @@ run (void *cls,
1223 } 1213 }
1224 1214
1225 1215
1226 ti_timeout = GNUNET_SCHEDULER_add_delayed (sched, TEST_TIMEOUT, &task_timeout, NULL); 1216 ti_timeout = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &task_timeout, NULL);
1227 1217
1228 /* testing plugin functionality */ 1218 /* testing plugin functionality */
1229 GNUNET_assert (0!=fail_notify_address_count); 1219 GNUNET_assert (0!=fail_notify_address_count);
diff --git a/src/transport/test_plugin_transport_https.c b/src/transport/test_plugin_transport_https.c
index 192ca764d..0ca13ad5c 100644
--- a/src/transport/test_plugin_transport_https.c
+++ b/src/transport/test_plugin_transport_https.c
@@ -231,11 +231,6 @@ static long long unsigned int port;
231static char * test_addr; 231static char * test_addr;
232 232
233/** 233/**
234 * Our scheduler.
235 */
236struct GNUNET_SCHEDULER_Handle *sched;
237
238/**
239 * Our statistics handle. 234 * Our statistics handle.
240 */ 235 */
241struct GNUNET_STATISTICS_Handle *stats; 236struct GNUNET_STATISTICS_Handle *stats;
@@ -449,19 +444,19 @@ shutdown_clean ()
449 444
450 if (ti_send != GNUNET_SCHEDULER_NO_TASK) 445 if (ti_send != GNUNET_SCHEDULER_NO_TASK)
451 { 446 {
452 GNUNET_SCHEDULER_cancel(sched,ti_send); 447 GNUNET_SCHEDULER_cancel(ti_send);
453 ti_send = GNUNET_SCHEDULER_NO_TASK; 448 ti_send = GNUNET_SCHEDULER_NO_TASK;
454 } 449 }
455 450
456 if (http_task_send != GNUNET_SCHEDULER_NO_TASK) 451 if (http_task_send != GNUNET_SCHEDULER_NO_TASK)
457 { 452 {
458 GNUNET_SCHEDULER_cancel(sched,http_task_send); 453 GNUNET_SCHEDULER_cancel(http_task_send);
459 http_task_send = GNUNET_SCHEDULER_NO_TASK; 454 http_task_send = GNUNET_SCHEDULER_NO_TASK;
460 } 455 }
461 456
462 if (ti_timeout != GNUNET_SCHEDULER_NO_TASK) 457 if (ti_timeout != GNUNET_SCHEDULER_NO_TASK)
463 { 458 {
464 GNUNET_SCHEDULER_cancel(sched,ti_timeout); 459 GNUNET_SCHEDULER_cancel(ti_timeout);
465 ti_timeout = GNUNET_SCHEDULER_NO_TASK; 460 ti_timeout = GNUNET_SCHEDULER_NO_TASK;
466 } 461 }
467 462
@@ -469,7 +464,7 @@ shutdown_clean ()
469 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unloading https plugin\n"); 464 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unloading https plugin\n");
470 GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_plugin_transport_https", api)); 465 GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_plugin_transport_https", api));
471 466
472 GNUNET_SCHEDULER_shutdown(sched); 467 GNUNET_SCHEDULER_shutdown();
473 GNUNET_DISK_directory_remove ("/tmp/test_plugin_transport_http"); 468 GNUNET_DISK_directory_remove ("/tmp/test_plugin_transport_http");
474 469
475 struct stat sbuf; 470 struct stat sbuf;
@@ -804,8 +799,7 @@ static size_t send_prepare( struct HTTP_Transfer * result)
804 gws = GNUNET_NETWORK_fdset_create (); 799 gws = GNUNET_NETWORK_fdset_create ();
805 GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1); 800 GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1);
806 GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1); 801 GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1);
807 http_task_send = GNUNET_SCHEDULER_add_select (sched, 802 http_task_send = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
808 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
809 GNUNET_SCHEDULER_NO_TASK, 803 GNUNET_SCHEDULER_NO_TASK,
810 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 0), 804 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 0),
811 grs, 805 grs,
@@ -933,7 +927,6 @@ static void
933setup_plugin_environment () 927setup_plugin_environment ()
934{ 928{
935 env.cfg = cfg; 929 env.cfg = cfg;
936 env.sched = sched;
937 env.stats = stats; 930 env.stats = stats;
938 env.my_identity = &my_identity; 931 env.my_identity = &my_identity;
939 env.cls = &env; 932 env.cls = &env;
@@ -1149,17 +1142,14 @@ static void run_connection_tests( int phase , void * cls)
1149 * Runs the test. 1142 * Runs the test.
1150 * 1143 *
1151 * @param cls closure 1144 * @param cls closure
1152 * @param s scheduler to use
1153 * @param c configuration to use 1145 * @param c configuration to use
1154 */ 1146 */
1155static void 1147static void
1156run (void *cls, 1148run (void *cls,
1157 struct GNUNET_SCHEDULER_Handle *s,
1158 char *const *args, 1149 char *const *args,
1159 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) 1150 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
1160{ 1151{
1161 char * libname; 1152 char * libname;
1162 sched = s;
1163 cfg = c; 1153 cfg = c;
1164 char *keyfile; 1154 char *keyfile;
1165 unsigned long long tneigh; 1155 unsigned long long tneigh;
@@ -1288,7 +1278,7 @@ run (void *cls,
1288 return; 1278 return;
1289 } 1279 }
1290 1280
1291 ti_timeout = GNUNET_SCHEDULER_add_delayed (sched, TEST_TIMEOUT, &task_timeout, NULL); 1281 ti_timeout = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &task_timeout, NULL);
1292 1282
1293 /* testing plugin functionality */ 1283 /* testing plugin functionality */
1294 GNUNET_assert (0!=fail_notify_address_count); 1284 GNUNET_assert (0!=fail_notify_address_count);
diff --git a/src/transport/test_plugin_transport_udp.c b/src/transport/test_plugin_transport_udp.c
index aaa6c18d3..f297a05c1 100644
--- a/src/transport/test_plugin_transport_udp.c
+++ b/src/transport/test_plugin_transport_udp.c
@@ -61,11 +61,6 @@ static struct GNUNET_PeerIdentity my_identity;
61static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key; 61static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key;
62 62
63/** 63/**
64 * Our scheduler.
65 */
66struct GNUNET_SCHEDULER_Handle *sched;
67
68/**
69 * Our configuration. 64 * Our configuration.
70 */ 65 */
71const struct GNUNET_CONFIGURATION_Handle *cfg; 66const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -162,7 +157,6 @@ static void
162setup_plugin_environment () 157setup_plugin_environment ()
163{ 158{
164 env.cfg = cfg; 159 env.cfg = cfg;
165 env.sched = sched;
166 env.my_identity = &my_identity; 160 env.my_identity = &my_identity;
167 env.cls = &env; 161 env.cls = &env;
168 env.receive = &receive; 162 env.receive = &receive;
@@ -174,12 +168,10 @@ setup_plugin_environment ()
174 * Runs the test. 168 * Runs the test.
175 * 169 *
176 * @param cls closure 170 * @param cls closure
177 * @param s scheduler to use
178 * @param c configuration to use 171 * @param c configuration to use
179 */ 172 */
180static void 173static void
181run (void *cls, 174run (void *cls,
182 struct GNUNET_SCHEDULER_Handle *s,
183 char *const *args, 175 char *const *args,
184 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) 176 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
185{ 177{
@@ -187,7 +179,6 @@ run (void *cls,
187 char *keyfile; 179 char *keyfile;
188 char *libname; 180 char *libname;
189 181
190 sched = s;
191 cfg = c; 182 cfg = c;
192 /* parse configuration */ 183 /* parse configuration */
193 if ((GNUNET_OK != 184 if ((GNUNET_OK !=
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c
index 77279897d..041bd0968 100644
--- a/src/transport/test_quota_compliance.c
+++ b/src/transport/test_quota_compliance.c
@@ -121,8 +121,6 @@ static struct PeerContext p1;
121 121
122static struct PeerContext p2; 122static struct PeerContext p2;
123 123
124static struct GNUNET_SCHEDULER_Handle *sched;
125
126static int ok; 124static int ok;
127 125
128static int connected; 126static int connected;
@@ -165,20 +163,20 @@ end_send ()
165static void 163static void
166end () 164end ()
167{ 165{
168 GNUNET_SCHEDULER_cancel (sched, die_task); 166 GNUNET_SCHEDULER_cancel (die_task);
169 die_task = GNUNET_SCHEDULER_NO_TASK; 167 die_task = GNUNET_SCHEDULER_NO_TASK;
170 168
171 if (measurement_task != GNUNET_SCHEDULER_NO_TASK) 169 if (measurement_task != GNUNET_SCHEDULER_NO_TASK)
172 { 170 {
173 GNUNET_SCHEDULER_cancel (sched, measurement_task); 171 GNUNET_SCHEDULER_cancel (measurement_task);
174 measurement_task = GNUNET_SCHEDULER_NO_TASK; 172 measurement_task = GNUNET_SCHEDULER_NO_TASK;
175 } 173 }
176 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) 174 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
177 { 175 {
178 GNUNET_SCHEDULER_cancel (sched, measurement_counter_task); 176 GNUNET_SCHEDULER_cancel (measurement_counter_task);
179 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; 177 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
180 } 178 }
181 GNUNET_SCHEDULER_shutdown (sched); 179 GNUNET_SCHEDULER_shutdown ();
182#if DEBUG_CONNECTIONS 180#if DEBUG_CONNECTIONS
183 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); 181 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
184#endif 182#endif
@@ -188,7 +186,7 @@ end ()
188 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 186 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
189 "Transports disconnected, returning success!\n"); 187 "Transports disconnected, returning success!\n");
190#endif 188#endif
191 GNUNET_SCHEDULER_shutdown (sched); 189 GNUNET_SCHEDULER_shutdown ();
192} 190}
193 191
194 192
@@ -213,12 +211,12 @@ end_badly (void *cls,
213{ 211{
214 if (measurement_task != GNUNET_SCHEDULER_NO_TASK) 212 if (measurement_task != GNUNET_SCHEDULER_NO_TASK)
215 { 213 {
216 GNUNET_SCHEDULER_cancel (sched, measurement_task); 214 GNUNET_SCHEDULER_cancel (measurement_task);
217 measurement_task = GNUNET_SCHEDULER_NO_TASK; 215 measurement_task = GNUNET_SCHEDULER_NO_TASK;
218 } 216 }
219 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) 217 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
220 { 218 {
221 GNUNET_SCHEDULER_cancel (sched, measurement_counter_task); 219 GNUNET_SCHEDULER_cancel (measurement_counter_task);
222 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; 220 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
223 } 221 }
224 GNUNET_break (0); 222 GNUNET_break (0);
@@ -355,8 +353,7 @@ static void measurement_counter
355#if VERBOSE 353#if VERBOSE
356 fprintf(stderr,"."); 354 fprintf(stderr,".");
357#endif 355#endif
358 measurement_counter_task = GNUNET_SCHEDULER_add_delayed (sched, 356 measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
359 GNUNET_TIME_UNIT_SECONDS,
360 &measurement_counter, 357 &measurement_counter,
361 NULL); 358 NULL);
362} 359}
@@ -379,7 +376,7 @@ measurement_end (void *cls,
379 376
380 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) 377 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
381 { 378 {
382 GNUNET_SCHEDULER_cancel (sched, measurement_counter_task); 379 GNUNET_SCHEDULER_cancel (measurement_counter_task);
383 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; 380 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
384 } 381 }
385#if VERBOSE 382#if VERBOSE
@@ -498,19 +495,16 @@ static void measure (unsigned long long quota_p1, unsigned long long quota_p2 )
498 GNUNET_TIME_UNIT_FOREVER_REL, 495 GNUNET_TIME_UNIT_FOREVER_REL,
499 NULL, NULL); 496 NULL, NULL);
500 497
501 GNUNET_SCHEDULER_cancel (sched, die_task); 498 GNUNET_SCHEDULER_cancel (die_task);
502 die_task = GNUNET_SCHEDULER_add_delayed (sched, 499 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
503 TIMEOUT,
504 &end_badly, 500 &end_badly,
505 NULL); 501 NULL);
506 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) 502 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
507 GNUNET_SCHEDULER_cancel (sched, measurement_counter_task); 503 GNUNET_SCHEDULER_cancel (measurement_counter_task);
508 measurement_counter_task = GNUNET_SCHEDULER_add_delayed (sched, 504 measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
509 GNUNET_TIME_UNIT_SECONDS,
510 &measurement_counter, 505 &measurement_counter,
511 NULL); 506 NULL);
512 measurement_task = GNUNET_SCHEDULER_add_delayed (sched, 507 measurement_task = GNUNET_SCHEDULER_add_delayed (MEASUREMENT_INTERVALL,
513 MEASUREMENT_INTERVALL,
514 &measurement_end, 508 &measurement_end,
515 NULL); 509 NULL);
516 total_bytes_sent = 0; 510 total_bytes_sent = 0;
@@ -588,7 +582,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
588#endif 582#endif
589 583
590 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 584 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
591 p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, 585 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL,
592 p, 586 p,
593 &notify_receive_new, 587 &notify_receive_new,
594 &notify_connect, 588 &notify_connect,
@@ -634,16 +628,13 @@ exchange_hello (void *cls,
634 628
635static void 629static void
636run (void *cls, 630run (void *cls,
637 struct GNUNET_SCHEDULER_Handle *s,
638 char *const *args, 631 char *const *args,
639 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 632 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
640{ 633{
641 GNUNET_assert (ok == 1); 634 GNUNET_assert (ok == 1);
642 OKPP; 635 OKPP;
643 sched = s;
644 636
645 die_task = GNUNET_SCHEDULER_add_delayed (sched, 637 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
646 TIMEOUT,
647 &end_badly, 638 &end_badly,
648 NULL); 639 NULL);
649 measurement_running = GNUNET_NO; 640 measurement_running = GNUNET_NO;
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c
index cee1da25b..e429ad7a7 100644
--- a/src/transport/test_transport_api.c
+++ b/src/transport/test_transport_api.c
@@ -68,8 +68,6 @@ static struct PeerContext p1;
68 68
69static struct PeerContext p2; 69static struct PeerContext p2;
70 70
71static struct GNUNET_SCHEDULER_Handle *sched;
72
73static int ok; 71static int ok;
74 72
75static int is_tcp; 73static int is_tcp;
@@ -104,7 +102,7 @@ end ()
104{ 102{
105 /* do work here */ 103 /* do work here */
106 GNUNET_assert (ok == 6); 104 GNUNET_assert (ok == 6);
107 GNUNET_SCHEDULER_cancel (sched, die_task); 105 GNUNET_SCHEDULER_cancel (die_task);
108 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); 106 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
109 GNUNET_TRANSPORT_disconnect (p1.th); 107 GNUNET_TRANSPORT_disconnect (p1.th);
110 GNUNET_TRANSPORT_disconnect (p2.th); 108 GNUNET_TRANSPORT_disconnect (p2.th);
@@ -193,9 +191,8 @@ notify_connect (void *cls,
193{ 191{
194 if (cls == &p1) 192 if (cls == &p1)
195 { 193 {
196 GNUNET_SCHEDULER_cancel (sched, die_task); 194 GNUNET_SCHEDULER_cancel (die_task);
197 die_task = GNUNET_SCHEDULER_add_delayed (sched, 195 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT,
198 TIMEOUT_TRANSMIT,
199 &end_badly, NULL); 196 &end_badly, NULL);
200 197
201 GNUNET_TRANSPORT_notify_transmit_ready (p1.th, 198 GNUNET_TRANSPORT_notify_transmit_ready (p1.th,
@@ -288,7 +285,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
288 } 285 }
289 } 286 }
290 287
291 p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, 288 p->th = GNUNET_TRANSPORT_connect (p->cfg,
292 NULL, p, 289 NULL, p,
293 &notify_receive, 290 &notify_receive,
294 &notify_connect, &notify_disconnect); 291 &notify_connect, &notify_disconnect);
@@ -341,15 +338,12 @@ exchange_hello (void *cls,
341 338
342static void 339static void
343run (void *cls, 340run (void *cls,
344 struct GNUNET_SCHEDULER_Handle *s,
345 char *const *args, 341 char *const *args,
346 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 342 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
347{ 343{
348 GNUNET_assert (ok == 1); 344 GNUNET_assert (ok == 1);
349 OKPP; 345 OKPP;
350 sched = s; 346 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
351 die_task = GNUNET_SCHEDULER_add_delayed (sched,
352 TIMEOUT,
353 &end_badly, NULL); 347 &end_badly, NULL);
354 348
355 if (is_udp) 349 if (is_udp)
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c
index a8633e089..ce031af7f 100644
--- a/src/transport/test_transport_api_reliability.c
+++ b/src/transport/test_transport_api_reliability.c
@@ -70,8 +70,6 @@ static struct PeerContext p1;
70 70
71static struct PeerContext p2; 71static struct PeerContext p2;
72 72
73static struct GNUNET_SCHEDULER_Handle *sched;
74
75static int ok; 73static int ok;
76 74
77static int is_tcp; 75static int is_tcp;
@@ -116,7 +114,7 @@ end ()
116{ 114{
117 unsigned long long delta; 115 unsigned long long delta;
118 116
119 GNUNET_SCHEDULER_cancel (sched, die_task); 117 GNUNET_SCHEDULER_cancel (die_task);
120 die_task = GNUNET_SCHEDULER_NO_TASK; 118 die_task = GNUNET_SCHEDULER_NO_TASK;
121#if VERBOSE 119#if VERBOSE
122 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); 120 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
@@ -208,8 +206,8 @@ notify_receive (void *cls,
208 n, s, 206 n, s,
209 ntohs (message->size), 207 ntohs (message->size),
210 ntohl (hdr->num)); 208 ntohl (hdr->num));
211 GNUNET_SCHEDULER_cancel (sched, die_task); 209 GNUNET_SCHEDULER_cancel (die_task);
212 die_task = GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL); 210 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
213 return; 211 return;
214 } 212 }
215 if (ntohl (hdr->num) != n) 213 if (ntohl (hdr->num) != n)
@@ -219,8 +217,8 @@ notify_receive (void *cls,
219 n, s, 217 n, s,
220 ntohs (message->size), 218 ntohs (message->size),
221 ntohl (hdr->num)); 219 ntohl (hdr->num));
222 GNUNET_SCHEDULER_cancel (sched, die_task); 220 GNUNET_SCHEDULER_cancel (die_task);
223 die_task = GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL); 221 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
224 return; 222 return;
225 } 223 }
226 memset (cbuf, n, s - sizeof (struct TestMessage)); 224 memset (cbuf, n, s - sizeof (struct TestMessage));
@@ -231,8 +229,8 @@ notify_receive (void *cls,
231 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 229 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
232 "Expected message %u with bits %u, but body did not match\n", 230 "Expected message %u with bits %u, but body did not match\n",
233 n, (unsigned char) n); 231 n, (unsigned char) n);
234 GNUNET_SCHEDULER_cancel (sched, die_task); 232 GNUNET_SCHEDULER_cancel (die_task);
235 die_task = GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL); 233 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
236 return; 234 return;
237 } 235 }
238#if VERBOSE 236#if VERBOSE
@@ -248,9 +246,8 @@ notify_receive (void *cls,
248 if (0 == (n % (TOTAL_MSGS/100))) 246 if (0 == (n % (TOTAL_MSGS/100)))
249 { 247 {
250 fprintf (stderr, "."); 248 fprintf (stderr, ".");
251 GNUNET_SCHEDULER_cancel (sched, die_task); 249 GNUNET_SCHEDULER_cancel (die_task);
252 die_task = GNUNET_SCHEDULER_add_delayed (sched, 250 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
253 TIMEOUT,
254 &end_badly, 251 &end_badly,
255 NULL); 252 NULL);
256 } 253 }
@@ -450,7 +447,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
450 } 447 }
451 } 448 }
452 449
453 p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, 450 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL,
454 p, 451 p,
455 &notify_receive, 452 &notify_receive,
456 &notify_connect, 453 &notify_connect,
@@ -622,15 +619,12 @@ check_gnunet_nat_binary(char *binary)
622 619
623static void 620static void
624run (void *cls, 621run (void *cls,
625 struct GNUNET_SCHEDULER_Handle *s,
626 char *const *args, 622 char *const *args,
627 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 623 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
628{ 624{
629 GNUNET_assert (ok == 1); 625 GNUNET_assert (ok == 1);
630 OKPP; 626 OKPP;
631 sched = s; 627 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
632 die_task = GNUNET_SCHEDULER_add_delayed (sched,
633 TIMEOUT,
634 &end_badly, 628 &end_badly,
635 NULL); 629 NULL);
636 if (is_tcp) 630 if (is_tcp)
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c
index c0f32f93d..6fb35b5d6 100644
--- a/src/transport/transport_api.c
+++ b/src/transport/transport_api.c
@@ -327,11 +327,6 @@ struct GNUNET_TRANSPORT_Handle
327 struct HelloWaitList *hwl_head; 327 struct HelloWaitList *hwl_head;
328 328
329 /** 329 /**
330 * My scheduler.
331 */
332 struct GNUNET_SCHEDULER_Handle *sched;
333
334 /**
335 * My configuration. 330 * My configuration.
336 */ 331 */
337 const struct GNUNET_CONFIGURATION_Handle *cfg; 332 const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -444,8 +439,7 @@ schedule_peer_transmission (struct GNUNET_TRANSPORT_Handle *h)
444 439
445 if (h->quota_task != GNUNET_SCHEDULER_NO_TASK) 440 if (h->quota_task != GNUNET_SCHEDULER_NO_TASK)
446 { 441 {
447 GNUNET_SCHEDULER_cancel (h->sched, 442 GNUNET_SCHEDULER_cancel (h->quota_task);
448 h->quota_task);
449 h->quota_task = GNUNET_SCHEDULER_NO_TASK; 443 h->quota_task = GNUNET_SCHEDULER_NO_TASK;
450 } 444 }
451 retry_time = GNUNET_TIME_UNIT_FOREVER_REL; 445 retry_time = GNUNET_TIME_UNIT_FOREVER_REL;
@@ -476,7 +470,7 @@ schedule_peer_transmission (struct GNUNET_TRANSPORT_Handle *h)
476#endif 470#endif
477 if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) 471 if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
478 { 472 {
479 GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); 473 GNUNET_SCHEDULER_cancel (th->notify_delay_task);
480 th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; 474 th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
481 } 475 }
482 n->transmit_stage = TS_NEW; 476 n->transmit_stage = TS_NEW;
@@ -510,8 +504,7 @@ schedule_peer_transmission (struct GNUNET_TRANSPORT_Handle *h)
510 ret = th; 504 ret = th;
511 } 505 }
512 if (ret == NULL) 506 if (ret == NULL)
513 h->quota_task = GNUNET_SCHEDULER_add_delayed (h->sched, 507 h->quota_task = GNUNET_SCHEDULER_add_delayed (retry_time,
514 retry_time,
515 &quota_transmit_ready, 508 &quota_transmit_ready,
516 h); 509 h);
517 return ret; 510 return ret;
@@ -556,7 +549,7 @@ transport_notify_ready (void *cls, size_t size, void *buf)
556 { 549 {
557 if (cm->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) 550 if (cm->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
558 { 551 {
559 GNUNET_SCHEDULER_cancel (h->sched, cm->notify_delay_task); 552 GNUNET_SCHEDULER_cancel (cm->notify_delay_task);
560 cm->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; 553 cm->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
561 } 554 }
562 GNUNET_CONTAINER_DLL_remove (h->control_head, 555 GNUNET_CONTAINER_DLL_remove (h->control_head,
@@ -578,7 +571,7 @@ transport_notify_ready (void *cls, size_t size, void *buf)
578 { 571 {
579 if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) 572 if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
580 { 573 {
581 GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); 574 GNUNET_SCHEDULER_cancel (th->notify_delay_task);
582 th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; 575 th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
583 } 576 }
584 n = th->neighbour; 577 n = th->neighbour;
@@ -763,8 +756,7 @@ schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h,
763 th->notify_cls = notify_cls; 756 th->notify_cls = notify_cls;
764 th->notify_size = size; 757 th->notify_size = size;
765 th->notify_delay_task 758 th->notify_delay_task
766 = GNUNET_SCHEDULER_add_delayed (h->sched, 759 = GNUNET_SCHEDULER_add_delayed (timeout, &control_transmit_timeout, th);
767 timeout, &control_transmit_timeout, th);
768 if (at_head) 760 if (at_head)
769 GNUNET_CONTAINER_DLL_insert (h->control_head, 761 GNUNET_CONTAINER_DLL_insert (h->control_head,
770 h->control_tail, 762 h->control_tail,
@@ -810,8 +802,7 @@ send_set_quota (void *cls, size_t size, void *buf)
810 802
811 if (buf == NULL) 803 if (buf == NULL)
812 { 804 {
813 GNUNET_SCHEDULER_add_continuation (sqc->handle->sched, 805 GNUNET_SCHEDULER_add_continuation (sqc->cont,
814 sqc->cont,
815 sqc->cont_cls, 806 sqc->cont_cls,
816 GNUNET_SCHEDULER_REASON_TIMEOUT); 807 GNUNET_SCHEDULER_REASON_TIMEOUT);
817 GNUNET_free (sqc); 808 GNUNET_free (sqc);
@@ -830,8 +821,7 @@ send_set_quota (void *cls, size_t size, void *buf)
830 msg->quota = sqc->quota_in; 821 msg->quota = sqc->quota_in;
831 memcpy (&msg->peer, &sqc->target, sizeof (struct GNUNET_PeerIdentity)); 822 memcpy (&msg->peer, &sqc->target, sizeof (struct GNUNET_PeerIdentity));
832 if (sqc->cont != NULL) 823 if (sqc->cont != NULL)
833 GNUNET_SCHEDULER_add_continuation (sqc->handle->sched, 824 GNUNET_SCHEDULER_add_continuation (sqc->cont,
834 sqc->cont,
835 sqc->cont_cls, 825 sqc->cont_cls,
836 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 826 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
837 GNUNET_free (sqc); 827 GNUNET_free (sqc);
@@ -1192,7 +1182,7 @@ reconnect (void *cls,
1192 "Connecting to transport service.\n"); 1182 "Connecting to transport service.\n");
1193#endif 1183#endif
1194 GNUNET_assert (h->client == NULL); 1184 GNUNET_assert (h->client == NULL);
1195 h->client = GNUNET_CLIENT_connect (h->sched, "transport", h->cfg); 1185 h->client = GNUNET_CLIENT_connect ("transport", h->cfg);
1196 GNUNET_assert (h->client != NULL); 1186 GNUNET_assert (h->client != NULL);
1197 /* make sure we don't send "START" twice, remove existing entry from 1187 /* make sure we don't send "START" twice, remove existing entry from
1198 queue (if present) */ 1188 queue (if present) */
@@ -1206,7 +1196,7 @@ reconnect (void *cls,
1206 pos); 1196 pos);
1207 if (GNUNET_SCHEDULER_NO_TASK != pos->notify_delay_task) 1197 if (GNUNET_SCHEDULER_NO_TASK != pos->notify_delay_task)
1208 { 1198 {
1209 GNUNET_SCHEDULER_cancel (h->sched, pos->notify_delay_task); 1199 GNUNET_SCHEDULER_cancel (pos->notify_delay_task);
1210 pos->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; 1200 pos->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
1211 } 1201 }
1212 GNUNET_free (pos); 1202 GNUNET_free (pos);
@@ -1240,8 +1230,7 @@ schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h)
1240 GNUNET_assert (h->client == NULL); 1230 GNUNET_assert (h->client == NULL);
1241 GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK); 1231 GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK);
1242 h->reconnect_task 1232 h->reconnect_task
1243 = GNUNET_SCHEDULER_add_delayed (h->sched, 1233 = GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
1244 h->reconnect_delay, &reconnect, h);
1245 if (h->reconnect_delay.rel_value == 0) 1234 if (h->reconnect_delay.rel_value == 0)
1246 { 1235 {
1247 h->reconnect_delay = GNUNET_TIME_UNIT_MILLISECONDS; 1236 h->reconnect_delay = GNUNET_TIME_UNIT_MILLISECONDS;
@@ -1353,7 +1342,6 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h,
1353 * Connect to the transport service. Note that the connection may 1342 * Connect to the transport service. Note that the connection may
1354 * complete (or fail) asynchronously. 1343 * complete (or fail) asynchronously.
1355 * 1344 *
1356 * @param sched scheduler to use
1357 * @param cfg configuration to use 1345 * @param cfg configuration to use
1358 * @param self our own identity (API should check that it matches 1346 * @param self our own identity (API should check that it matches
1359 * the identity found by transport), or NULL (no check) 1347 * the identity found by transport), or NULL (no check)
@@ -1363,8 +1351,7 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h,
1363 * @param nd function to call on disconnect events 1351 * @param nd function to call on disconnect events
1364 */ 1352 */
1365struct GNUNET_TRANSPORT_Handle * 1353struct GNUNET_TRANSPORT_Handle *
1366GNUNET_TRANSPORT_connect (struct GNUNET_SCHEDULER_Handle *sched, 1354GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
1367 const struct GNUNET_CONFIGURATION_Handle *cfg,
1368 const struct GNUNET_PeerIdentity *self, 1355 const struct GNUNET_PeerIdentity *self,
1369 void *cls, 1356 void *cls,
1370 GNUNET_TRANSPORT_ReceiveCallback rec, 1357 GNUNET_TRANSPORT_ReceiveCallback rec,
@@ -1379,7 +1366,6 @@ GNUNET_TRANSPORT_connect (struct GNUNET_SCHEDULER_Handle *sched,
1379 ret->self = *self; 1366 ret->self = *self;
1380 ret->check_self = GNUNET_YES; 1367 ret->check_self = GNUNET_YES;
1381 } 1368 }
1382 ret->sched = sched;
1383 ret->cfg = cfg; 1369 ret->cfg = cfg;
1384 ret->cls = cls; 1370 ret->cls = cls;
1385 ret->rec = rec; 1371 ret->rec = rec;
@@ -1421,8 +1407,7 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle)
1421 th = &n->transmit_handle; 1407 th = &n->transmit_handle;
1422 if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) 1408 if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
1423 { 1409 {
1424 GNUNET_SCHEDULER_cancel (handle->sched, 1410 GNUNET_SCHEDULER_cancel (th->notify_delay_task);
1425 th->notify_delay_task);
1426 th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; 1411 th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
1427 } 1412 }
1428 GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); 1413 GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL));
@@ -1454,7 +1439,7 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle)
1454#endif 1439#endif
1455 if (cm->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) 1440 if (cm->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
1456 { 1441 {
1457 GNUNET_SCHEDULER_cancel (handle->sched, cm->notify_delay_task); 1442 GNUNET_SCHEDULER_cancel (cm->notify_delay_task);
1458 cm->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; 1443 cm->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
1459 } 1444 }
1460 GNUNET_CONTAINER_DLL_remove (handle->control_head, 1445 GNUNET_CONTAINER_DLL_remove (handle->control_head,
@@ -1466,12 +1451,12 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle)
1466 1451
1467 if (handle->reconnect_task != GNUNET_SCHEDULER_NO_TASK) 1452 if (handle->reconnect_task != GNUNET_SCHEDULER_NO_TASK)
1468 { 1453 {
1469 GNUNET_SCHEDULER_cancel (handle->sched, handle->reconnect_task); 1454 GNUNET_SCHEDULER_cancel (handle->reconnect_task);
1470 handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK; 1455 handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
1471 } 1456 }
1472 if (handle->quota_task != GNUNET_SCHEDULER_NO_TASK) 1457 if (handle->quota_task != GNUNET_SCHEDULER_NO_TASK)
1473 { 1458 {
1474 GNUNET_SCHEDULER_cancel (handle->sched, handle->quota_task); 1459 GNUNET_SCHEDULER_cancel (handle->quota_task);
1475 handle->quota_task = GNUNET_SCHEDULER_NO_TASK; 1460 handle->quota_task = GNUNET_SCHEDULER_NO_TASK;
1476 } 1461 }
1477 GNUNET_free_non_null (handle->my_hello); 1462 GNUNET_free_non_null (handle->my_hello);
@@ -1857,7 +1842,7 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle
1857 th->notify_size = size + sizeof (struct OutboundMessage); 1842 th->notify_size = size + sizeof (struct OutboundMessage);
1858 th->priority = priority; 1843 th->priority = priority;
1859 th->notify_delay_task 1844 th->notify_delay_task
1860 = GNUNET_SCHEDULER_add_delayed (handle->sched, timeout, 1845 = GNUNET_SCHEDULER_add_delayed (timeout,
1861 &peer_transmit_timeout, th); 1846 &peer_transmit_timeout, th);
1862 schedule_transmission (handle); 1847 schedule_transmission (handle);
1863 return th; 1848 return th;
@@ -1902,8 +1887,7 @@ GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct
1902 } 1887 }
1903 if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) 1888 if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
1904 { 1889 {
1905 GNUNET_SCHEDULER_cancel (n->h->sched, 1890 GNUNET_SCHEDULER_cancel (th->notify_delay_task);
1906 th->notify_delay_task);
1907 th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; 1891 th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
1908 } 1892 }
1909} 1893}
diff --git a/src/transport/transport_api_address_lookup.c b/src/transport/transport_api_address_lookup.c
index cb15f0565..022d5f03b 100644
--- a/src/transport/transport_api_address_lookup.c
+++ b/src/transport/transport_api_address_lookup.c
@@ -108,7 +108,6 @@ address_response_processor (void *cls,
108/** 108/**
109 * Convert a binary address into a human readable address. 109 * Convert a binary address into a human readable address.
110 * 110 *
111 * @param sched scheduler to use
112 * @param cfg configuration to use 111 * @param cfg configuration to use
113 * @param address address to convert (binary format) 112 * @param address address to convert (binary format)
114 * @param addressLen number of bytes in address 113 * @param addressLen number of bytes in address
@@ -120,8 +119,7 @@ address_response_processor (void *cls,
120 * @param aluc_cls closure for aluc 119 * @param aluc_cls closure for aluc
121 */ 120 */
122void 121void
123GNUNET_TRANSPORT_address_lookup (struct GNUNET_SCHEDULER_Handle *sched, 122GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg,
124 const struct GNUNET_CONFIGURATION_Handle *cfg,
125 const char *address, 123 const char *address,
126 size_t addressLen, 124 size_t addressLen,
127 int numeric, 125 int numeric,
@@ -146,7 +144,7 @@ GNUNET_TRANSPORT_address_lookup (struct GNUNET_SCHEDULER_Handle *sched,
146 aluc (aluc_cls, NULL); 144 aluc (aluc_cls, NULL);
147 return; 145 return;
148 } 146 }
149 client = GNUNET_CLIENT_connect (sched, "transport", cfg); 147 client = GNUNET_CLIENT_connect ("transport", cfg);
150 if (client == NULL) 148 if (client == NULL)
151 { 149 {
152 aluc (aluc_cls, NULL); 150 aluc (aluc_cls, NULL);
diff --git a/src/transport/transport_api_blacklist.c b/src/transport/transport_api_blacklist.c
index 1025edef4..2315b515f 100644
--- a/src/transport/transport_api_blacklist.c
+++ b/src/transport/transport_api_blacklist.c
@@ -45,11 +45,6 @@ struct GNUNET_TRANSPORT_Blacklist
45 struct GNUNET_CLIENT_Connection * client; 45 struct GNUNET_CLIENT_Connection * client;
46 46
47 /** 47 /**
48 * Scheduler to use.
49 */
50 struct GNUNET_SCHEDULER_Handle *sched;
51
52 /**
53 * Configuration to use. 48 * Configuration to use.
54 */ 49 */
55 const struct GNUNET_CONFIGURATION_Handle *cfg; 50 const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -175,8 +170,7 @@ reconnect (struct GNUNET_TRANSPORT_Blacklist *br)
175{ 170{
176 if (br->client != NULL) 171 if (br->client != NULL)
177 GNUNET_CLIENT_disconnect (br->client, GNUNET_NO); 172 GNUNET_CLIENT_disconnect (br->client, GNUNET_NO);
178 br->client = GNUNET_CLIENT_connect (br->sched, 173 br->client = GNUNET_CLIENT_connect ("transport",
179 "transport",
180 br->cfg); 174 br->cfg);
181 GNUNET_assert (br->client != NULL); 175 GNUNET_assert (br->client != NULL);
182 br->th = GNUNET_CLIENT_notify_transmit_ready (br->client, 176 br->th = GNUNET_CLIENT_notify_transmit_ready (br->client,
@@ -249,27 +243,24 @@ reply (struct GNUNET_TRANSPORT_Blacklist *br)
249 * only way to re-enable connections from peers that were previously 243 * only way to re-enable connections from peers that were previously
250 * blacklisted. 244 * blacklisted.
251 * 245 *
252 * @param sched scheduler to use
253 * @param cfg configuration to use 246 * @param cfg configuration to use
254 * @param cb callback to invoke to check if connections are allowed 247 * @param cb callback to invoke to check if connections are allowed
255 * @param cb_cls closure for cb 248 * @param cb_cls closure for cb
256 * @return NULL on error, otherwise handle for cancellation 249 * @return NULL on error, otherwise handle for cancellation
257 */ 250 */
258struct GNUNET_TRANSPORT_Blacklist * 251struct GNUNET_TRANSPORT_Blacklist *
259GNUNET_TRANSPORT_blacklist (struct GNUNET_SCHEDULER_Handle *sched, 252GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg,
260 const struct GNUNET_CONFIGURATION_Handle *cfg,
261 GNUNET_TRANSPORT_BlacklistCallback cb, 253 GNUNET_TRANSPORT_BlacklistCallback cb,
262 void *cb_cls) 254 void *cb_cls)
263{ 255{
264 struct GNUNET_CLIENT_Connection * client; 256 struct GNUNET_CLIENT_Connection * client;
265 struct GNUNET_TRANSPORT_Blacklist *ret; 257 struct GNUNET_TRANSPORT_Blacklist *ret;
266 258
267 client = GNUNET_CLIENT_connect (sched, "transport", cfg); 259 client = GNUNET_CLIENT_connect ("transport", cfg);
268 if (NULL == client) 260 if (NULL == client)
269 return NULL; 261 return NULL;
270 ret = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_Blacklist)); 262 ret = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_Blacklist));
271 ret->client = client; 263 ret->client = client;
272 ret->sched = sched;
273 ret->cfg = cfg; 264 ret->cfg = cfg;
274 ret->th = GNUNET_CLIENT_notify_transmit_ready (client, 265 ret->th = GNUNET_CLIENT_notify_transmit_ready (client,
275 sizeof (struct GNUNET_MessageHeader), 266 sizeof (struct GNUNET_MessageHeader),
diff --git a/src/util/client.c b/src/util/client.c
index 13c4062a5..171e9e957 100644
--- a/src/util/client.c
+++ b/src/util/client.c
@@ -151,11 +151,6 @@ struct GNUNET_CLIENT_Connection
151 struct GNUNET_CONNECTION_Handle *sock; 151 struct GNUNET_CONNECTION_Handle *sock;
152 152
153 /** 153 /**
154 * Our scheduler.
155 */
156 struct GNUNET_SCHEDULER_Handle *sched;
157
158 /**
159 * Our configuration. 154 * Our configuration.
160 * FIXME: why do we DUP the configuration? Avoid this! 155 * FIXME: why do we DUP the configuration? Avoid this!
161 */ 156 */
@@ -262,15 +257,13 @@ struct GNUNET_CLIENT_Connection
262/** 257/**
263 * Try to connect to the service. 258 * Try to connect to the service.
264 * 259 *
265 * @param sched scheduler to use
266 * @param service_name name of service to connect to 260 * @param service_name name of service to connect to
267 * @param cfg configuration to use 261 * @param cfg configuration to use
268 * @param attempt counter used to alternate between IP and UNIX domain sockets 262 * @param attempt counter used to alternate between IP and UNIX domain sockets
269 * @return NULL on error 263 * @return NULL on error
270 */ 264 */
271static struct GNUNET_CONNECTION_Handle * 265static struct GNUNET_CONNECTION_Handle *
272do_connect (struct GNUNET_SCHEDULER_Handle *sched, 266do_connect (const char *service_name,
273 const char *service_name,
274 const struct GNUNET_CONFIGURATION_Handle *cfg, 267 const struct GNUNET_CONFIGURATION_Handle *cfg,
275 unsigned int attempt) 268 unsigned int attempt)
276{ 269{
@@ -288,8 +281,7 @@ do_connect (struct GNUNET_SCHEDULER_Handle *sched,
288 service_name, 281 service_name,
289 "UNIXPATH", &unixpath)) 282 "UNIXPATH", &unixpath))
290 { 283 {
291 sock = GNUNET_CONNECTION_create_from_connect_to_unixpath (sched, 284 sock = GNUNET_CONNECTION_create_from_connect_to_unixpath (cfg,
292 cfg,
293 unixpath); 285 unixpath);
294 GNUNET_free (unixpath); 286 GNUNET_free (unixpath);
295 if (sock != NULL) 287 if (sock != NULL)
@@ -323,8 +315,7 @@ do_connect (struct GNUNET_SCHEDULER_Handle *sched,
323 service_name); 315 service_name);
324 return NULL; 316 return NULL;
325 } 317 }
326 sock = GNUNET_CONNECTION_create_from_connect (sched, 318 sock = GNUNET_CONNECTION_create_from_connect (cfg,
327 cfg,
328 hostname, 319 hostname,
329 port); 320 port);
330 GNUNET_free (hostname); 321 GNUNET_free (hostname);
@@ -335,28 +326,24 @@ do_connect (struct GNUNET_SCHEDULER_Handle *sched,
335/** 326/**
336 * Get a connection with a service. 327 * Get a connection with a service.
337 * 328 *
338 * @param sched scheduler to use
339 * @param service_name name of the service 329 * @param service_name name of the service
340 * @param cfg configuration to use 330 * @param cfg configuration to use
341 * @return NULL on error (service unknown to configuration) 331 * @return NULL on error (service unknown to configuration)
342 */ 332 */
343struct GNUNET_CLIENT_Connection * 333struct GNUNET_CLIENT_Connection *
344GNUNET_CLIENT_connect (struct GNUNET_SCHEDULER_Handle *sched, 334GNUNET_CLIENT_connect (const char *service_name,
345 const char *service_name,
346 const struct GNUNET_CONFIGURATION_Handle *cfg) 335 const struct GNUNET_CONFIGURATION_Handle *cfg)
347{ 336{
348 struct GNUNET_CLIENT_Connection *ret; 337 struct GNUNET_CLIENT_Connection *ret;
349 struct GNUNET_CONNECTION_Handle *sock; 338 struct GNUNET_CONNECTION_Handle *sock;
350 339
351 sock = do_connect (sched, 340 sock = do_connect (service_name,
352 service_name,
353 cfg, 0); 341 cfg, 0);
354 if (sock == NULL) 342 if (sock == NULL)
355 return NULL; 343 return NULL;
356 ret = GNUNET_malloc (sizeof (struct GNUNET_CLIENT_Connection)); 344 ret = GNUNET_malloc (sizeof (struct GNUNET_CLIENT_Connection));
357 ret->attempts = 1; 345 ret->attempts = 1;
358 ret->sock = sock; 346 ret->sock = sock;
359 ret->sched = sched;
360 ret->service_name = GNUNET_strdup (service_name); 347 ret->service_name = GNUNET_strdup (service_name);
361 ret->cfg = GNUNET_CONFIGURATION_dup (cfg); 348 ret->cfg = GNUNET_CONFIGURATION_dup (cfg);
362 ret->back_off = GNUNET_TIME_UNIT_MILLISECONDS; 349 ret->back_off = GNUNET_TIME_UNIT_MILLISECONDS;
@@ -418,7 +405,7 @@ GNUNET_CLIENT_disconnect (struct GNUNET_CLIENT_Connection *sock,
418 GNUNET_CLIENT_notify_transmit_ready_cancel (sock->th); 405 GNUNET_CLIENT_notify_transmit_ready_cancel (sock->th);
419 if (sock->receive_task != GNUNET_SCHEDULER_NO_TASK) 406 if (sock->receive_task != GNUNET_SCHEDULER_NO_TASK)
420 { 407 {
421 GNUNET_SCHEDULER_cancel (sock->sched, sock->receive_task); 408 GNUNET_SCHEDULER_cancel (sock->receive_task);
422 sock->receive_task = GNUNET_SCHEDULER_NO_TASK; 409 sock->receive_task = GNUNET_SCHEDULER_NO_TASK;
423 } 410 }
424 GNUNET_array_grow (sock->received_buf, sock->received_size, 0); 411 GNUNET_array_grow (sock->received_buf, sock->received_size, 0);
@@ -569,8 +556,7 @@ GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock,
569 sock->receive_timeout = GNUNET_TIME_relative_to_absolute (timeout); 556 sock->receive_timeout = GNUNET_TIME_relative_to_absolute (timeout);
570 if (GNUNET_YES == sock->msg_complete) 557 if (GNUNET_YES == sock->msg_complete)
571 { 558 {
572 sock->receive_task = GNUNET_SCHEDULER_add_after (sock->sched, 559 sock->receive_task = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK,
573 GNUNET_SCHEDULER_NO_TASK,
574 &receive_task, sock); 560 &receive_task, sock);
575 } 561 }
576 else 562 else
@@ -588,11 +574,9 @@ GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock,
588 * Report service unavailable. 574 * Report service unavailable.
589 */ 575 */
590static void 576static void
591service_test_error (struct GNUNET_SCHEDULER_Handle *s, 577service_test_error (GNUNET_SCHEDULER_Task task, void *task_cls)
592 GNUNET_SCHEDULER_Task task, void *task_cls)
593{ 578{
594 GNUNET_SCHEDULER_add_continuation (s, 579 GNUNET_SCHEDULER_add_continuation (task,
595 task,
596 task_cls, 580 task_cls,
597 GNUNET_SCHEDULER_REASON_TIMEOUT); 581 GNUNET_SCHEDULER_REASON_TIMEOUT);
598} 582}
@@ -617,14 +601,13 @@ confirm_handler (void *cls, const struct GNUNET_MessageHeader *msg)
617 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 601 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
618 "Received confirmation that service is running.\n"); 602 "Received confirmation that service is running.\n");
619#endif 603#endif
620 GNUNET_SCHEDULER_add_continuation (conn->sched, 604 GNUNET_SCHEDULER_add_continuation (conn->test_cb,
621 conn->test_cb,
622 conn->test_cb_cls, 605 conn->test_cb_cls,
623 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 606 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
624 } 607 }
625 else 608 else
626 { 609 {
627 service_test_error (conn->sched, conn->test_cb, conn->test_cb_cls); 610 service_test_error (conn->test_cb, conn->test_cb_cls);
628 } 611 }
629 GNUNET_CLIENT_disconnect (conn, GNUNET_NO); 612 GNUNET_CLIENT_disconnect (conn, GNUNET_NO);
630} 613}
@@ -642,7 +625,7 @@ write_test (void *cls, size_t size, void *buf)
642 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 625 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
643 _("Failure to transmit TEST request.\n")); 626 _("Failure to transmit TEST request.\n"));
644#endif 627#endif
645 service_test_error (conn->sched, conn->test_cb, conn->test_cb_cls); 628 service_test_error (conn->test_cb, conn->test_cb_cls);
646 GNUNET_CLIENT_disconnect (conn, GNUNET_NO); 629 GNUNET_CLIENT_disconnect (conn, GNUNET_NO);
647 return 0; /* client disconnected */ 630 return 0; /* client disconnected */
648 } 631 }
@@ -664,7 +647,6 @@ write_test (void *cls, size_t size, void *buf)
664/** 647/**
665 * Wait until the service is running. 648 * Wait until the service is running.
666 * 649 *
667 * @param sched scheduler to use
668 * @param service name of the service to wait for 650 * @param service name of the service to wait for
669 * @param cfg configuration to use 651 * @param cfg configuration to use
670 * @param timeout how long to wait at most in ms 652 * @param timeout how long to wait at most in ms
@@ -674,8 +656,7 @@ write_test (void *cls, size_t size, void *buf)
674 * @param task_cls closure for task 656 * @param task_cls closure for task
675 */ 657 */
676void 658void
677GNUNET_CLIENT_service_test (struct GNUNET_SCHEDULER_Handle *sched, 659GNUNET_CLIENT_service_test (const char *service,
678 const char *service,
679 const struct GNUNET_CONFIGURATION_Handle *cfg, 660 const struct GNUNET_CONFIGURATION_Handle *cfg,
680 struct GNUNET_TIME_Relative timeout, 661 struct GNUNET_TIME_Relative timeout,
681 GNUNET_SCHEDULER_Task task, void *task_cls) 662 GNUNET_SCHEDULER_Task task, void *task_cls)
@@ -686,14 +667,14 @@ GNUNET_CLIENT_service_test (struct GNUNET_SCHEDULER_Handle *sched,
686 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 667 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
687 "Testing if service `%s' is running.\n", service); 668 "Testing if service `%s' is running.\n", service);
688#endif 669#endif
689 conn = GNUNET_CLIENT_connect (sched, service, cfg); 670 conn = GNUNET_CLIENT_connect (service, cfg);
690 if (conn == NULL) 671 if (conn == NULL)
691 { 672 {
692 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 673 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
693 _ 674 _
694 ("Could not connect to service `%s', must not be running.\n"), 675 ("Could not connect to service `%s', must not be running.\n"),
695 service); 676 service);
696 service_test_error (sched, task, task_cls); 677 service_test_error (task, task_cls);
697 return; 678 return;
698 } 679 }
699 conn->test_cb = task; 680 conn->test_cb = task;
@@ -709,7 +690,7 @@ GNUNET_CLIENT_service_test (struct GNUNET_SCHEDULER_Handle *sched,
709 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 690 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
710 _("Failure to transmit request to service `%s'\n"), 691 _("Failure to transmit request to service `%s'\n"),
711 service); 692 service);
712 service_test_error (sched, task, task_cls); 693 service_test_error (task, task_cls);
713 GNUNET_CLIENT_disconnect (conn, GNUNET_NO); 694 GNUNET_CLIENT_disconnect (conn, GNUNET_NO);
714 return; 695 return;
715 } 696 }
@@ -791,7 +772,7 @@ client_notify (void *cls, size_t size, void *buf)
791 { 772 {
792 delay = GNUNET_TIME_absolute_get_remaining (th->timeout); 773 delay = GNUNET_TIME_absolute_get_remaining (th->timeout);
793 delay.rel_value /= 2; 774 delay.rel_value /= 2;
794 if ( (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & GNUNET_SCHEDULER_get_reason (th->sock->sched))) || 775 if ( (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & GNUNET_SCHEDULER_get_reason ())) ||
795 (GNUNET_YES != th->auto_retry) || 776 (GNUNET_YES != th->auto_retry) ||
796 (0 == --th->attempts_left) || 777 (0 == --th->attempts_left) ||
797 (delay.rel_value < 1) ) 778 (delay.rel_value < 1) )
@@ -807,8 +788,7 @@ client_notify (void *cls, size_t size, void *buf)
807 } 788 }
808 /* auto-retry */ 789 /* auto-retry */
809 GNUNET_CONNECTION_destroy (th->sock->sock, GNUNET_NO); 790 GNUNET_CONNECTION_destroy (th->sock->sock, GNUNET_NO);
810 th->sock->sock = do_connect (th->sock->sched, 791 th->sock->sock = do_connect (th->sock->service_name,
811 th->sock->service_name,
812 th->sock->cfg, 792 th->sock->cfg,
813 th->sock->attempts++); 793 th->sock->attempts++);
814 GNUNET_assert (NULL != th->sock->sock); 794 GNUNET_assert (NULL != th->sock->sock);
@@ -824,8 +804,7 @@ client_notify (void *cls, size_t size, void *buf)
824 MAX_ATTEMPTS - th->attempts_left, 804 MAX_ATTEMPTS - th->attempts_left,
825 (unsigned long long) delay.rel_value); 805 (unsigned long long) delay.rel_value);
826#endif 806#endif
827 th->reconnect_task = GNUNET_SCHEDULER_add_delayed (th->sock->sched, 807 th->reconnect_task = GNUNET_SCHEDULER_add_delayed (delay,
828 delay,
829 &client_delayed_retry, 808 &client_delayed_retry,
830 th); 809 th);
831 th->sock->th = th; 810 th->sock->th = th;
@@ -904,7 +883,7 @@ GNUNET_CLIENT_notify_transmit_ready_cancel (struct
904 if (th->reconnect_task != GNUNET_SCHEDULER_NO_TASK) 883 if (th->reconnect_task != GNUNET_SCHEDULER_NO_TASK)
905 { 884 {
906 GNUNET_break (NULL == th->th); 885 GNUNET_break (NULL == th->th);
907 GNUNET_SCHEDULER_cancel (th->sock->sched, th->reconnect_task); 886 GNUNET_SCHEDULER_cancel (th->reconnect_task);
908 th->reconnect_task = GNUNET_SCHEDULER_NO_TASK; 887 th->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
909 } 888 }
910 else 889 else
diff --git a/src/util/connection.c b/src/util/connection.c
index 04d0c864d..a25dc0350 100644
--- a/src/util/connection.c
+++ b/src/util/connection.c
@@ -161,11 +161,6 @@ struct GNUNET_CONNECTION_Handle
161{ 161{
162 162
163 /** 163 /**
164 * Scheduler that was used for the connect task.
165 */
166 struct GNUNET_SCHEDULER_Handle *sched;
167
168 /**
169 * Configuration to use. 164 * Configuration to use.
170 */ 165 */
171 const struct GNUNET_CONFIGURATION_Handle *cfg; 166 const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -312,14 +307,11 @@ void GNUNET_CONNECTION_persist_(struct GNUNET_CONNECTION_Handle *sock)
312 * socket should henceforth be no longer used directly. 307 * socket should henceforth be no longer used directly.
313 * GNUNET_socket_destroy will close it. 308 * GNUNET_socket_destroy will close it.
314 * 309 *
315 * @param sched scheduler to use
316 * @param osSocket existing socket to box 310 * @param osSocket existing socket to box
317 * @return the boxed socket handle 311 * @return the boxed socket handle
318 */ 312 */
319struct GNUNET_CONNECTION_Handle * 313struct GNUNET_CONNECTION_Handle *
320GNUNET_CONNECTION_create_from_existing (struct GNUNET_SCHEDULER_Handle 314GNUNET_CONNECTION_create_from_existing (struct GNUNET_NETWORK_Handle
321 *sched,
322 struct GNUNET_NETWORK_Handle
323 *osSocket) 315 *osSocket)
324{ 316{
325 struct GNUNET_CONNECTION_Handle *ret; 317 struct GNUNET_CONNECTION_Handle *ret;
@@ -327,7 +319,6 @@ GNUNET_CONNECTION_create_from_existing (struct GNUNET_SCHEDULER_Handle
327 ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; 319 ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
328 ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); 320 ret->write_buffer = GNUNET_malloc(ret->write_buffer_size);
329 ret->sock = osSocket; 321 ret->sock = osSocket;
330 ret->sched = sched;
331 return ret; 322 return ret;
332} 323}
333 324
@@ -336,16 +327,13 @@ GNUNET_CONNECTION_create_from_existing (struct GNUNET_SCHEDULER_Handle
336 * Create a socket handle by accepting on a listen socket. This 327 * Create a socket handle by accepting on a listen socket. This
337 * function may block if the listen socket has no connection ready. 328 * function may block if the listen socket has no connection ready.
338 * 329 *
339 * @param sched scheduler to use
340 * @param access function to use to check if access is allowed 330 * @param access function to use to check if access is allowed
341 * @param access_cls closure for access 331 * @param access_cls closure for access
342 * @param lsock listen socket 332 * @param lsock listen socket
343 * @return the socket handle, NULL on error 333 * @return the socket handle, NULL on error
344 */ 334 */
345struct GNUNET_CONNECTION_Handle * 335struct GNUNET_CONNECTION_Handle *
346GNUNET_CONNECTION_create_from_accept (struct GNUNET_SCHEDULER_Handle 336GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access,
347 *sched,
348 GNUNET_CONNECTION_AccessCheck access,
349 void *access_cls, 337 void *access_cls,
350 struct GNUNET_NETWORK_Handle *lsock) 338 struct GNUNET_NETWORK_Handle *lsock)
351{ 339{
@@ -416,7 +404,6 @@ GNUNET_CONNECTION_create_from_accept (struct GNUNET_SCHEDULER_Handle
416 ret->addr = uaddr; 404 ret->addr = uaddr;
417 ret->addrlen = addrlen; 405 ret->addrlen = addrlen;
418 ret->sock = sock; 406 ret->sock = sock;
419 ret->sched = sched;
420#if DEBUG_CONNECTION 407#if DEBUG_CONNECTION
421 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 408 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
422 _("Accepting connection from `%s': %p\n"), 409 _("Accepting connection from `%s': %p\n"),
@@ -494,8 +481,7 @@ destroy_continuation (void *cls,
494#endif 481#endif
495 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); 482 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task);
496 sock->destroy_task 483 sock->destroy_task
497 = GNUNET_SCHEDULER_add_after (sock->sched, 484 = GNUNET_SCHEDULER_add_after (sock->write_task,
498 sock->write_task,
499 &destroy_continuation, sock); 485 &destroy_continuation, sock);
500 return; 486 return;
501 } 487 }
@@ -517,8 +503,7 @@ destroy_continuation (void *cls,
517 { 503 {
518 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); 504 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task);
519 sock->destroy_task 505 sock->destroy_task
520 = GNUNET_SCHEDULER_add_after (sock->sched, 506 = GNUNET_SCHEDULER_add_after (sock->read_task,
521 sock->read_task,
522 &destroy_continuation, sock); 507 &destroy_continuation, sock);
523 return; 508 return;
524 } 509 }
@@ -529,7 +514,7 @@ destroy_continuation (void *cls,
529 while (NULL != (pos = sock->ap_head)) 514 while (NULL != (pos = sock->ap_head))
530 { 515 {
531 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock)); 516 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock));
532 GNUNET_SCHEDULER_cancel (sock->sched, pos->task); 517 GNUNET_SCHEDULER_cancel (pos->task);
533 GNUNET_CONTAINER_DLL_remove (sock->ap_head, sock->ap_tail, pos); 518 GNUNET_CONTAINER_DLL_remove (sock->ap_head, sock->ap_tail, pos);
534 GNUNET_free (pos); 519 GNUNET_free (pos);
535 } 520 }
@@ -606,8 +591,7 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h)
606 h); 591 h);
607#endif 592#endif
608 h->ccs -= COCO_RECEIVE_AGAIN; 593 h->ccs -= COCO_RECEIVE_AGAIN;
609 h->read_task = GNUNET_SCHEDULER_add_after (h->sched, 594 h->read_task = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK,
610 GNUNET_SCHEDULER_NO_TASK,
611 &receive_again, h); 595 &receive_again, h);
612 } 596 }
613 if (0 != (h->ccs & COCO_TRANSMIT_READY)) 597 if (0 != (h->ccs & COCO_TRANSMIT_READY))
@@ -618,12 +602,11 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h)
618 h); 602 h);
619#endif 603#endif
620 GNUNET_assert (h->nth.timeout_task != GNUNET_SCHEDULER_NO_TASK); 604 GNUNET_assert (h->nth.timeout_task != GNUNET_SCHEDULER_NO_TASK);
621 GNUNET_SCHEDULER_cancel (h->sched, h->nth.timeout_task); 605 GNUNET_SCHEDULER_cancel (h->nth.timeout_task);
622 h->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK; 606 h->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK;
623 h->ccs -= COCO_TRANSMIT_READY; 607 h->ccs -= COCO_TRANSMIT_READY;
624 GNUNET_assert (h->write_task == GNUNET_SCHEDULER_NO_TASK); 608 GNUNET_assert (h->write_task == GNUNET_SCHEDULER_NO_TASK);
625 h->write_task = GNUNET_SCHEDULER_add_after (h->sched, 609 h->write_task = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK,
626 GNUNET_SCHEDULER_NO_TASK,
627 &transmit_ready, h); 610 &transmit_ready, h);
628 } 611 }
629 if (0 != (h->ccs & COCO_DESTROY_CONTINUATION)) 612 if (0 != (h->ccs & COCO_DESTROY_CONTINUATION))
@@ -636,8 +619,7 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h)
636 h->ccs -= COCO_DESTROY_CONTINUATION; 619 h->ccs -= COCO_DESTROY_CONTINUATION;
637 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->destroy_task); 620 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->destroy_task);
638 h->destroy_task 621 h->destroy_task
639 = GNUNET_SCHEDULER_add_now (h->sched, 622 = GNUNET_SCHEDULER_add_now (&destroy_continuation,
640 &destroy_continuation,
641 h); 623 h);
642 } 624 }
643} 625}
@@ -665,8 +647,7 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *h)
665 h); 647 h);
666#endif 648#endif
667 h->ccs -= COCO_RECEIVE_AGAIN; 649 h->ccs -= COCO_RECEIVE_AGAIN;
668 h->read_task = GNUNET_SCHEDULER_add_after (h->sched, 650 h->read_task = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK,
669 GNUNET_SCHEDULER_NO_TASK,
670 &receive_again, h); 651 &receive_again, h);
671 } 652 }
672 if (0 != (h->ccs & COCO_TRANSMIT_READY)) 653 if (0 != (h->ccs & COCO_TRANSMIT_READY))
@@ -677,13 +658,12 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *h)
677 h); 658 h);
678#endif 659#endif
679 GNUNET_assert (h->nth.timeout_task != GNUNET_SCHEDULER_NO_TASK); 660 GNUNET_assert (h->nth.timeout_task != GNUNET_SCHEDULER_NO_TASK);
680 GNUNET_SCHEDULER_cancel (h->sched, h->nth.timeout_task); 661 GNUNET_SCHEDULER_cancel (h->nth.timeout_task);
681 h->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK; 662 h->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK;
682 h->ccs -= COCO_TRANSMIT_READY; 663 h->ccs -= COCO_TRANSMIT_READY;
683 GNUNET_assert (h->write_task == GNUNET_SCHEDULER_NO_TASK); 664 GNUNET_assert (h->write_task == GNUNET_SCHEDULER_NO_TASK);
684 h->write_task = 665 h->write_task =
685 GNUNET_SCHEDULER_add_write_net (h->sched, 666 GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining
686 GNUNET_TIME_absolute_get_remaining
687 (h->nth.transmit_timeout), h->sock, 667 (h->nth.transmit_timeout), h->sock,
688 &transmit_ready, h); 668 &transmit_ready, h);
689 } 669 }
@@ -697,9 +677,8 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *h)
697 h->ccs -= COCO_DESTROY_CONTINUATION; 677 h->ccs -= COCO_DESTROY_CONTINUATION;
698 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->destroy_task); 678 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->destroy_task);
699 h->destroy_task 679 h->destroy_task
700 = GNUNET_SCHEDULER_add_now (h->sched, 680 = GNUNET_SCHEDULER_add_now (&destroy_continuation,
701 &destroy_continuation, 681 h);
702 h);
703 } 682 }
704} 683}
705 684
@@ -749,7 +728,7 @@ connect_probe_continuation (void *cls,
749 while (NULL != (pos = h->ap_head)) 728 while (NULL != (pos = h->ap_head))
750 { 729 {
751 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock)); 730 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock));
752 GNUNET_SCHEDULER_cancel (h->sched, pos->task); 731 GNUNET_SCHEDULER_cancel (pos->task);
753 GNUNET_CONTAINER_DLL_remove (h->ap_head, h->ap_tail, pos); 732 GNUNET_CONTAINER_DLL_remove (h->ap_head, h->ap_tail, pos);
754 GNUNET_free (pos); 733 GNUNET_free (pos);
755 } 734 }
@@ -842,7 +821,7 @@ try_connect_using_address (void *cls,
842 GNUNET_TIME_absolute_get_remaining 821 GNUNET_TIME_absolute_get_remaining
843 (h->receive_timeout)); 822 (h->receive_timeout));
844 ap->task = 823 ap->task =
845 GNUNET_SCHEDULER_add_write_net (h->sched, delay, ap->sock, 824 GNUNET_SCHEDULER_add_write_net (delay, ap->sock,
846 &connect_probe_continuation, ap); 825 &connect_probe_continuation, ap);
847} 826}
848 827
@@ -852,15 +831,13 @@ try_connect_using_address (void *cls,
852 * This function returns immediately, even if the connection has not 831 * This function returns immediately, even if the connection has not
853 * yet been established. This function only creates TCP connections. 832 * yet been established. This function only creates TCP connections.
854 * 833 *
855 * @param sched scheduler to use
856 * @param cfg configuration to use 834 * @param cfg configuration to use
857 * @param hostname name of the host to connect to 835 * @param hostname name of the host to connect to
858 * @param port port to connect to 836 * @param port port to connect to
859 * @return the socket handle 837 * @return the socket handle
860 */ 838 */
861struct GNUNET_CONNECTION_Handle * 839struct GNUNET_CONNECTION_Handle *
862GNUNET_CONNECTION_create_from_connect (struct GNUNET_SCHEDULER_Handle *sched, 840GNUNET_CONNECTION_create_from_connect (const struct
863 const struct
864 GNUNET_CONFIGURATION_Handle *cfg, 841 GNUNET_CONFIGURATION_Handle *cfg,
865 const char *hostname, uint16_t port) 842 const char *hostname, uint16_t port)
866{ 843{
@@ -869,13 +846,11 @@ GNUNET_CONNECTION_create_from_connect (struct GNUNET_SCHEDULER_Handle *sched,
869 GNUNET_assert (0 < strlen (hostname)); /* sanity check */ 846 GNUNET_assert (0 < strlen (hostname)); /* sanity check */
870 ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); 847 ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle));
871 ret->cfg = cfg; 848 ret->cfg = cfg;
872 ret->sched = sched;
873 ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; 849 ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
874 ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); 850 ret->write_buffer = GNUNET_malloc(ret->write_buffer_size);
875 ret->port = port; 851 ret->port = port;
876 ret->hostname = GNUNET_strdup (hostname); 852 ret->hostname = GNUNET_strdup (hostname);
877 ret->dns_active = GNUNET_RESOLVER_ip_get (sched, 853 ret->dns_active = GNUNET_RESOLVER_ip_get (cfg,
878 cfg,
879 ret->hostname, 854 ret->hostname,
880 AF_UNSPEC, 855 AF_UNSPEC,
881 GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT, 856 GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT,
@@ -889,14 +864,12 @@ GNUNET_CONNECTION_create_from_connect (struct GNUNET_SCHEDULER_Handle *sched,
889 * This function returns immediately, even if the connection has not 864 * This function returns immediately, even if the connection has not
890 * yet been established. This function only creates UNIX connections. 865 * yet been established. This function only creates UNIX connections.
891 * 866 *
892 * @param sched scheduler to use
893 * @param cfg configuration to use 867 * @param cfg configuration to use
894 * @param unixpath path to connect to 868 * @param unixpath path to connect to
895 * @return the socket handle, NULL on systems without UNIX support 869 * @return the socket handle, NULL on systems without UNIX support
896 */ 870 */
897struct GNUNET_CONNECTION_Handle * 871struct GNUNET_CONNECTION_Handle *
898GNUNET_CONNECTION_create_from_connect_to_unixpath (struct GNUNET_SCHEDULER_Handle *sched, 872GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct
899 const struct
900 GNUNET_CONFIGURATION_Handle *cfg, 873 GNUNET_CONFIGURATION_Handle *cfg,
901 const char *unixpath) 874 const char *unixpath)
902{ 875{
@@ -922,7 +895,6 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (struct GNUNET_SCHEDULER_Handl
922#endif 895#endif
923 ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); 896 ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle));
924 ret->cfg = cfg; 897 ret->cfg = cfg;
925 ret->sched = sched;
926 ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; 898 ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
927 ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); 899 ret->write_buffer = GNUNET_malloc(ret->write_buffer_size);
928 ret->port = 0; 900 ret->port = 0;
@@ -960,15 +932,13 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (struct GNUNET_SCHEDULER_Handl
960 * This function returns immediately, even if the connection has not 932 * This function returns immediately, even if the connection has not
961 * yet been established. This function only creates TCP connections. 933 * yet been established. This function only creates TCP connections.
962 * 934 *
963 * @param sched scheduler to use
964 * @param af_family address family to use 935 * @param af_family address family to use
965 * @param serv_addr server address 936 * @param serv_addr server address
966 * @param addrlen length of server address 937 * @param addrlen length of server address
967 * @return the socket handle 938 * @return the socket handle
968 */ 939 */
969struct GNUNET_CONNECTION_Handle * 940struct GNUNET_CONNECTION_Handle *
970GNUNET_CONNECTION_create_from_sockaddr (struct GNUNET_SCHEDULER_Handle 941GNUNET_CONNECTION_create_from_sockaddr (int af_family,
971 *sched, int af_family,
972 const struct sockaddr *serv_addr, 942 const struct sockaddr *serv_addr,
973 socklen_t addrlen) 943 socklen_t addrlen)
974{ 944{
@@ -990,7 +960,7 @@ GNUNET_CONNECTION_create_from_sockaddr (struct GNUNET_SCHEDULER_Handle
990 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s)); 960 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s));
991 return NULL; 961 return NULL;
992 } 962 }
993 ret = GNUNET_CONNECTION_create_from_existing (sched, s); 963 ret = GNUNET_CONNECTION_create_from_existing (s);
994 ret->addr = GNUNET_malloc (addrlen); 964 ret->addr = GNUNET_malloc (addrlen);
995 memcpy (ret->addr, serv_addr, addrlen); 965 memcpy (ret->addr, serv_addr, addrlen);
996 ret->addrlen = addrlen; 966 ret->addrlen = addrlen;
@@ -1041,8 +1011,7 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *sock,
1041 { 1011 {
1042 if (sock->write_task != GNUNET_SCHEDULER_NO_TASK) 1012 if (sock->write_task != GNUNET_SCHEDULER_NO_TASK)
1043 { 1013 {
1044 GNUNET_SCHEDULER_cancel (sock->sched, 1014 GNUNET_SCHEDULER_cancel (sock->write_task);
1045 sock->write_task);
1046 sock->write_task = GNUNET_SCHEDULER_NO_TASK; 1015 sock->write_task = GNUNET_SCHEDULER_NO_TASK;
1047 sock->write_buffer_off = 0; 1016 sock->write_buffer_off = 0;
1048 } 1017 }
@@ -1052,11 +1021,10 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *sock,
1052 GNUNET_RESOLVER_request_cancel (sock->dns_active); 1021 GNUNET_RESOLVER_request_cancel (sock->dns_active);
1053 sock->dns_active = NULL; 1022 sock->dns_active = NULL;
1054 } 1023 }
1055 GNUNET_assert (sock->sched != NULL); 1024
1056 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); 1025 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task);
1057 sock->destroy_task 1026 sock->destroy_task
1058 = GNUNET_SCHEDULER_add_now (sock->sched, 1027 = GNUNET_SCHEDULER_add_now (&destroy_continuation, sock);
1059 &destroy_continuation, sock);
1060} 1028}
1061 1029
1062 1030
@@ -1113,8 +1081,7 @@ receive_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1113 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1081 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1114 "Ignoring shutdown signal per configuration\n"); 1082 "Ignoring shutdown signal per configuration\n");
1115#endif 1083#endif
1116 sh->read_task = GNUNET_SCHEDULER_add_read_net (tc->sched, 1084 sh->read_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining
1117 GNUNET_TIME_absolute_get_remaining
1118 (sh->receive_timeout), 1085 (sh->receive_timeout),
1119 sh->sock, 1086 sh->sock,
1120 &receive_ready, sh); 1087 &receive_ready, sh);
@@ -1212,8 +1179,7 @@ receive_again (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1212 } 1179 }
1213 GNUNET_assert (sh->sock != NULL); 1180 GNUNET_assert (sh->sock != NULL);
1214 /* connect succeeded, wait for data! */ 1181 /* connect succeeded, wait for data! */
1215 sh->read_task = GNUNET_SCHEDULER_add_read_net (tc->sched, 1182 sh->read_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining
1216 GNUNET_TIME_absolute_get_remaining
1217 (sh->receive_timeout), 1183 (sh->receive_timeout),
1218 sh->sock, 1184 sh->sock,
1219 &receive_ready, sh); 1185 &receive_ready, sh);
@@ -1252,7 +1218,6 @@ GNUNET_CONNECTION_receive (struct GNUNET_CONNECTION_Handle *sock,
1252 if (sock->sock != NULL) 1218 if (sock->sock != NULL)
1253 { 1219 {
1254 memset (&tc, 0, sizeof (tc)); 1220 memset (&tc, 0, sizeof (tc));
1255 tc.sched = sock->sched;
1256 tc.reason = GNUNET_SCHEDULER_REASON_PREREQ_DONE; 1221 tc.reason = GNUNET_SCHEDULER_REASON_PREREQ_DONE;
1257 receive_again (sock, &tc); 1222 receive_again (sock, &tc);
1258 return; 1223 return;
@@ -1293,8 +1258,7 @@ GNUNET_CONNECTION_receive_cancel (struct GNUNET_CONNECTION_Handle *sock)
1293{ 1258{
1294 if (sock->read_task != GNUNET_SCHEDULER_NO_TASK) 1259 if (sock->read_task != GNUNET_SCHEDULER_NO_TASK)
1295 { 1260 {
1296 GNUNET_assert (sock == GNUNET_SCHEDULER_cancel (sock->sched, 1261 GNUNET_assert (sock == GNUNET_SCHEDULER_cancel (sock->read_task));
1297 sock->read_task));
1298 sock->read_task = GNUNET_SCHEDULER_NO_TASK; 1262 sock->read_task = GNUNET_SCHEDULER_NO_TASK;
1299 } 1263 }
1300 else 1264 else
@@ -1421,8 +1385,7 @@ transmit_error (struct GNUNET_CONNECTION_Handle *sock)
1421 } 1385 }
1422 if (sock->read_task != GNUNET_SCHEDULER_NO_TASK) 1386 if (sock->read_task != GNUNET_SCHEDULER_NO_TASK)
1423 { 1387 {
1424 GNUNET_SCHEDULER_cancel (sock->sched, 1388 GNUNET_SCHEDULER_cancel (sock->read_task);
1425 sock->read_task);
1426 sock->read_task = GNUNET_SCHEDULER_NO_TASK; 1389 sock->read_task = GNUNET_SCHEDULER_NO_TASK;
1427 signal_timeout (sock); 1390 signal_timeout (sock);
1428 return; 1391 return;
@@ -1567,8 +1530,7 @@ SCHEDULE_WRITE:
1567#endif 1530#endif
1568 if (sock->write_task == GNUNET_SCHEDULER_NO_TASK) 1531 if (sock->write_task == GNUNET_SCHEDULER_NO_TASK)
1569 sock->write_task = 1532 sock->write_task =
1570 GNUNET_SCHEDULER_add_write_net (tc->sched, 1533 GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining
1571 GNUNET_TIME_absolute_get_remaining
1572 (sock->nth.transmit_timeout), 1534 (sock->nth.transmit_timeout),
1573 sock->sock, &transmit_ready, sock); 1535 sock->sock, &transmit_ready, sock);
1574} 1536}
@@ -1612,10 +1574,8 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle
1612 (sock->ap_head == NULL) && (sock->dns_active == NULL)) 1574 (sock->ap_head == NULL) && (sock->dns_active == NULL))
1613 { 1575 {
1614 if (sock->write_task != GNUNET_SCHEDULER_NO_TASK) 1576 if (sock->write_task != GNUNET_SCHEDULER_NO_TASK)
1615 GNUNET_SCHEDULER_cancel (sock->sched, 1577 GNUNET_SCHEDULER_cancel (sock->write_task);
1616 sock->write_task); 1578 sock->write_task = GNUNET_SCHEDULER_add_now (&connect_error, sock);
1617 sock->write_task = GNUNET_SCHEDULER_add_now (sock->sched,
1618 &connect_error, sock);
1619 return &sock->nth; 1579 return &sock->nth;
1620 } 1580 }
1621 if (GNUNET_SCHEDULER_NO_TASK != sock->write_task) 1581 if (GNUNET_SCHEDULER_NO_TASK != sock->write_task)
@@ -1626,8 +1586,7 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle
1626 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1586 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1627 "Scheduling transmit_ready (%p).\n", sock); 1587 "Scheduling transmit_ready (%p).\n", sock);
1628#endif 1588#endif
1629 sock->write_task = GNUNET_SCHEDULER_add_write_net (sock->sched, 1589 sock->write_task = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining
1630 GNUNET_TIME_absolute_get_remaining
1631 (sock->nth. 1590 (sock->nth.
1632 transmit_timeout), 1591 transmit_timeout),
1633 sock->sock, 1592 sock->sock,
@@ -1642,8 +1601,7 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle
1642 sock); 1601 sock);
1643#endif 1602#endif
1644 sock->ccs |= COCO_TRANSMIT_READY; 1603 sock->ccs |= COCO_TRANSMIT_READY;
1645 sock->nth.timeout_task = GNUNET_SCHEDULER_add_delayed (sock->sched, 1604 sock->nth.timeout_task = GNUNET_SCHEDULER_add_delayed (timeout,
1646 timeout,
1647 &transmit_timeout, 1605 &transmit_timeout,
1648 sock); 1606 sock);
1649 } 1607 }
@@ -1668,7 +1626,7 @@ GNUNET_CONNECTION_notify_transmit_ready_cancel (struct
1668 "notify_transmit_ready_cancel cancels timeout_task (%p)\n", 1626 "notify_transmit_ready_cancel cancels timeout_task (%p)\n",
1669 h); 1627 h);
1670#endif 1628#endif
1671 GNUNET_SCHEDULER_cancel (h->sh->sched, h->timeout_task); 1629 GNUNET_SCHEDULER_cancel (h->timeout_task);
1672 h->timeout_task = GNUNET_SCHEDULER_NO_TASK; 1630 h->timeout_task = GNUNET_SCHEDULER_NO_TASK;
1673 h->sh->ccs -= COCO_TRANSMIT_READY; 1631 h->sh->ccs -= COCO_TRANSMIT_READY;
1674 } 1632 }
@@ -1676,7 +1634,7 @@ GNUNET_CONNECTION_notify_transmit_ready_cancel (struct
1676 { 1634 {
1677 if (h->sh->write_task != GNUNET_SCHEDULER_NO_TASK) 1635 if (h->sh->write_task != GNUNET_SCHEDULER_NO_TASK)
1678 { 1636 {
1679 GNUNET_SCHEDULER_cancel (h->sh->sched, h->sh->write_task); 1637 GNUNET_SCHEDULER_cancel (h->sh->write_task);
1680 h->sh->write_task = GNUNET_SCHEDULER_NO_TASK; 1638 h->sh->write_task = GNUNET_SCHEDULER_NO_TASK;
1681 } 1639 }
1682 } 1640 }
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c
index ab6fc28cf..9e5af4ab5 100644
--- a/src/util/crypto_hash.c
+++ b/src/util/crypto_hash.c
@@ -83,11 +83,6 @@ struct GNUNET_CRYPTO_FileHashContext
83 struct GNUNET_DISK_FileHandle *fh; 83 struct GNUNET_DISK_FileHandle *fh;
84 84
85 /** 85 /**
86 * Our scheduler.
87 */
88 struct GNUNET_SCHEDULER_Handle *sched;
89
90 /**
91 * Cummulated hash. 86 * Cummulated hash.
92 */ 87 */
93 gcry_md_hd_t md; 88 gcry_md_hd_t md;
@@ -166,8 +161,7 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
166 return; 161 return;
167 } 162 }
168 fhc->task 163 fhc->task
169 = GNUNET_SCHEDULER_add_after (tc->sched, 164 = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK,
170 GNUNET_SCHEDULER_NO_TASK,
171 &file_hash_task, fhc); 165 &file_hash_task, fhc);
172} 166}
173 167
@@ -175,7 +169,6 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
175/** 169/**
176 * Compute the hash of an entire file. 170 * Compute the hash of an entire file.
177 * 171 *
178 * @param sched scheduler to use
179 * @param priority scheduling priority to use 172 * @param priority scheduling priority to use
180 * @param filename name of file to hash 173 * @param filename name of file to hash
181 * @param blocksize number of bytes to process in one task 174 * @param blocksize number of bytes to process in one task
@@ -184,8 +177,7 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
184 * @return NULL on (immediate) errror 177 * @return NULL on (immediate) errror
185 */ 178 */
186struct GNUNET_CRYPTO_FileHashContext * 179struct GNUNET_CRYPTO_FileHashContext *
187GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched, 180GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority,
188 enum GNUNET_SCHEDULER_Priority priority,
189 const char *filename, 181 const char *filename,
190 size_t blocksize, 182 size_t blocksize,
191 GNUNET_CRYPTO_HashCompletedCallback callback, 183 GNUNET_CRYPTO_HashCompletedCallback callback,
@@ -197,7 +189,6 @@ GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched,
197 fhc = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_FileHashContext) + blocksize); 189 fhc = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_FileHashContext) + blocksize);
198 fhc->callback = callback; 190 fhc->callback = callback;
199 fhc->callback_cls = callback_cls; 191 fhc->callback_cls = callback_cls;
200 fhc->sched = sched;
201 fhc->buffer = (unsigned char *) &fhc[1]; 192 fhc->buffer = (unsigned char *) &fhc[1];
202 fhc->filename = GNUNET_strdup (filename); 193 fhc->filename = GNUNET_strdup (filename);
203 if (GPG_ERR_NO_ERROR != gcry_md_open (&fhc->md, GCRY_MD_SHA512, 0)) 194 if (GPG_ERR_NO_ERROR != gcry_md_open (&fhc->md, GCRY_MD_SHA512, 0))
@@ -223,7 +214,7 @@ GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched,
223 return NULL; 214 return NULL;
224 } 215 }
225 fhc->task 216 fhc->task
226 = GNUNET_SCHEDULER_add_with_priority (sched, priority, 217 = GNUNET_SCHEDULER_add_with_priority (priority,
227 &file_hash_task, fhc); 218 &file_hash_task, fhc);
228 return fhc; 219 return fhc;
229} 220}
@@ -237,8 +228,7 @@ GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched,
237void 228void
238GNUNET_CRYPTO_hash_file_cancel (struct GNUNET_CRYPTO_FileHashContext *fhc) 229GNUNET_CRYPTO_hash_file_cancel (struct GNUNET_CRYPTO_FileHashContext *fhc)
239{ 230{
240 GNUNET_SCHEDULER_cancel (fhc->sched, 231 GNUNET_SCHEDULER_cancel (fhc->task);
241 fhc->task);
242 GNUNET_free (fhc->filename); 232 GNUNET_free (fhc->filename);
243 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fhc->fh)); 233 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fhc->fh));
244 GNUNET_free (fhc); 234 GNUNET_free (fhc);
diff --git a/src/util/disk.c b/src/util/disk.c
index 265295922..307c4535b 100644
--- a/src/util/disk.c
+++ b/src/util/disk.c
@@ -810,10 +810,6 @@ GNUNET_DISK_directory_scan (const char *dirName,
810 */ 810 */
811struct GNUNET_DISK_DirectoryIterator 811struct GNUNET_DISK_DirectoryIterator
812{ 812{
813 /**
814 * Our scheduler.
815 */
816 struct GNUNET_SCHEDULER_Handle *sched;
817 813
818 /** 814 /**
819 * Function to call on directory entries. 815 * Function to call on directory entries.
@@ -906,8 +902,7 @@ GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator
906 GNUNET_DISK_directory_iterator_next (iter, GNUNET_YES); 902 GNUNET_DISK_directory_iterator_next (iter, GNUNET_YES);
907 return GNUNET_NO; 903 return GNUNET_NO;
908 } 904 }
909 GNUNET_SCHEDULER_add_with_priority (iter->sched, 905 GNUNET_SCHEDULER_add_with_priority (iter->priority,
910 iter->priority,
911 &directory_iterator_task, iter); 906 &directory_iterator_task, iter);
912 return GNUNET_YES; 907 return GNUNET_YES;
913} 908}
@@ -919,15 +914,13 @@ GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator
919 * If a scheduler does not need to be used, GNUNET_DISK_directory_scan 914 * If a scheduler does not need to be used, GNUNET_DISK_directory_scan
920 * may provide a simpler API. 915 * may provide a simpler API.
921 * 916 *
922 * @param sched scheduler to use
923 * @param prio priority to use 917 * @param prio priority to use
924 * @param dirName the name of the directory 918 * @param dirName the name of the directory
925 * @param callback the method to call for each file 919 * @param callback the method to call for each file
926 * @param callback_cls closure for callback 920 * @param callback_cls closure for callback
927 */ 921 */
928void 922void
929GNUNET_DISK_directory_iterator_start (struct GNUNET_SCHEDULER_Handle *sched, 923GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio,
930 enum GNUNET_SCHEDULER_Priority prio,
931 const char *dirName, 924 const char *dirName,
932 GNUNET_DISK_DirectoryIteratorCallback 925 GNUNET_DISK_DirectoryIteratorCallback
933 callback, void *callback_cls) 926 callback, void *callback_cls)
@@ -935,7 +928,6 @@ GNUNET_DISK_directory_iterator_start (struct GNUNET_SCHEDULER_Handle *sched,
935 struct GNUNET_DISK_DirectoryIterator *di; 928 struct GNUNET_DISK_DirectoryIterator *di;
936 929
937 di = GNUNET_malloc (sizeof (struct GNUNET_DISK_DirectoryIterator)); 930 di = GNUNET_malloc (sizeof (struct GNUNET_DISK_DirectoryIterator));
938 di->sched = sched;
939 di->callback = callback; 931 di->callback = callback;
940 di->callback_cls = callback_cls; 932 di->callback_cls = callback_cls;
941 di->directory = OPENDIR (dirName); 933 di->directory = OPENDIR (dirName);
diff --git a/src/util/gnunet-resolver.c b/src/util/gnunet-resolver.c
index 9686d3a06..18ce232f2 100644
--- a/src/util/gnunet-resolver.c
+++ b/src/util/gnunet-resolver.c
@@ -49,21 +49,19 @@ printer (void *cls,
49 * Main function that will be run by the scheduler. 49 * Main function that will be run by the scheduler.
50 * 50 *
51 * @param cls closure 51 * @param cls closure
52 * @param sched the scheduler to use
53 * @param args remaining command-line arguments 52 * @param args remaining command-line arguments
54 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 53 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
55 * @param cfg configuration 54 * @param cfg configuration
56 */ 55 */
57static void 56static void
58run (void *cls, 57run (void *cls,
59 struct GNUNET_SCHEDULER_Handle *sched,
60 char *const *args, 58 char *const *args,
61 const char *cfgfile, 59 const char *cfgfile,
62 const struct GNUNET_CONFIGURATION_Handle *cfg) 60 const struct GNUNET_CONFIGURATION_Handle *cfg)
63{ 61{
64 if (args[0] == NULL) 62 if (args[0] == NULL)
65 return; 63 return;
66 GNUNET_RESOLVER_ip_get (sched, cfg, 64 GNUNET_RESOLVER_ip_get (cfg,
67 args[0], 65 args[0],
68 AF_UNSPEC, 66 AF_UNSPEC,
69 GET_TIMEOUT, 67 GET_TIMEOUT,
diff --git a/src/util/gnunet-service-resolver.c b/src/util/gnunet-service-resolver.c
index b0e2f0be4..68d2daae7 100644
--- a/src/util/gnunet-service-resolver.c
+++ b/src/util/gnunet-service-resolver.c
@@ -477,13 +477,11 @@ handle_get (void *cls,
477 * Process resolver requests. 477 * Process resolver requests.
478 * 478 *
479 * @param cls closure 479 * @param cls closure
480 * @param sched scheduler to use
481 * @param server the initialized server 480 * @param server the initialized server
482 * @param cfg configuration to use 481 * @param cfg configuration to use
483 */ 482 */
484static void 483static void
485run (void *cls, 484run (void *cls,
486 struct GNUNET_SCHEDULER_Handle *sched,
487 struct GNUNET_SERVER_Handle *server, 485 struct GNUNET_SERVER_Handle *server,
488 const struct GNUNET_CONFIGURATION_Handle *cfg) 486 const struct GNUNET_CONFIGURATION_Handle *cfg)
489{ 487{
diff --git a/src/util/program.c b/src/util/program.c
index 9a5ee8833..6f8467837 100644
--- a/src/util/program.c
+++ b/src/util/program.c
@@ -77,7 +77,7 @@ program_main (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
77{ 77{
78 struct CommandContext *cc = cls; 78 struct CommandContext *cc = cls;
79 79
80 cc->task (cc->task_cls, tc->sched, cc->args, cc->cfgfile, cc->cfg); 80 cc->task (cc->task_cls, cc->args, cc->cfgfile, cc->cfg);
81} 81}
82 82
83 83
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c
index f4832ed9c..7daaaf1cc 100644
--- a/src/util/resolver_api.c
+++ b/src/util/resolver_api.c
@@ -80,11 +80,6 @@ struct GNUNET_RESOLVER_RequestHandle
80 struct GNUNET_CLIENT_Connection *client; 80 struct GNUNET_CLIENT_Connection *client;
81 81
82 /** 82 /**
83 * Our scheduler.
84 */
85 struct GNUNET_SCHEDULER_Handle *sched;
86
87 /**
88 * Name of the host that we are resolving. 83 * Name of the host that we are resolving.
89 */ 84 */
90 const char *hostname; 85 const char *hostname;
@@ -401,7 +396,6 @@ loopback_resolution (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
401/** 396/**
402 * Convert a string to one or more IP addresses. 397 * Convert a string to one or more IP addresses.
403 * 398 *
404 * @param sched scheduler to use
405 * @param cfg configuration to use 399 * @param cfg configuration to use
406 * @param hostname the hostname to resolve 400 * @param hostname the hostname to resolve
407 * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any" 401 * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any"
@@ -411,8 +405,7 @@ loopback_resolution (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
411 * @return handle that can be used to cancel the request, NULL on error 405 * @return handle that can be used to cancel the request, NULL on error
412 */ 406 */
413struct GNUNET_RESOLVER_RequestHandle * 407struct GNUNET_RESOLVER_RequestHandle *
414GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, 408GNUNET_RESOLVER_ip_get (const struct GNUNET_CONFIGURATION_Handle *cfg,
415 const struct GNUNET_CONFIGURATION_Handle *cfg,
416 const char *hostname, 409 const char *hostname,
417 int domain, 410 int domain,
418 struct GNUNET_TIME_Relative timeout, 411 struct GNUNET_TIME_Relative timeout,
@@ -436,7 +429,6 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched,
436 return NULL; 429 return NULL;
437 } 430 }
438 rh = GNUNET_malloc (sizeof (struct GNUNET_RESOLVER_RequestHandle) + slen); 431 rh = GNUNET_malloc (sizeof (struct GNUNET_RESOLVER_RequestHandle) + slen);
439 rh->sched = sched;
440 rh->domain = domain; 432 rh->domain = domain;
441 rh->addr_callback = callback; 433 rh->addr_callback = callback;
442 rh->cls = callback_cls; 434 rh->cls = callback_cls;
@@ -454,8 +446,7 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched,
454 &v6)) && 446 &v6)) &&
455 ((domain == AF_INET6) || (domain == AF_UNSPEC)))) 447 ((domain == AF_INET6) || (domain == AF_UNSPEC))))
456 { 448 {
457 rh->task = GNUNET_SCHEDULER_add_now (sched, 449 rh->task = GNUNET_SCHEDULER_add_now (&numeric_resolution, rh);
458 &numeric_resolution, rh);
459 return rh; 450 return rh;
460 } 451 }
461 /* then, check if this is a loopback address */ 452 /* then, check if this is a loopback address */
@@ -463,12 +454,11 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched,
463 while (loopback[i] != NULL) 454 while (loopback[i] != NULL)
464 if (0 == strcasecmp (loopback[i++], hostname)) 455 if (0 == strcasecmp (loopback[i++], hostname))
465 { 456 {
466 rh->task = GNUNET_SCHEDULER_add_now (sched, 457 rh->task = GNUNET_SCHEDULER_add_now (&loopback_resolution, rh);
467 &loopback_resolution, rh);
468 return rh; 458 return rh;
469 } 459 }
470 460
471 client = GNUNET_CLIENT_connect (sched, "resolver", cfg); 461 client = GNUNET_CLIENT_connect ("resolver", cfg);
472 if (client == NULL) 462 if (client == NULL)
473 { 463 {
474 GNUNET_free (rh); 464 GNUNET_free (rh);
@@ -595,7 +585,6 @@ numeric_reverse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
595/** 585/**
596 * Get an IP address as a string. 586 * Get an IP address as a string.
597 * 587 *
598 * @param sched scheduler to use
599 * @param cfg configuration to use 588 * @param cfg configuration to use
600 * @param sa host address 589 * @param sa host address
601 * @param salen length of host address 590 * @param salen length of host address
@@ -606,8 +595,7 @@ numeric_reverse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
606 * @return handle that can be used to cancel the request 595 * @return handle that can be used to cancel the request
607 */ 596 */
608struct GNUNET_RESOLVER_RequestHandle * 597struct GNUNET_RESOLVER_RequestHandle *
609GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, 598GNUNET_RESOLVER_hostname_get (const struct GNUNET_CONFIGURATION_Handle *cfg,
610 const struct GNUNET_CONFIGURATION_Handle *cfg,
611 const struct sockaddr *sa, 599 const struct sockaddr *sa,
612 socklen_t salen, 600 socklen_t salen,
613 int do_resolve, 601 int do_resolve,
@@ -625,14 +613,12 @@ GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched,
625 rh->name_callback = callback; 613 rh->name_callback = callback;
626 rh->cls = cls; 614 rh->cls = cls;
627 rh->timeout = GNUNET_TIME_relative_to_absolute (timeout); 615 rh->timeout = GNUNET_TIME_relative_to_absolute (timeout);
628 rh->sched = sched;
629 rh->salen = salen; 616 rh->salen = salen;
630 memcpy (&rh[1], sa, salen); 617 memcpy (&rh[1], sa, salen);
631 618
632 if (GNUNET_NO == do_resolve) 619 if (GNUNET_NO == do_resolve)
633 { 620 {
634 rh->task = GNUNET_SCHEDULER_add_now (sched, 621 rh->task = GNUNET_SCHEDULER_add_now (&numeric_reverse, rh);
635 &numeric_reverse, rh);
636 return rh; 622 return rh;
637 } 623 }
638 if (salen + sizeof (struct GNUNET_RESOLVER_GetMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 624 if (salen + sizeof (struct GNUNET_RESOLVER_GetMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
@@ -641,7 +627,7 @@ GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched,
641 GNUNET_free (rh); 627 GNUNET_free (rh);
642 return NULL; 628 return NULL;
643 } 629 }
644 client = GNUNET_CLIENT_connect (sched, "resolver", cfg); 630 client = GNUNET_CLIENT_connect ("resolver", cfg);
645 if (client == NULL) 631 if (client == NULL)
646 { 632 {
647 GNUNET_free (rh); 633 GNUNET_free (rh);
@@ -710,7 +696,6 @@ GNUNET_RESOLVER_local_fqdn_get ( void )
710/** 696/**
711 * Looking our own hostname. 697 * Looking our own hostname.
712 * 698 *
713 * @param sched scheduler to use
714 * @param cfg configuration to use 699 * @param cfg configuration to use
715 * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any" 700 * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any"
716 * @param callback function to call with addresses 701 * @param callback function to call with addresses
@@ -719,8 +704,7 @@ GNUNET_RESOLVER_local_fqdn_get ( void )
719 * @return handle that can be used to cancel the request, NULL on error 704 * @return handle that can be used to cancel the request, NULL on error
720 */ 705 */
721struct GNUNET_RESOLVER_RequestHandle * 706struct GNUNET_RESOLVER_RequestHandle *
722GNUNET_RESOLVER_hostname_resolve (struct GNUNET_SCHEDULER_Handle *sched, 707GNUNET_RESOLVER_hostname_resolve (const struct GNUNET_CONFIGURATION_Handle
723 const struct GNUNET_CONFIGURATION_Handle
724 *cfg, int domain, 708 *cfg, int domain,
725 struct GNUNET_TIME_Relative timeout, 709 struct GNUNET_TIME_Relative timeout,
726 GNUNET_RESOLVER_AddressCallback callback, 710 GNUNET_RESOLVER_AddressCallback callback,
@@ -739,8 +723,7 @@ GNUNET_RESOLVER_hostname_resolve (struct GNUNET_SCHEDULER_Handle *sched,
739 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 723 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
740 _("Resolving our hostname `%s'\n"), hostname); 724 _("Resolving our hostname `%s'\n"), hostname);
741#endif 725#endif
742 return GNUNET_RESOLVER_ip_get (sched, 726 return GNUNET_RESOLVER_ip_get (cfg, hostname, domain, timeout, callback,
743 cfg, hostname, domain, timeout, callback,
744 cls); 727 cls);
745} 728}
746 729
@@ -759,7 +742,7 @@ GNUNET_RESOLVER_request_cancel (struct GNUNET_RESOLVER_RequestHandle *h)
759 if (h->client != NULL) 742 if (h->client != NULL)
760 GNUNET_CLIENT_disconnect (h->client, GNUNET_NO); 743 GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
761 if (h->task != GNUNET_SCHEDULER_NO_TASK) 744 if (h->task != GNUNET_SCHEDULER_NO_TASK)
762 GNUNET_SCHEDULER_cancel (h->sched, h->task); 745 GNUNET_SCHEDULER_cancel (h->task);
763 GNUNET_free (h); 746 GNUNET_free (h);
764} 747}
765 748
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index 9b8ab4b29..341400bba 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -163,84 +163,76 @@ struct Task
163 163
164 164
165/** 165/**
166 * Handle for the scheduling service. 166* List of tasks waiting for an event.
167 */ 167*/
168struct GNUNET_SCHEDULER_Handle 168struct Task *pending;
169{
170
171 /**
172 * List of tasks waiting for an event.
173 */
174 struct Task *pending;
175
176 /**
177 * List of tasks waiting ONLY for a timeout event.
178 * Sorted by timeout (earliest first). Used so that
179 * we do not traverse the list of these tasks when
180 * building select sets (we just look at the head
181 * to determine the respective timeout ONCE).
182 */
183 struct Task *pending_timeout;
184 169
185 /** 170/**
186 * Last inserted task waiting ONLY for a timeout event. 171* List of tasks waiting ONLY for a timeout event.
187 * Used to (heuristically) speed up insertion. 172* Sorted by timeout (earliest first). Used so that
188 */ 173* we do not traverse the list of these tasks when
189 struct Task *pending_timeout_last; 174* building select sets (we just look at the head
175* to determine the respective timeout ONCE).
176*/
177struct Task *pending_timeout;
190 178
191 /** 179/**
192 * ID of the task that is running right now. 180* Last inserted task waiting ONLY for a timeout event.
193 */ 181* Used to (heuristically) speed up insertion.
194 struct Task *active_task; 182*/
183struct Task *pending_timeout_last;
195 184
196 /** 185/**
197 * List of tasks ready to run right now, 186* ID of the task that is running right now.
198 * grouped by importance. 187*/
199 */ 188struct Task *active_task;
200 struct Task *ready[GNUNET_SCHEDULER_PRIORITY_COUNT];
201 189
202 /** 190/**
203 * Identity of the last task queued. Incremented for each task to 191* List of tasks ready to run right now,
204 * generate a unique task ID (it is virtually impossible to start 192* grouped by importance.
205 * more than 2^64 tasks during the lifetime of a process). 193*/
206 */ 194struct Task *ready[GNUNET_SCHEDULER_PRIORITY_COUNT];
207 GNUNET_SCHEDULER_TaskIdentifier last_id;
208 195
209 /** 196/**
210 * Highest number so that all tasks with smaller identifiers 197* Identity of the last task queued. Incremented for each task to
211 * have already completed. Also the lowest number of a task 198* generate a unique task ID (it is virtually impossible to start
212 * still waiting to be executed. 199* more than 2^64 tasks during the lifetime of a process).
213 */ 200*/
214 GNUNET_SCHEDULER_TaskIdentifier lowest_pending_id; 201GNUNET_SCHEDULER_TaskIdentifier last_id;
215 202
216 /** 203/**
217 * Number of tasks on the ready list. 204* Highest number so that all tasks with smaller identifiers
218 */ 205* have already completed. Also the lowest number of a task
219 unsigned int ready_count; 206* still waiting to be executed.
207*/
208GNUNET_SCHEDULER_TaskIdentifier lowest_pending_id;
220 209
221 /** 210/**
222 * How many tasks have we run so far? 211* Number of tasks on the ready list.
223 */ 212*/
224 unsigned long long tasks_run; 213unsigned int ready_count;
225 214
226 /** 215/**
227 * Priority of the task running right now. Only 216* How many tasks have we run so far?
228 * valid while a task is running. 217*/
229 */ 218unsigned long long tasks_run;
230 enum GNUNET_SCHEDULER_Priority current_priority;
231 219
232 /** 220/**
233 * Priority of the highest task added in the current select 221* Priority of the task running right now. Only
234 * iteration. 222* valid while a task is running.
235 */ 223*/
236 enum GNUNET_SCHEDULER_Priority max_priority_added; 224enum GNUNET_SCHEDULER_Priority current_priority;
237 225
238 /** 226/**
239 * How 'nice' are we right now? 227* Priority of the highest task added in the current select
240 */ 228* iteration.
241 int nice_level; 229*/
230enum GNUNET_SCHEDULER_Priority max_priority_added;
242 231
243}; 232/**
233* How 'nice' are we right now?
234*/
235int nice_level;
244 236
245 237
246/** 238/**
@@ -270,17 +262,16 @@ check_priority (enum GNUNET_SCHEDULER_Priority p)
270 * @return GNUNET_YES if so, GNUNET_NO if not 262 * @return GNUNET_YES if so, GNUNET_NO if not
271 */ 263 */
272static int 264static int
273is_pending (struct GNUNET_SCHEDULER_Handle *sched, 265is_pending (GNUNET_SCHEDULER_TaskIdentifier id)
274 GNUNET_SCHEDULER_TaskIdentifier id)
275{ 266{
276 struct Task *pos; 267 struct Task *pos;
277 enum GNUNET_SCHEDULER_Priority p; 268 enum GNUNET_SCHEDULER_Priority p;
278 GNUNET_SCHEDULER_TaskIdentifier min; 269 GNUNET_SCHEDULER_TaskIdentifier min;
279 270
280 if (id < sched->lowest_pending_id) 271 if (id < lowest_pending_id)
281 return GNUNET_NO; 272 return GNUNET_NO;
282 min = -1; /* maximum value */ 273 min = -1; /* maximum value */
283 pos = sched->pending; 274 pos = pending;
284 while (pos != NULL) 275 while (pos != NULL)
285 { 276 {
286 if (pos->id == id) 277 if (pos->id == id)
@@ -289,7 +280,7 @@ is_pending (struct GNUNET_SCHEDULER_Handle *sched,
289 min = pos->id; 280 min = pos->id;
290 pos = pos->next; 281 pos = pos->next;
291 } 282 }
292 pos = sched->pending_timeout; 283 pos = pending_timeout;
293 while (pos != NULL) 284 while (pos != NULL)
294 { 285 {
295 if (pos->id == id) 286 if (pos->id == id)
@@ -300,7 +291,7 @@ is_pending (struct GNUNET_SCHEDULER_Handle *sched,
300 } 291 }
301 for (p = 0; p < GNUNET_SCHEDULER_PRIORITY_COUNT; p++) 292 for (p = 0; p < GNUNET_SCHEDULER_PRIORITY_COUNT; p++)
302 { 293 {
303 pos = sched->ready[p]; 294 pos = ready[p];
304 while (pos != NULL) 295 while (pos != NULL)
305 { 296 {
306 if (pos->id == id) 297 if (pos->id == id)
@@ -310,7 +301,7 @@ is_pending (struct GNUNET_SCHEDULER_Handle *sched,
310 pos = pos->next; 301 pos = pos->next;
311 } 302 }
312 } 303 }
313 sched->lowest_pending_id = min; 304 lowest_pending_id = min;
314 return GNUNET_NO; 305 return GNUNET_NO;
315} 306}
316 307
@@ -324,8 +315,7 @@ is_pending (struct GNUNET_SCHEDULER_Handle *sched,
324 * @param timeout next timeout (updated) 315 * @param timeout next timeout (updated)
325 */ 316 */
326static void 317static void
327update_sets (struct GNUNET_SCHEDULER_Handle *sched, 318update_sets (struct GNUNET_NETWORK_FDSet *rs,
328 struct GNUNET_NETWORK_FDSet *rs,
329 struct GNUNET_NETWORK_FDSet *ws, 319 struct GNUNET_NETWORK_FDSet *ws,
330 struct GNUNET_TIME_Relative *timeout) 320 struct GNUNET_TIME_Relative *timeout)
331{ 321{
@@ -334,7 +324,7 @@ update_sets (struct GNUNET_SCHEDULER_Handle *sched,
334 struct GNUNET_TIME_Relative to; 324 struct GNUNET_TIME_Relative to;
335 325
336 now = GNUNET_TIME_absolute_get (); 326 now = GNUNET_TIME_absolute_get ();
337 pos = sched->pending_timeout; 327 pos = pending_timeout;
338 if (pos != NULL) 328 if (pos != NULL)
339 { 329 {
340 to = GNUNET_TIME_absolute_get_difference (now, pos->timeout); 330 to = GNUNET_TIME_absolute_get_difference (now, pos->timeout);
@@ -343,11 +333,11 @@ update_sets (struct GNUNET_SCHEDULER_Handle *sched,
343 if (pos->reason != 0) 333 if (pos->reason != 0)
344 *timeout = GNUNET_TIME_UNIT_ZERO; 334 *timeout = GNUNET_TIME_UNIT_ZERO;
345 } 335 }
346 pos = sched->pending; 336 pos = pending;
347 while (pos != NULL) 337 while (pos != NULL)
348 { 338 {
349 if ((pos->prereq_id != GNUNET_SCHEDULER_NO_TASK) && 339 if ((pos->prereq_id != GNUNET_SCHEDULER_NO_TASK) &&
350 (GNUNET_YES == is_pending (sched, pos->prereq_id))) 340 (GNUNET_YES == is_pending (pos->prereq_id)))
351 { 341 {
352 pos = pos->next; 342 pos = pos->next;
353 continue; 343 continue;
@@ -411,8 +401,7 @@ set_overlaps (const struct GNUNET_NETWORK_FDSet *ready,
411 * @return GNUNET_YES if we can run it, GNUNET_NO if not. 401 * @return GNUNET_YES if we can run it, GNUNET_NO if not.
412 */ 402 */
413static int 403static int
414is_ready (struct GNUNET_SCHEDULER_Handle *sched, 404is_ready (struct Task *task,
415 struct Task *task,
416 struct GNUNET_TIME_Absolute now, 405 struct GNUNET_TIME_Absolute now,
417 const struct GNUNET_NETWORK_FDSet *rs, 406 const struct GNUNET_NETWORK_FDSet *rs,
418 const struct GNUNET_NETWORK_FDSet *ws) 407 const struct GNUNET_NETWORK_FDSet *ws)
@@ -436,7 +425,7 @@ is_ready (struct GNUNET_SCHEDULER_Handle *sched,
436 return GNUNET_NO; /* not ready */ 425 return GNUNET_NO; /* not ready */
437 if (task->prereq_id != GNUNET_SCHEDULER_NO_TASK) 426 if (task->prereq_id != GNUNET_SCHEDULER_NO_TASK)
438 { 427 {
439 if (GNUNET_YES == is_pending (sched, task->prereq_id)) 428 if (GNUNET_YES == is_pending (task->prereq_id))
440 { 429 {
441 task->reason = reason; 430 task->reason = reason;
442 return GNUNET_NO; /* prereq waiting */ 431 return GNUNET_NO; /* prereq waiting */
@@ -455,15 +444,14 @@ is_ready (struct GNUNET_SCHEDULER_Handle *sched,
455 * @param task task ready for execution 444 * @param task task ready for execution
456 */ 445 */
457static void 446static void
458queue_ready_task (struct GNUNET_SCHEDULER_Handle *handle, 447queue_ready_task (struct Task *task)
459 struct Task *task)
460{ 448{
461 enum GNUNET_SCHEDULER_Priority p = task->priority; 449 enum GNUNET_SCHEDULER_Priority p = task->priority;
462 if (0 != (task->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 450 if (0 != (task->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
463 p = GNUNET_SCHEDULER_PRIORITY_SHUTDOWN; 451 p = GNUNET_SCHEDULER_PRIORITY_SHUTDOWN;
464 task->next = handle->ready[check_priority (p)]; 452 task->next = ready[check_priority (p)];
465 handle->ready[check_priority (p)] = task; 453 ready[check_priority (p)] = task;
466 handle->ready_count++; 454 ready_count++;
467} 455}
468 456
469 457
@@ -476,8 +464,7 @@ queue_ready_task (struct GNUNET_SCHEDULER_Handle *handle,
476 * @param ws FDs ready for writing 464 * @param ws FDs ready for writing
477 */ 465 */
478static void 466static void
479check_ready (struct GNUNET_SCHEDULER_Handle *handle, 467check_ready (const struct GNUNET_NETWORK_FDSet *rs,
480 const struct GNUNET_NETWORK_FDSet *rs,
481 const struct GNUNET_NETWORK_FDSet *ws) 468 const struct GNUNET_NETWORK_FDSet *ws)
482{ 469{
483 struct Task *pos; 470 struct Task *pos;
@@ -487,7 +474,7 @@ check_ready (struct GNUNET_SCHEDULER_Handle *handle,
487 474
488 now = GNUNET_TIME_absolute_get (); 475 now = GNUNET_TIME_absolute_get ();
489 prev = NULL; 476 prev = NULL;
490 pos = handle->pending_timeout; 477 pos = pending_timeout;
491 while (pos != NULL) 478 while (pos != NULL)
492 { 479 {
493 next = pos->next; 480 next = pos->next;
@@ -495,13 +482,13 @@ check_ready (struct GNUNET_SCHEDULER_Handle *handle,
495 pos->reason |= GNUNET_SCHEDULER_REASON_TIMEOUT; 482 pos->reason |= GNUNET_SCHEDULER_REASON_TIMEOUT;
496 if (0 == pos->reason) 483 if (0 == pos->reason)
497 break; 484 break;
498 handle->pending_timeout = next; 485 pending_timeout = next;
499 if (handle->pending_timeout_last == pos) 486 if (pending_timeout_last == pos)
500 handle->pending_timeout_last = NULL; 487 pending_timeout_last = NULL;
501 queue_ready_task (handle, pos); 488 queue_ready_task (pos);
502 pos = next; 489 pos = next;
503 } 490 }
504 pos = handle->pending; 491 pos = pending;
505 while (pos != NULL) 492 while (pos != NULL)
506 { 493 {
507#if DEBUG_TASKS 494#if DEBUG_TASKS
@@ -510,13 +497,13 @@ check_ready (struct GNUNET_SCHEDULER_Handle *handle,
510 pos->id, pos->callback_cls); 497 pos->id, pos->callback_cls);
511#endif 498#endif
512 next = pos->next; 499 next = pos->next;
513 if (GNUNET_YES == is_ready (handle, pos, now, rs, ws)) 500 if (GNUNET_YES == is_ready (pos, now, rs, ws))
514 { 501 {
515 if (prev == NULL) 502 if (prev == NULL)
516 handle->pending = next; 503 pending = next;
517 else 504 else
518 prev->next = next; 505 prev->next = next;
519 queue_ready_task (handle, pos); 506 queue_ready_task (pos);
520 pos = next; 507 pos = next;
521 continue; 508 continue;
522 } 509 }
@@ -536,12 +523,12 @@ check_ready (struct GNUNET_SCHEDULER_Handle *handle,
536 * @param sched the scheduler 523 * @param sched the scheduler
537 */ 524 */
538void 525void
539GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched) 526GNUNET_SCHEDULER_shutdown ()
540{ 527{
541 struct Task *pos; 528 struct Task *pos;
542 int i; 529 int i;
543 530
544 pos = sched->pending_timeout; 531 pos = pending_timeout;
545 while (pos != NULL) 532 while (pos != NULL)
546 { 533 {
547 pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN; 534 pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN;
@@ -550,7 +537,7 @@ GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched)
550 readiness-factors */ 537 readiness-factors */
551 pos = pos->next; 538 pos = pos->next;
552 } 539 }
553 pos = sched->pending; 540 pos = pending;
554 while (pos != NULL) 541 while (pos != NULL)
555 { 542 {
556 pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN; 543 pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN;
@@ -561,7 +548,7 @@ GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched)
561 } 548 }
562 for (i=0;i<GNUNET_SCHEDULER_PRIORITY_COUNT;i++) 549 for (i=0;i<GNUNET_SCHEDULER_PRIORITY_COUNT;i++)
563 { 550 {
564 pos = sched->ready[i]; 551 pos = ready[i];
565 while (pos != NULL) 552 while (pos != NULL)
566 { 553 {
567 pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN; 554 pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN;
@@ -605,37 +592,36 @@ destroy_task (struct Task *t)
605 * @param ws FDs ready for writing 592 * @param ws FDs ready for writing
606 */ 593 */
607static void 594static void
608run_ready (struct GNUNET_SCHEDULER_Handle *sched, 595run_ready (struct GNUNET_NETWORK_FDSet *rs,
609 struct GNUNET_NETWORK_FDSet *rs,
610 struct GNUNET_NETWORK_FDSet *ws) 596 struct GNUNET_NETWORK_FDSet *ws)
611{ 597{
612 enum GNUNET_SCHEDULER_Priority p; 598 enum GNUNET_SCHEDULER_Priority p;
613 struct Task *pos; 599 struct Task *pos;
614 struct GNUNET_SCHEDULER_TaskContext tc; 600 struct GNUNET_SCHEDULER_TaskContext tc;
615 601
616 sched->max_priority_added = GNUNET_SCHEDULER_PRIORITY_KEEP; 602 max_priority_added = GNUNET_SCHEDULER_PRIORITY_KEEP;
617 do 603 do
618 { 604 {
619 if (sched->ready_count == 0) 605 if (ready_count == 0)
620 return; 606 return;
621 GNUNET_assert (sched->ready[GNUNET_SCHEDULER_PRIORITY_KEEP] == NULL); 607 GNUNET_assert (ready[GNUNET_SCHEDULER_PRIORITY_KEEP] == NULL);
622 /* yes, p>0 is correct, 0 is "KEEP" which should 608 /* yes, p>0 is correct, 0 is "KEEP" which should
623 always be an empty queue (see assertion)! */ 609 always be an empty queue (see assertion)! */
624 for (p = GNUNET_SCHEDULER_PRIORITY_COUNT - 1; p > 0; p--) 610 for (p = GNUNET_SCHEDULER_PRIORITY_COUNT - 1; p > 0; p--)
625 { 611 {
626 pos = sched->ready[p]; 612 pos = ready[p];
627 if (pos != NULL) 613 if (pos != NULL)
628 break; 614 break;
629 } 615 }
630 GNUNET_assert (pos != NULL); /* ready_count wrong? */ 616 GNUNET_assert (pos != NULL); /* ready_count wrong? */
631 sched->ready[p] = pos->next; 617 ready[p] = pos->next;
632 sched->ready_count--; 618 ready_count--;
633 if (sched->current_priority != pos->priority) 619 if (current_priority != pos->priority)
634 { 620 {
635 sched->current_priority = pos->priority; 621 current_priority = pos->priority;
636 (void) GNUNET_OS_set_process_priority (GNUNET_OS_process_current (), pos->priority); 622 (void) GNUNET_OS_set_process_priority (GNUNET_OS_process_current (), pos->priority);
637 } 623 }
638 sched->active_task = pos; 624 active_task = pos;
639#if PROFILE_DELAYS 625#if PROFILE_DELAYS
640 if (GNUNET_TIME_absolute_get_duration (pos->start_time).rel_value > 626 if (GNUNET_TIME_absolute_get_duration (pos->start_time).rel_value >
641 DELAY_THRESHOLD.rel_value) 627 DELAY_THRESHOLD.rel_value)
@@ -646,7 +632,6 @@ run_ready (struct GNUNET_SCHEDULER_Handle *sched,
646 (unsigned long long) GNUNET_TIME_absolute_get_duration (pos->start_time).rel_value); 632 (unsigned long long) GNUNET_TIME_absolute_get_duration (pos->start_time).rel_value);
647 } 633 }
648#endif 634#endif
649 tc.sched = sched;
650 tc.reason = pos->reason; 635 tc.reason = pos->reason;
651 tc.read_ready = (pos->read_set == NULL) ? rs : pos->read_set; 636 tc.read_ready = (pos->read_set == NULL) ? rs : pos->read_set;
652 if ( (pos->read_fd != -1) && 637 if ( (pos->read_fd != -1) &&
@@ -677,11 +662,11 @@ run_ready (struct GNUNET_SCHEDULER_Handle *sched,
677 i, 662 i,
678 pos->backtrace_strings[i]); 663 pos->backtrace_strings[i]);
679#endif 664#endif
680 sched->active_task = NULL; 665 active_task = NULL;
681 destroy_task (pos); 666 destroy_task (pos);
682 sched->tasks_run++; 667 tasks_run++;
683 } 668 }
684 while ( (sched->pending == NULL) || (p >= sched->max_priority_added) ); 669 while ( (pending == NULL) || (p >= max_priority_added) );
685} 670}
686 671
687/** 672/**
@@ -732,7 +717,6 @@ sighandler_shutdown ()
732void 717void
733GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls) 718GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls)
734{ 719{
735 struct GNUNET_SCHEDULER_Handle sched;
736 struct GNUNET_NETWORK_FDSet *rs; 720 struct GNUNET_NETWORK_FDSet *rs;
737 struct GNUNET_NETWORK_FDSet *ws; 721 struct GNUNET_NETWORK_FDSet *ws;
738 struct GNUNET_TIME_Relative timeout; 722 struct GNUNET_TIME_Relative timeout;
@@ -763,24 +747,22 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls)
763 shc_quit = GNUNET_SIGNAL_handler_install (SIGQUIT, &sighandler_shutdown); 747 shc_quit = GNUNET_SIGNAL_handler_install (SIGQUIT, &sighandler_shutdown);
764 shc_hup = GNUNET_SIGNAL_handler_install (SIGHUP, &sighandler_shutdown); 748 shc_hup = GNUNET_SIGNAL_handler_install (SIGHUP, &sighandler_shutdown);
765#endif 749#endif
766 memset (&sched, 0, sizeof (sched)); 750 current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT;
767 sched.current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT; 751 GNUNET_SCHEDULER_add_continuation (task,
768 GNUNET_SCHEDULER_add_continuation (&sched,
769 task,
770 task_cls, 752 task_cls,
771 GNUNET_SCHEDULER_REASON_STARTUP); 753 GNUNET_SCHEDULER_REASON_STARTUP);
772 last_tr = 0; 754 last_tr = 0;
773 busy_wait_warning = 0; 755 busy_wait_warning = 0;
774 while ((sched.pending != NULL) || 756 while ((pending != NULL) ||
775 (sched.pending_timeout != NULL) || 757 (pending_timeout != NULL) ||
776 (sched.ready_count > 0)) 758 (ready_count > 0))
777 { 759 {
778 GNUNET_NETWORK_fdset_zero (rs); 760 GNUNET_NETWORK_fdset_zero (rs);
779 GNUNET_NETWORK_fdset_zero (ws); 761 GNUNET_NETWORK_fdset_zero (ws);
780 timeout = GNUNET_TIME_UNIT_FOREVER_REL; 762 timeout = GNUNET_TIME_UNIT_FOREVER_REL;
781 update_sets (&sched, rs, ws, &timeout); 763 update_sets (rs, ws, &timeout);
782 GNUNET_NETWORK_fdset_handle_set (rs, pr); 764 GNUNET_NETWORK_fdset_handle_set (rs, pr);
783 if (sched.ready_count > 0) 765 if (ready_count > 0)
784 { 766 {
785 /* no blocking, more work already ready! */ 767 /* no blocking, more work already ready! */
786 timeout = GNUNET_TIME_UNIT_ZERO; 768 timeout = GNUNET_TIME_UNIT_ZERO;
@@ -810,22 +792,22 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls)
810 _("Looks like we're busy waiting...\n")); 792 _("Looks like we're busy waiting...\n"));
811 sleep (1); /* mitigate */ 793 sleep (1); /* mitigate */
812 } 794 }
813 check_ready (&sched, rs, ws); 795 check_ready (rs, ws);
814 run_ready (&sched, rs, ws); 796 run_ready (rs, ws);
815 if (GNUNET_NETWORK_fdset_handle_isset (rs, pr)) 797 if (GNUNET_NETWORK_fdset_handle_isset (rs, pr))
816 { 798 {
817 /* consume the signal */ 799 /* consume the signal */
818 GNUNET_DISK_file_read (pr, &c, sizeof (c)); 800 GNUNET_DISK_file_read (pr, &c, sizeof (c));
819 /* mark all active tasks as ready due to shutdown */ 801 /* mark all active tasks as ready due to shutdown */
820 GNUNET_SCHEDULER_shutdown (&sched); 802 GNUNET_SCHEDULER_shutdown ();
821 } 803 }
822 if (last_tr == sched.tasks_run) 804 if (last_tr == tasks_run)
823 { 805 {
824 busy_wait_warning++; 806 busy_wait_warning++;
825 } 807 }
826 else 808 else
827 { 809 {
828 last_tr = sched.tasks_run; 810 last_tr = tasks_run;
829 busy_wait_warning = 0; 811 busy_wait_warning = 0;
830 } 812 }
831 } 813 }
@@ -852,9 +834,9 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls)
852 * @return reason(s) why the current task is run 834 * @return reason(s) why the current task is run
853 */ 835 */
854enum GNUNET_SCHEDULER_Reason 836enum GNUNET_SCHEDULER_Reason
855GNUNET_SCHEDULER_get_reason (struct GNUNET_SCHEDULER_Handle *sched) 837GNUNET_SCHEDULER_get_reason ()
856{ 838{
857 return sched->active_task->reason; 839 return active_task->reason;
858} 840}
859 841
860 842
@@ -869,18 +851,17 @@ GNUNET_SCHEDULER_get_reason (struct GNUNET_SCHEDULER_Handle *sched)
869 * @return number of tasks pending right now 851 * @return number of tasks pending right now
870 */ 852 */
871unsigned int 853unsigned int
872GNUNET_SCHEDULER_get_load (struct GNUNET_SCHEDULER_Handle *sched, 854GNUNET_SCHEDULER_get_load (enum GNUNET_SCHEDULER_Priority p)
873 enum GNUNET_SCHEDULER_Priority p)
874{ 855{
875 struct Task *pos; 856 struct Task *pos;
876 unsigned int ret; 857 unsigned int ret;
877 858
878 if (p == GNUNET_SCHEDULER_PRIORITY_COUNT) 859 if (p == GNUNET_SCHEDULER_PRIORITY_COUNT)
879 return sched->ready_count; 860 return ready_count;
880 if (p == GNUNET_SCHEDULER_PRIORITY_KEEP) 861 if (p == GNUNET_SCHEDULER_PRIORITY_KEEP)
881 p = sched->current_priority; 862 p = current_priority;
882 ret = 0; 863 ret = 0;
883 pos = sched->ready[check_priority (p)]; 864 pos = ready[check_priority (p)];
884 while (pos != NULL) 865 while (pos != NULL)
885 { 866 {
886 pos = pos->next; 867 pos = pos->next;
@@ -899,8 +880,7 @@ GNUNET_SCHEDULER_get_load (struct GNUNET_SCHEDULER_Handle *sched,
899 * @return original closure of the task 880 * @return original closure of the task
900 */ 881 */
901void * 882void *
902GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched, 883GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_TaskIdentifier task)
903 GNUNET_SCHEDULER_TaskIdentifier task)
904{ 884{
905 struct Task *t; 885 struct Task *t;
906 struct Task *prev; 886 struct Task *prev;
@@ -910,7 +890,7 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched,
910 890
911 to = 0; 891 to = 0;
912 prev = NULL; 892 prev = NULL;
913 t = sched->pending; 893 t = pending;
914 while (t != NULL) 894 while (t != NULL)
915 { 895 {
916 if (t->id == task) 896 if (t->id == task)
@@ -922,7 +902,7 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched,
922 { 902 {
923 prev = NULL; 903 prev = NULL;
924 to = 1; 904 to = 1;
925 t = sched->pending_timeout; 905 t = pending_timeout;
926 while (t != NULL) 906 while (t != NULL)
927 { 907 {
928 if (t->id == task) 908 if (t->id == task)
@@ -930,8 +910,8 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched,
930 prev = t; 910 prev = t;
931 t = t->next; 911 t = t->next;
932 } 912 }
933 if (sched->pending_timeout_last == t) 913 if (pending_timeout_last == t)
934 sched->pending_timeout_last = NULL; 914 pending_timeout_last = NULL;
935 } 915 }
936 p = 0; 916 p = 0;
937 while (t == NULL) 917 while (t == NULL)
@@ -939,12 +919,12 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched,
939 p++; 919 p++;
940 GNUNET_assert (p < GNUNET_SCHEDULER_PRIORITY_COUNT); 920 GNUNET_assert (p < GNUNET_SCHEDULER_PRIORITY_COUNT);
941 prev = NULL; 921 prev = NULL;
942 t = sched->ready[p]; 922 t = ready[p];
943 while (t != NULL) 923 while (t != NULL)
944 { 924 {
945 if (t->id == task) 925 if (t->id == task)
946 { 926 {
947 sched->ready_count--; 927 ready_count--;
948 break; 928 break;
949 } 929 }
950 prev = t; 930 prev = t;
@@ -957,16 +937,16 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched,
957 { 937 {
958 if (to == 0) 938 if (to == 0)
959 { 939 {
960 sched->pending = t->next; 940 pending = t->next;
961 } 941 }
962 else 942 else
963 { 943 {
964 sched->pending_timeout = t->next; 944 pending_timeout = t->next;
965 } 945 }
966 } 946 }
967 else 947 else
968 { 948 {
969 sched->ready[p] = t->next; 949 ready[p] = t->next;
970 } 950 }
971 } 951 }
972 else 952 else
@@ -994,8 +974,7 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched,
994 * @param reason reason for task invocation 974 * @param reason reason for task invocation
995 */ 975 */
996void 976void
997GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched, 977GNUNET_SCHEDULER_add_continuation (GNUNET_SCHEDULER_Task task,
998 GNUNET_SCHEDULER_Task task,
999 void *task_cls, 978 void *task_cls,
1000 enum GNUNET_SCHEDULER_Reason reason) 979 enum GNUNET_SCHEDULER_Reason reason)
1001{ 980{
@@ -1012,18 +991,18 @@ GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched,
1012 t->write_fd = -1; 991 t->write_fd = -1;
1013 t->callback = task; 992 t->callback = task;
1014 t->callback_cls = task_cls; 993 t->callback_cls = task_cls;
1015 t->id = ++sched->last_id; 994 t->id = ++last_id;
1016#if PROFILE_DELAYS 995#if PROFILE_DELAYS
1017 t->start_time = GNUNET_TIME_absolute_get (); 996 t->start_time = GNUNET_TIME_absolute_get ();
1018#endif 997#endif
1019 t->reason = reason; 998 t->reason = reason;
1020 t->priority = sched->current_priority; 999 t->priority = current_priority;
1021#if DEBUG_TASKS 1000#if DEBUG_TASKS
1022 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1001 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1023 "Adding continuation task: %llu / %p\n", 1002 "Adding continuation task: %llu / %p\n",
1024 t->id, t->callback_cls); 1003 t->id, t->callback_cls);
1025#endif 1004#endif
1026 queue_ready_task (sched, t); 1005 queue_ready_task (t);
1027} 1006}
1028 1007
1029 1008
@@ -1046,12 +1025,10 @@ GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched,
1046 * only valid until "task" is started! 1025 * only valid until "task" is started!
1047 */ 1026 */
1048GNUNET_SCHEDULER_TaskIdentifier 1027GNUNET_SCHEDULER_TaskIdentifier
1049GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched, 1028GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_TaskIdentifier prerequisite_task,
1050 GNUNET_SCHEDULER_TaskIdentifier prerequisite_task,
1051 GNUNET_SCHEDULER_Task task, void *task_cls) 1029 GNUNET_SCHEDULER_Task task, void *task_cls)
1052{ 1030{
1053 return GNUNET_SCHEDULER_add_select (sched, 1031 return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP,
1054 GNUNET_SCHEDULER_PRIORITY_KEEP,
1055 prerequisite_task, 1032 prerequisite_task,
1056 GNUNET_TIME_UNIT_ZERO, 1033 GNUNET_TIME_UNIT_ZERO,
1057 NULL, NULL, task, task_cls); 1034 NULL, NULL, task, task_cls);
@@ -1069,13 +1046,11 @@ GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched,
1069 * only valid until "task" is started! 1046 * only valid until "task" is started!
1070 */ 1047 */
1071GNUNET_SCHEDULER_TaskIdentifier 1048GNUNET_SCHEDULER_TaskIdentifier
1072GNUNET_SCHEDULER_add_with_priority (struct GNUNET_SCHEDULER_Handle * sched, 1049GNUNET_SCHEDULER_add_with_priority (enum GNUNET_SCHEDULER_Priority prio,
1073 enum GNUNET_SCHEDULER_Priority prio,
1074 GNUNET_SCHEDULER_Task task, 1050 GNUNET_SCHEDULER_Task task,
1075 void *task_cls) 1051 void *task_cls)
1076{ 1052{
1077 return GNUNET_SCHEDULER_add_select (sched, 1053 return GNUNET_SCHEDULER_add_select (prio,
1078 prio,
1079 GNUNET_SCHEDULER_NO_TASK, 1054 GNUNET_SCHEDULER_NO_TASK,
1080 GNUNET_TIME_UNIT_ZERO, 1055 GNUNET_TIME_UNIT_ZERO,
1081 NULL, NULL, task, task_cls); 1056 NULL, NULL, task, task_cls);
@@ -1097,8 +1072,7 @@ GNUNET_SCHEDULER_add_with_priority (struct GNUNET_SCHEDULER_Handle * sched,
1097 * only valid until "task" is started! 1072 * only valid until "task" is started!
1098 */ 1073 */
1099GNUNET_SCHEDULER_TaskIdentifier 1074GNUNET_SCHEDULER_TaskIdentifier
1100GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched, 1075GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay,
1101 struct GNUNET_TIME_Relative delay,
1102 GNUNET_SCHEDULER_Task task, void *task_cls) 1076 GNUNET_SCHEDULER_Task task, void *task_cls)
1103{ 1077{
1104#if 1 1078#if 1
@@ -1120,15 +1094,15 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched,
1120#endif 1094#endif
1121 t->read_fd = -1; 1095 t->read_fd = -1;
1122 t->write_fd = -1; 1096 t->write_fd = -1;
1123 t->id = ++sched->last_id; 1097 t->id = ++last_id;
1124#if PROFILE_DELAYS 1098#if PROFILE_DELAYS
1125 t->start_time = GNUNET_TIME_absolute_get (); 1099 t->start_time = GNUNET_TIME_absolute_get ();
1126#endif 1100#endif
1127 t->timeout = GNUNET_TIME_relative_to_absolute (delay); 1101 t->timeout = GNUNET_TIME_relative_to_absolute (delay);
1128 t->priority = sched->current_priority; 1102 t->priority = current_priority;
1129 /* try tail first (optimization in case we are 1103 /* try tail first (optimization in case we are
1130 appending to a long list of tasks with timeouts) */ 1104 appending to a long list of tasks with timeouts) */
1131 prev = sched->pending_timeout_last; 1105 prev = pending_timeout_last;
1132 if (prev != NULL) 1106 if (prev != NULL)
1133 { 1107 {
1134 if (prev->timeout.abs_value > t->timeout.abs_value) 1108 if (prev->timeout.abs_value > t->timeout.abs_value)
@@ -1139,7 +1113,7 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched,
1139 if (prev == NULL) 1113 if (prev == NULL)
1140 { 1114 {
1141 /* heuristic failed, do traversal of timeout list */ 1115 /* heuristic failed, do traversal of timeout list */
1142 pos = sched->pending_timeout; 1116 pos = pending_timeout;
1143 } 1117 }
1144 while ( (pos != NULL) && 1118 while ( (pos != NULL) &&
1145 ( (pos->timeout.abs_value <= t->timeout.abs_value) || 1119 ( (pos->timeout.abs_value <= t->timeout.abs_value) ||
@@ -1149,12 +1123,12 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched,
1149 pos = pos->next; 1123 pos = pos->next;
1150 } 1124 }
1151 if (prev == NULL) 1125 if (prev == NULL)
1152 sched->pending_timeout = t; 1126 pending_timeout = t;
1153 else 1127 else
1154 prev->next = t; 1128 prev->next = t;
1155 t->next = pos; 1129 t->next = pos;
1156 /* hyper-optimization... */ 1130 /* hyper-optimization... */
1157 sched->pending_timeout_last = t; 1131 pending_timeout_last = t;
1158 1132
1159#if DEBUG_TASKS 1133#if DEBUG_TASKS
1160 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1134 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1194,12 +1168,10 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched,
1194 * only valid until "task" is started! 1168 * only valid until "task" is started!
1195 */ 1169 */
1196GNUNET_SCHEDULER_TaskIdentifier 1170GNUNET_SCHEDULER_TaskIdentifier
1197GNUNET_SCHEDULER_add_now (struct GNUNET_SCHEDULER_Handle *sched, 1171GNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_Task task,
1198 GNUNET_SCHEDULER_Task task, 1172 void *task_cls)
1199 void *task_cls)
1200{ 1173{
1201 return GNUNET_SCHEDULER_add_select (sched, 1174 return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP,
1202 GNUNET_SCHEDULER_PRIORITY_KEEP,
1203 GNUNET_SCHEDULER_NO_TASK, 1175 GNUNET_SCHEDULER_NO_TASK,
1204 GNUNET_TIME_UNIT_ZERO, 1176 GNUNET_TIME_UNIT_ZERO,
1205 NULL, NULL, task, task_cls); 1177 NULL, NULL, task, task_cls);
@@ -1236,8 +1208,7 @@ GNUNET_SCHEDULER_add_now (struct GNUNET_SCHEDULER_Handle *sched,
1236 * only valid until "task" is started! 1208 * only valid until "task" is started!
1237 */ 1209 */
1238GNUNET_SCHEDULER_TaskIdentifier 1210GNUNET_SCHEDULER_TaskIdentifier
1239add_without_sets (struct GNUNET_SCHEDULER_Handle * sched, 1211add_without_sets (struct GNUNET_TIME_Relative delay,
1240 struct GNUNET_TIME_Relative delay,
1241 int rfd, 1212 int rfd,
1242 int wfd, 1213 int wfd,
1243 GNUNET_SCHEDULER_Task task, void *task_cls) 1214 GNUNET_SCHEDULER_Task task, void *task_cls)
@@ -1257,16 +1228,16 @@ add_without_sets (struct GNUNET_SCHEDULER_Handle * sched,
1257#endif 1228#endif
1258 t->read_fd = rfd; 1229 t->read_fd = rfd;
1259 t->write_fd = wfd; 1230 t->write_fd = wfd;
1260 t->id = ++sched->last_id; 1231 t->id = ++last_id;
1261#if PROFILE_DELAYS 1232#if PROFILE_DELAYS
1262 t->start_time = GNUNET_TIME_absolute_get (); 1233 t->start_time = GNUNET_TIME_absolute_get ();
1263#endif 1234#endif
1264 t->prereq_id = GNUNET_SCHEDULER_NO_TASK; 1235 t->prereq_id = GNUNET_SCHEDULER_NO_TASK;
1265 t->timeout = GNUNET_TIME_relative_to_absolute (delay); 1236 t->timeout = GNUNET_TIME_relative_to_absolute (delay);
1266 t->priority = check_priority (sched->current_priority); 1237 t->priority = check_priority (current_priority);
1267 t->next = sched->pending; 1238 t->next = pending;
1268 sched->pending = t; 1239 pending = t;
1269 sched->max_priority_added = GNUNET_MAX (sched->max_priority_added, 1240 max_priority_added = GNUNET_MAX (max_priority_added,
1270 t->priority); 1241 t->priority);
1271#if DEBUG_TASKS 1242#if DEBUG_TASKS
1272 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1243 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1305,13 +1276,11 @@ add_without_sets (struct GNUNET_SCHEDULER_Handle * sched,
1305 * only valid until "task" is started! 1276 * only valid until "task" is started!
1306 */ 1277 */
1307GNUNET_SCHEDULER_TaskIdentifier 1278GNUNET_SCHEDULER_TaskIdentifier
1308GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle * sched, 1279GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay,
1309 struct GNUNET_TIME_Relative delay,
1310 struct GNUNET_NETWORK_Handle * rfd, 1280 struct GNUNET_NETWORK_Handle * rfd,
1311 GNUNET_SCHEDULER_Task task, void *task_cls) 1281 GNUNET_SCHEDULER_Task task, void *task_cls)
1312{ 1282{
1313 return add_without_sets (sched, 1283 return add_without_sets (delay,
1314 delay,
1315 GNUNET_NETWORK_get_fd (rfd), 1284 GNUNET_NETWORK_get_fd (rfd),
1316 -1, 1285 -1,
1317 task, 1286 task,
@@ -1337,13 +1306,11 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle * sched,
1337 * only valid until "task" is started! 1306 * only valid until "task" is started!
1338 */ 1307 */
1339GNUNET_SCHEDULER_TaskIdentifier 1308GNUNET_SCHEDULER_TaskIdentifier
1340GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle * sched, 1309GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay,
1341 struct GNUNET_TIME_Relative delay,
1342 struct GNUNET_NETWORK_Handle * wfd, 1310 struct GNUNET_NETWORK_Handle * wfd,
1343 GNUNET_SCHEDULER_Task task, void *task_cls) 1311 GNUNET_SCHEDULER_Task task, void *task_cls)
1344{ 1312{
1345 return add_without_sets (sched, 1313 return add_without_sets (delay,
1346 delay,
1347 -1, 1314 -1,
1348 GNUNET_NETWORK_get_fd (wfd), 1315 GNUNET_NETWORK_get_fd (wfd),
1349 task, 1316 task,
@@ -1369,8 +1336,7 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle * sched,
1369 * only valid until "task" is started! 1336 * only valid until "task" is started!
1370 */ 1337 */
1371GNUNET_SCHEDULER_TaskIdentifier 1338GNUNET_SCHEDULER_TaskIdentifier
1372GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle * sched, 1339GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay,
1373 struct GNUNET_TIME_Relative delay,
1374 const struct GNUNET_DISK_FileHandle * rfd, 1340 const struct GNUNET_DISK_FileHandle * rfd,
1375 GNUNET_SCHEDULER_Task task, void *task_cls) 1341 GNUNET_SCHEDULER_Task task, void *task_cls)
1376{ 1342{
@@ -1391,8 +1357,7 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle * sched,
1391 int fd; 1357 int fd;
1392 1358
1393 GNUNET_DISK_internal_file_handle_ (rfd, &fd, sizeof (int)); 1359 GNUNET_DISK_internal_file_handle_ (rfd, &fd, sizeof (int));
1394 return add_without_sets (sched, 1360 return add_without_sets (delay,
1395 delay,
1396 fd, 1361 fd,
1397 -1, 1362 -1,
1398 task, 1363 task,
@@ -1420,8 +1385,7 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle * sched,
1420 * only valid until "task" is started! 1385 * only valid until "task" is started!
1421 */ 1386 */
1422GNUNET_SCHEDULER_TaskIdentifier 1387GNUNET_SCHEDULER_TaskIdentifier
1423GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle * sched, 1388GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay,
1424 struct GNUNET_TIME_Relative delay,
1425 const struct GNUNET_DISK_FileHandle * wfd, 1389 const struct GNUNET_DISK_FileHandle * wfd,
1426 GNUNET_SCHEDULER_Task task, void *task_cls) 1390 GNUNET_SCHEDULER_Task task, void *task_cls)
1427{ 1391{
@@ -1442,8 +1406,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle * sched,
1442 int fd; 1406 int fd;
1443 1407
1444 GNUNET_DISK_internal_file_handle_ (wfd, &fd, sizeof (int)); 1408 GNUNET_DISK_internal_file_handle_ (wfd, &fd, sizeof (int));
1445 return add_without_sets (sched, 1409 return add_without_sets (delay,
1446 delay,
1447 -1, 1410 -1,
1448 fd, 1411 fd,
1449 task, 1412 task,
@@ -1488,8 +1451,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle * sched,
1488 * only valid until "task" is started! 1451 * only valid until "task" is started!
1489 */ 1452 */
1490GNUNET_SCHEDULER_TaskIdentifier 1453GNUNET_SCHEDULER_TaskIdentifier
1491GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle * sched, 1454GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio,
1492 enum GNUNET_SCHEDULER_Priority prio,
1493 GNUNET_SCHEDULER_TaskIdentifier 1455 GNUNET_SCHEDULER_TaskIdentifier
1494 prerequisite_task, 1456 prerequisite_task,
1495 struct GNUNET_TIME_Relative delay, 1457 struct GNUNET_TIME_Relative delay,
@@ -1522,7 +1484,7 @@ GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle * sched,
1522 t->write_set = GNUNET_NETWORK_fdset_create (); 1484 t->write_set = GNUNET_NETWORK_fdset_create ();
1523 GNUNET_NETWORK_fdset_copy (t->write_set, ws); 1485 GNUNET_NETWORK_fdset_copy (t->write_set, ws);
1524 } 1486 }
1525 t->id = ++sched->last_id; 1487 t->id = ++last_id;
1526#if PROFILE_DELAYS 1488#if PROFILE_DELAYS
1527 t->start_time = GNUNET_TIME_absolute_get (); 1489 t->start_time = GNUNET_TIME_absolute_get ();
1528#endif 1490#endif
@@ -1530,11 +1492,11 @@ GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle * sched,
1530 t->timeout = GNUNET_TIME_relative_to_absolute (delay); 1492 t->timeout = GNUNET_TIME_relative_to_absolute (delay);
1531 t->priority = 1493 t->priority =
1532 check_priority ((prio == 1494 check_priority ((prio ==
1533 GNUNET_SCHEDULER_PRIORITY_KEEP) ? sched->current_priority 1495 GNUNET_SCHEDULER_PRIORITY_KEEP) ? current_priority
1534 : prio); 1496 : prio);
1535 t->next = sched->pending; 1497 t->next = pending;
1536 sched->pending = t; 1498 pending = t;
1537 sched->max_priority_added = GNUNET_MAX (sched->max_priority_added, 1499 max_priority_added = GNUNET_MAX (max_priority_added,
1538 t->priority); 1500 t->priority);
1539#if DEBUG_TASKS 1501#if DEBUG_TASKS
1540 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1502 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/util/server.c b/src/util/server.c
index 516885fed..f586e4204 100644
--- a/src/util/server.c
+++ b/src/util/server.c
@@ -80,11 +80,6 @@ struct NotifyList
80struct GNUNET_SERVER_Handle 80struct GNUNET_SERVER_Handle
81{ 81{
82 /** 82 /**
83 * My scheduler.
84 */
85 struct GNUNET_SCHEDULER_Handle *sched;
86
87 /**
88 * List of handlers for incoming messages. 83 * List of handlers for incoming messages.
89 */ 84 */
90 struct HandlerList *handlers; 85 struct HandlerList *handlers;
@@ -249,8 +244,7 @@ process_listen_socket (void *cls,
249 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 244 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
250 { 245 {
251 /* ignore shutdown, someone else will take care of it! */ 246 /* ignore shutdown, someone else will take care of it! */
252 server->listen_task = GNUNET_SCHEDULER_add_select (server->sched, 247 server->listen_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH,
253 GNUNET_SCHEDULER_PRIORITY_HIGH,
254 GNUNET_SCHEDULER_NO_TASK, 248 GNUNET_SCHEDULER_NO_TASK,
255 GNUNET_TIME_UNIT_FOREVER_REL, 249 GNUNET_TIME_UNIT_FOREVER_REL,
256 r, NULL, 250 r, NULL,
@@ -266,7 +260,7 @@ process_listen_socket (void *cls,
266 (tc->read_ready, server->listen_sockets[i])) 260 (tc->read_ready, server->listen_sockets[i]))
267 { 261 {
268 sock = 262 sock =
269 GNUNET_CONNECTION_create_from_accept (tc->sched, server->access, 263 GNUNET_CONNECTION_create_from_accept (server->access,
270 server->access_cls, 264 server->access_cls,
271 server->listen_sockets[i]); 265 server->listen_sockets[i]);
272 if (sock != NULL) 266 if (sock != NULL)
@@ -285,8 +279,7 @@ process_listen_socket (void *cls,
285 i++; 279 i++;
286 } 280 }
287 /* listen for more! */ 281 /* listen for more! */
288 server->listen_task = GNUNET_SCHEDULER_add_select (server->sched, 282 server->listen_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH,
289 GNUNET_SCHEDULER_PRIORITY_HIGH,
290 GNUNET_SCHEDULER_NO_TASK, 283 GNUNET_SCHEDULER_NO_TASK,
291 GNUNET_TIME_UNIT_FOREVER_REL, 284 GNUNET_TIME_UNIT_FOREVER_REL,
292 r, NULL, 285 r, NULL,
@@ -386,7 +379,6 @@ open_listen_socket (const struct sockaddr *serverAddr, socklen_t socklen)
386/** 379/**
387 * Create a new server. 380 * Create a new server.
388 * 381 *
389 * @param sched scheduler to use
390 * @param access function for access control 382 * @param access function for access control
391 * @param access_cls closure for access 383 * @param access_cls closure for access
392 * @param lsocks NULL-terminated array of listen sockets 384 * @param lsocks NULL-terminated array of listen sockets
@@ -397,8 +389,7 @@ open_listen_socket (const struct sockaddr *serverAddr, socklen_t socklen)
397 * (typically, "port" already in use) 389 * (typically, "port" already in use)
398 */ 390 */
399struct GNUNET_SERVER_Handle * 391struct GNUNET_SERVER_Handle *
400GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched, 392GNUNET_SERVER_create_with_sockets (GNUNET_CONNECTION_AccessCheck access, void *access_cls,
401 GNUNET_CONNECTION_AccessCheck access, void *access_cls,
402 struct GNUNET_NETWORK_Handle **lsocks, 393 struct GNUNET_NETWORK_Handle **lsocks,
403 struct GNUNET_TIME_Relative 394 struct GNUNET_TIME_Relative
404 idle_timeout, 395 idle_timeout,
@@ -409,7 +400,6 @@ GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched,
409 int i; 400 int i;
410 401
411 ret = GNUNET_malloc (sizeof (struct GNUNET_SERVER_Handle)); 402 ret = GNUNET_malloc (sizeof (struct GNUNET_SERVER_Handle));
412 ret->sched = sched;
413 ret->idle_timeout = idle_timeout; 403 ret->idle_timeout = idle_timeout;
414 ret->listen_sockets = lsocks; 404 ret->listen_sockets = lsocks;
415 ret->access = access; 405 ret->access = access;
@@ -421,8 +411,7 @@ GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched,
421 i = 0; 411 i = 0;
422 while (NULL != ret->listen_sockets[i]) 412 while (NULL != ret->listen_sockets[i])
423 GNUNET_NETWORK_fdset_set (r, ret->listen_sockets[i++]); 413 GNUNET_NETWORK_fdset_set (r, ret->listen_sockets[i++]);
424 ret->listen_task = GNUNET_SCHEDULER_add_select (sched, 414 ret->listen_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH,
425 GNUNET_SCHEDULER_PRIORITY_HIGH,
426 GNUNET_SCHEDULER_NO_TASK, 415 GNUNET_SCHEDULER_NO_TASK,
427 GNUNET_TIME_UNIT_FOREVER_REL, 416 GNUNET_TIME_UNIT_FOREVER_REL,
428 r, NULL, 417 r, NULL,
@@ -437,7 +426,6 @@ GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched,
437/** 426/**
438 * Create a new server. 427 * Create a new server.
439 * 428 *
440 * @param sched scheduler to use
441 * @param access function for access control 429 * @param access function for access control
442 * @param access_cls closure for access 430 * @param access_cls closure for access
443 * @param serverAddr address to listen on (including port), NULL terminated array 431 * @param serverAddr address to listen on (including port), NULL terminated array
@@ -449,8 +437,7 @@ GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched,
449 * (typically, "port" already in use) 437 * (typically, "port" already in use)
450 */ 438 */
451struct GNUNET_SERVER_Handle * 439struct GNUNET_SERVER_Handle *
452GNUNET_SERVER_create (struct GNUNET_SCHEDULER_Handle *sched, 440GNUNET_SERVER_create (GNUNET_CONNECTION_AccessCheck access,
453 GNUNET_CONNECTION_AccessCheck access,
454 void *access_cls, 441 void *access_cls,
455 struct sockaddr *const *serverAddr, 442 struct sockaddr *const *serverAddr,
456 const socklen_t * socklen, 443 const socklen_t * socklen,
@@ -489,8 +476,7 @@ GNUNET_SERVER_create (struct GNUNET_SCHEDULER_Handle *sched,
489 { 476 {
490 lsocks = NULL; 477 lsocks = NULL;
491 } 478 }
492 return GNUNET_SERVER_create_with_sockets (sched, 479 return GNUNET_SERVER_create_with_sockets (access, access_cls,
493 access, access_cls,
494 lsocks, 480 lsocks,
495 idle_timeout, 481 idle_timeout,
496 require_found); 482 require_found);
@@ -514,7 +500,7 @@ GNUNET_SERVER_destroy (struct GNUNET_SERVER_Handle *s)
514#endif 500#endif
515 if (GNUNET_SCHEDULER_NO_TASK != s->listen_task) 501 if (GNUNET_SCHEDULER_NO_TASK != s->listen_task)
516 { 502 {
517 GNUNET_SCHEDULER_cancel (s->sched, s->listen_task); 503 GNUNET_SCHEDULER_cancel (s->listen_task);
518 s->listen_task = GNUNET_SCHEDULER_NO_TASK; 504 s->listen_task = GNUNET_SCHEDULER_NO_TASK;
519 } 505 }
520 if (s->listen_sockets != NULL) 506 if (s->listen_sockets != NULL)
@@ -1023,8 +1009,7 @@ GNUNET_SERVER_client_disconnect (struct GNUNET_SERVER_Client *client)
1023#endif 1009#endif
1024 if (client->restart_task != GNUNET_SCHEDULER_NO_TASK) 1010 if (client->restart_task != GNUNET_SCHEDULER_NO_TASK)
1025 { 1011 {
1026 GNUNET_SCHEDULER_cancel (client->server->sched, 1012 GNUNET_SCHEDULER_cancel (client->restart_task);
1027 client->restart_task);
1028 client->restart_task = GNUNET_SCHEDULER_NO_TASK; 1013 client->restart_task = GNUNET_SCHEDULER_NO_TASK;
1029 } 1014 }
1030 if (GNUNET_YES == client->receive_pending) 1015 if (GNUNET_YES == client->receive_pending)
@@ -1053,8 +1038,7 @@ GNUNET_SERVER_client_disconnect (struct GNUNET_SERVER_Client *client)
1053 prev->next = pos->next; 1038 prev->next = pos->next;
1054 if (client->restart_task != GNUNET_SCHEDULER_NO_TASK) 1039 if (client->restart_task != GNUNET_SCHEDULER_NO_TASK)
1055 { 1040 {
1056 GNUNET_SCHEDULER_cancel (server->sched, 1041 GNUNET_SCHEDULER_cancel (client->restart_task);
1057 client->restart_task);
1058 client->restart_task = GNUNET_SCHEDULER_NO_TASK; 1042 client->restart_task = GNUNET_SCHEDULER_NO_TASK;
1059 } 1043 }
1060 n = server->disconnect_notify_list; 1044 n = server->disconnect_notify_list;
@@ -1182,8 +1166,7 @@ GNUNET_SERVER_receive_done (struct GNUNET_SERVER_Client *client, int success)
1182 "GNUNET_SERVER_receive_done causes restart in reading from the socket\n"); 1166 "GNUNET_SERVER_receive_done causes restart in reading from the socket\n");
1183#endif 1167#endif
1184 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == client->restart_task); 1168 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == client->restart_task);
1185 client->restart_task = GNUNET_SCHEDULER_add_now (client->server->sched, 1169 client->restart_task = GNUNET_SCHEDULER_add_now (&restart_processing,
1186 &restart_processing,
1187 client); 1170 client);
1188} 1171}
1189 1172
diff --git a/src/util/service.c b/src/util/service.c
index d18d4e9e3..3423b58cb 100644
--- a/src/util/service.c
+++ b/src/util/service.c
@@ -430,11 +430,6 @@ struct GNUNET_SERVICE_Context
430 struct GNUNET_SERVER_Handle *server; 430 struct GNUNET_SERVER_Handle *server;
431 431
432 /** 432 /**
433 * Scheduler for the server.
434 */
435 struct GNUNET_SCHEDULER_Handle *sched;
436
437 /**
438 * NULL-terminated array of addresses to bind to, NULL if we got pre-bound 433 * NULL-terminated array of addresses to bind to, NULL if we got pre-bound
439 * listen sockets. 434 * listen sockets.
440 */ 435 */
@@ -1290,16 +1285,13 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1290 struct GNUNET_SERVICE_Context *sctx = cls; 1285 struct GNUNET_SERVICE_Context *sctx = cls;
1291 unsigned int i; 1286 unsigned int i;
1292 1287
1293 sctx->sched = tc->sched;
1294 if (sctx->lsocks != NULL) 1288 if (sctx->lsocks != NULL)
1295 sctx->server = GNUNET_SERVER_create_with_sockets (tc->sched, 1289 sctx->server = GNUNET_SERVER_create_with_sockets (&check_access,
1296 &check_access,
1297 sctx, 1290 sctx,
1298 sctx->lsocks, 1291 sctx->lsocks,
1299 sctx->timeout, sctx->require_found); 1292 sctx->timeout, sctx->require_found);
1300 else 1293 else
1301 sctx->server = GNUNET_SERVER_create (tc->sched, 1294 sctx->server = GNUNET_SERVER_create (&check_access,
1302 &check_access,
1303 sctx, 1295 sctx,
1304 sctx->addrs, 1296 sctx->addrs,
1305 sctx->addrlens, 1297 sctx->addrlens,
@@ -1325,8 +1317,7 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1325 { 1317 {
1326 /* install a task that will kill the server 1318 /* install a task that will kill the server
1327 process if the scheduler ever gets a shutdown signal */ 1319 process if the scheduler ever gets a shutdown signal */
1328 GNUNET_SCHEDULER_add_delayed (tc->sched, 1320 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
1329 GNUNET_TIME_UNIT_FOREVER_REL,
1330 &shutdown_task, sctx->server); 1321 &shutdown_task, sctx->server);
1331 } 1322 }
1332 sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers)); 1323 sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers));
@@ -1354,7 +1345,7 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1354 i++; 1345 i++;
1355 } 1346 }
1356 } 1347 }
1357 sctx->task (sctx->task_cls, tc->sched, sctx->server, sctx->cfg); 1348 sctx->task (sctx->task_cls, sctx->server, sctx->cfg);
1358} 1349}
1359 1350
1360 1351
@@ -1612,13 +1603,11 @@ shutdown:
1612 * initialized system. 1603 * initialized system.
1613 * 1604 *
1614 * @param serviceName our service name 1605 * @param serviceName our service name
1615 * @param sched scheduler to use
1616 * @param cfg configuration to use 1606 * @param cfg configuration to use
1617 * @return NULL on error, service handle 1607 * @return NULL on error, service handle
1618 */ 1608 */
1619struct GNUNET_SERVICE_Context * 1609struct GNUNET_SERVICE_Context *
1620GNUNET_SERVICE_start (const char *serviceName, 1610GNUNET_SERVICE_start (const char *serviceName,
1621 struct GNUNET_SCHEDULER_Handle *sched,
1622 const struct GNUNET_CONFIGURATION_Handle *cfg) 1611 const struct GNUNET_CONFIGURATION_Handle *cfg)
1623{ 1612{
1624 int i; 1613 int i;
@@ -1630,7 +1619,6 @@ GNUNET_SERVICE_start (const char *serviceName,
1630 sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL; 1619 sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
1631 sctx->serviceName = serviceName; 1620 sctx->serviceName = serviceName;
1632 sctx->cfg = cfg; 1621 sctx->cfg = cfg;
1633 sctx->sched = sched;
1634 1622
1635 /* setup subsystems */ 1623 /* setup subsystems */
1636 if (GNUNET_OK != setup_service (sctx)) 1624 if (GNUNET_OK != setup_service (sctx))
@@ -1639,14 +1627,12 @@ GNUNET_SERVICE_start (const char *serviceName,
1639 return NULL; 1627 return NULL;
1640 } 1628 }
1641 if (sctx->lsocks != NULL) 1629 if (sctx->lsocks != NULL)
1642 sctx->server = GNUNET_SERVER_create_with_sockets (sched, 1630 sctx->server = GNUNET_SERVER_create_with_sockets (&check_access,
1643 &check_access,
1644 sctx, 1631 sctx,
1645 sctx->lsocks, 1632 sctx->lsocks,
1646 sctx->timeout, sctx->require_found); 1633 sctx->timeout, sctx->require_found);
1647 else 1634 else
1648 sctx->server = GNUNET_SERVER_create (sched, 1635 sctx->server = GNUNET_SERVER_create (&check_access,
1649 &check_access,
1650 sctx, 1636 sctx,
1651 sctx->addrs, 1637 sctx->addrs,
1652 sctx->addrlens, 1638 sctx->addrlens,
diff --git a/src/util/test_client.c b/src/util/test_client.c
index ead6751a4..3851744c2 100644
--- a/src/util/test_client.c
+++ b/src/util/test_client.c
@@ -150,8 +150,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
150#endif 150#endif
151 sa.sin_family = AF_INET; 151 sa.sin_family = AF_INET;
152 sa.sin_port = htons (PORT); 152 sa.sin_port = htons (PORT);
153 server = GNUNET_SERVER_create (tc->sched, 153 server = GNUNET_SERVER_create (NULL,
154 NULL,
155 NULL, 154 NULL,
156 sap, 155 sap,
157 slens, 156 slens,
@@ -162,7 +161,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
162 handlers[0].callback_cls = cls; 161 handlers[0].callback_cls = cls;
163 handlers[1].callback_cls = cls; 162 handlers[1].callback_cls = cls;
164 GNUNET_SERVER_add_handlers (server, handlers); 163 GNUNET_SERVER_add_handlers (server, handlers);
165 client = GNUNET_CLIENT_connect (tc->sched, MYNAME, cfg); 164 client = GNUNET_CLIENT_connect (MYNAME, cfg);
166 GNUNET_assert (client != NULL); 165 GNUNET_assert (client != NULL);
167 GNUNET_assert (NULL != 166 GNUNET_assert (NULL !=
168 GNUNET_CLIENT_notify_transmit_ready (client, 167 GNUNET_CLIENT_notify_transmit_ready (client,
diff --git a/src/util/test_connection.c b/src/util/test_connection.c
index 0cc02059d..71b37c8ac 100644
--- a/src/util/test_connection.c
+++ b/src/util/test_connection.c
@@ -118,8 +118,7 @@ run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
118#if VERBOSE 118#if VERBOSE
119 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test accepts connection\n"); 119 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test accepts connection\n");
120#endif 120#endif
121 asock = GNUNET_CONNECTION_create_from_accept (tc->sched, 121 asock = GNUNET_CONNECTION_create_from_accept (NULL, NULL, ls);
122 NULL, NULL, ls);
123 GNUNET_assert (asock != NULL); 122 GNUNET_assert (asock != NULL);
124 GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); 123 GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock));
125#if VERBOSE 124#if VERBOSE
@@ -157,10 +156,9 @@ static void
157task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 156task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
158{ 157{
159 ls = open_listen_socket (); 158 ls = open_listen_socket ();
160 lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls); 159 lsock = GNUNET_CONNECTION_create_from_existing (ls);
161 GNUNET_assert (lsock != NULL); 160 GNUNET_assert (lsock != NULL);
162 csock = GNUNET_CONNECTION_create_from_connect (tc->sched, 161 csock = GNUNET_CONNECTION_create_from_connect (cfg,
163 cfg,
164 "localhost", PORT); 162 "localhost", PORT);
165 GNUNET_assert (csock != NULL); 163 GNUNET_assert (csock != NULL);
166#if VERBOSE 164#if VERBOSE
@@ -174,8 +172,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
174#if VERBOSE 172#if VERBOSE
175 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test prepares to accept\n"); 173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test prepares to accept\n");
176#endif 174#endif
177 GNUNET_SCHEDULER_add_read_net (tc->sched, 175 GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
178 GNUNET_TIME_UNIT_FOREVER_REL,
179 ls, &run_accept, cls); 176 ls, &run_accept, cls);
180} 177}
181 178
diff --git a/src/util/test_connection_addressing.c b/src/util/test_connection_addressing.c
index 4c10bd074..f5328be92 100644
--- a/src/util/test_connection_addressing.c
+++ b/src/util/test_connection_addressing.c
@@ -115,8 +115,7 @@ run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
115 struct sockaddr_in *v4; 115 struct sockaddr_in *v4;
116 struct sockaddr_in expect; 116 struct sockaddr_in expect;
117 117
118 asock = GNUNET_CONNECTION_create_from_accept (tc->sched, 118 asock = GNUNET_CONNECTION_create_from_accept (NULL, NULL, ls);
119 NULL, NULL, ls);
120 GNUNET_assert (asock != NULL); 119 GNUNET_assert (asock != NULL);
121 GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); 120 GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock));
122 GNUNET_assert (GNUNET_OK == 121 GNUNET_assert (GNUNET_OK ==
@@ -153,7 +152,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
153{ 152{
154 struct sockaddr_in v4; 153 struct sockaddr_in v4;
155 ls = open_listen_socket (); 154 ls = open_listen_socket ();
156 lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls); 155 lsock = GNUNET_CONNECTION_create_from_existing (ls);
157 GNUNET_assert (lsock != NULL); 156 GNUNET_assert (lsock != NULL);
158 157
159#if HAVE_SOCKADDR_IN_SIN_LEN 158#if HAVE_SOCKADDR_IN_SIN_LEN
@@ -162,8 +161,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
162 v4.sin_family = AF_INET; 161 v4.sin_family = AF_INET;
163 v4.sin_port = htons (PORT); 162 v4.sin_port = htons (PORT);
164 v4.sin_addr.s_addr = htonl (INADDR_LOOPBACK); 163 v4.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
165 csock = GNUNET_CONNECTION_create_from_sockaddr (tc->sched, 164 csock = GNUNET_CONNECTION_create_from_sockaddr (AF_INET,
166 AF_INET,
167 (const struct sockaddr 165 (const struct sockaddr
168 *) &v4, sizeof (v4)); 166 *) &v4, sizeof (v4));
169 GNUNET_assert (csock != NULL); 167 GNUNET_assert (csock != NULL);
@@ -173,8 +171,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
173 GNUNET_TIME_UNIT_SECONDS, 171 GNUNET_TIME_UNIT_SECONDS,
174 &make_hello, NULL)); 172 &make_hello, NULL));
175 GNUNET_CONNECTION_destroy (csock, GNUNET_YES); 173 GNUNET_CONNECTION_destroy (csock, GNUNET_YES);
176 GNUNET_SCHEDULER_add_read_net (tc->sched, 174 GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
177 GNUNET_TIME_UNIT_FOREVER_REL,
178 ls, &run_accept, cls); 175 ls, &run_accept, cls);
179} 176}
180 177
diff --git a/src/util/test_connection_receive_cancel.c b/src/util/test_connection_receive_cancel.c
index e4d7111d4..1e6720235 100644
--- a/src/util/test_connection_receive_cancel.c
+++ b/src/util/test_connection_receive_cancel.c
@@ -90,8 +90,7 @@ static void
90run_accept_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 90run_accept_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
91{ 91{
92 92
93 asock = GNUNET_CONNECTION_create_from_accept (tc->sched, 93 asock = GNUNET_CONNECTION_create_from_accept (NULL, NULL, ls);
94 NULL, NULL, ls);
95 GNUNET_assert (asock != NULL); 94 GNUNET_assert (asock != NULL);
96 GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); 95 GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock));
97 GNUNET_CONNECTION_destroy (lsock, GNUNET_YES); 96 GNUNET_CONNECTION_destroy (lsock, GNUNET_YES);
@@ -119,16 +118,14 @@ static void
119task_receive_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 118task_receive_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
120{ 119{
121 ls = open_listen_socket (); 120 ls = open_listen_socket ();
122 lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls); 121 lsock = GNUNET_CONNECTION_create_from_existing (ls);
123 GNUNET_assert (lsock != NULL); 122 GNUNET_assert (lsock != NULL);
124 csock = GNUNET_CONNECTION_create_from_connect (tc->sched, cfg, 123 csock = GNUNET_CONNECTION_create_from_connect (cfg,
125 "localhost", PORT); 124 "localhost", PORT);
126 GNUNET_assert (csock != NULL); 125 GNUNET_assert (csock != NULL);
127 GNUNET_SCHEDULER_add_read_net (tc->sched, 126 GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
128 GNUNET_TIME_UNIT_FOREVER_REL,
129 ls, &run_accept_cancel, cls); 127 ls, &run_accept_cancel, cls);
130 GNUNET_SCHEDULER_add_delayed (tc->sched, 128 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
131 GNUNET_TIME_UNIT_SECONDS,
132 &receive_cancel_task, cls); 129 &receive_cancel_task, cls);
133} 130}
134 131
diff --git a/src/util/test_connection_timeout.c b/src/util/test_connection_timeout.c
index 5291ad3c4..0e2190e41 100644
--- a/src/util/test_connection_timeout.c
+++ b/src/util/test_connection_timeout.c
@@ -107,9 +107,9 @@ task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
107{ 107{
108 108
109 ls = open_listen_socket (); 109 ls = open_listen_socket ();
110 lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls); 110 lsock = GNUNET_CONNECTION_create_from_existing (ls);
111 GNUNET_assert (lsock != NULL); 111 GNUNET_assert (lsock != NULL);
112 csock = GNUNET_CONNECTION_create_from_connect (tc->sched, cfg, 112 csock = GNUNET_CONNECTION_create_from_connect (cfg,
113 "localhost", PORT); 113 "localhost", PORT);
114 GNUNET_assert (csock != NULL); 114 GNUNET_assert (csock != NULL);
115 GNUNET_assert (NULL != 115 GNUNET_assert (NULL !=
diff --git a/src/util/test_connection_timeout_no_connect.c b/src/util/test_connection_timeout_no_connect.c
index 468e965ca..3519f197b 100644
--- a/src/util/test_connection_timeout_no_connect.c
+++ b/src/util/test_connection_timeout_no_connect.c
@@ -53,7 +53,7 @@ handle_timeout (void *cls, size_t size, void *buf)
53static void 53static void
54task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 54task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
55{ 55{
56 csock = GNUNET_CONNECTION_create_from_connect (tc->sched, cfg, 56 csock = GNUNET_CONNECTION_create_from_connect (cfg,
57 "localhost", PORT); 57 "localhost", PORT);
58 GNUNET_assert (csock != NULL); 58 GNUNET_assert (csock != NULL);
59 GNUNET_assert (NULL != 59 GNUNET_assert (NULL !=
diff --git a/src/util/test_connection_transmit_cancel.c b/src/util/test_connection_transmit_cancel.c
index d4456b00d..72e27243b 100644
--- a/src/util/test_connection_transmit_cancel.c
+++ b/src/util/test_connection_transmit_cancel.c
@@ -50,7 +50,7 @@ task_transmit_cancel (void *cls,
50 struct GNUNET_CONNECTION_TransmitHandle *th; 50 struct GNUNET_CONNECTION_TransmitHandle *th;
51 struct GNUNET_CONNECTION_Handle *csock; 51 struct GNUNET_CONNECTION_Handle *csock;
52 52
53 csock = GNUNET_CONNECTION_create_from_connect (tc->sched, cfg, 53 csock = GNUNET_CONNECTION_create_from_connect (cfg,
54 "localhost", PORT); 54 "localhost", PORT);
55 GNUNET_assert (csock != NULL); 55 GNUNET_assert (csock != NULL);
56 th = GNUNET_CONNECTION_notify_transmit_ready (csock, 56 th = GNUNET_CONNECTION_notify_transmit_ready (csock,
diff --git a/src/util/test_crypto_hash.c b/src/util/test_crypto_hash.c
index 33f19c804..85de9fbbb 100644
--- a/src/util/test_crypto_hash.c
+++ b/src/util/test_crypto_hash.c
@@ -123,8 +123,7 @@ static void
123file_hasher (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 123file_hasher (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
124{ 124{
125 GNUNET_assert (NULL != 125 GNUNET_assert (NULL !=
126 GNUNET_CRYPTO_hash_file (tc->sched, 126 GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
127 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
128 FILENAME, 1024, 127 FILENAME, 1024,
129 &finished_task, cls)); 128 &finished_task, cls));
130} 129}
diff --git a/src/util/test_disk.c b/src/util/test_disk.c
index 9a5ea3a57..fb79e7cd8 100644
--- a/src/util/test_disk.c
+++ b/src/util/test_disk.c
@@ -169,8 +169,7 @@ iter_callback (void *cls,
169static void 169static void
170iter_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 170iter_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
171{ 171{
172 GNUNET_DISK_directory_iterator_start (tc->sched, 172 GNUNET_DISK_directory_iterator_start (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
173 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
174 "test", &iter_callback, cls); 173 "test", &iter_callback, cls);
175} 174}
176 175
diff --git a/src/util/test_os_start_process.c b/src/util/test_os_start_process.c
index bce1c7151..f82860e83 100644
--- a/src/util/test_os_start_process.c
+++ b/src/util/test_os_start_process.c
@@ -78,8 +78,8 @@ read_call (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
78 { 78 {
79 GNUNET_break (0); 79 GNUNET_break (0);
80 ok = 1; 80 ok = 1;
81 GNUNET_SCHEDULER_cancel(tc->sched, die_task); 81 GNUNET_SCHEDULER_cancel(die_task);
82 GNUNET_SCHEDULER_add_now(tc->sched, &end_task, NULL); 82 GNUNET_SCHEDULER_add_now(&end_task, NULL);
83 return; 83 return;
84 } 84 }
85 85
@@ -89,13 +89,12 @@ read_call (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
89#endif 89#endif
90 if (ok == 0) 90 if (ok == 0)
91 { 91 {
92 GNUNET_SCHEDULER_cancel(tc->sched, die_task); 92 GNUNET_SCHEDULER_cancel(die_task);
93 GNUNET_SCHEDULER_add_now(tc->sched, &end_task, NULL); 93 GNUNET_SCHEDULER_add_now(&end_task, NULL);
94 return; 94 return;
95 } 95 }
96 96
97 GNUNET_SCHEDULER_add_read_file (tc->sched, 97 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
98 GNUNET_TIME_UNIT_FOREVER_REL,
99 stdout_read_handle, &read_call, stdout_read_handle); 98 stdout_read_handle, &read_call, stdout_read_handle);
100 99
101} 100}
@@ -145,10 +144,9 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
145 144
146 stdout_read_handle = GNUNET_DISK_pipe_handle(hello_pipe_stdout, GNUNET_DISK_PIPE_END_READ); 145 stdout_read_handle = GNUNET_DISK_pipe_handle(hello_pipe_stdout, GNUNET_DISK_PIPE_END_READ);
147 146
148 die_task = GNUNET_SCHEDULER_add_delayed(tc->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 1), &end_task, NULL); 147 die_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 1), &end_task, NULL);
149 148
150 GNUNET_SCHEDULER_add_read_file (tc->sched, 149 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
151 GNUNET_TIME_UNIT_FOREVER_REL,
152 stdout_read_handle, &read_call, (void *)stdout_read_handle); 150 stdout_read_handle, &read_call, (void *)stdout_read_handle);
153 151
154} 152}
diff --git a/src/util/test_program.c b/src/util/test_program.c
index e7745abff..33a6b50ea 100644
--- a/src/util/test_program.c
+++ b/src/util/test_program.c
@@ -58,13 +58,11 @@ static struct GNUNET_GETOPT_CommandLineOption options4[] = {
58 58
59static void 59static void
60runner (void *cls, 60runner (void *cls,
61 struct GNUNET_SCHEDULER_Handle *sched,
62 char *const *args, 61 char *const *args,
63 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 62 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
64{ 63{
65 int *ok = cls; 64 int *ok = cls;
66 GNUNET_assert (setme1 == 1); 65 GNUNET_assert (setme1 == 1);
67 GNUNET_assert (sched != NULL);
68 GNUNET_assert (0 == strcmp (args[0], "extra")); 66 GNUNET_assert (0 == strcmp (args[0], "extra"));
69 GNUNET_assert (args[1] == NULL); 67 GNUNET_assert (args[1] == NULL);
70 GNUNET_assert (0 == strcmp (cfgfile, "test_program_data.conf")); 68 GNUNET_assert (0 == strcmp (cfgfile, "test_program_data.conf"));
diff --git a/src/util/test_resolver_api.c b/src/util/test_resolver_api.c
index 734420e84..bf2f8f00f 100644
--- a/src/util/test_resolver_api.c
+++ b/src/util/test_resolver_api.c
@@ -219,7 +219,7 @@ check_rootserver_name(void *cls, const char *hostname)
219} 219}
220 220
221static void 221static void
222run(void *cls, struct GNUNET_SCHEDULER_Handle *sched, char * const *args, 222run(void *cls, char * const *args,
223 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 223 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
224{ 224{
225 int *ok = cls; 225 int *ok = cls;
@@ -232,13 +232,13 @@ run(void *cls, struct GNUNET_SCHEDULER_Handle *sched, char * const *args,
232 memset(&sa, 0, sizeof(sa)); 232 memset(&sa, 0, sizeof(sa));
233 sa.sin_family = AF_INET; 233 sa.sin_family = AF_INET;
234 sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); 234 sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
235 GNUNET_RESOLVER_ip_get(sched, cfg, "localhost", AF_INET, timeout, &check_127, 235 GNUNET_RESOLVER_ip_get(cfg, "localhost", AF_INET, timeout, &check_127,
236 cls); 236 cls);
237 GNUNET_RESOLVER_hostname_get(sched, cfg, (const struct sockaddr *) &sa, 237 GNUNET_RESOLVER_hostname_get(cfg, (const struct sockaddr *) &sa,
238 sizeof(struct sockaddr), GNUNET_YES, timeout, &check_localhost, cls); 238 sizeof(struct sockaddr), GNUNET_YES, timeout, &check_localhost, cls);
239 GNUNET_RESOLVER_hostname_get(sched, cfg, (const struct sockaddr *) &sa, 239 GNUNET_RESOLVER_hostname_get(cfg, (const struct sockaddr *) &sa,
240 sizeof(struct sockaddr), GNUNET_NO, timeout, &check_localhost_num, cls); 240 sizeof(struct sockaddr), GNUNET_NO, timeout, &check_localhost_num, cls);
241 GNUNET_RESOLVER_hostname_resolve(sched, cfg, AF_UNSPEC, timeout, 241 GNUNET_RESOLVER_hostname_resolve(cfg, AF_UNSPEC, timeout,
242 &check_hostname, cls); 242 &check_hostname, cls);
243 243
244 244
@@ -297,7 +297,7 @@ run(void *cls, struct GNUNET_SCHEDULER_Handle *sched, char * const *args,
297#endif 297#endif
298 298
299 /* Resolve the same using GNUNET */ 299 /* Resolve the same using GNUNET */
300 GNUNET_RESOLVER_ip_get(sched, cfg, ROOTSERVER_NAME, AF_INET, timeout, 300 GNUNET_RESOLVER_ip_get(cfg, ROOTSERVER_NAME, AF_INET, timeout,
301 &check_rootserver_ip, cls); 301 &check_rootserver_ip, cls);
302 302
303 /* 303 /*
@@ -350,7 +350,7 @@ run(void *cls, struct GNUNET_SCHEDULER_Handle *sched, char * const *args,
350#else 350#else
351 sa.sin_addr.S_un.S_addr = inet_addr(ROOTSERVER_IP); 351 sa.sin_addr.S_un.S_addr = inet_addr(ROOTSERVER_IP);
352#endif 352#endif
353 GNUNET_RESOLVER_hostname_get(sched, cfg, (const struct sockaddr *) &sa, 353 GNUNET_RESOLVER_hostname_get(cfg, (const struct sockaddr *) &sa,
354 sizeof(struct sockaddr), GNUNET_YES, timeout, &check_rootserver_name, cls); 354 sizeof(struct sockaddr), GNUNET_YES, timeout, &check_rootserver_name, cls);
355} 355}
356 356
diff --git a/src/util/test_scheduler.c b/src/util/test_scheduler.c
index 0ac186588..f0c908d7d 100644
--- a/src/util/test_scheduler.c
+++ b/src/util/test_scheduler.c
@@ -34,8 +34,7 @@ task3 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
34{ 34{
35 int *ok = cls; 35 int *ok = cls;
36 /* t4 should be ready (albeit with lower priority) */ 36 /* t4 should be ready (albeit with lower priority) */
37 GNUNET_assert (1 == GNUNET_SCHEDULER_get_load (tc->sched, 37 GNUNET_assert (1 == GNUNET_SCHEDULER_get_load (GNUNET_SCHEDULER_PRIORITY_COUNT));
38 GNUNET_SCHEDULER_PRIORITY_COUNT));
39 GNUNET_assert (3 == *ok); 38 GNUNET_assert (3 == *ok);
40 (*ok) = 4; 39 (*ok) = 4;
41} 40}
@@ -48,8 +47,7 @@ task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
48 GNUNET_assert (2 == *ok); 47 GNUNET_assert (2 == *ok);
49 (*ok) = 3; 48 (*ok) = 3;
50 /* t3 will go before t4: higher priority */ 49 /* t3 will go before t4: higher priority */
51 GNUNET_SCHEDULER_add_with_priority (tc->sched, 50 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI,
52 GNUNET_SCHEDULER_PRIORITY_UI,
53 &task3, cls); 51 &task3, cls);
54} 52}
55 53
@@ -101,10 +99,9 @@ taskRd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
101 GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0])); 99 GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0]));
102 GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1)); 100 GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1));
103 (*ok) = 8; 101 (*ok) = 8;
104 GNUNET_SCHEDULER_add_with_priority (tc->sched, 102 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
105 GNUNET_SCHEDULER_PRIORITY_IDLE,
106 &taskLast, cls); 103 &taskLast, cls);
107 GNUNET_SCHEDULER_shutdown (tc->sched); 104 GNUNET_SCHEDULER_shutdown ();
108} 105}
109 106
110 107
@@ -118,11 +115,9 @@ task5 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
118 GNUNET_assert (NULL != p); 115 GNUNET_assert (NULL != p);
119 fds[0] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_READ); 116 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); 117 fds[1] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_WRITE);
121 GNUNET_SCHEDULER_add_read_file (tc->sched, 118 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
122 GNUNET_TIME_UNIT_FOREVER_REL,
123 fds[0], &taskRd, cls); 119 fds[0], &taskRd, cls);
124 GNUNET_SCHEDULER_add_write_file (tc->sched, 120 GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL,
125 GNUNET_TIME_UNIT_FOREVER_REL,
126 fds[1], &taskWrt, cls); 121 fds[1], &taskWrt, cls);
127} 122}
128 123
@@ -137,12 +132,11 @@ task1 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
137 GNUNET_assert (1 == *ok); 132 GNUNET_assert (1 == *ok);
138 (*ok) = 2; 133 (*ok) = 2;
139 /* t2 will go first -- prereq for all */ 134 /* t2 will go first -- prereq for all */
140 t2 = GNUNET_SCHEDULER_add_after (tc->sched, 135 t2 = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, &task2, cls);
141 GNUNET_SCHEDULER_NO_TASK, &task2, cls);
142 /* t4 will go after t2 ('add after') and after t3 (priority) */ 136 /* t4 will go after t2 ('add after') and after t3 (priority) */
143 t4 = GNUNET_SCHEDULER_add_after (tc->sched, t2, &task4, cls); 137 t4 = GNUNET_SCHEDULER_add_after (t2, &task4, cls);
144 /* t5 will go last (after p4) */ 138 /* t5 will go last (after p4) */
145 GNUNET_SCHEDULER_add_after (tc->sched, t4, &task5, cls); 139 GNUNET_SCHEDULER_add_after (t4, &task5, cls);
146} 140}
147 141
148 142
@@ -168,9 +162,8 @@ taskShutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
168 int *ok = cls; 162 int *ok = cls;
169 GNUNET_assert (1 == *ok); 163 GNUNET_assert (1 == *ok);
170 *ok = 8; 164 *ok = 8;
171 GNUNET_SCHEDULER_add_delayed (tc->sched, 165 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &taskLast, cls);
172 GNUNET_TIME_UNIT_FOREVER_REL, &taskLast, cls); 166 GNUNET_SCHEDULER_shutdown ();
173 GNUNET_SCHEDULER_shutdown (tc->sched);
174} 167}
175 168
176 169
@@ -195,8 +188,7 @@ taskSig (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
195 int *ok = cls; 188 int *ok = cls;
196 GNUNET_assert (1 == *ok); 189 GNUNET_assert (1 == *ok);
197 *ok = 8; 190 *ok = 8;
198 GNUNET_SCHEDULER_add_delayed (tc->sched, 191 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &taskLast, cls);
199 GNUNET_TIME_UNIT_FOREVER_REL, &taskLast, cls);
200 GNUNET_break (0 == PLIBC_KILL (getpid (), SIGTERM)); 192 GNUNET_break (0 == PLIBC_KILL (getpid (), SIGTERM));
201} 193}
202 194
@@ -223,9 +215,7 @@ taskCancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
223 215
224 GNUNET_assert (1 == *ok); 216 GNUNET_assert (1 == *ok);
225 *ok = 0; 217 *ok = 0;
226 GNUNET_SCHEDULER_cancel (tc->sched, 218 GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK,
227 GNUNET_SCHEDULER_add_after (tc->sched,
228 GNUNET_SCHEDULER_NO_TASK,
229 &taskNeverRun, NULL)); 219 &taskNeverRun, NULL));
230} 220}
231 221
diff --git a/src/util/test_scheduler_delay.c b/src/util/test_scheduler_delay.c
index 24d30be99..1f60ca9fd 100644
--- a/src/util/test_scheduler_delay.c
+++ b/src/util/test_scheduler_delay.c
@@ -65,8 +65,7 @@ test_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
65 fprintf (stderr, "\n"); 65 fprintf (stderr, "\n");
66 return; 66 return;
67 } 67 }
68 GNUNET_SCHEDULER_add_delayed (tc->sched, 68 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
69 GNUNET_TIME_relative_multiply
70 (GNUNET_TIME_UNIT_MILLISECONDS, i), 69 (GNUNET_TIME_UNIT_MILLISECONDS, i),
71 &test_task, NULL); 70 &test_task, NULL);
72 i += INCR; 71 i += INCR;
diff --git a/src/util/test_server.c b/src/util/test_server.c
index 78e2d52bf..00d4352f8 100644
--- a/src/util/test_server.c
+++ b/src/util/test_server.c
@@ -45,8 +45,6 @@ static struct GNUNET_SERVER_Client *argclient;
45 45
46static struct GNUNET_CONFIGURATION_Handle *cfg; 46static struct GNUNET_CONFIGURATION_Handle *cfg;
47 47
48static struct GNUNET_SCHEDULER_Handle *sched;
49
50static int ok; 48static int ok;
51 49
52 50
@@ -70,8 +68,7 @@ recv_fin_cb (void *cls,
70 GNUNET_assert (ok == 5); 68 GNUNET_assert (ok == 5);
71 ok = 6; 69 ok = 6;
72 GNUNET_SERVER_receive_done (client, GNUNET_OK); 70 GNUNET_SERVER_receive_done (client, GNUNET_OK);
73 GNUNET_SCHEDULER_add_now (sched, 71 GNUNET_SCHEDULER_add_now (&finish_up,
74 &finish_up,
75 NULL); 72 NULL);
76} 73}
77 74
@@ -181,15 +178,13 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
181 slens[0] = sizeof (sa); 178 slens[0] = sizeof (sa);
182 sap[1] = NULL; 179 sap[1] = NULL;
183 slens[1] = 0; 180 slens[1] = 0;
184 sched = tc->sched;
185 memset (&sa, 0, sizeof (sa)); 181 memset (&sa, 0, sizeof (sa));
186#if HAVE_SOCKADDR_IN_SIN_LEN 182#if HAVE_SOCKADDR_IN_SIN_LEN
187 sa.sin_len = sizeof (sa); 183 sa.sin_len = sizeof (sa);
188#endif 184#endif
189 sa.sin_family = AF_INET; 185 sa.sin_family = AF_INET;
190 sa.sin_port = htons (PORT); 186 sa.sin_port = htons (PORT);
191 server = GNUNET_SERVER_create (tc->sched, 187 server = GNUNET_SERVER_create (NULL,
192 NULL,
193 NULL, 188 NULL,
194 sap, 189 sap,
195 slens, 190 slens,
@@ -201,8 +196,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
201 GNUNET_CONFIGURATION_set_value_number (cfg, "test-server", "PORT", PORT); 196 GNUNET_CONFIGURATION_set_value_number (cfg, "test-server", "PORT", PORT);
202 GNUNET_CONFIGURATION_set_value_string (cfg, "test-server", "HOSTNAME", "localhost"); 197 GNUNET_CONFIGURATION_set_value_string (cfg, "test-server", "HOSTNAME", "localhost");
203 GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", "localhost"); 198 GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", "localhost");
204 cc = GNUNET_CLIENT_connect (tc->sched, 199 cc = GNUNET_CLIENT_connect ("test-server",
205 "test-server",
206 cfg); 200 cfg);
207 GNUNET_assert (cc != NULL); 201 GNUNET_assert (cc != NULL);
208 GNUNET_assert (NULL != 202 GNUNET_assert (NULL !=
diff --git a/src/util/test_server_disconnect.c b/src/util/test_server_disconnect.c
index 2fef5642e..8ab8ef35b 100644
--- a/src/util/test_server_disconnect.c
+++ b/src/util/test_server_disconnect.c
@@ -42,8 +42,6 @@ static struct GNUNET_CLIENT_Connection *cc;
42 42
43static struct GNUNET_CONFIGURATION_Handle *cfg; 43static struct GNUNET_CONFIGURATION_Handle *cfg;
44 44
45static struct GNUNET_SCHEDULER_Handle *sched;
46
47static int ok; 45static int ok;
48 46
49 47
@@ -66,8 +64,7 @@ notify_disconnect (void *cls, struct GNUNET_SERVER_Client *clientarg)
66 return; 64 return;
67 GNUNET_assert (ok == 4); 65 GNUNET_assert (ok == 4);
68 ok = 5; 66 ok = 5;
69 GNUNET_SCHEDULER_add_now (sched, 67 GNUNET_SCHEDULER_add_now (&finish_up,
70 &finish_up,
71 NULL); 68 NULL);
72} 69}
73 70
@@ -91,8 +88,7 @@ recv_cb (void *cls,
91 GNUNET_assert (ok == 2); 88 GNUNET_assert (ok == 2);
92 ok = 3; 89 ok = 3;
93 GNUNET_SERVER_client_keep (client); 90 GNUNET_SERVER_client_keep (client);
94 GNUNET_SCHEDULER_add_now (sched, 91 GNUNET_SCHEDULER_add_now (&server_disconnect, client);
95 &server_disconnect, client);
96 GNUNET_assert (sizeof (struct GNUNET_MessageHeader) == 92 GNUNET_assert (sizeof (struct GNUNET_MessageHeader) ==
97 ntohs (message->size)); 93 ntohs (message->size));
98 GNUNET_assert (MY_TYPE == ntohs (message->type)); 94 GNUNET_assert (MY_TYPE == ntohs (message->type));
@@ -134,15 +130,13 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
134 slens[0] = sizeof (sa); 130 slens[0] = sizeof (sa);
135 sap[1] = NULL; 131 sap[1] = NULL;
136 slens[1] = 0; 132 slens[1] = 0;
137 sched = tc->sched;
138 memset (&sa, 0, sizeof (sa)); 133 memset (&sa, 0, sizeof (sa));
139#if HAVE_SOCKADDR_IN_SIN_LEN 134#if HAVE_SOCKADDR_IN_SIN_LEN
140 sa.sin_len = sizeof (sa); 135 sa.sin_len = sizeof (sa);
141#endif 136#endif
142 sa.sin_family = AF_INET; 137 sa.sin_family = AF_INET;
143 sa.sin_port = htons (PORT); 138 sa.sin_port = htons (PORT);
144 server = GNUNET_SERVER_create (tc->sched, 139 server = GNUNET_SERVER_create (NULL,
145 NULL,
146 NULL, 140 NULL,
147 sap, 141 sap,
148 slens, 142 slens,
@@ -155,8 +149,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
155 GNUNET_CONFIGURATION_set_value_number (cfg, "test-server", "PORT", PORT); 149 GNUNET_CONFIGURATION_set_value_number (cfg, "test-server", "PORT", PORT);
156 GNUNET_CONFIGURATION_set_value_string (cfg, "test-server", "HOSTNAME", "localhost"); 150 GNUNET_CONFIGURATION_set_value_string (cfg, "test-server", "HOSTNAME", "localhost");
157 GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", "localhost"); 151 GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", "localhost");
158 cc = GNUNET_CLIENT_connect (tc->sched, 152 cc = GNUNET_CLIENT_connect ("test-server",
159 "test-server",
160 cfg); 153 cfg);
161 GNUNET_assert (cc != NULL); 154 GNUNET_assert (cc != NULL);
162 GNUNET_assert (NULL != 155 GNUNET_assert (NULL !=
diff --git a/src/util/test_server_with_client.c b/src/util/test_server_with_client.c
index 4157be250..5c36b7b03 100644
--- a/src/util/test_server_with_client.c
+++ b/src/util/test_server_with_client.c
@@ -41,8 +41,6 @@ static struct GNUNET_SERVER_Handle *server;
41 41
42static struct GNUNET_CLIENT_Connection *client; 42static struct GNUNET_CLIENT_Connection *client;
43 43
44static struct GNUNET_SCHEDULER_Handle *sched;
45
46static struct GNUNET_CONFIGURATION_Handle *cfg; 44static struct GNUNET_CONFIGURATION_Handle *cfg;
47 45
48static int ok; 46static int ok;
@@ -86,8 +84,7 @@ recv_cb (void *cls,
86 { 84 {
87 case 2: 85 case 2:
88 ok++; 86 ok++;
89 GNUNET_SCHEDULER_add_delayed (sched, 87 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
90 GNUNET_TIME_relative_multiply
91 (GNUNET_TIME_UNIT_MILLISECONDS, 50), 88 (GNUNET_TIME_UNIT_MILLISECONDS, 50),
92 &send_done, argclient); 89 &send_done, argclient);
93 break; 90 break;
@@ -127,8 +124,7 @@ notify_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
127 return; 124 return;
128 GNUNET_assert (ok == 5); 125 GNUNET_assert (ok == 5);
129 ok = 0; 126 ok = 0;
130 GNUNET_SCHEDULER_add_now (sched, 127 GNUNET_SCHEDULER_add_now (&clean_up, NULL);
131 &clean_up, NULL);
132} 128}
133 129
134 130
@@ -167,15 +163,13 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
167 slens[0] = sizeof (sa); 163 slens[0] = sizeof (sa);
168 sap[1] = NULL; 164 sap[1] = NULL;
169 slens[1] = 0; 165 slens[1] = 0;
170 sched = tc->sched;
171 memset (&sa, 0, sizeof (sa)); 166 memset (&sa, 0, sizeof (sa));
172#if HAVE_SOCKADDR_IN_SIN_LEN 167#if HAVE_SOCKADDR_IN_SIN_LEN
173 sa.sin_len = sizeof (sa); 168 sa.sin_len = sizeof (sa);
174#endif 169#endif
175 sa.sin_family = AF_INET; 170 sa.sin_family = AF_INET;
176 sa.sin_port = htons (PORT); 171 sa.sin_port = htons (PORT);
177 server = GNUNET_SERVER_create (tc->sched, 172 server = GNUNET_SERVER_create (NULL,
178 NULL,
179 NULL, 173 NULL,
180 sap, 174 sap,
181 slens, 175 slens,
@@ -192,7 +186,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
192 "localhost"); 186 "localhost");
193 GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", 187 GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME",
194 "localhost"); 188 "localhost");
195 client = GNUNET_CLIENT_connect (tc->sched, "test", cfg); 189 client = GNUNET_CLIENT_connect ("test", cfg);
196 GNUNET_assert (client != NULL); 190 GNUNET_assert (client != NULL);
197 GNUNET_CLIENT_notify_transmit_ready (client, 191 GNUNET_CLIENT_notify_transmit_ready (client,
198 256, 192 256,
diff --git a/src/util/test_service.c b/src/util/test_service.c
index 6c78a4eb9..9bd58352b 100644
--- a/src/util/test_service.c
+++ b/src/util/test_service.c
@@ -37,8 +37,6 @@
37 37
38#define MY_TYPE 256 38#define MY_TYPE 256
39 39
40static struct GNUNET_SCHEDULER_Handle *sched;
41
42static struct GNUNET_SERVICE_Context *sctx; 40static struct GNUNET_SERVICE_Context *sctx;
43 41
44static int ok = 1; 42static int ok = 1;
@@ -67,8 +65,7 @@ ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
67 65
68 GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); 66 GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE));
69 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service confirmed running\n"); 67 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service confirmed running\n");
70 sched = tc->sched; 68 client = GNUNET_CLIENT_connect ("test_service", cfg);
71 client = GNUNET_CLIENT_connect (tc->sched, "test_service", cfg);
72 GNUNET_assert (client != NULL); 69 GNUNET_assert (client != NULL);
73 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 70 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
74 "Client connecting, waiting to transmit\n"); 71 "Client connecting, waiting to transmit\n");
@@ -94,9 +91,9 @@ recv_cb (void *cls,
94 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving client message...\n"); 91 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving client message...\n");
95 GNUNET_SERVER_receive_done (client, GNUNET_OK); 92 GNUNET_SERVER_receive_done (client, GNUNET_OK);
96 if (sctx != NULL) 93 if (sctx != NULL)
97 GNUNET_SCHEDULER_add_now (sched, &do_stop, NULL); 94 GNUNET_SCHEDULER_add_now (&do_stop, NULL);
98 else 95 else
99 GNUNET_SCHEDULER_shutdown (sched); 96 GNUNET_SCHEDULER_shutdown ();
100 ok = 0; 97 ok = 0;
101} 98}
102 99
@@ -110,14 +107,12 @@ static struct GNUNET_SERVER_MessageHandler myhandlers[] = {
110 107
111static void 108static void
112runner (void *cls, 109runner (void *cls,
113 struct GNUNET_SCHEDULER_Handle *sched,
114 struct GNUNET_SERVER_Handle *server, 110 struct GNUNET_SERVER_Handle *server,
115 const struct GNUNET_CONFIGURATION_Handle *cfg) 111 const struct GNUNET_CONFIGURATION_Handle *cfg)
116{ 112{
117 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service initializing\n"); 113 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service initializing\n");
118 GNUNET_SERVER_add_handlers (server, myhandlers); 114 GNUNET_SERVER_add_handlers (server, myhandlers);
119 GNUNET_CLIENT_service_test (sched, 115 GNUNET_CLIENT_service_test ("test_service",
120 "test_service",
121 cfg, GNUNET_TIME_UNIT_SECONDS, &ready, 116 cfg, GNUNET_TIME_UNIT_SECONDS, &ready,
122 (void *) cfg); 117 (void *) cfg);
123} 118}
@@ -161,9 +156,8 @@ ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
161 struct GNUNET_CLIENT_Connection *client; 156 struct GNUNET_CLIENT_Connection *client;
162 157
163 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 ready\n"); 158 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 ready\n");
164 sched = tc->sched;
165 GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); 159 GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE));
166 client = GNUNET_CLIENT_connect (tc->sched, "test_service6", cfg); 160 client = GNUNET_CLIENT_connect ("test_service6", cfg);
167 GNUNET_assert (client != NULL); 161 GNUNET_assert (client != NULL);
168 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 client connected\n"); 162 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 client connected\n");
169 GNUNET_CLIENT_notify_transmit_ready (client, 163 GNUNET_CLIENT_notify_transmit_ready (client,
@@ -174,14 +168,12 @@ ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
174 168
175static void 169static void
176runner6 (void *cls, 170runner6 (void *cls,
177 struct GNUNET_SCHEDULER_Handle *sched,
178 struct GNUNET_SERVER_Handle *server, 171 struct GNUNET_SERVER_Handle *server,
179 const struct GNUNET_CONFIGURATION_Handle *cfg) 172 const struct GNUNET_CONFIGURATION_Handle *cfg)
180{ 173{
181 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initializing v6 service\n"); 174 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initializing v6 service\n");
182 GNUNET_SERVER_add_handlers (server, myhandlers); 175 GNUNET_SERVER_add_handlers (server, myhandlers);
183 GNUNET_CLIENT_service_test (sched, 176 GNUNET_CLIENT_service_test ("test_service6",
184 "test_service6",
185 cfg, GNUNET_TIME_UNIT_SECONDS, &ready6, 177 cfg, GNUNET_TIME_UNIT_SECONDS, &ready6,
186 (void *) cfg); 178 (void *) cfg);
187} 179}
@@ -220,7 +212,6 @@ check6 ()
220 212
221static void 213static void
222start_stop_main (void *cls, 214start_stop_main (void *cls,
223 struct GNUNET_SCHEDULER_Handle *sched,
224 char *const *args, 215 char *const *args,
225 const char *cfgfile, 216 const char *cfgfile,
226 const struct GNUNET_CONFIGURATION_Handle *cfg) 217 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -228,9 +219,9 @@ start_stop_main (void *cls,
228 int *ret = cls; 219 int *ret = cls;
229 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 220 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
230 "Starting service using start method\n"); 221 "Starting service using start method\n");
231 sctx = GNUNET_SERVICE_start ("test_service", sched, cfg); 222 sctx = GNUNET_SERVICE_start ("test_service", cfg);
232 GNUNET_assert (NULL != sctx); 223 GNUNET_assert (NULL != sctx);
233 runner (cls, sched, GNUNET_SERVICE_get_server (sctx), cfg); 224 runner (cls, GNUNET_SERVICE_get_server (sctx), cfg);
234 *ret = 0; 225 *ret = 0;
235} 226}
236 227
diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c
index d4ff33b9c..f6a20f8a6 100644
--- a/src/vpn/gnunet-daemon-vpn.c
+++ b/src/vpn/gnunet-daemon-vpn.c
@@ -21,7 +21,7 @@
21/** 21/**
22 * @file vpn/gnunet-daemon-vpn.c 22 * @file vpn/gnunet-daemon-vpn.c
23 * @brief 23 * @brief
24 * @author Philipp Tölke 24 * @author Philipp Toelke
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_getopt_lib.h" 27#include "gnunet_getopt_lib.h"
@@ -44,11 +44,6 @@
44static int ret; 44static int ret;
45 45
46/** 46/**
47 * The scheduler to use throughout the daemon
48 */
49static struct GNUNET_SCHEDULER_Handle *sched;
50
51/**
52 * The configuration to use 47 * The configuration to use
53 */ 48 */
54static const struct GNUNET_CONFIGURATION_Handle *cfg; 49static const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -222,7 +217,7 @@ start_helper_and_schedule(void *cls,
222 restart_hijack = 1; 217 restart_hijack = 1;
223 GNUNET_CLIENT_notify_transmit_ready(dns_connection, sizeof(struct GNUNET_MessageHeader), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, NULL); 218 GNUNET_CLIENT_notify_transmit_ready(dns_connection, sizeof(struct GNUNET_MessageHeader), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, NULL);
224 219
225 GNUNET_SCHEDULER_add_read_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, fh_from_helper, &helper_read, NULL); 220 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, fh_from_helper, &helper_read, NULL);
226} 221}
227 222
228/** 223/**
@@ -240,7 +235,7 @@ restart_helper(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) {
240 GNUNET_DISK_pipe_close(helper_out); 235 GNUNET_DISK_pipe_close(helper_out);
241 236
242 /* Restart the helper */ 237 /* Restart the helper */
243 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_UNIT_SECONDS, start_helper_and_schedule, NULL); 238 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, start_helper_and_schedule, NULL);
244} 239}
245 240
246/** 241/**
@@ -259,13 +254,13 @@ helper_read(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tsdkctx) {
259 /* On read-error, restart the helper */ 254 /* On read-error, restart the helper */
260 if (t<=0) { 255 if (t<=0) {
261 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Read error for header from vpn-helper: %m\n"); 256 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Read error for header from vpn-helper: %m\n");
262 GNUNET_SCHEDULER_add_now(sched, restart_helper, cls); 257 GNUNET_SCHEDULER_add_now(restart_helper, cls);
263 return; 258 return;
264 } 259 }
265 260
266 /* FIXME */ GNUNET_SERVER_mst_receive(mst, NULL, buf, t, 0, 0); 261 /* FIXME */ GNUNET_SERVER_mst_receive(mst, NULL, buf, t, 0, 0);
267 262
268 GNUNET_SCHEDULER_add_read_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, fh_from_helper, &helper_read, NULL); 263 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, fh_from_helper, &helper_read, NULL);
269} 264}
270 265
271/** 266/**
@@ -343,8 +338,7 @@ helper_write(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tsdkctx) {
343 338
344 /* if more packets are available, reschedule */ 339 /* if more packets are available, reschedule */
345 if (answer_proc_head != NULL) 340 if (answer_proc_head != NULL)
346 GNUNET_SCHEDULER_add_write_file (sched, 341 GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL,
347 GNUNET_TIME_UNIT_FOREVER_REL,
348 fh_to_helper, 342 fh_to_helper,
349 &helper_write, 343 &helper_write,
350 NULL); 344 NULL);
@@ -429,7 +423,7 @@ message_token(void *cls,
429 memcpy(pkt6_icmp, pkt6, ntohs(pkt6->shdr.size)); 423 memcpy(pkt6_icmp, pkt6, ntohs(pkt6->shdr.size));
430 /* If this packet is an icmp-echo-request and a mapping exists, answer */ 424 /* If this packet is an icmp-echo-request and a mapping exists, answer */
431 if (pkt6_icmp->icmp_hdr.type == 0x80 && address_mapping_exists(pkt6->ip6_hdr.sadr)) 425 if (pkt6_icmp->icmp_hdr.type == 0x80 && address_mapping_exists(pkt6->ip6_hdr.sadr))
432 GNUNET_SCHEDULER_add_now(sched, &send_icmp_response, pkt6_icmp); 426 GNUNET_SCHEDULER_add_now(&send_icmp_response, pkt6_icmp);
433 break; 427 break;
434 } 428 }
435 } 429 }
@@ -477,7 +471,7 @@ connect_to_service_dns (void *cls,
477 return; 471 return;
478 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connecting to service-dns\n"); 472 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connecting to service-dns\n");
479 GNUNET_assert (dns_connection == NULL); 473 GNUNET_assert (dns_connection == NULL);
480 dns_connection = GNUNET_CLIENT_connect (sched, "dns", cfg); 474 dns_connection = GNUNET_CLIENT_connect ("dns", cfg);
481 GNUNET_CLIENT_receive(dns_connection, &dns_answer_handler, NULL, GNUNET_TIME_UNIT_FOREVER_REL); 475 GNUNET_CLIENT_receive(dns_connection, &dns_answer_handler, NULL, GNUNET_TIME_UNIT_FOREVER_REL);
482 476
483 /* If a packet is already in the list, schedule to send it */ 477 /* If a packet is already in the list, schedule to send it */
@@ -565,7 +559,7 @@ process_answer(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tc) {
565 559
566 GNUNET_CONTAINER_DLL_insert_after(answer_proc_head, answer_proc_tail, answer_proc_tail, list); 560 GNUNET_CONTAINER_DLL_insert_after(answer_proc_head, answer_proc_tail, answer_proc_tail, list);
567 561
568 GNUNET_SCHEDULER_add_write_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, fh_to_helper, &helper_write, NULL); 562 GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, fh_to_helper, &helper_write, NULL);
569 563
570 return; 564 return;
571} 565}
@@ -581,8 +575,7 @@ dns_answer_handler(void* cls, const struct GNUNET_MessageHeader *msg) {
581 { 575 {
582 GNUNET_CLIENT_disconnect(dns_connection, GNUNET_NO); 576 GNUNET_CLIENT_disconnect(dns_connection, GNUNET_NO);
583 dns_connection = NULL; 577 dns_connection = NULL;
584 GNUNET_SCHEDULER_add_delayed (sched, 578 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
585 GNUNET_TIME_UNIT_SECONDS,
586 &connect_to_service_dns, 579 &connect_to_service_dns,
587 NULL); 580 NULL);
588 return; 581 return;
@@ -594,8 +587,7 @@ dns_answer_handler(void* cls, const struct GNUNET_MessageHeader *msg) {
594 GNUNET_break (0); 587 GNUNET_break (0);
595 GNUNET_CLIENT_disconnect(dns_connection, GNUNET_NO); 588 GNUNET_CLIENT_disconnect(dns_connection, GNUNET_NO);
596 dns_connection = NULL; 589 dns_connection = NULL;
597 GNUNET_SCHEDULER_add_now (sched, 590 GNUNET_SCHEDULER_add_now (&connect_to_service_dns,
598 &connect_to_service_dns,
599 NULL); 591 NULL);
600 return; 592 return;
601 } 593 }
@@ -603,7 +595,7 @@ dns_answer_handler(void* cls, const struct GNUNET_MessageHeader *msg) {
603 595
604 memcpy(pkt, msg, ntohs(msg->size)); 596 memcpy(pkt, msg, ntohs(msg->size));
605 597
606 GNUNET_SCHEDULER_add_now(sched, process_answer, pkt); 598 GNUNET_SCHEDULER_add_now(process_answer, pkt);
607 GNUNET_CLIENT_receive(dns_connection, &dns_answer_handler, NULL, GNUNET_TIME_UNIT_FOREVER_REL); 599 GNUNET_CLIENT_receive(dns_connection, &dns_answer_handler, NULL, GNUNET_TIME_UNIT_FOREVER_REL);
608} 600}
609 601
@@ -611,24 +603,21 @@ dns_answer_handler(void* cls, const struct GNUNET_MessageHeader *msg) {
611 * Main function that will be run by the scheduler. 603 * Main function that will be run by the scheduler.
612 * 604 *
613 * @param cls closure 605 * @param cls closure
614 * @param sched the scheduler to use
615 * @param args remaining command-line arguments 606 * @param args remaining command-line arguments
616 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 607 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
617 * @param cfg configuration 608 * @param cfg configuration
618 */ 609 */
619static void 610static void
620run (void *cls, 611run (void *cls,
621 struct GNUNET_SCHEDULER_Handle *sched_,
622 char *const *args, 612 char *const *args,
623 const char *cfgfile, 613 const char *cfgfile,
624 const struct GNUNET_CONFIGURATION_Handle *cfg_) { 614 const struct GNUNET_CONFIGURATION_Handle *cfg_) {
625 sched = sched_;
626 mst = GNUNET_SERVER_mst_create(&message_token, NULL); 615 mst = GNUNET_SERVER_mst_create(&message_token, NULL);
627 cfg = cfg_; 616 cfg = cfg_;
628 restart_hijack = 0; 617 restart_hijack = 0;
629 GNUNET_SCHEDULER_add_now (sched, connect_to_service_dns, NULL); 618 GNUNET_SCHEDULER_add_now (connect_to_service_dns, NULL);
630 GNUNET_SCHEDULER_add_now (sched, start_helper_and_schedule, NULL); 619 GNUNET_SCHEDULER_add_now (start_helper_and_schedule, NULL);
631 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls); 620 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls);
632} 621}
633 622
634/** 623/**
diff --git a/src/vpn/gnunet-service-dns.c b/src/vpn/gnunet-service-dns.c
index 7997112c4..f8b1209e9 100644
--- a/src/vpn/gnunet-service-dns.c
+++ b/src/vpn/gnunet-service-dns.c
@@ -39,10 +39,6 @@
39#include "gnunet_crypto_lib.h" 39#include "gnunet_crypto_lib.h"
40#include "gnunet_signatures.h" 40#include "gnunet_signatures.h"
41 41
42/**
43 * The scheduler to use throughout the service
44 */
45static struct GNUNET_SCHEDULER_Handle *sched;
46 42
47/** 43/**
48 * The UDP-Socket through which DNS-Resolves will be sent if they are not to be 44 * The UDP-Socket through which DNS-Resolves will be sent if they are not to be
@@ -107,17 +103,17 @@ struct receive_dht_cls {
107 * Hijack all outgoing DNS-Traffic but for traffic leaving "our" port. 103 * Hijack all outgoing DNS-Traffic but for traffic leaving "our" port.
108 */ 104 */
109static void 105static void
110hijack(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tc) { 106hijack(unsigned short port) {
111 char port_s[6]; 107 char port_s[6];
112 108
113 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Hijacking, port is %d\n", dnsoutport); 109 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Hijacking, port is %d\n", port);
114 snprintf(port_s, 6, "%d", dnsoutport); 110 snprintf(port_s, 6, "%d", port);
115 GNUNET_OS_process_close (GNUNET_OS_start_process(NULL, 111 GNUNET_OS_start_process(NULL,
116 NULL, 112 NULL,
117 "gnunet-helper-hijack-dns", 113 "gnunet-helper-hijack-dns",
118 "gnunet-hijack-dns", 114 "gnunet-hijack-dns",
119 port_s, 115 port_s,
120 NULL)); 116 NULL);
121} 117}
122 118
123/** 119/**
@@ -166,81 +162,6 @@ send_answer(void* cls, size_t size, void* buf) {
166 return len; 162 return len;
167} 163}
168 164
169static void
170send_rev_query(void * cls, const struct GNUNET_SCHEDULER_TaskContext *tc) {
171 struct dns_pkt_parsed* pdns = (struct dns_pkt_parsed*) cls;
172
173 unsigned short id = pdns->s.id;
174
175 if (query_states[id].valid != GNUNET_YES) return;
176 query_states[id].valid = GNUNET_NO;
177
178 GNUNET_assert(query_states[id].namelen == 74);
179
180 size_t len = sizeof(struct answer_packet) - 1 \
181 + sizeof(struct dns_static) \
182 + 74 /* this is the length of a reverse ipv6-lookup */ \
183 + sizeof(struct dns_query_line) \
184 + 2 /* To hold the pointer (as defined in RFC1035) to the name */ \
185 + sizeof(struct dns_record_line) - 1 \
186 - 2 /* We do not know the lenght of the answer yet*/ \
187 - 2 /* No idea why... */ ;
188
189 struct answer_packet_list* answer = GNUNET_malloc(len + 2*sizeof(struct answer_packet_list*));
190 memset(answer, 0, len + 2*sizeof(struct answer_packet_list*));
191
192 answer->pkt.hdr.type = htons(GNUNET_MESSAGE_TYPE_LOCAL_RESPONSE_DNS);
193 answer->pkt.hdr.size = htons(len);
194 answer->pkt.subtype = GNUNET_DNS_ANSWER_TYPE_REV;
195
196 answer->pkt.from = query_states[id].remote_ip;
197
198 answer->pkt.to = query_states[id].local_ip;
199 answer->pkt.dst_port = query_states[id].local_port;
200
201 struct dns_pkt *dpkt = (struct dns_pkt*)answer->pkt.data;
202
203 dpkt->s.id = id;
204 dpkt->s.aa = 1;
205 dpkt->s.qr = 1;
206 dpkt->s.ra = 1;
207 dpkt->s.qdcount = htons(1);
208 dpkt->s.ancount = htons(1);
209
210 memcpy(dpkt->data, query_states[id].name, query_states[id].namelen);
211 GNUNET_free(query_states[id].name);
212
213 struct dns_query_line* dque = (struct dns_query_line*)(dpkt->data+(query_states[id].namelen));
214 dque->type = htons(12); /* PTR */
215 dque->class = htons(1); /* IN */
216
217 char* anname = (char*)(dpkt->data+(query_states[id].namelen)+sizeof(struct dns_query_line));
218 memcpy(anname, (char[]){0xc0, 0x0c}, 2);
219
220 struct dns_record_line *drec_data = (struct dns_record_line*)(dpkt->data+(query_states[id].namelen)+sizeof(struct dns_query_line)+2);
221 drec_data->type = htons(12); /* AAAA */
222 drec_data->class = htons(1); /* IN */
223 drec_data->ttl = htonl(3600); /* FIXME: read from block */
224
225 /* Calculate at which offset in the packet the length of the name and the
226 * name, it is filled in by the daemon-vpn */
227 answer->pkt.addroffset = htons((unsigned short)((unsigned long)(&drec_data->data_len)-(unsigned long)(&answer->pkt)));
228
229 GNUNET_CONTAINER_DLL_insert_after(head, tail, tail, answer);
230
231 GNUNET_SERVER_notify_transmit_ready(query_states[id].client,
232 len,
233 GNUNET_TIME_UNIT_FOREVER_REL,
234 &send_answer,
235 query_states[id].client);
236
237 /*
238 * build
239 * complete dns-packet with empty name in the answer
240 * provide offsett of the name
241 */
242}
243
244/** 165/**
245 * Receive a block from the dht. 166 * Receive a block from the dht.
246 */ 167 */
@@ -315,6 +236,7 @@ receive_dht(void *cls,
315 memcpy(dpkt->data, query_states[id].name, query_states[id].namelen); 236 memcpy(dpkt->data, query_states[id].name, query_states[id].namelen);
316 GNUNET_free(query_states[id].name); 237 GNUNET_free(query_states[id].name);
317 238
239
318 struct dns_query_line* dque = (struct dns_query_line*)(dpkt->data+(query_states[id].namelen)); 240 struct dns_query_line* dque = (struct dns_query_line*)(dpkt->data+(query_states[id].namelen));
319 dque->type = htons(28); /* AAAA */ 241 dque->type = htons(28); /* AAAA */
320 dque->class = htons(1); /* IN */ 242 dque->class = htons(1); /* IN */
@@ -351,9 +273,7 @@ rehijack(void *cls,
351 struct GNUNET_SERVER_Client *client, 273 struct GNUNET_SERVER_Client *client,
352 const struct GNUNET_MessageHeader *message) { 274 const struct GNUNET_MessageHeader *message) {
353 unhijack(dnsoutport); 275 unhijack(dnsoutport);
354 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_UNIT_SECONDS, hijack, NULL); 276 hijack(dnsoutport);
355
356 GNUNET_SERVER_receive_done(client, GNUNET_OK);
357} 277}
358 278
359/** 279/**
@@ -376,7 +296,6 @@ receive_query(void *cls,
376 query_states[dns->s.id].name = GNUNET_malloc(query_states[dns->s.id].namelen); 296 query_states[dns->s.id].name = GNUNET_malloc(query_states[dns->s.id].namelen);
377 memcpy(query_states[dns->s.id].name, dns->data, query_states[dns->s.id].namelen); 297 memcpy(query_states[dns->s.id].name, dns->data, query_states[dns->s.id].namelen);
378 298
379 /* The query is for a .gnunet-address */
380 if (pdns->queries[0]->namelen > 9 && 299 if (pdns->queries[0]->namelen > 9 &&
381 0 == strncmp(pdns->queries[0]->name+(pdns->queries[0]->namelen - 9), ".gnunet.", 9)) 300 0 == strncmp(pdns->queries[0]->name+(pdns->queries[0]->namelen - 9), ".gnunet.", 9))
382 { 301 {
@@ -404,18 +323,6 @@ receive_query(void *cls,
404 receive_dht, 323 receive_dht,
405 cls); 324 cls);
406 325
407 goto outfree;
408 }
409
410 /* The query is for a PTR of a previosly resolved virtual IP */
411 if (htons(pdns->queries[0]->qtype) == 12 &&
412 pdns->queries[0]->namelen > 19 &&
413 0 == strncmp(pdns->queries[0]->name+(pdns->queries[0]->namelen - 19), ".4.3.2.1.ip6.arpa.", 19))
414 {
415 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Reverse-Query for .gnunet!\n");
416
417 GNUNET_SCHEDULER_add_now(sched, send_rev_query, pdns);
418
419 goto out; 326 goto out;
420 } 327 }
421 328
@@ -432,10 +339,9 @@ receive_query(void *cls,
432 (struct sockaddr*) &dest, 339 (struct sockaddr*) &dest,
433 sizeof dest); 340 sizeof dest);
434 341
435outfree: 342out:
436 free_parsed_dns_packet(pdns); 343 free_parsed_dns_packet(pdns);
437 pdns = NULL; 344 pdns = NULL;
438out:
439 GNUNET_SERVER_receive_done(client, GNUNET_OK); 345 GNUNET_SERVER_receive_done(client, GNUNET_OK);
440} 346}
441 347
@@ -485,8 +391,7 @@ read_response (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) {
485 query_states[dns->s.id].client); 391 query_states[dns->s.id].client);
486 } 392 }
487 393
488 GNUNET_SCHEDULER_add_read_net(sched, 394 GNUNET_SCHEDULER_add_read_net(GNUNET_TIME_UNIT_FOREVER_REL,
489 GNUNET_TIME_UNIT_FOREVER_REL,
490 dnsout, 395 dnsout,
491 &read_response, 396 &read_response,
492 NULL); 397 NULL);
@@ -567,21 +472,18 @@ publish_name (void *cls,
567 NULL, 472 NULL,
568 NULL); 473 NULL);
569 474
570 GNUNET_SCHEDULER_add_delayed (sched, 475 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_HOURS,
571 GNUNET_TIME_UNIT_HOURS,
572 publish_name, 476 publish_name,
573 NULL); 477 NULL);
574} 478}
575 479
576/** 480/**
577 * @param cls closure 481 * @param cls closure
578 * @param sched scheduler to use
579 * @param server the initialized server 482 * @param server the initialized server
580 * @param cfg configuration to use 483 * @param cfg configuration to use
581 */ 484 */
582static void 485static void
583run (void *cls, 486run (void *cls,
584 struct GNUNET_SCHEDULER_Handle *sched_,
585 struct GNUNET_SERVER_Handle *server, 487 struct GNUNET_SERVER_Handle *server,
586 const struct GNUNET_CONFIGURATION_Handle *cfg_) 488 const struct GNUNET_CONFIGURATION_Handle *cfg_)
587{ 489{
@@ -593,14 +495,13 @@ run (void *cls,
593 }; 495 };
594 496
595 cfg = cfg_; 497 cfg = cfg_;
596 sched = sched_;
597 498
598 unsigned int i; 499 unsigned int i;
599 for (i = 0; i < 65536; i++) { 500 for (i = 0; i < 65536; i++) {
600 query_states[i].valid = GNUNET_NO; 501 query_states[i].valid = GNUNET_NO;
601 } 502 }
602 503
603 dht = GNUNET_DHT_connect(sched, cfg, 1024); 504 dht = GNUNET_DHT_connect(cfg, 1024);
604 505
605 struct sockaddr_in addr; 506 struct sockaddr_in addr;
606 507
@@ -626,13 +527,14 @@ run (void *cls,
626 527
627 dnsoutport = htons(addr.sin_port); 528 dnsoutport = htons(addr.sin_port);
628 529
629 GNUNET_SCHEDULER_add_now (sched, publish_name, NULL); 530 hijack(htons(addr.sin_port));
531
532 GNUNET_SCHEDULER_add_now (publish_name, NULL);
630 533
631 GNUNET_SCHEDULER_add_read_net(sched, GNUNET_TIME_UNIT_FOREVER_REL, dnsout, &read_response, NULL); 534 GNUNET_SCHEDULER_add_read_net(GNUNET_TIME_UNIT_FOREVER_REL, dnsout, &read_response, NULL);
632 535
633 GNUNET_SERVER_add_handlers (server, handlers); 536 GNUNET_SERVER_add_handlers (server, handlers);
634 GNUNET_SCHEDULER_add_delayed (sched, 537 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
635 GNUNET_TIME_UNIT_FOREVER_REL,
636 &cleanup_task, 538 &cleanup_task,
637 cls); 539 cls);
638} 540}