diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-11-07 09:54:12 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-11-07 09:54:12 +0000 |
commit | 0a859b345cb6aac54a97079e2af0a90e0e93a106 (patch) | |
tree | 7bc51274e4797d9330c63b80017e031ed87f277b /src/transport/gnunet-service-transport_clients.c | |
parent | 6ab9d54e195d11a52b049919574362c6b95c67d9 (diff) | |
download | gnunet-0a859b345cb6aac54a97079e2af0a90e0e93a106.tar.gz gnunet-0a859b345cb6aac54a97079e2af0a90e0e93a106.zip |
fix mem leak mantis 0002635
Diffstat (limited to 'src/transport/gnunet-service-transport_clients.c')
-rw-r--r-- | src/transport/gnunet-service-transport_clients.c | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index db725084a..764eff531 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c | |||
@@ -116,6 +116,26 @@ struct TransportClient | |||
116 | int send_payload; | 116 | int send_payload; |
117 | }; | 117 | }; |
118 | 118 | ||
119 | /** | ||
120 | * Context for address to string operations | ||
121 | */ | ||
122 | struct AddressToStringContext | ||
123 | { | ||
124 | /** | ||
125 | * This is a doubly-linked list. | ||
126 | */ | ||
127 | struct AddressToStringContext *next; | ||
128 | |||
129 | /** | ||
130 | * This is a doubly-linked list. | ||
131 | */ | ||
132 | struct AddressToStringContext *prev; | ||
133 | |||
134 | /** | ||
135 | * Transmission context | ||
136 | */ | ||
137 | struct GNUNET_SERVER_TransmitContext* tc; | ||
138 | }; | ||
119 | 139 | ||
120 | /** | 140 | /** |
121 | * Client monitoring changes of active addresses of our neighbours. | 141 | * Client monitoring changes of active addresses of our neighbours. |
@@ -157,6 +177,16 @@ static struct TransportClient *clients_head; | |||
157 | static struct TransportClient *clients_tail; | 177 | static struct TransportClient *clients_tail; |
158 | 178 | ||
159 | /** | 179 | /** |
180 | * Head of linked list of all pending address iterations | ||
181 | */ | ||
182 | struct AddressToStringContext *a2s_head; | ||
183 | |||
184 | /** | ||
185 | * Tail of linked list of all pending address iterations | ||
186 | */ | ||
187 | struct AddressToStringContext *a2s_tail; | ||
188 | |||
189 | /** | ||
160 | * Head of linked list of monitoring clients. | 190 | * Head of linked list of monitoring clients. |
161 | */ | 191 | */ |
162 | static struct MonitoringClient *monitoring_clients_head; | 192 | static struct MonitoringClient *monitoring_clients_head; |
@@ -720,16 +750,18 @@ clients_handle_request_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
720 | static void | 750 | static void |
721 | transmit_address_to_client (void *cls, const char *buf) | 751 | transmit_address_to_client (void *cls, const char *buf) |
722 | { | 752 | { |
723 | struct GNUNET_SERVER_TransmitContext *tc = cls; | 753 | struct AddressToStringContext *actx = cls; |
724 | 754 | ||
725 | if (NULL == buf) | 755 | if (NULL == buf) |
726 | { | 756 | { |
727 | GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, | 757 | GNUNET_SERVER_transmit_context_append_data (actx->tc, NULL, 0, |
728 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); | 758 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); |
729 | GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); | 759 | GNUNET_SERVER_transmit_context_run (actx->tc, GNUNET_TIME_UNIT_FOREVER_REL); |
760 | GNUNET_CONTAINER_DLL_remove (a2s_head, a2s_tail, actx); | ||
761 | GNUNET_free (actx); | ||
730 | return; | 762 | return; |
731 | } | 763 | } |
732 | GNUNET_SERVER_transmit_context_append_data (tc, buf, strlen (buf) + 1, | 764 | GNUNET_SERVER_transmit_context_append_data (actx->tc, buf, strlen (buf) + 1, |
733 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); | 765 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); |
734 | } | 766 | } |
735 | 767 | ||
@@ -753,6 +785,7 @@ clients_handle_address_to_string (void *cls, | |||
753 | uint32_t address_len; | 785 | uint32_t address_len; |
754 | uint16_t size; | 786 | uint16_t size; |
755 | struct GNUNET_SERVER_TransmitContext *tc; | 787 | struct GNUNET_SERVER_TransmitContext *tc; |
788 | struct AddressToStringContext *actx; | ||
756 | struct GNUNET_TIME_Relative rtimeout; | 789 | struct GNUNET_TIME_Relative rtimeout; |
757 | int32_t numeric; | 790 | int32_t numeric; |
758 | 791 | ||
@@ -791,10 +824,13 @@ clients_handle_address_to_string (void *cls, | |||
791 | GNUNET_SERVER_transmit_context_run (tc, rtimeout); | 824 | GNUNET_SERVER_transmit_context_run (tc, rtimeout); |
792 | return; | 825 | return; |
793 | } | 826 | } |
827 | actx = GNUNET_malloc (sizeof (struct AddressToStringContext)); | ||
828 | actx->tc = tc; | ||
829 | GNUNET_CONTAINER_DLL_insert (a2s_head, a2s_tail, actx); | ||
794 | GNUNET_SERVER_disable_receive_done_warning (client); | 830 | GNUNET_SERVER_disable_receive_done_warning (client); |
795 | papi->address_pretty_printer (papi->cls, plugin_name, address, address_len, | 831 | papi->address_pretty_printer (papi->cls, plugin_name, address, address_len, |
796 | numeric, rtimeout, &transmit_address_to_client, | 832 | numeric, rtimeout, &transmit_address_to_client, |
797 | tc); | 833 | actx); |
798 | } | 834 | } |
799 | 835 | ||
800 | 836 | ||
@@ -981,6 +1017,15 @@ GST_clients_start (struct GNUNET_SERVER_Handle *server) | |||
981 | void | 1017 | void |
982 | GST_clients_stop () | 1018 | GST_clients_stop () |
983 | { | 1019 | { |
1020 | struct AddressToStringContext *cur; | ||
1021 | |||
1022 | while (NULL != (cur = a2s_head)) | ||
1023 | { | ||
1024 | GNUNET_SERVER_transmit_context_destroy (cur->tc, GNUNET_NO); | ||
1025 | GNUNET_CONTAINER_DLL_remove (a2s_head, a2s_tail, cur); | ||
1026 | GNUNET_free (cur); | ||
1027 | } | ||
1028 | |||
984 | if (NULL != nc) | 1029 | if (NULL != nc) |
985 | { | 1030 | { |
986 | GNUNET_SERVER_notification_context_destroy (nc); | 1031 | GNUNET_SERVER_notification_context_destroy (nc); |