diff options
Diffstat (limited to 'src/transport/plugin_transport_udp.c')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 96 |
1 files changed, 43 insertions, 53 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 9bf2d8181..08a532aed 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -75,7 +75,7 @@ static struct PrettyPrinterContext *ppc_dll_tail; | |||
75 | 75 | ||
76 | 76 | ||
77 | /** | 77 | /** |
78 | * Closure for 'append_port'. | 78 | * Closure for #append_port(). |
79 | */ | 79 | */ |
80 | struct PrettyPrinterContext | 80 | struct PrettyPrinterContext |
81 | { | 81 | { |
@@ -717,23 +717,6 @@ udp_string_to_address (void *cls, | |||
717 | } | 717 | } |
718 | 718 | ||
719 | 719 | ||
720 | static void | ||
721 | ppc_cancel_task (void *cls, | ||
722 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
723 | { | ||
724 | struct PrettyPrinterContext *ppc = cls; | ||
725 | |||
726 | ppc->timeout_task = GNUNET_SCHEDULER_NO_TASK; | ||
727 | if (NULL != ppc->resolver_handle) | ||
728 | { | ||
729 | GNUNET_RESOLVER_request_cancel (ppc->resolver_handle); | ||
730 | ppc->resolver_handle = NULL; | ||
731 | } | ||
732 | GNUNET_CONTAINER_DLL_remove(ppc_dll_head, ppc_dll_tail, ppc); | ||
733 | GNUNET_free(ppc); | ||
734 | } | ||
735 | |||
736 | |||
737 | /** | 720 | /** |
738 | * Append our port and forward the result. | 721 | * Append our port and forward the result. |
739 | * | 722 | * |
@@ -744,37 +727,39 @@ static void | |||
744 | append_port (void *cls, const char *hostname) | 727 | append_port (void *cls, const char *hostname) |
745 | { | 728 | { |
746 | struct PrettyPrinterContext *ppc = cls; | 729 | struct PrettyPrinterContext *ppc = cls; |
747 | struct PrettyPrinterContext *cur; | ||
748 | char *ret; | 730 | char *ret; |
749 | 731 | ||
750 | if (hostname == NULL ) | 732 | if (NULL == hostname) |
751 | { | 733 | { |
752 | ppc->asc (ppc->asc_cls, NULL, GNUNET_OK); /* Final call, done */ | 734 | /* Final call, done */ |
753 | GNUNET_CONTAINER_DLL_remove(ppc_dll_head, ppc_dll_tail, ppc); | 735 | ppc->asc (ppc->asc_cls, |
754 | GNUNET_SCHEDULER_cancel (ppc->timeout_task); | 736 | NULL, |
755 | ppc->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 737 | GNUNET_OK); |
738 | GNUNET_CONTAINER_DLL_remove (ppc_dll_head, | ||
739 | ppc_dll_tail, | ||
740 | ppc); | ||
756 | ppc->resolver_handle = NULL; | 741 | ppc->resolver_handle = NULL; |
757 | GNUNET_free(ppc); | 742 | GNUNET_free (ppc); |
758 | return; | 743 | return; |
759 | } | 744 | } |
760 | for (cur = ppc_dll_head; (NULL != cur); cur = cur->next) | ||
761 | if (cur == ppc) | ||
762 | break; | ||
763 | if (NULL == cur) | ||
764 | { | ||
765 | ppc->asc (ppc->asc_cls, NULL, GNUNET_SYSERR); | ||
766 | GNUNET_break(0); | ||
767 | return; | ||
768 | } | ||
769 | |||
770 | if (GNUNET_YES == ppc->ipv6) | 745 | if (GNUNET_YES == ppc->ipv6) |
771 | GNUNET_asprintf (&ret, "%s.%u.[%s]:%d", PLUGIN_NAME, ppc->options, hostname, | 746 | GNUNET_asprintf (&ret, |
772 | ppc->port); | 747 | "%s.%u.[%s]:%d", |
748 | PLUGIN_NAME, | ||
749 | ppc->options, | ||
750 | hostname, | ||
751 | ppc->port); | ||
773 | else | 752 | else |
774 | GNUNET_asprintf (&ret, "%s.%u.%s:%d", PLUGIN_NAME, ppc->options, hostname, | 753 | GNUNET_asprintf (&ret, |
775 | ppc->port); | 754 | "%s.%u.%s:%d", |
776 | ppc->asc (ppc->asc_cls, ret, GNUNET_OK); | 755 | PLUGIN_NAME, |
777 | GNUNET_free(ret); | 756 | ppc->options, |
757 | hostname, | ||
758 | ppc->port); | ||
759 | ppc->asc (ppc->asc_cls, | ||
760 | ret, | ||
761 | GNUNET_OK); | ||
762 | GNUNET_free (ret); | ||
778 | } | 763 | } |
779 | 764 | ||
780 | 765 | ||
@@ -845,7 +830,7 @@ udp_plugin_address_pretty_printer (void *cls, | |||
845 | else | 830 | else |
846 | { | 831 | { |
847 | /* invalid address */ | 832 | /* invalid address */ |
848 | GNUNET_break_op(0); | 833 | GNUNET_break_op (0); |
849 | asc (asc_cls, NULL , GNUNET_SYSERR); | 834 | asc (asc_cls, NULL , GNUNET_SYSERR); |
850 | asc (asc_cls, NULL, GNUNET_OK); | 835 | asc (asc_cls, NULL, GNUNET_OK); |
851 | return; | 836 | return; |
@@ -859,11 +844,15 @@ udp_plugin_address_pretty_printer (void *cls, | |||
859 | ppc->ipv6 = GNUNET_YES; | 844 | ppc->ipv6 = GNUNET_YES; |
860 | else | 845 | else |
861 | ppc->ipv6 = GNUNET_NO; | 846 | ppc->ipv6 = GNUNET_NO; |
862 | ppc->timeout_task = GNUNET_SCHEDULER_add_delayed ( | 847 | GNUNET_CONTAINER_DLL_insert (ppc_dll_head, |
863 | GNUNET_TIME_relative_multiply (timeout, 2), &ppc_cancel_task, ppc); | 848 | ppc_dll_tail, |
864 | GNUNET_CONTAINER_DLL_insert(ppc_dll_head, ppc_dll_tail, ppc); | 849 | ppc); |
865 | ppc->resolver_handle = GNUNET_RESOLVER_hostname_get (sb, sbs, !numeric, | 850 | ppc->resolver_handle |
866 | timeout, &append_port, ppc); | 851 | = GNUNET_RESOLVER_hostname_get (sb, |
852 | sbs, | ||
853 | ! numeric, | ||
854 | timeout, | ||
855 | &append_port, ppc); | ||
867 | } | 856 | } |
868 | 857 | ||
869 | 858 | ||
@@ -3313,8 +3302,8 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
3313 | } | 3302 | } |
3314 | 3303 | ||
3315 | /* Clean up sessions */ | 3304 | /* Clean up sessions */ |
3316 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 3305 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3317 | "Cleaning up sessions\n"); | 3306 | "Cleaning up sessions\n"); |
3318 | GNUNET_CONTAINER_multipeermap_iterate (plugin->sessions, | 3307 | GNUNET_CONTAINER_multipeermap_iterate (plugin->sessions, |
3319 | &disconnect_and_free_it, plugin); | 3308 | &disconnect_and_free_it, plugin); |
3320 | GNUNET_CONTAINER_multipeermap_destroy (plugin->sessions); | 3309 | GNUNET_CONTAINER_multipeermap_destroy (plugin->sessions); |
@@ -3322,12 +3311,13 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
3322 | next = ppc_dll_head; | 3311 | next = ppc_dll_head; |
3323 | for (cur = next; NULL != cur; cur = next) | 3312 | for (cur = next; NULL != cur; cur = next) |
3324 | { | 3313 | { |
3314 | GNUNET_break(0); | ||
3325 | next = cur->next; | 3315 | next = cur->next; |
3326 | GNUNET_CONTAINER_DLL_remove(ppc_dll_head, ppc_dll_tail, cur); | 3316 | GNUNET_CONTAINER_DLL_remove (ppc_dll_head, |
3317 | ppc_dll_tail, | ||
3318 | cur); | ||
3327 | GNUNET_RESOLVER_request_cancel (cur->resolver_handle); | 3319 | GNUNET_RESOLVER_request_cancel (cur->resolver_handle); |
3328 | GNUNET_SCHEDULER_cancel (cur->timeout_task); | 3320 | GNUNET_free (cur); |
3329 | GNUNET_free(cur); | ||
3330 | GNUNET_break(0); | ||
3331 | } | 3321 | } |
3332 | GNUNET_free (plugin); | 3322 | GNUNET_free (plugin); |
3333 | GNUNET_free (api); | 3323 | GNUNET_free (api); |