aboutsummaryrefslogtreecommitdiff
path: root/src/datastore
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-11-05 18:21:50 +0000
committerNathan S. Evans <evans@in.tum.de>2010-11-05 18:21:50 +0000
commit75a33a1499cf60ea4364c9aa673816629a6c1413 (patch)
tree0620da4312bb04de4d7b65074fdd3b0c3dd6cc0e /src/datastore
parent7217c601ad30760872823193d62307e7a335d226 (diff)
downloadgnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.tar.gz
gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.zip
big scheduler refactoring, expect some issues
Diffstat (limited to 'src/datastore')
-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
10 files changed, 50 insertions, 124 deletions
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",