aboutsummaryrefslogtreecommitdiff
path: root/src/util/helper.c
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/util/helper.c
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/util/helper.c')
-rw-r--r--src/util/helper.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/util/helper.c b/src/util/helper.c
index f0123460b..3ed1c7276 100644
--- a/src/util/helper.c
+++ b/src/util/helper.c
@@ -138,7 +138,7 @@ struct GNUNET_HELPER_Handle
138 * NULL-terminated list of command-line arguments. 138 * NULL-terminated list of command-line arguments.
139 */ 139 */
140 char **binary_argv; 140 char **binary_argv;
141 141
142 /** 142 /**
143 * Task to read from the helper. 143 * Task to read from the helper.
144 */ 144 */
@@ -305,28 +305,26 @@ stop_helper (struct GNUNET_HELPER_Handle *h,
305 * Restart the helper process. 305 * Restart the helper process.
306 * 306 *
307 * @param cls handle to the helper process 307 * @param cls handle to the helper process
308 * @param tc scheduler context
309 */ 308 */
310static void 309static void
311restart_task (void *cls, 310restart_task (void *cls);
312 const struct GNUNET_SCHEDULER_TaskContext *tc);
313 311
314 312
315/** 313/**
316 * Read from the helper-process 314 * Read from the helper-process
317 * 315 *
318 * @param cls handle to the helper process 316 * @param cls handle to the helper process
319 * @param tc scheduler context
320 */ 317 */
321static void 318static void
322helper_read (void *cls, 319helper_read (void *cls)
323 const struct GNUNET_SCHEDULER_TaskContext *tc)
324{ 320{
325 struct GNUNET_HELPER_Handle *h = cls; 321 struct GNUNET_HELPER_Handle *h = cls;
322 const struct GNUNET_SCHEDULER_TaskContext *tc;
326 char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE] GNUNET_ALIGN; 323 char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE] GNUNET_ALIGN;
327 ssize_t t; 324 ssize_t t;
328 325
329 h->read_task = NULL; 326 h->read_task = NULL;
327 tc = GNUNET_SCHEDULER_get_task_context ();
330 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 328 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
331 { 329 {
332 /* try again */ 330 /* try again */
@@ -458,17 +456,15 @@ start_helper (struct GNUNET_HELPER_Handle *h)
458 * Restart the helper process. 456 * Restart the helper process.
459 * 457 *
460 * @param cls handle to the helper process 458 * @param cls handle to the helper process
461 * @param tc scheduler context
462 */ 459 */
463static void 460static void
464restart_task (void *cls, 461restart_task (void *cls)
465 const struct GNUNET_SCHEDULER_TaskContext *tc)
466{ 462{
467 struct GNUNET_HELPER_Handle*h = cls; 463 struct GNUNET_HELPER_Handle*h = cls;
468 464
469 h->restart_task = NULL; 465 h->restart_task = NULL;
470 h->retry_back_off++; 466 h->retry_back_off++;
471 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 467 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
472 "Restarting helper with back-off %u\n", 468 "Restarting helper with back-off %u\n",
473 h->retry_back_off); 469 h->retry_back_off);
474 start_helper (h); 470 start_helper (h);
@@ -582,18 +578,18 @@ GNUNET_HELPER_stop (struct GNUNET_HELPER_Handle *h,
582 * Write to the helper-process 578 * Write to the helper-process
583 * 579 *
584 * @param cls handle to the helper process 580 * @param cls handle to the helper process
585 * @param tc scheduler context
586 */ 581 */
587static void 582static void
588helper_write (void *cls, 583helper_write (void *cls)
589 const struct GNUNET_SCHEDULER_TaskContext *tc)
590{ 584{
591 struct GNUNET_HELPER_Handle *h = cls; 585 struct GNUNET_HELPER_Handle *h = cls;
586 const struct GNUNET_SCHEDULER_TaskContext *tc;
592 struct GNUNET_HELPER_SendHandle *sh; 587 struct GNUNET_HELPER_SendHandle *sh;
593 const char *buf; 588 const char *buf;
594 ssize_t t; 589 ssize_t t;
595 590
596 h->write_task = NULL; 591 h->write_task = NULL;
592 tc = GNUNET_SCHEDULER_get_task_context ();
597 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 593 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
598 { 594 {
599 /* try again */ 595 /* try again */