aboutsummaryrefslogtreecommitdiff
path: root/src/regex
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/regex
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/regex')
-rw-r--r--src/regex/gnunet-daemon-regexprofiler.c10
-rw-r--r--src/regex/gnunet-regex-profiler.c36
-rw-r--r--src/regex/gnunet-regex-simulation-profiler.c9
-rw-r--r--src/regex/gnunet-service-regex.c10
-rw-r--r--src/regex/test_regex_api.c5
-rw-r--r--src/regex/test_regex_integration.c5
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 */
111static void 110static void
112shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 111shutdown_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 */
142static void 140static void
143reannounce_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 141reannounce_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 */
389static void 388static void
390announce_next_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 389announce_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 */
404static void 402static void
405do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 403do_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 */
476static void 473static void
477do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 474do_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 */
669static void 665static void
670do_collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 666do_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 */
699static void 694static void
700find_string (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 695find_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 */
813static void 807static void
814search_timed_out (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 808search_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 */
851static void 844static void
852find_timed_out (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 845find_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 */
875static void 868static void
876find_string (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 869find_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 */
964static void 959static void
965do_announce (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 960do_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 */
987static void 981static void
988announce_next_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 982announce_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 */
276static void 275static void
277do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 276do_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 */
297static void 295static void
298do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 296do_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 */
569static void 566static void
570do_directory_scan (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 567do_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 */
157static void 156static void
158cleanup_task (void *cls, 157cleanup_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 */
184static void 181static void
185reannounce (void *cls, 182reannounce (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
46static int ok = 1; 46static int ok = 1;
47 47
48static struct GNUNET_SCHEDULER_Task * die_task; 48static struct GNUNET_SCHEDULER_Task *die_task;
49 49
50 50
51static void 51static void
52end (void *cls, 52end (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
59static void 59static void
60end (void *cls, 60end (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
77end_badly () 76end_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