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/cadet/gnunet-cadet.c | |
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/cadet/gnunet-cadet.c')
-rw-r--r-- | src/cadet/gnunet-cadet.c | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c index 5c5ec54b9..14b499aae 100644 --- a/src/cadet/gnunet-cadet.c +++ b/src/cadet/gnunet-cadet.c | |||
@@ -191,11 +191,9 @@ conn_2s (uint16_t status) | |||
191 | * Stops monitoring activity. | 191 | * Stops monitoring activity. |
192 | * | 192 | * |
193 | * @param cls Closure (unused). | 193 | * @param cls Closure (unused). |
194 | * @param tc scheduler context | ||
195 | */ | 194 | */ |
196 | static void | 195 | static void |
197 | shutdown_task (void *cls, | 196 | shutdown_task (void *cls) |
198 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
199 | { | 197 | { |
200 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n"); | 198 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n"); |
201 | if (NULL != th) | 199 | if (NULL != th) |
@@ -268,14 +266,14 @@ data_ready (void *cls, size_t size, void *buf) | |||
268 | * Task run in stdio mode, after some data is available at stdin. | 266 | * Task run in stdio mode, after some data is available at stdin. |
269 | * | 267 | * |
270 | * @param cls Closure (unused). | 268 | * @param cls Closure (unused). |
271 | * @param tc scheduler context | ||
272 | */ | 269 | */ |
273 | static void | 270 | static void |
274 | read_stdio (void *cls, | 271 | read_stdio (void *cls) |
275 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
276 | { | 272 | { |
277 | static char buf[60000]; | 273 | static char buf[60000]; |
274 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
278 | 275 | ||
276 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
279 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 277 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
280 | { | 278 | { |
281 | return; | 279 | return; |
@@ -406,11 +404,13 @@ channel_incoming (void *cls, | |||
406 | * @brief Send an echo request to the remote peer. | 404 | * @brief Send an echo request to the remote peer. |
407 | * | 405 | * |
408 | * @param cls Closure (NULL). | 406 | * @param cls Closure (NULL). |
409 | * @param tc Task context. | ||
410 | */ | 407 | */ |
411 | static void | 408 | static void |
412 | send_echo (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 409 | send_echo (void *cls) |
413 | { | 410 | { |
411 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
412 | |||
413 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
414 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) || NULL == ch) | 414 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) || NULL == ch) |
415 | return; | 415 | return; |
416 | 416 | ||
@@ -426,10 +426,9 @@ send_echo (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
426 | * Call CADET's monitor API, request debug dump on the service. | 426 | * Call CADET's monitor API, request debug dump on the service. |
427 | * | 427 | * |
428 | * @param cls Closure (unused). | 428 | * @param cls Closure (unused). |
429 | * @param tc TaskContext | ||
430 | */ | 429 | */ |
431 | static void | 430 | static void |
432 | request_dump (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 431 | request_dump (void *cls) |
433 | { | 432 | { |
434 | GNUNET_CADET_request_dump (mh); | 433 | GNUNET_CADET_request_dump (mh); |
435 | GNUNET_SCHEDULER_cancel (sd); | 434 | GNUNET_SCHEDULER_cancel (sd); |
@@ -441,10 +440,9 @@ request_dump (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
441 | * Call CADET's monitor API, get info of one connection. | 440 | * Call CADET's monitor API, get info of one connection. |
442 | * | 441 | * |
443 | * @param cls Closure (unused). | 442 | * @param cls Closure (unused). |
444 | * @param tc TaskContext | ||
445 | */ | 443 | */ |
446 | static void | 444 | static void |
447 | create_channel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 445 | create_channel (void *cls) |
448 | { | 446 | { |
449 | struct GNUNET_PeerIdentity pid; | 447 | struct GNUNET_PeerIdentity pid; |
450 | enum GNUNET_CADET_ChannelOption opt; | 448 | enum GNUNET_CADET_ChannelOption opt; |
@@ -703,11 +701,13 @@ tunnel_callback (void *cls, | |||
703 | * Call CADET's meta API, get all peers known to a peer. | 701 | * Call CADET's meta API, get all peers known to a peer. |
704 | * | 702 | * |
705 | * @param cls Closure (unused). | 703 | * @param cls Closure (unused). |
706 | * @param tc TaskContext | ||
707 | */ | 704 | */ |
708 | static void | 705 | static void |
709 | get_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 706 | get_peers (void *cls) |
710 | { | 707 | { |
708 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
709 | |||
710 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
711 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 711 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
712 | { | 712 | { |
713 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n"); | 713 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n"); |
@@ -721,18 +721,17 @@ get_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
721 | * Call CADET's monitor API, get info of one peer. | 721 | * Call CADET's monitor API, get info of one peer. |
722 | * | 722 | * |
723 | * @param cls Closure (unused). | 723 | * @param cls Closure (unused). |
724 | * @param tc TaskContext | ||
725 | */ | 724 | */ |
726 | static void | 725 | static void |
727 | show_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 726 | show_peer (void *cls) |
728 | { | 727 | { |
729 | struct GNUNET_PeerIdentity pid; | 728 | struct GNUNET_PeerIdentity pid; |
730 | 729 | ||
731 | if (GNUNET_OK != | 730 | if (GNUNET_OK != |
732 | GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id, | 731 | GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id, |
733 | strlen (peer_id), | 732 | strlen (peer_id), |
734 | &pid.public_key)) | 733 | &pid.public_key)) |
735 | { | 734 | { |
736 | fprintf (stderr, | 735 | fprintf (stderr, |
737 | _("Invalid peer ID `%s'\n"), | 736 | _("Invalid peer ID `%s'\n"), |
738 | peer_id); | 737 | peer_id); |
@@ -746,11 +745,13 @@ show_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
746 | * Call CADET's meta API, get all tunnels known to a peer. | 745 | * Call CADET's meta API, get all tunnels known to a peer. |
747 | * | 746 | * |
748 | * @param cls Closure (unused). | 747 | * @param cls Closure (unused). |
749 | * @param tc TaskContext | ||
750 | */ | 748 | */ |
751 | static void | 749 | static void |
752 | get_tunnels (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 750 | get_tunnels (void *cls) |
753 | { | 751 | { |
752 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
753 | |||
754 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
754 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 755 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
755 | { | 756 | { |
756 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n"); | 757 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n"); |
@@ -764,10 +765,9 @@ get_tunnels (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
764 | * Call CADET's monitor API, get info of one tunnel. | 765 | * Call CADET's monitor API, get info of one tunnel. |
765 | * | 766 | * |
766 | * @param cls Closure (unused). | 767 | * @param cls Closure (unused). |
767 | * @param tc TaskContext | ||
768 | */ | 768 | */ |
769 | static void | 769 | static void |
770 | show_tunnel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 770 | show_tunnel (void *cls) |
771 | { | 771 | { |
772 | struct GNUNET_PeerIdentity pid; | 772 | struct GNUNET_PeerIdentity pid; |
773 | 773 | ||
@@ -790,10 +790,9 @@ show_tunnel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
790 | * Call CADET's monitor API, get info of one channel. | 790 | * Call CADET's monitor API, get info of one channel. |
791 | * | 791 | * |
792 | * @param cls Closure (unused). | 792 | * @param cls Closure (unused). |
793 | * @param tc TaskContext | ||
794 | */ | 793 | */ |
795 | static void | 794 | static void |
796 | show_channel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 795 | show_channel (void *cls) |
797 | { | 796 | { |
798 | 797 | ||
799 | } | 798 | } |
@@ -803,10 +802,9 @@ show_channel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
803 | * Call CADET's monitor API, get info of one connection. | 802 | * Call CADET's monitor API, get info of one connection. |
804 | * | 803 | * |
805 | * @param cls Closure (unused). | 804 | * @param cls Closure (unused). |
806 | * @param tc TaskContext | ||
807 | */ | 805 | */ |
808 | static void | 806 | static void |
809 | show_connection (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 807 | show_connection (void *cls) |
810 | { | 808 | { |
811 | 809 | ||
812 | } | 810 | } |