aboutsummaryrefslogtreecommitdiff
path: root/src/datastore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-04-09 23:14:03 +0000
committerChristian Grothoff <christian@grothoff.org>2016-04-09 23:14:03 +0000
commit29e6158507a0758192075ac6ece7ba8e75ddc49a (patch)
treeb91ded48da322f8ba4c9bb0f5504228aa036c2d1 /src/datastore
parent5dfcb058ab5db9ae0c4b147d8a99c64ca0980028 (diff)
downloadgnunet-29e6158507a0758192075ac6ece7ba8e75ddc49a.tar.gz
gnunet-29e6158507a0758192075ac6ece7ba8e75ddc49a.zip
small API change: do no longer pass rarely needed GNUNET_SCHEDULER_TaskContext to all scheduler tasks; instead, allow the relatively few tasks that need it to obtain the context via GNUNET_SCHEDULER_get_task_context()
Diffstat (limited to 'src/datastore')
-rw-r--r--src/datastore/datastore_api.c10
-rw-r--r--src/datastore/gnunet-datastore.c3
-rw-r--r--src/datastore/gnunet-service-datastore.c10
-rw-r--r--src/datastore/perf_datastore_api.c10
-rw-r--r--src/datastore/perf_plugin_datastore.c13
-rw-r--r--src/datastore/test_datastore_api.c8
-rw-r--r--src/datastore/test_datastore_api_management.c4
-rw-r--r--src/datastore/test_plugin_datastore.c27
8 files changed, 36 insertions, 49 deletions
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
index cca67f6bc..832829e24 100644
--- a/src/datastore/datastore_api.c
+++ b/src/datastore/datastore_api.c
@@ -278,11 +278,9 @@ GNUNET_DATASTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
278 * Task used by 'transmit_drop' to disconnect the datastore. 278 * Task used by 'transmit_drop' to disconnect the datastore.
279 * 279 *
280 * @param cls the datastore handle 280 * @param cls the datastore handle
281 * @param tc scheduler context
282 */ 281 */
283static void 282static void
284disconnect_after_drop (void *cls, 283disconnect_after_drop (void *cls)
285 const struct GNUNET_SCHEDULER_TaskContext *tc)
286{ 284{
287 struct GNUNET_DATASTORE_Handle *h = cls; 285 struct GNUNET_DATASTORE_Handle *h = cls;
288 286
@@ -383,10 +381,9 @@ GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h,
383 * A request has timed out (before being transmitted to the service). 381 * A request has timed out (before being transmitted to the service).
384 * 382 *
385 * @param cls the `struct GNUNET_DATASTORE_QueueEntry` 383 * @param cls the `struct GNUNET_DATASTORE_QueueEntry`
386 * @param tc scheduler context
387 */ 384 */
388static void 385static void
389timeout_queue_entry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 386timeout_queue_entry (void *cls)
390{ 387{
391 struct GNUNET_DATASTORE_QueueEntry *qe = cls; 388 struct GNUNET_DATASTORE_QueueEntry *qe = cls;
392 struct GNUNET_DATASTORE_Handle *h = qe->h; 389 struct GNUNET_DATASTORE_Handle *h = qe->h;
@@ -520,10 +517,9 @@ process_queue (struct GNUNET_DATASTORE_Handle *h);
520 * Try reconnecting to the datastore service. 517 * Try reconnecting to the datastore service.
521 * 518 *
522 * @param cls the `struct GNUNET_DATASTORE_Handle` 519 * @param cls the `struct GNUNET_DATASTORE_Handle`
523 * @param tc scheduler context
524 */ 520 */
525static void 521static void
526try_reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 522try_reconnect (void *cls)
527{ 523{
528 struct GNUNET_DATASTORE_Handle *h = cls; 524 struct GNUNET_DATASTORE_Handle *h = cls;
529 525
diff --git a/src/datastore/gnunet-datastore.c b/src/datastore/gnunet-datastore.c
index 93c23c3fc..186889e4c 100644
--- a/src/datastore/gnunet-datastore.c
+++ b/src/datastore/gnunet-datastore.c
@@ -70,8 +70,7 @@ static struct GNUNET_DATASTORE_QueueEntry *qe;
70 70
71 71
72static void 72static void
73do_shutdown (void *cls, 73do_shutdown (void *cls)
74 const struct GNUNET_SCHEDULER_TaskContext *tc)
75{ 74{
76 if (NULL != qe) 75 if (NULL != qe)
77 GNUNET_DATASTORE_cancel (qe); 76 GNUNET_DATASTORE_cancel (qe);
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index 4979f4482..fdccd925e 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -303,11 +303,9 @@ static struct GNUNET_SERVER_Handle *server;
303 * content quickly. 303 * content quickly.
304 * 304 *
305 * @param cls not used 305 * @param cls not used
306 * @param tc task context
307 */ 306 */
308static void 307static void
309delete_expired (void *cls, 308delete_expired (void *cls);
310 const struct GNUNET_SCHEDULER_TaskContext *tc);
311 309
312 310
313/** 311/**
@@ -388,10 +386,9 @@ expired_processor (void *cls,
388 * content quickly. 386 * content quickly.
389 * 387 *
390 * @param cls not used 388 * @param cls not used
391 * @param tc task context
392 */ 389 */
393static void 390static void
394delete_expired (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 391delete_expired (void *cls)
395{ 392{
396 expired_kill_task = NULL; 393 expired_kill_task = NULL;
397 plugin->api->get_expiration (plugin->api->cls, &expired_processor, NULL); 394 plugin->api->get_expiration (plugin->api->cls, &expired_processor, NULL);
@@ -1579,8 +1576,7 @@ process_stat_done (void *cls,
1579 * Task run during shutdown. 1576 * Task run during shutdown.
1580 */ 1577 */
1581static void 1578static void
1582cleaning_task (void *cls, 1579cleaning_task (void *cls)
1583 const struct GNUNET_SCHEDULER_TaskContext *tc)
1584{ 1580{
1585 struct TransmitCallbackContext *tcc; 1581 struct TransmitCallbackContext *tcc;
1586 1582
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c
index e430bfe93..41cac1283 100644
--- a/src/datastore/perf_datastore_api.c
+++ b/src/datastore/perf_datastore_api.c
@@ -186,11 +186,9 @@ struct CpsRunContext
186 * depending on the current state. 186 * depending on the current state.
187 * 187 *
188 * @param cls the `struct CpsRunContext` 188 * @param cls the `struct CpsRunContext`
189 * @param tc scheduler context (unused)
190 */ 189 */
191static void 190static void
192run_continuation (void *cls, 191run_continuation (void *cls);
193 const struct GNUNET_SCHEDULER_TaskContext *tc);
194 192
195 193
196/** 194/**
@@ -344,18 +342,18 @@ delete_value (void *cls,
344 * depending on the current state. 342 * depending on the current state.
345 * 343 *
346 * @param cls the `struct CpsRunContext` 344 * @param cls the `struct CpsRunContext`
347 * @param tc scheduler context (unused)
348 */ 345 */
349static void 346static void
350run_continuation (void *cls, 347run_continuation (void *cls)
351 const struct GNUNET_SCHEDULER_TaskContext *tc)
352{ 348{
353 struct CpsRunContext *crc = cls; 349 struct CpsRunContext *crc = cls;
354 size_t size; 350 size_t size;
355 static struct GNUNET_HashCode key; 351 static struct GNUNET_HashCode key;
356 static char data[65536]; 352 static char data[65536];
357 char gstr[128]; 353 char gstr[128];
354 const struct GNUNET_SCHEDULER_TaskContext *tc;
358 355
356 tc = GNUNET_SCHEDULER_get_task_context ();
359 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 357 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
360 crc->phase = RP_ERROR; 358 crc->phase = RP_ERROR;
361 ok = (int) crc->phase; 359 ok = (int) crc->phase;
diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c
index 4365fbd25..0aeb426ab 100644
--- a/src/datastore/perf_plugin_datastore.c
+++ b/src/datastore/perf_plugin_datastore.c
@@ -99,8 +99,7 @@ disk_utilization_change_cb (void *cls, int delta)
99 99
100 100
101static void 101static void
102test (void *cls, 102test (void *cls);
103 const struct GNUNET_SCHEDULER_TaskContext *tc);
104 103
105 104
106/** 105/**
@@ -115,8 +114,8 @@ test (void *cls,
115static void 114static void
116put_continuation (void *cls, 115put_continuation (void *cls,
117 const struct GNUNET_HashCode *key, 116 const struct GNUNET_HashCode *key,
118 uint32_t size, 117 uint32_t size,
119 int status, 118 int status,
120 const char *msg) 119 const char *msg)
121{ 120{
122 struct CpsRunContext *crc = cls; 121 struct CpsRunContext *crc = cls;
@@ -376,7 +375,7 @@ unload_plugin (struct GNUNET_DATASTORE_PluginFunctions *api,
376 * the transport and core. 375 * the transport and core.
377 */ 376 */
378static void 377static void
379cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 378cleaning_task (void *cls)
380{ 379{
381 struct CpsRunContext *crc = cls; 380 struct CpsRunContext *crc = cls;
382 381
@@ -386,10 +385,12 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
386 385
387 386
388static void 387static void
389test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 388test (void *cls)
390{ 389{
391 struct CpsRunContext *crc = cls; 390 struct CpsRunContext *crc = cls;
391 const struct GNUNET_SCHEDULER_TaskContext *tc;
392 392
393 tc = GNUNET_SCHEDULER_get_task_context ();
393 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 394 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
394 { 395 {
395 GNUNET_break (0); 396 GNUNET_break (0);
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c
index 12f2ef762..7d4565de6 100644
--- a/src/datastore/test_datastore_api.c
+++ b/src/datastore/test_datastore_api.c
@@ -168,11 +168,9 @@ struct CpsRunContext
168 * depending on the current state. 168 * depending on the current state.
169 * 169 *
170 * @param cls the `struct CpsRunContext` 170 * @param cls the `struct CpsRunContext`
171 * @param tc scheduler context (unused)
172 */ 171 */
173static void 172static void
174run_continuation (void *cls, 173run_continuation (void *cls);
175 const struct GNUNET_SCHEDULER_TaskContext *tc);
176 174
177 175
178/** 176/**
@@ -394,11 +392,9 @@ check_update (void *cls,
394 * depending on the current state. 392 * depending on the current state.
395 * 393 *
396 * @param cls the `struct CpsRunContext` 394 * @param cls the `struct CpsRunContext`
397 * @param tc scheduler context (unused)
398 */ 395 */
399static void 396static void
400run_continuation (void *cls, 397run_continuation (void *cls)
401 const struct GNUNET_SCHEDULER_TaskContext *tc)
402{ 398{
403 struct CpsRunContext *crc = cls; 399 struct CpsRunContext *crc = cls;
404 400
diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c
index 9ef83c55c..c9fec79e3 100644
--- a/src/datastore/test_datastore_api_management.c
+++ b/src/datastore/test_datastore_api_management.c
@@ -119,7 +119,7 @@ get_expiration (int i)
119 119
120 120
121static void 121static void
122run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 122run_continuation (void *cls);
123 123
124 124
125static void 125static void
@@ -182,7 +182,7 @@ check_nothing (void *cls, const struct GNUNET_HashCode * key, size_t size,
182 182
183 183
184static void 184static void
185run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 185run_continuation (void *cls)
186{ 186{
187 struct CpsRunContext *crc = cls; 187 struct CpsRunContext *crc = cls;
188 188
diff --git a/src/datastore/test_plugin_datastore.c b/src/datastore/test_plugin_datastore.c
index 4efad74be..d7dff1041 100644
--- a/src/datastore/test_plugin_datastore.c
+++ b/src/datastore/test_plugin_datastore.c
@@ -84,8 +84,7 @@ disk_utilization_change_cb (void *cls, int delta)
84 84
85 85
86static void 86static void
87test (void *cls, 87test (void *cls);
88 const struct GNUNET_SCHEDULER_TaskContext *tc);
89 88
90 89
91/** 90/**
@@ -98,10 +97,10 @@ test (void *cls,
98 * @param msg error message on error 97 * @param msg error message on error
99 */ 98 */
100static void 99static void
101put_continuation (void *cls, 100put_continuation (void *cls,
102 const struct GNUNET_HashCode *key, 101 const struct GNUNET_HashCode *key,
103 uint32_t size, 102 uint32_t size,
104 int status, 103 int status,
105 const char *msg) 104 const char *msg)
106{ 105{
107 struct CpsRunContext *crc = cls; 106 struct CpsRunContext *crc = cls;
@@ -241,7 +240,7 @@ unload_plugin (struct GNUNET_DATASTORE_PluginFunctions *api,
241 * the transport and core. 240 * the transport and core.
242 */ 241 */
243static void 242static void
244cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 243cleaning_task (void *cls)
245{ 244{
246 struct CpsRunContext *crc = cls; 245 struct CpsRunContext *crc = cls;
247 246
@@ -251,7 +250,7 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
251 250
252 251
253static void 252static void
254update_continuation (void *cls, 253update_continuation (void *cls,
255 int status, 254 int status,
256 const char *msg) 255 const char *msg)
257{ 256{
@@ -264,11 +263,13 @@ update_continuation (void *cls,
264 263
265 264
266static void 265static void
267test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 266test (void *cls)
268{ 267{
269 struct CpsRunContext *crc = cls; 268 struct CpsRunContext *crc = cls;
270 struct GNUNET_HashCode key; 269 struct GNUNET_HashCode key;
270 const struct GNUNET_SCHEDULER_TaskContext *tc;
271 271
272 tc = GNUNET_SCHEDULER_get_task_context ();
272 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 273 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
273 { 274 {
274 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test aborted.\n"); 275 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test aborted.\n");
@@ -302,9 +303,9 @@ test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
302 case RP_UPDATE: 303 case RP_UPDATE:
303 crc->api->update (crc->api->cls, 304 crc->api->update (crc->api->cls,
304 guid, 305 guid,
305 1, 306 1,
306 GNUNET_TIME_UNIT_ZERO_ABS, 307 GNUNET_TIME_UNIT_ZERO_ABS,
307 &update_continuation, 308 &update_continuation,
308 crc); 309 crc);
309 break; 310 break;
310 311
@@ -344,8 +345,8 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg)
344 char *libname; 345 char *libname;
345 346
346 if (GNUNET_OK != 347 if (GNUNET_OK !=
347 GNUNET_CONFIGURATION_get_value_string (cfg, 348 GNUNET_CONFIGURATION_get_value_string (cfg,
348 "DATASTORE", 349 "DATASTORE",
349 "DATABASE", 350 "DATABASE",
350 &name)) 351 &name))
351 { 352 {
@@ -366,7 +367,7 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg)
366 FPRINTF (stderr, "Failed to load plugin `%s'!\n", name); 367 FPRINTF (stderr, "Failed to load plugin `%s'!\n", name);
367 GNUNET_free (libname); 368 GNUNET_free (libname);
368 GNUNET_free (name); 369 GNUNET_free (name);
369 ok = 77; /* mark test as skipped */ 370 ok = 77; /* mark test as skipped */
370 return NULL; 371 return NULL;
371 } 372 }
372 GNUNET_free (libname); 373 GNUNET_free (libname);