diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-07-08 16:34:31 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-07-08 16:34:31 +0000 |
commit | 6e3599bab213760c66f13f6103ebf650bbe5b7e9 (patch) | |
tree | f56a0bbe3ce64c818c87bae6171ba800ab05b701 /src/hostlist | |
parent | 2c0a286c8c29e135c68556658b6ac6cef48a874a (diff) | |
download | gnunet-6e3599bab213760c66f13f6103ebf650bbe5b7e9.tar.gz gnunet-6e3599bab213760c66f13f6103ebf650bbe5b7e9.zip |
migrate transport_core API to MQ
Diffstat (limited to 'src/hostlist')
-rw-r--r-- | src/hostlist/gnunet-daemon-hostlist_client.c | 76 | ||||
-rw-r--r-- | src/hostlist/test_gnunet_daemon_hostlist.c | 2 | ||||
-rw-r--r-- | src/hostlist/test_gnunet_daemon_hostlist_reconnect.c | 2 |
3 files changed, 59 insertions, 21 deletions
diff --git a/src/hostlist/gnunet-daemon-hostlist_client.c b/src/hostlist/gnunet-daemon-hostlist_client.c index df0cabe1d..c8c74a9ba 100644 --- a/src/hostlist/gnunet-daemon-hostlist_client.c +++ b/src/hostlist/gnunet-daemon-hostlist_client.c | |||
@@ -142,6 +142,14 @@ struct Hostlist | |||
142 | }; | 142 | }; |
143 | 143 | ||
144 | 144 | ||
145 | struct HelloOffer | ||
146 | { | ||
147 | struct HelloOffer *next; | ||
148 | struct HelloOffer *prev; | ||
149 | struct GNUNET_TRANSPORT_OfferHelloHandle *ohh; | ||
150 | }; | ||
151 | |||
152 | |||
145 | /** | 153 | /** |
146 | * Our configuration. | 154 | * Our configuration. |
147 | */ | 155 | */ |
@@ -153,11 +161,6 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg; | |||
153 | static struct GNUNET_STATISTICS_Handle *stats; | 161 | static struct GNUNET_STATISTICS_Handle *stats; |
154 | 162 | ||
155 | /** | 163 | /** |
156 | * Transport handle. | ||
157 | */ | ||
158 | static struct GNUNET_TRANSPORT_Handle *transport; | ||
159 | |||
160 | /** | ||
161 | * Proxy hostname or ip we are using (can be NULL). | 164 | * Proxy hostname or ip we are using (can be NULL). |
162 | */ | 165 | */ |
163 | static char *proxy; | 166 | static char *proxy; |
@@ -312,6 +315,25 @@ static unsigned int stat_hellos_obtained; | |||
312 | */ | 315 | */ |
313 | static unsigned int stat_connection_count; | 316 | static unsigned int stat_connection_count; |
314 | 317 | ||
318 | static struct HelloOffer *ho_head; | ||
319 | |||
320 | static struct HelloOffer *ho_tail; | ||
321 | |||
322 | |||
323 | /** | ||
324 | * Hello offer complete. Clean up. | ||
325 | */ | ||
326 | static void | ||
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 | * Process downloaded bits by calling callback on each HELLO. | 339 | * Process downloaded bits by calling callback on each HELLO. |
@@ -331,6 +353,7 @@ callback_download (void *ptr, | |||
331 | static char download_buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; | 353 | static char download_buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; |
332 | const char *cbuf = ptr; | 354 | const char *cbuf = ptr; |
333 | const struct GNUNET_MessageHeader *msg; | 355 | const struct GNUNET_MessageHeader *msg; |
356 | struct HelloOffer *ho; | ||
334 | size_t total; | 357 | size_t total; |
335 | size_t cpy; | 358 | size_t cpy; |
336 | size_t left; | 359 | size_t left; |
@@ -390,7 +413,22 @@ callback_download (void *ptr, | |||
390 | ("# valid HELLOs downloaded from hostlist servers"), | 413 | ("# valid HELLOs downloaded from hostlist servers"), |
391 | 1, GNUNET_NO); | 414 | 1, GNUNET_NO); |
392 | stat_hellos_obtained++; | 415 | stat_hellos_obtained++; |
393 | GNUNET_TRANSPORT_offer_hello (transport, msg, NULL, NULL); | 416 | |
417 | ho = GNUNET_new (struct HelloOffer); | ||
418 | ho->ohh = GNUNET_TRANSPORT_offer_hello (cfg, | ||
419 | msg, | ||
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 | } | ||
394 | } | 432 | } |
395 | else | 433 | else |
396 | { | 434 | { |
@@ -405,7 +443,9 @@ callback_download (void *ptr, | |||
405 | stat_hellos_obtained++; | 443 | stat_hellos_obtained++; |
406 | return total; | 444 | return total; |
407 | } | 445 | } |
408 | memmove (download_buffer, &download_buffer[msize], download_pos - msize); | 446 | memmove (download_buffer, |
447 | &download_buffer[msize], | ||
448 | download_pos - msize); | ||
409 | download_pos -= msize; | 449 | download_pos -= msize; |
410 | } | 450 | } |
411 | return total; | 451 | return total; |
@@ -1532,13 +1572,6 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
1532 | GNUNET_break (0); | 1572 | GNUNET_break (0); |
1533 | return GNUNET_SYSERR; | 1573 | return GNUNET_SYSERR; |
1534 | } | 1574 | } |
1535 | transport = GNUNET_TRANSPORT_connect (c, NULL, NULL, NULL, NULL, NULL); | ||
1536 | if (NULL == transport) | ||
1537 | { | ||
1538 | GNUNET_break (0); | ||
1539 | curl_global_cleanup (); | ||
1540 | return GNUNET_SYSERR; | ||
1541 | } | ||
1542 | cfg = c; | 1575 | cfg = c; |
1543 | stats = st; | 1576 | stats = st; |
1544 | 1577 | ||
@@ -1687,8 +1720,18 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
1687 | void | 1720 | void |
1688 | GNUNET_HOSTLIST_client_stop () | 1721 | GNUNET_HOSTLIST_client_stop () |
1689 | { | 1722 | { |
1723 | struct HelloOffer *ho; | ||
1724 | |||
1690 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1725 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1691 | "Hostlist client shutdown\n"); | 1726 | "Hostlist client shutdown\n"); |
1727 | while (NULL != (ho = ho_head)) | ||
1728 | { | ||
1729 | GNUNET_CONTAINER_DLL_remove (ho_head, | ||
1730 | ho_tail, | ||
1731 | ho); | ||
1732 | GNUNET_TRANSPORT_offer_hello_cancel (ho->ohh); | ||
1733 | GNUNET_free (ho); | ||
1734 | } | ||
1692 | if (NULL != sget) | 1735 | if (NULL != sget) |
1693 | { | 1736 | { |
1694 | GNUNET_STATISTICS_get_cancel (sget); | 1737 | GNUNET_STATISTICS_get_cancel (sget); |
@@ -1725,11 +1768,6 @@ GNUNET_HOSTLIST_client_stop () | |||
1725 | ti_check_download = NULL; | 1768 | ti_check_download = NULL; |
1726 | curl_global_cleanup (); | 1769 | curl_global_cleanup (); |
1727 | } | 1770 | } |
1728 | if (NULL != transport) | ||
1729 | { | ||
1730 | GNUNET_TRANSPORT_disconnect (transport); | ||
1731 | transport = NULL; | ||
1732 | } | ||
1733 | GNUNET_free_non_null (proxy); | 1771 | GNUNET_free_non_null (proxy); |
1734 | proxy = NULL; | 1772 | proxy = NULL; |
1735 | GNUNET_free_non_null (proxy_username); | 1773 | GNUNET_free_non_null (proxy_username); |
diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c index 5f8ece9b8..6a5850c4d 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist.c +++ b/src/hostlist/test_gnunet_daemon_hostlist.c | |||
@@ -147,7 +147,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
147 | p->th = | 147 | p->th = |
148 | GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, ¬ify_connect, NULL); | 148 | GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, ¬ify_connect, NULL); |
149 | GNUNET_assert (p->th != NULL); | 149 | GNUNET_assert (p->th != NULL); |
150 | p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); | 150 | p->ghh = GNUNET_TRANSPORT_get_hello (p->cfg, &process_hello, p); |
151 | GNUNET_free (binary); | 151 | GNUNET_free (binary); |
152 | } | 152 | } |
153 | 153 | ||
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c index 3dad137a2..30f26717f 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c | |||
@@ -116,7 +116,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
116 | p->th = | 116 | p->th = |
117 | GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, ¬ify_connect, NULL); | 117 | GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, ¬ify_connect, NULL); |
118 | GNUNET_assert (p->th != NULL); | 118 | GNUNET_assert (p->th != NULL); |
119 | p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); | 119 | p->ghh = GNUNET_TRANSPORT_get_hello (p->cfg, &process_hello, p); |
120 | GNUNET_free (binary); | 120 | GNUNET_free (binary); |
121 | } | 121 | } |
122 | 122 | ||