aboutsummaryrefslogtreecommitdiff
path: root/src/nse
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/nse
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/nse')
-rw-r--r--src/nse/gnunet-nse-profiler.c21
-rw-r--r--src/nse/gnunet-nse.c7
-rw-r--r--src/nse/gnunet-service-nse.c22
-rw-r--r--src/nse/nse_api.c7
-rw-r--r--src/nse/test_nse_api.c3
-rw-r--r--src/nse/test_nse_multipeer.c2
6 files changed, 24 insertions, 38 deletions
diff --git a/src/nse/gnunet-nse-profiler.c b/src/nse/gnunet-nse-profiler.c
index 91ca97fbd..5b893ae47 100644
--- a/src/nse/gnunet-nse-profiler.c
+++ b/src/nse/gnunet-nse-profiler.c
@@ -265,10 +265,9 @@ close_monitor_connections ()
265 * Task run on shutdown; cleans up everything. 265 * Task run on shutdown; cleans up everything.
266 * 266 *
267 * @param cls unused 267 * @param cls unused
268 * @param tc unused
269 */ 268 */
270static void 269static void
271shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 270shutdown_task (void *cls)
272{ 271{
273 shutdown_task_id = NULL; 272 shutdown_task_id = NULL;
274 if (GNUNET_YES == shutting_down) 273 if (GNUNET_YES == shutting_down)
@@ -542,11 +541,9 @@ connect_nse_service ()
542 * Task that starts/stops peers to move to the next round. 541 * Task that starts/stops peers to move to the next round.
543 * 542 *
544 * @param cls NULL, unused 543 * @param cls NULL, unused
545 * @param tc scheduler context (unused)
546 */ 544 */
547static void 545static void
548next_round (void *cls, 546next_round (void *cls);
549 const struct GNUNET_SCHEDULER_TaskContext *tc);
550 547
551 548
552/** 549/**
@@ -555,12 +552,13 @@ next_round (void *cls,
555 * the next round. 552 * the next round.
556 * 553 *
557 * @param cls unused, NULL 554 * @param cls unused, NULL
558 * @param tc unused
559 */ 555 */
560static void 556static void
561finish_round (void *cls, 557finish_round (void *cls)
562 const struct GNUNET_SCHEDULER_TaskContext *tc)
563{ 558{
559 const struct GNUNET_SCHEDULER_TaskContext *tc;
560
561 tc = GNUNET_SCHEDULER_get_task_context ();
564 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) 562 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
565 return; 563 return;
566 LOG (GNUNET_ERROR_TYPE_INFO, "Have %u connections\n", total_connections); 564 LOG (GNUNET_ERROR_TYPE_INFO, "Have %u connections\n", total_connections);
@@ -670,12 +668,13 @@ adjust_running_peers ()
670 * peers; then get statistics from *all* peers. 668 * peers; then get statistics from *all* peers.
671 * 669 *
672 * @param cls NULL, unused 670 * @param cls NULL, unused
673 * @param tc unused
674 */ 671 */
675static void 672static void
676next_round (void *cls, 673next_round (void *cls)
677 const struct GNUNET_SCHEDULER_TaskContext *tc)
678{ 674{
675 const struct GNUNET_SCHEDULER_TaskContext *tc;
676
677 tc = GNUNET_SCHEDULER_get_task_context ();
679 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) 678 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
680 return; 679 return;
681 LOG_DEBUG ("Disconnecting nse service of peers\n"); 680 LOG_DEBUG ("Disconnecting nse service of peers\n");
diff --git a/src/nse/gnunet-nse.c b/src/nse/gnunet-nse.c
index 29f0003cb..97c3da29b 100644
--- a/src/nse/gnunet-nse.c
+++ b/src/nse/gnunet-nse.c
@@ -21,7 +21,7 @@
21/** 21/**
22 * @file nse/gnunet-nse.c 22 * @file nse/gnunet-nse.c
23 * @brief Program to display network size estimates from the NSE service 23 * @brief Program to display network size estimates from the NSE service
24 * @author Sree Harsha Totakura <sreeharsha@totakura.in> 24 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
25 */ 25 */
26 26
27#include "platform.h" 27#include "platform.h"
@@ -57,10 +57,9 @@ static int status;
57 * Task to shutdown and clean up all state 57 * Task to shutdown and clean up all state
58 * 58 *
59 * @param cls NULL 59 * @param cls NULL
60 * @param tc the scheduler task context
61 */ 60 */
62static void 61static void
63do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 62do_shutdown (void *cls)
64{ 63{
65 shutdown_task = NULL; 64 shutdown_task = NULL;
66 if (NULL != test) 65 if (NULL != test)
@@ -160,7 +159,7 @@ main (int argc, char *const *argv)
160 static struct GNUNET_GETOPT_CommandLineOption options[] = { 159 static struct GNUNET_GETOPT_CommandLineOption options[] = {
161 GNUNET_GETOPT_OPTION_END 160 GNUNET_GETOPT_OPTION_END
162 }; 161 };
163 162
164 status = 1; 163 status = 1;
165 if (GNUNET_OK != 164 if (GNUNET_OK !=
166 GNUNET_PROGRAM_run (argc, argv, "gnunet-nse", 165 GNUNET_PROGRAM_run (argc, argv, "gnunet-nse",
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c
index 12e4100d7..608274ae1 100644
--- a/src/nse/gnunet-service-nse.c
+++ b/src/nse/gnunet-service-nse.c
@@ -593,11 +593,9 @@ get_transmit_delay (int round_offset)
593 * Task that triggers a NSE P2P transmission. 593 * Task that triggers a NSE P2P transmission.
594 * 594 *
595 * @param cls the `struct NSEPeerEntry *` 595 * @param cls the `struct NSEPeerEntry *`
596 * @param tc scheduler context
597 */ 596 */
598static void 597static void
599transmit_task_cb (void *cls, 598transmit_task_cb (void *cls);
600 const struct GNUNET_SCHEDULER_TaskContext *tc);
601 599
602 600
603/** 601/**
@@ -673,11 +671,9 @@ transmit_ready (void *cls,
673 * Task that triggers a NSE P2P transmission. 671 * Task that triggers a NSE P2P transmission.
674 * 672 *
675 * @param cls the `struct NSEPeerEntry *` 673 * @param cls the `struct NSEPeerEntry *`
676 * @param tc scheduler context
677 */ 674 */
678static void 675static void
679transmit_task_cb (void *cls, 676transmit_task_cb (void *cls)
680 const struct GNUNET_SCHEDULER_TaskContext *tc)
681{ 677{
682 struct NSEPeerEntry *peer_entry = cls; 678 struct NSEPeerEntry *peer_entry = cls;
683 679
@@ -797,16 +793,16 @@ schedule_current_round (void *cls,
797 * Update our flood message to be sent (and our timestamps). 793 * Update our flood message to be sent (and our timestamps).
798 * 794 *
799 * @param cls unused 795 * @param cls unused
800 * @param tc context for this message
801 */ 796 */
802static void 797static void
803update_flood_message (void *cls, 798update_flood_message (void *cls)
804 const struct GNUNET_SCHEDULER_TaskContext *tc)
805{ 799{
806 struct GNUNET_TIME_Relative offset; 800 struct GNUNET_TIME_Relative offset;
807 unsigned int i; 801 unsigned int i;
802 const struct GNUNET_SCHEDULER_TaskContext *tc;
808 803
809 flood_task = NULL; 804 flood_task = NULL;
805 tc = GNUNET_SCHEDULER_get_task_context ();
810 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 806 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
811 return; 807 return;
812 offset = GNUNET_TIME_absolute_get_remaining (next_timestamp); 808 offset = GNUNET_TIME_absolute_get_remaining (next_timestamp);
@@ -918,11 +914,9 @@ write_proof ()
918 * Find our proof of work. 914 * Find our proof of work.
919 * 915 *
920 * @param cls closure (unused) 916 * @param cls closure (unused)
921 * @param tc task context
922 */ 917 */
923static void 918static void
924find_proof (void *cls, 919find_proof (void *cls)
925 const struct GNUNET_SCHEDULER_TaskContext *tc)
926{ 920{
927#define ROUND_SIZE 10 921#define ROUND_SIZE 10
928 uint64_t counter; 922 uint64_t counter;
@@ -1343,11 +1337,9 @@ flush_comp_cb (void *cls,
1343 * Task run during shutdown. 1337 * Task run during shutdown.
1344 * 1338 *
1345 * @param cls unused 1339 * @param cls unused
1346 * @param tc unused
1347 */ 1340 */
1348static void 1341static void
1349shutdown_task (void *cls, 1342shutdown_task (void *cls)
1350 const struct GNUNET_SCHEDULER_TaskContext *tc)
1351{ 1343{
1352 if (NULL != flood_task) 1344 if (NULL != flood_task)
1353 { 1345 {
diff --git a/src/nse/nse_api.c b/src/nse/nse_api.c
index 2c1260047..a42dcb369 100644
--- a/src/nse/nse_api.c
+++ b/src/nse/nse_api.c
@@ -81,10 +81,9 @@ struct GNUNET_NSE_Handle
81 * Try again to connect to network size estimation service. 81 * Try again to connect to network size estimation service.
82 * 82 *
83 * @param cls the handle to the transport service 83 * @param cls the handle to the transport service
84 * @param tc scheduler context
85 */ 84 */
86static void 85static void
87reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 86reconnect (void *cls);
88 87
89 88
90/** 89/**
@@ -198,11 +197,9 @@ send_start (void *cls, size_t size, void *buf)
198 * Try again to connect to network size estimation service. 197 * Try again to connect to network size estimation service.
199 * 198 *
200 * @param cls the `struct GNUNET_NSE_Handle *` 199 * @param cls the `struct GNUNET_NSE_Handle *`
201 * @param tc scheduler context
202 */ 200 */
203static void 201static void
204reconnect (void *cls, 202reconnect (void *cls)
205 const struct GNUNET_SCHEDULER_TaskContext *tc)
206{ 203{
207 struct GNUNET_NSE_Handle *h = cls; 204 struct GNUNET_NSE_Handle *h = cls;
208 205
diff --git a/src/nse/test_nse_api.c b/src/nse/test_nse_api.c
index 9f3c85c5c..22826b298 100644
--- a/src/nse/test_nse_api.c
+++ b/src/nse/test_nse_api.c
@@ -36,10 +36,9 @@ static struct GNUNET_SCHEDULER_Task * die_task;
36 * Signature of the main function of a task. 36 * Signature of the main function of a task.
37 * 37 *
38 * @param cls closure 38 * @param cls closure
39 * @param tc context information (why was this task triggered now)
40 */ 39 */
41static void 40static void
42end_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 41end_test (void *cls)
43{ 42{
44 if (h != NULL) 43 if (h != NULL)
45 { 44 {
diff --git a/src/nse/test_nse_multipeer.c b/src/nse/test_nse_multipeer.c
index 549cbdf12..5e6c31e6c 100644
--- a/src/nse/test_nse_multipeer.c
+++ b/src/nse/test_nse_multipeer.c
@@ -72,7 +72,7 @@ static int ok;
72 * Task run on timeout to shut everything down. 72 * Task run on timeout to shut everything down.
73 */ 73 */
74static void 74static void
75shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 75shutdown_task (void *cls)
76{ 76{
77 unsigned int i; 77 unsigned int i;
78 78