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/regex | |
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/regex')
-rw-r--r-- | src/regex/gnunet-daemon-regexprofiler.c | 10 | ||||
-rw-r--r-- | src/regex/gnunet-regex-profiler.c | 36 | ||||
-rw-r--r-- | src/regex/gnunet-regex-simulation-profiler.c | 9 | ||||
-rw-r--r-- | src/regex/gnunet-service-regex.c | 10 | ||||
-rw-r--r-- | src/regex/test_regex_api.c | 5 | ||||
-rw-r--r-- | src/regex/test_regex_integration.c | 5 |
6 files changed, 31 insertions, 44 deletions
diff --git a/src/regex/gnunet-daemon-regexprofiler.c b/src/regex/gnunet-daemon-regexprofiler.c index 2ff8ad0f2..1ff3b55e3 100644 --- a/src/regex/gnunet-daemon-regexprofiler.c +++ b/src/regex/gnunet-daemon-regexprofiler.c | |||
@@ -106,10 +106,9 @@ static struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key; | |||
106 | * Task run during shutdown. | 106 | * Task run during shutdown. |
107 | * | 107 | * |
108 | * @param cls unused | 108 | * @param cls unused |
109 | * @param tc unused | ||
110 | */ | 109 | */ |
111 | static void | 110 | static void |
112 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 111 | shutdown_task (void *cls) |
113 | { | 112 | { |
114 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "shutting down\n"); | 113 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "shutting down\n"); |
115 | 114 | ||
@@ -137,15 +136,16 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
137 | * Announce a previously announced regex re-using cached data. | 136 | * Announce a previously announced regex re-using cached data. |
138 | * | 137 | * |
139 | * @param cls Closure (regex to announce if needed). | 138 | * @param cls Closure (regex to announce if needed). |
140 | * @param tc TaskContext. | ||
141 | */ | 139 | */ |
142 | static void | 140 | static void |
143 | reannounce_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 141 | reannounce_regex (void *cls) |
144 | { | 142 | { |
145 | struct GNUNET_TIME_Relative random_delay; | ||
146 | char *regex = cls; | 143 | char *regex = cls; |
144 | struct GNUNET_TIME_Relative random_delay; | ||
145 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
147 | 146 | ||
148 | reannounce_task = NULL; | 147 | reannounce_task = NULL; |
148 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
149 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 149 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
150 | { | 150 | { |
151 | GNUNET_free (regex); | 151 | GNUNET_free (regex); |
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c index 5fe6186cf..5938c99b1 100644 --- a/src/regex/gnunet-regex-profiler.c +++ b/src/regex/gnunet-regex-profiler.c | |||
@@ -384,10 +384,9 @@ stats_connect_cb (void *cls, | |||
384 | * Start announcing the next regex in the DHT. | 384 | * Start announcing the next regex in the DHT. |
385 | * | 385 | * |
386 | * @param cls Index of the next peer in the peers array. | 386 | * @param cls Index of the next peer in the peers array. |
387 | * @param tc TaskContext. | ||
388 | */ | 387 | */ |
389 | static void | 388 | static void |
390 | announce_next_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 389 | announce_next_regex (void *cls); |
391 | 390 | ||
392 | 391 | ||
393 | /******************************************************************************/ | 392 | /******************************************************************************/ |
@@ -399,10 +398,9 @@ announce_next_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | |||
399 | * Shutdown nicely | 398 | * Shutdown nicely |
400 | * | 399 | * |
401 | * @param cls NULL | 400 | * @param cls NULL |
402 | * @param tc the task context | ||
403 | */ | 401 | */ |
404 | static void | 402 | static void |
405 | do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 403 | do_shutdown (void *cls) |
406 | { | 404 | { |
407 | struct RegexPeer *peer; | 405 | struct RegexPeer *peer; |
408 | unsigned int peer_cnt; | 406 | unsigned int peer_cnt; |
@@ -471,10 +469,9 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
471 | * abort task to run on test timed out | 469 | * abort task to run on test timed out |
472 | * | 470 | * |
473 | * @param cls NULL | 471 | * @param cls NULL |
474 | * @param tc the task context | ||
475 | */ | 472 | */ |
476 | static void | 473 | static void |
477 | do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 474 | do_abort (void *cls) |
478 | { | 475 | { |
479 | unsigned long i = (unsigned long) cls; | 476 | unsigned long i = (unsigned long) cls; |
480 | 477 | ||
@@ -664,10 +661,9 @@ stats_connect_cb (void *cls, | |||
664 | * profiler, when done. | 661 | * profiler, when done. |
665 | * | 662 | * |
666 | * @param cls NULL | 663 | * @param cls NULL |
667 | * @param tc the task context | ||
668 | */ | 664 | */ |
669 | static void | 665 | static void |
670 | do_collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 666 | do_collect_stats (void *cls) |
671 | { | 667 | { |
672 | struct RegexPeer *peer = &peers[0]; | 668 | struct RegexPeer *peer = &peers[0]; |
673 | 669 | ||
@@ -694,10 +690,9 @@ do_collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
694 | * Start searching for the next string in the DHT. | 690 | * Start searching for the next string in the DHT. |
695 | * | 691 | * |
696 | * @param cls Index of the next peer in the peers array. | 692 | * @param cls Index of the next peer in the peers array. |
697 | * @param tc TaskContext. | ||
698 | */ | 693 | */ |
699 | static void | 694 | static void |
700 | find_string (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 695 | find_string (void *cls); |
701 | 696 | ||
702 | 697 | ||
703 | /** | 698 | /** |
@@ -808,10 +803,9 @@ regex_found_handler (void *cls, | |||
808 | * specified timeout 'search_timeout'. | 803 | * specified timeout 'search_timeout'. |
809 | * | 804 | * |
810 | * @param cls NULL | 805 | * @param cls NULL |
811 | * @param tc the task context | ||
812 | */ | 806 | */ |
813 | static void | 807 | static void |
814 | search_timed_out (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | 808 | search_timed_out (void *cls) |
815 | { | 809 | { |
816 | unsigned int i; | 810 | unsigned int i; |
817 | 811 | ||
@@ -846,15 +840,15 @@ search_timed_out (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
846 | * but we should start another one. | 840 | * but we should start another one. |
847 | * | 841 | * |
848 | * @param cls Index of the next peer in the peers array. | 842 | * @param cls Index of the next peer in the peers array. |
849 | * @param tc TaskContext. | ||
850 | */ | 843 | */ |
851 | static void | 844 | static void |
852 | find_timed_out (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 845 | find_timed_out (void *cls) |
853 | { | 846 | { |
854 | struct RegexPeer *p = cls; | 847 | struct RegexPeer *p = cls; |
848 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
855 | 849 | ||
856 | p->timeout = NULL; | 850 | p->timeout = NULL; |
857 | 851 | tc = GNUNET_SCHEDULER_get_task_context (); | |
858 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 852 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
859 | return; | 853 | return; |
860 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 854 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -870,13 +864,14 @@ find_timed_out (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
870 | * Start searching for a string in the DHT. | 864 | * Start searching for a string in the DHT. |
871 | * | 865 | * |
872 | * @param cls Index of the next peer in the peers array. | 866 | * @param cls Index of the next peer in the peers array. |
873 | * @param tc TaskContext. | ||
874 | */ | 867 | */ |
875 | static void | 868 | static void |
876 | find_string (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 869 | find_string (void *cls) |
877 | { | 870 | { |
878 | unsigned int search_peer = (unsigned int) (long) cls; | 871 | unsigned int search_peer = (unsigned int) (long) cls; |
872 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
879 | 873 | ||
874 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
880 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) || | 875 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) || |
881 | search_peer >= num_peers || | 876 | search_peer >= num_peers || |
882 | GNUNET_YES == in_shutdown) | 877 | GNUNET_YES == in_shutdown) |
@@ -962,7 +957,7 @@ daemon_started (void *cls, struct GNUNET_TESTBED_Operation *op, | |||
962 | * @param tc the task context | 957 | * @param tc the task context |
963 | */ | 958 | */ |
964 | static void | 959 | static void |
965 | do_announce (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 960 | do_announce (void *cls) |
966 | { | 961 | { |
967 | unsigned int i; | 962 | unsigned int i; |
968 | 963 | ||
@@ -982,13 +977,14 @@ do_announce (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
982 | * Start announcing the next regex in the DHT. | 977 | * Start announcing the next regex in the DHT. |
983 | * | 978 | * |
984 | * @param cls Closure (unused). | 979 | * @param cls Closure (unused). |
985 | * @param tc TaskContext. | ||
986 | */ | 980 | */ |
987 | static void | 981 | static void |
988 | announce_next_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 982 | announce_next_regex (void *cls) |
989 | { | 983 | { |
990 | struct RegexPeer *peer; | 984 | struct RegexPeer *peer; |
985 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
991 | 986 | ||
987 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
992 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 988 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
993 | return; | 989 | return; |
994 | if (next_search >= num_peers) | 990 | if (next_search >= num_peers) |
diff --git a/src/regex/gnunet-regex-simulation-profiler.c b/src/regex/gnunet-regex-simulation-profiler.c index 04aa66b32..27dfa773d 100644 --- a/src/regex/gnunet-regex-simulation-profiler.c +++ b/src/regex/gnunet-regex-simulation-profiler.c | |||
@@ -271,10 +271,9 @@ free_meter (struct ProgressMeter *meter) | |||
271 | * Shutdown task. | 271 | * Shutdown task. |
272 | * | 272 | * |
273 | * @param cls NULL | 273 | * @param cls NULL |
274 | * @param tc the task context | ||
275 | */ | 274 | */ |
276 | static void | 275 | static void |
277 | do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 276 | do_shutdown (void *cls) |
278 | { | 277 | { |
279 | shutdown_task = NULL; | 278 | shutdown_task = NULL; |
280 | if (NULL != abort_task) | 279 | if (NULL != abort_task) |
@@ -292,10 +291,9 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
292 | * abort task to run on test timed out | 291 | * abort task to run on test timed out |
293 | * | 292 | * |
294 | * @param cls NULL | 293 | * @param cls NULL |
295 | * @param tc the task context | ||
296 | */ | 294 | */ |
297 | static void | 295 | static void |
298 | do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 296 | do_abort (void *cls) |
299 | { | 297 | { |
300 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Aborting\n"); | 298 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Aborting\n"); |
301 | abort_task = NULL; | 299 | abort_task = NULL; |
@@ -564,10 +562,9 @@ policy_filename_cb (void *cls, const char *filename) | |||
564 | * Iterate over files contained in policy_dir. | 562 | * Iterate over files contained in policy_dir. |
565 | * | 563 | * |
566 | * @param cls NULL | 564 | * @param cls NULL |
567 | * @param tc the task context | ||
568 | */ | 565 | */ |
569 | static void | 566 | static void |
570 | do_directory_scan (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 567 | do_directory_scan (void *cls) |
571 | { | 568 | { |
572 | struct GNUNET_TIME_Absolute start_time; | 569 | struct GNUNET_TIME_Absolute start_time; |
573 | struct GNUNET_TIME_Relative duration; | 570 | struct GNUNET_TIME_Relative duration; |
diff --git a/src/regex/gnunet-service-regex.c b/src/regex/gnunet-service-regex.c index 2150b0973..a70876534 100644 --- a/src/regex/gnunet-service-regex.c +++ b/src/regex/gnunet-service-regex.c | |||
@@ -152,11 +152,9 @@ handle_client_disconnect (void *cls, | |||
152 | * Task run during shutdown. | 152 | * Task run during shutdown. |
153 | * | 153 | * |
154 | * @param cls unused | 154 | * @param cls unused |
155 | * @param tc unused | ||
156 | */ | 155 | */ |
157 | static void | 156 | static void |
158 | cleanup_task (void *cls, | 157 | cleanup_task (void *cls) |
159 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
160 | { | 158 | { |
161 | struct ClientEntry *ce; | 159 | struct ClientEntry *ce; |
162 | 160 | ||
@@ -177,13 +175,11 @@ cleanup_task (void *cls, | |||
177 | /** | 175 | /** |
178 | * Periodic task to refresh our announcement of the regex. | 176 | * Periodic task to refresh our announcement of the regex. |
179 | * | 177 | * |
180 | * @param cls the 'struct ClientEntry' of the client that triggered the | 178 | * @param cls the `struct ClientEntry *` of the client that triggered the |
181 | * announcement | 179 | * announcement |
182 | * @param tc scheduler context | ||
183 | */ | 180 | */ |
184 | static void | 181 | static void |
185 | reannounce (void *cls, | 182 | reannounce (void *cls) |
186 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
187 | { | 183 | { |
188 | struct ClientEntry *ce = cls; | 184 | struct ClientEntry *ce = cls; |
189 | 185 | ||
diff --git a/src/regex/test_regex_api.c b/src/regex/test_regex_api.c index ab387d755..01f455854 100644 --- a/src/regex/test_regex_api.c +++ b/src/regex/test_regex_api.c | |||
@@ -45,12 +45,11 @@ static struct GNUNET_REGEX_Search *s; | |||
45 | 45 | ||
46 | static int ok = 1; | 46 | static int ok = 1; |
47 | 47 | ||
48 | static struct GNUNET_SCHEDULER_Task * die_task; | 48 | static struct GNUNET_SCHEDULER_Task *die_task; |
49 | 49 | ||
50 | 50 | ||
51 | static void | 51 | static void |
52 | end (void *cls, | 52 | end (void *cls) |
53 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
54 | { | 53 | { |
55 | die_task = NULL; | 54 | die_task = NULL; |
56 | GNUNET_REGEX_announce_cancel (a); | 55 | GNUNET_REGEX_announce_cancel (a); |
diff --git a/src/regex/test_regex_integration.c b/src/regex/test_regex_integration.c index 453500fa1..d98d80070 100644 --- a/src/regex/test_regex_integration.c +++ b/src/regex/test_regex_integration.c | |||
@@ -57,8 +57,7 @@ static struct GNUNET_SCHEDULER_Task *die_task; | |||
57 | 57 | ||
58 | 58 | ||
59 | static void | 59 | static void |
60 | end (void *cls, | 60 | end (void *cls) |
61 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
62 | { | 61 | { |
63 | die_task = NULL; | 62 | die_task = NULL; |
64 | GNUNET_REGEX_announce_cancel (a4); | 63 | GNUNET_REGEX_announce_cancel (a4); |
@@ -77,7 +76,7 @@ static void | |||
77 | end_badly () | 76 | end_badly () |
78 | { | 77 | { |
79 | FPRINTF (stderr, "%s", "Testcase failed (timeout).\n"); | 78 | FPRINTF (stderr, "%s", "Testcase failed (timeout).\n"); |
80 | end (NULL, NULL); | 79 | end (NULL); |
81 | ok = 1; | 80 | ok = 1; |
82 | } | 81 | } |
83 | 82 | ||