diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-04-09 23:14:03 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-04-09 23:14:03 +0000 |
commit | 29e6158507a0758192075ac6ece7ba8e75ddc49a (patch) | |
tree | b91ded48da322f8ba4c9bb0f5504228aa036c2d1 /src/datastore | |
parent | 5dfcb058ab5db9ae0c4b147d8a99c64ca0980028 (diff) | |
download | gnunet-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.c | 10 | ||||
-rw-r--r-- | src/datastore/gnunet-datastore.c | 3 | ||||
-rw-r--r-- | src/datastore/gnunet-service-datastore.c | 10 | ||||
-rw-r--r-- | src/datastore/perf_datastore_api.c | 10 | ||||
-rw-r--r-- | src/datastore/perf_plugin_datastore.c | 13 | ||||
-rw-r--r-- | src/datastore/test_datastore_api.c | 8 | ||||
-rw-r--r-- | src/datastore/test_datastore_api_management.c | 4 | ||||
-rw-r--r-- | src/datastore/test_plugin_datastore.c | 27 |
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 | */ |
283 | static void | 282 | static void |
284 | disconnect_after_drop (void *cls, | 283 | disconnect_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 | */ |
388 | static void | 385 | static void |
389 | timeout_queue_entry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 386 | timeout_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 | */ |
525 | static void | 521 | static void |
526 | try_reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 522 | try_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 | ||
72 | static void | 72 | static void |
73 | do_shutdown (void *cls, | 73 | do_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 | */ |
308 | static void | 307 | static void |
309 | delete_expired (void *cls, | 308 | delete_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 | */ |
393 | static void | 390 | static void |
394 | delete_expired (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 391 | delete_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 | */ |
1581 | static void | 1578 | static void |
1582 | cleaning_task (void *cls, | 1579 | cleaning_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 | */ |
191 | static void | 190 | static void |
192 | run_continuation (void *cls, | 191 | run_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 | */ |
349 | static void | 346 | static void |
350 | run_continuation (void *cls, | 347 | run_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 | ||
101 | static void | 101 | static void |
102 | test (void *cls, | 102 | test (void *cls); |
103 | const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
104 | 103 | ||
105 | 104 | ||
106 | /** | 105 | /** |
@@ -115,8 +114,8 @@ test (void *cls, | |||
115 | static void | 114 | static void |
116 | put_continuation (void *cls, | 115 | put_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 | */ |
378 | static void | 377 | static void |
379 | cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 378 | cleaning_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 | ||
388 | static void | 387 | static void |
389 | test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 388 | test (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 | */ |
173 | static void | 172 | static void |
174 | run_continuation (void *cls, | 173 | run_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 | */ |
399 | static void | 396 | static void |
400 | run_continuation (void *cls, | 397 | run_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 | ||
121 | static void | 121 | static void |
122 | run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 122 | run_continuation (void *cls); |
123 | 123 | ||
124 | 124 | ||
125 | static void | 125 | static void |
@@ -182,7 +182,7 @@ check_nothing (void *cls, const struct GNUNET_HashCode * key, size_t size, | |||
182 | 182 | ||
183 | 183 | ||
184 | static void | 184 | static void |
185 | run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 185 | run_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 | ||
86 | static void | 86 | static void |
87 | test (void *cls, | 87 | test (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 | */ |
100 | static void | 99 | static void |
101 | put_continuation (void *cls, | 100 | put_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 | */ |
243 | static void | 242 | static void |
244 | cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 243 | cleaning_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 | ||
253 | static void | 252 | static void |
254 | update_continuation (void *cls, | 253 | update_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 | ||
266 | static void | 265 | static void |
267 | test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 266 | test (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); |