diff options
Diffstat (limited to 'src/hostlist/gnunet-daemon-hostlist_client.c')
-rw-r--r-- | src/hostlist/gnunet-daemon-hostlist_client.c | 83 |
1 files changed, 21 insertions, 62 deletions
diff --git a/src/hostlist/gnunet-daemon-hostlist_client.c b/src/hostlist/gnunet-daemon-hostlist_client.c index 207cc4a81..43b4e4593 100644 --- a/src/hostlist/gnunet-daemon-hostlist_client.c +++ b/src/hostlist/gnunet-daemon-hostlist_client.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2001-2010, 2014, 2016 GNUnet e.V. | 3 | Copyright (C) 2001-2010, 2014, 2016 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | /** | 18 | /** |
21 | * @file hostlist/gnunet-daemon-hostlist_client.c | 19 | * @file hostlist/gnunet-daemon-hostlist_client.c |
@@ -28,6 +26,7 @@ | |||
28 | #include "gnunet_hello_lib.h" | 26 | #include "gnunet_hello_lib.h" |
29 | #include "gnunet_statistics_service.h" | 27 | #include "gnunet_statistics_service.h" |
30 | #include "gnunet_transport_service.h" | 28 | #include "gnunet_transport_service.h" |
29 | #include "gnunet_peerinfo_service.h" | ||
31 | #include "gnunet-daemon-hostlist.h" | 30 | #include "gnunet-daemon-hostlist.h" |
32 | #if HAVE_CURL_CURL_H | 31 | #if HAVE_CURL_CURL_H |
33 | #include <curl/curl.h> | 32 | #include <curl/curl.h> |
@@ -142,14 +141,6 @@ struct Hostlist | |||
142 | }; | 141 | }; |
143 | 142 | ||
144 | 143 | ||
145 | struct HelloOffer | ||
146 | { | ||
147 | struct HelloOffer *next; | ||
148 | struct HelloOffer *prev; | ||
149 | struct GNUNET_TRANSPORT_OfferHelloHandle *ohh; | ||
150 | }; | ||
151 | |||
152 | |||
153 | /** | 144 | /** |
154 | * Our configuration. | 145 | * Our configuration. |
155 | */ | 146 | */ |
@@ -315,24 +306,10 @@ static unsigned int stat_hellos_obtained; | |||
315 | */ | 306 | */ |
316 | static unsigned int stat_connection_count; | 307 | static unsigned int stat_connection_count; |
317 | 308 | ||
318 | static struct HelloOffer *ho_head; | ||
319 | |||
320 | static struct HelloOffer *ho_tail; | ||
321 | |||
322 | |||
323 | /** | 309 | /** |
324 | * Hello offer complete. Clean up. | 310 | * Handle to peerinfo service. |
325 | */ | 311 | */ |
326 | static void | 312 | static struct GNUNET_PEERINFO_Handle *pi; |
327 | done_offer_hello (void *cls) | ||
328 | { | ||
329 | struct HelloOffer *ho = cls; | ||
330 | |||
331 | GNUNET_CONTAINER_DLL_remove (ho_head, | ||
332 | ho_tail, | ||
333 | ho); | ||
334 | GNUNET_free (ho); | ||
335 | } | ||
336 | 313 | ||
337 | 314 | ||
338 | /** | 315 | /** |
@@ -353,7 +330,6 @@ callback_download (void *ptr, | |||
353 | static char download_buffer[GNUNET_MAX_MESSAGE_SIZE - 1]; | 330 | static char download_buffer[GNUNET_MAX_MESSAGE_SIZE - 1]; |
354 | const char *cbuf = ptr; | 331 | const char *cbuf = ptr; |
355 | const struct GNUNET_MessageHeader *msg; | 332 | const struct GNUNET_MessageHeader *msg; |
356 | struct HelloOffer *ho; | ||
357 | size_t total; | 333 | size_t total; |
358 | size_t cpy; | 334 | size_t cpy; |
359 | size_t left; | 335 | size_t left; |
@@ -413,22 +389,10 @@ callback_download (void *ptr, | |||
413 | ("# valid HELLOs downloaded from hostlist servers"), | 389 | ("# valid HELLOs downloaded from hostlist servers"), |
414 | 1, GNUNET_NO); | 390 | 1, GNUNET_NO); |
415 | stat_hellos_obtained++; | 391 | stat_hellos_obtained++; |
416 | 392 | (void) GNUNET_PEERINFO_add_peer (pi, | |
417 | ho = GNUNET_new (struct HelloOffer); | 393 | (const struct GNUNET_HELLO_Message *) msg, |
418 | ho->ohh = GNUNET_TRANSPORT_offer_hello (cfg, | 394 | NULL, |
419 | msg, | 395 | NULL); |
420 | &done_offer_hello, | ||
421 | ho); | ||
422 | if (NULL == ho->ohh) | ||
423 | { | ||
424 | GNUNET_free (ho); | ||
425 | } | ||
426 | else | ||
427 | { | ||
428 | GNUNET_CONTAINER_DLL_insert (ho_head, | ||
429 | ho_tail, | ||
430 | ho); | ||
431 | } | ||
432 | } | 396 | } |
433 | else | 397 | else |
434 | { | 398 | { |
@@ -1567,6 +1531,7 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
1567 | stats = st; | 1531 | stats = st; |
1568 | 1532 | ||
1569 | /* Read proxy configuration */ | 1533 | /* Read proxy configuration */ |
1534 | pi = GNUNET_PEERINFO_connect (c); | ||
1570 | if (GNUNET_OK == | 1535 | if (GNUNET_OK == |
1571 | GNUNET_CONFIGURATION_get_value_string (cfg, | 1536 | GNUNET_CONFIGURATION_get_value_string (cfg, |
1572 | "HOSTLIST", | 1537 | "HOSTLIST", |
@@ -1723,18 +1688,8 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
1723 | void | 1688 | void |
1724 | GNUNET_HOSTLIST_client_stop () | 1689 | GNUNET_HOSTLIST_client_stop () |
1725 | { | 1690 | { |
1726 | struct HelloOffer *ho; | ||
1727 | |||
1728 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1691 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1729 | "Hostlist client shutdown\n"); | 1692 | "Hostlist client shutdown\n"); |
1730 | while (NULL != (ho = ho_head)) | ||
1731 | { | ||
1732 | GNUNET_CONTAINER_DLL_remove (ho_head, | ||
1733 | ho_tail, | ||
1734 | ho); | ||
1735 | GNUNET_TRANSPORT_offer_hello_cancel (ho->ohh); | ||
1736 | GNUNET_free (ho); | ||
1737 | } | ||
1738 | if (NULL != sget) | 1693 | if (NULL != sget) |
1739 | { | 1694 | { |
1740 | GNUNET_STATISTICS_get_cancel (sget); | 1695 | GNUNET_STATISTICS_get_cancel (sget); |
@@ -1777,7 +1732,11 @@ GNUNET_HOSTLIST_client_stop () | |||
1777 | proxy_username = NULL; | 1732 | proxy_username = NULL; |
1778 | GNUNET_free_non_null (proxy_password); | 1733 | GNUNET_free_non_null (proxy_password); |
1779 | proxy_password = NULL; | 1734 | proxy_password = NULL; |
1780 | 1735 | if (NULL != pi) | |
1736 | { | ||
1737 | GNUNET_PEERINFO_disconnect (pi); | ||
1738 | pi = NULL; | ||
1739 | } | ||
1781 | cfg = NULL; | 1740 | cfg = NULL; |
1782 | } | 1741 | } |
1783 | 1742 | ||