diff options
Diffstat (limited to 'src/hostlist/gnunet-daemon-hostlist_client.c')
-rw-r--r-- | src/hostlist/gnunet-daemon-hostlist_client.c | 65 |
1 files changed, 13 insertions, 52 deletions
diff --git a/src/hostlist/gnunet-daemon-hostlist_client.c b/src/hostlist/gnunet-daemon-hostlist_client.c index 207cc4a81..2283efe6c 100644 --- a/src/hostlist/gnunet-daemon-hostlist_client.c +++ b/src/hostlist/gnunet-daemon-hostlist_client.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "gnunet_hello_lib.h" | 28 | #include "gnunet_hello_lib.h" |
29 | #include "gnunet_statistics_service.h" | 29 | #include "gnunet_statistics_service.h" |
30 | #include "gnunet_transport_service.h" | 30 | #include "gnunet_transport_service.h" |
31 | #include "gnunet_peerinfo_service.h" | ||
31 | #include "gnunet-daemon-hostlist.h" | 32 | #include "gnunet-daemon-hostlist.h" |
32 | #if HAVE_CURL_CURL_H | 33 | #if HAVE_CURL_CURL_H |
33 | #include <curl/curl.h> | 34 | #include <curl/curl.h> |
@@ -142,14 +143,6 @@ struct Hostlist | |||
142 | }; | 143 | }; |
143 | 144 | ||
144 | 145 | ||
145 | struct HelloOffer | ||
146 | { | ||
147 | struct HelloOffer *next; | ||
148 | struct HelloOffer *prev; | ||
149 | struct GNUNET_TRANSPORT_OfferHelloHandle *ohh; | ||
150 | }; | ||
151 | |||
152 | |||
153 | /** | 146 | /** |
154 | * Our configuration. | 147 | * Our configuration. |
155 | */ | 148 | */ |
@@ -315,24 +308,10 @@ static unsigned int stat_hellos_obtained; | |||
315 | */ | 308 | */ |
316 | static unsigned int stat_connection_count; | 309 | static unsigned int stat_connection_count; |
317 | 310 | ||
318 | static struct HelloOffer *ho_head; | ||
319 | |||
320 | static struct HelloOffer *ho_tail; | ||
321 | |||
322 | |||
323 | /** | 311 | /** |
324 | * Hello offer complete. Clean up. | 312 | * Handle to peerinfo service. |
325 | */ | 313 | */ |
326 | static void | 314 | 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 | 315 | ||
337 | 316 | ||
338 | /** | 317 | /** |
@@ -353,7 +332,6 @@ callback_download (void *ptr, | |||
353 | static char download_buffer[GNUNET_MAX_MESSAGE_SIZE - 1]; | 332 | static char download_buffer[GNUNET_MAX_MESSAGE_SIZE - 1]; |
354 | const char *cbuf = ptr; | 333 | const char *cbuf = ptr; |
355 | const struct GNUNET_MessageHeader *msg; | 334 | const struct GNUNET_MessageHeader *msg; |
356 | struct HelloOffer *ho; | ||
357 | size_t total; | 335 | size_t total; |
358 | size_t cpy; | 336 | size_t cpy; |
359 | size_t left; | 337 | size_t left; |
@@ -413,22 +391,10 @@ callback_download (void *ptr, | |||
413 | ("# valid HELLOs downloaded from hostlist servers"), | 391 | ("# valid HELLOs downloaded from hostlist servers"), |
414 | 1, GNUNET_NO); | 392 | 1, GNUNET_NO); |
415 | stat_hellos_obtained++; | 393 | stat_hellos_obtained++; |
416 | 394 | (void) GNUNET_PEERINFO_add_peer (pi, | |
417 | ho = GNUNET_new (struct HelloOffer); | 395 | (const struct GNUNET_HELLO_Message *) msg, |
418 | ho->ohh = GNUNET_TRANSPORT_offer_hello (cfg, | 396 | NULL, |
419 | msg, | 397 | 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 | } | 398 | } |
433 | else | 399 | else |
434 | { | 400 | { |
@@ -1567,6 +1533,7 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
1567 | stats = st; | 1533 | stats = st; |
1568 | 1534 | ||
1569 | /* Read proxy configuration */ | 1535 | /* Read proxy configuration */ |
1536 | pi = GNUNET_PEERINFO_connect (c); | ||
1570 | if (GNUNET_OK == | 1537 | if (GNUNET_OK == |
1571 | GNUNET_CONFIGURATION_get_value_string (cfg, | 1538 | GNUNET_CONFIGURATION_get_value_string (cfg, |
1572 | "HOSTLIST", | 1539 | "HOSTLIST", |
@@ -1723,18 +1690,8 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
1723 | void | 1690 | void |
1724 | GNUNET_HOSTLIST_client_stop () | 1691 | GNUNET_HOSTLIST_client_stop () |
1725 | { | 1692 | { |
1726 | struct HelloOffer *ho; | ||
1727 | |||
1728 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1693 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1729 | "Hostlist client shutdown\n"); | 1694 | "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) | 1695 | if (NULL != sget) |
1739 | { | 1696 | { |
1740 | GNUNET_STATISTICS_get_cancel (sget); | 1697 | GNUNET_STATISTICS_get_cancel (sget); |
@@ -1777,7 +1734,11 @@ GNUNET_HOSTLIST_client_stop () | |||
1777 | proxy_username = NULL; | 1734 | proxy_username = NULL; |
1778 | GNUNET_free_non_null (proxy_password); | 1735 | GNUNET_free_non_null (proxy_password); |
1779 | proxy_password = NULL; | 1736 | proxy_password = NULL; |
1780 | 1737 | if (NULL != pi) | |
1738 | { | ||
1739 | GNUNET_PEERINFO_disconnect (pi); | ||
1740 | pi = NULL; | ||
1741 | } | ||
1781 | cfg = NULL; | 1742 | cfg = NULL; |
1782 | } | 1743 | } |
1783 | 1744 | ||