diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-06-12 16:18:14 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-06-12 16:18:14 +0000 |
commit | ac5fff04d81839d0d509fb6cc31725a8a753e5bf (patch) | |
tree | 7e55ac5feddf9fc8a2c8f7ebcd9397ed4bbaf22b /src/gns/gnunet-gns-proxy.c | |
parent | 3e07554a8000e87ff6120fea57333585e69367b3 (diff) | |
download | gnunet-ac5fff04d81839d0d509fb6cc31725a8a753e5bf.tar.gz gnunet-ac5fff04d81839d0d509fb6cc31725a8a753e5bf.zip |
-lots of fixes
Diffstat (limited to 'src/gns/gnunet-gns-proxy.c')
-rw-r--r-- | src/gns/gnunet-gns-proxy.c | 158 |
1 files changed, 112 insertions, 46 deletions
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index 243e94c08..a4f665425 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c | |||
@@ -123,6 +123,20 @@ struct Socks5Request | |||
123 | int cleanup_sock; | 123 | int cleanup_sock; |
124 | }; | 124 | }; |
125 | 125 | ||
126 | /** | ||
127 | * DLL for Network Handles | ||
128 | */ | ||
129 | struct NetworkHandleList | ||
130 | { | ||
131 | /*DLL*/ | ||
132 | struct NetworkHandleList *next; | ||
133 | |||
134 | /*DLL*/ | ||
135 | struct NetworkHandleList *prev; | ||
136 | |||
137 | /* The handle */ | ||
138 | struct GNUNET_NETWORK_Handle *h; | ||
139 | }; | ||
126 | 140 | ||
127 | /** | 141 | /** |
128 | * A structure for all running Httpds | 142 | * A structure for all running Httpds |
@@ -149,6 +163,12 @@ struct MhdHttpList | |||
149 | 163 | ||
150 | /* The task ID */ | 164 | /* The task ID */ |
151 | GNUNET_SCHEDULER_TaskIdentifier httpd_task; | 165 | GNUNET_SCHEDULER_TaskIdentifier httpd_task; |
166 | |||
167 | /* Handles associated with this daemon */ | ||
168 | struct NetworkHandleList *socket_handles_head; | ||
169 | |||
170 | /* Handles associated with this daemon */ | ||
171 | struct NetworkHandleList *socket_handles_tail; | ||
152 | }; | 172 | }; |
153 | 173 | ||
154 | /** | 174 | /** |
@@ -221,6 +241,9 @@ struct ProxyCurlTask | |||
221 | 241 | ||
222 | /* The associated daemon list entry */ | 242 | /* The associated daemon list entry */ |
223 | struct MhdHttpList *mhd; | 243 | struct MhdHttpList *mhd; |
244 | |||
245 | /* The associated response */ | ||
246 | struct MHD_Response *response; | ||
224 | 247 | ||
225 | }; | 248 | }; |
226 | 249 | ||
@@ -455,7 +478,11 @@ callback_download (void *ptr, size_t size, size_t nmemb, void *ctx) | |||
455 | return total; | 478 | return total; |
456 | } | 479 | } |
457 | 480 | ||
458 | 481 | /** | |
482 | * Ask cURL for the select sets and schedule download | ||
483 | */ | ||
484 | static void | ||
485 | curl_download_prepare (); | ||
459 | 486 | ||
460 | /** | 487 | /** |
461 | * Callback to free content | 488 | * Callback to free content |
@@ -463,17 +490,18 @@ callback_download (void *ptr, size_t size, size_t nmemb, void *ctx) | |||
463 | * @param cls content to free | 490 | * @param cls content to free |
464 | */ | 491 | */ |
465 | static void | 492 | static void |
466 | mhd_content_free (void *cls) | 493 | mhd_content_free (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
467 | { | 494 | { |
468 | struct ProxyCurlTask *ctask = cls; | 495 | struct ProxyCurlTask *ctask = cls; |
469 | 496 | ||
470 | if (NULL != ctask->headers) | 497 | if (NULL != ctask->headers) |
471 | curl_slist_free_all (ctask->headers); | 498 | curl_slist_free_all (ctask->headers); |
472 | 499 | ||
473 | if (NULL != ctask->curl) | 500 | if (NULL != ctask->headers) |
474 | curl_easy_cleanup (ctask->curl); | 501 | curl_slist_free_all (ctask->resolver); |
475 | 502 | ||
476 | ctask->curl = NULL; | 503 | if (NULL != ctask->response) |
504 | MHD_destroy_response (ctask->response); | ||
477 | 505 | ||
478 | GNUNET_free (ctask); | 506 | GNUNET_free (ctask); |
479 | 507 | ||
@@ -516,28 +544,6 @@ process_shorten (void* cls, const char* short_name) | |||
516 | 544 | ||
517 | 545 | ||
518 | /** | 546 | /** |
519 | * Postprocessing task that uses GNS to shorten names | ||
520 | * | ||
521 | * @param cls the proxycurltask | ||
522 | * @param tc the task context | ||
523 | * | ||
524 | static void | ||
525 | postprocess_name (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
526 | { | ||
527 | struct ProxyCurlTask *ctask = cls; | ||
528 | char tmp[strlen(ctask->pp_buf)]; | ||
529 | |||
530 | sprintf ( tmp, "%s%s", ctask->pp_buf, ctask->authority); | ||
531 | |||
532 | GNUNET_GNS_shorten (gns_handle, | ||
533 | tmp, | ||
534 | &process_shorten, | ||
535 | ctask); | ||
536 | |||
537 | } | ||
538 | */ | ||
539 | |||
540 | /** | ||
541 | * Callback for MHD response | 547 | * Callback for MHD response |
542 | * | 548 | * |
543 | * @param cls closure | 549 | * @param cls closure |
@@ -559,7 +565,7 @@ mhd_content_cb (void *cls, | |||
559 | regmatch_t m[RE_N_MATCHES]; | 565 | regmatch_t m[RE_N_MATCHES]; |
560 | 566 | ||
561 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 567 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
562 | "MHD: content cb\n"); | 568 | "MHD: content cb %s\n", ctask->url); |
563 | 569 | ||
564 | if (ctask->download_successful && | 570 | if (ctask->download_successful && |
565 | (ctask->buf_status == BUF_WAIT_FOR_CURL)) | 571 | (ctask->buf_status == BUF_WAIT_FOR_CURL)) |
@@ -567,8 +573,7 @@ mhd_content_cb (void *cls, | |||
567 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 573 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
568 | "MHD: sending response for %s\n", ctask->url); | 574 | "MHD: sending response for %s\n", ctask->url); |
569 | ctask->download_in_progress = GNUNET_NO; | 575 | ctask->download_in_progress = GNUNET_NO; |
570 | curl_multi_remove_handle (curl_multi, ctask->curl); | 576 | GNUNET_SCHEDULER_add_now (&mhd_content_free, ctask); |
571 | curl_easy_cleanup (ctask->curl); | ||
572 | GNUNET_SCHEDULER_add_now (&run_mhd, ctask->mhd); | 577 | GNUNET_SCHEDULER_add_now (&run_mhd, ctask->mhd); |
573 | total_mhd_connections--; | 578 | total_mhd_connections--; |
574 | return MHD_CONTENT_READER_END_OF_STREAM; | 579 | return MHD_CONTENT_READER_END_OF_STREAM; |
@@ -580,8 +585,7 @@ mhd_content_cb (void *cls, | |||
580 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 585 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
581 | "MHD: sending error response\n"); | 586 | "MHD: sending error response\n"); |
582 | ctask->download_in_progress = GNUNET_NO; | 587 | ctask->download_in_progress = GNUNET_NO; |
583 | curl_multi_remove_handle (curl_multi, ctask->curl); | 588 | GNUNET_SCHEDULER_add_now (&mhd_content_free, ctask); |
584 | curl_easy_cleanup (ctask->curl); | ||
585 | GNUNET_SCHEDULER_add_now (&run_mhd, ctask->mhd); | 589 | GNUNET_SCHEDULER_add_now (&run_mhd, ctask->mhd); |
586 | total_mhd_connections--; | 590 | total_mhd_connections--; |
587 | return MHD_CONTENT_READER_END_WITH_ERROR; | 591 | return MHD_CONTENT_READER_END_WITH_ERROR; |
@@ -685,9 +689,6 @@ mhd_content_cb (void *cls, | |||
685 | &process_shorten, | 689 | &process_shorten, |
686 | ctask); | 690 | ctask); |
687 | 691 | ||
688 | //postprocess_name(ctask, NULL); | ||
689 | //ctask->pp_task = GNUNET_SCHEDULER_add_now (&postprocess_name, ctask); | ||
690 | |||
691 | return 0; | 692 | return 0; |
692 | } | 693 | } |
693 | } | 694 | } |
@@ -721,7 +722,8 @@ mhd_content_cb (void *cls, | |||
721 | ctask->bytes_in_buffer = 0; | 722 | ctask->bytes_in_buffer = 0; |
722 | ctask->buf_status = BUF_WAIT_FOR_CURL; | 723 | ctask->buf_status = BUF_WAIT_FOR_CURL; |
723 | ctask->buffer_ptr = ctask->buffer; | 724 | ctask->buffer_ptr = ctask->buffer; |
724 | curl_easy_pause (ctask->curl, CURLPAUSE_CONT); | 725 | if (NULL != ctask->curl) |
726 | curl_easy_pause (ctask->curl, CURLPAUSE_CONT); | ||
725 | GNUNET_SCHEDULER_add_now (&run_mhd, ctask->mhd); | 727 | GNUNET_SCHEDULER_add_now (&run_mhd, ctask->mhd); |
726 | } | 728 | } |
727 | } | 729 | } |
@@ -819,6 +821,9 @@ curl_task_download (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
819 | struct ProxyCurlTask *ctask; | 821 | struct ProxyCurlTask *ctask; |
820 | int num_ctasks; | 822 | int num_ctasks; |
821 | 823 | ||
824 | struct ProxyCurlTask *clean_head = NULL; | ||
825 | struct ProxyCurlTask *clean_tail = NULL; | ||
826 | |||
822 | curl_download_task = GNUNET_SCHEDULER_NO_TASK; | 827 | curl_download_task = GNUNET_SCHEDULER_NO_TASK; |
823 | 828 | ||
824 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 829 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
@@ -875,6 +880,9 @@ curl_task_download (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
875 | 880 | ||
876 | for (; ctask != NULL; ctask = ctask->next) | 881 | for (; ctask != NULL; ctask = ctask->next) |
877 | { | 882 | { |
883 | if (NULL == ctask->curl) | ||
884 | continue; | ||
885 | |||
878 | if (memcmp (msg->easy_handle, ctask->curl, sizeof (CURL)) != 0) | 886 | if (memcmp (msg->easy_handle, ctask->curl, sizeof (CURL)) != 0) |
879 | continue; | 887 | continue; |
880 | 888 | ||
@@ -886,8 +894,10 @@ curl_task_download (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
886 | ctask->download_error = GNUNET_YES; | 894 | ctask->download_error = GNUNET_YES; |
887 | //curl_multi_remove_handle (curl_multi, ctask->curl); | 895 | //curl_multi_remove_handle (curl_multi, ctask->curl); |
888 | //curl_easy_cleanup (ctask->curl); | 896 | //curl_easy_cleanup (ctask->curl); |
897 | //ctask->curl = NULL; | ||
889 | GNUNET_CONTAINER_DLL_remove (ctasks_head, ctasks_tail, | 898 | GNUNET_CONTAINER_DLL_remove (ctasks_head, ctasks_tail, |
890 | ctask); | 899 | ctask); |
900 | GNUNET_CONTAINER_DLL_insert (clean_head, clean_tail, ctask); | ||
891 | break; | 901 | break; |
892 | } | 902 | } |
893 | GNUNET_assert (ctask != NULL); | 903 | GNUNET_assert (ctask != NULL); |
@@ -899,6 +909,9 @@ curl_task_download (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
899 | 909 | ||
900 | for (; ctask != NULL; ctask = ctask->next) | 910 | for (; ctask != NULL; ctask = ctask->next) |
901 | { | 911 | { |
912 | if (NULL == ctask->curl) | ||
913 | continue; | ||
914 | |||
902 | if (memcmp (msg->easy_handle, ctask->curl, sizeof (CURL)) != 0) | 915 | if (memcmp (msg->easy_handle, ctask->curl, sizeof (CURL)) != 0) |
903 | continue; | 916 | continue; |
904 | 917 | ||
@@ -907,8 +920,11 @@ curl_task_download (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
907 | ctask->download_successful = GNUNET_YES; | 920 | ctask->download_successful = GNUNET_YES; |
908 | //curl_multi_remove_handle (curl_multi, ctask->curl); | 921 | //curl_multi_remove_handle (curl_multi, ctask->curl); |
909 | //curl_easy_cleanup (ctask->curl); | 922 | //curl_easy_cleanup (ctask->curl); |
923 | //ctask->curl = NULL; | ||
910 | GNUNET_CONTAINER_DLL_remove (ctasks_head, ctasks_tail, | 924 | GNUNET_CONTAINER_DLL_remove (ctasks_head, ctasks_tail, |
911 | ctask); | 925 | ctask); |
926 | GNUNET_CONTAINER_DLL_insert (clean_head, clean_tail, ctask); | ||
927 | |||
912 | break; | 928 | break; |
913 | } | 929 | } |
914 | GNUNET_assert (ctask != NULL); | 930 | GNUNET_assert (ctask != NULL); |
@@ -921,6 +937,15 @@ curl_task_download (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
921 | break; | 937 | break; |
922 | } | 938 | } |
923 | } while (msgnum > 0); | 939 | } while (msgnum > 0); |
940 | |||
941 | for (ctask=clean_head; ctask != NULL; ctask = ctask->next) | ||
942 | { | ||
943 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
944 | "Removing cURL task %s.\n", ctask->url); | ||
945 | curl_multi_remove_handle (curl_multi, ctask->curl); | ||
946 | curl_easy_cleanup (ctask->curl); | ||
947 | ctask->curl = NULL; | ||
948 | } | ||
924 | 949 | ||
925 | num_ctasks=0; | 950 | num_ctasks=0; |
926 | for (ctask=ctasks_head; ctask != NULL; ctask = ctask->next) | 951 | for (ctask=ctasks_head; ctask != NULL; ctask = ctask->next) |
@@ -1017,7 +1042,7 @@ process_leho_lookup (void *cls, | |||
1017 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1042 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1018 | "SSL target server: %s\n", ssl_ip); | 1043 | "SSL target server: %s\n", ssl_ip); |
1019 | sprintf (resolvename, "%s:%d:%s", ctask->leho, HTTPS_PORT, ssl_ip); | 1044 | sprintf (resolvename, "%s:%d:%s", ctask->leho, HTTPS_PORT, ssl_ip); |
1020 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1045 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1021 | "Curl resolve: %s\n", resolvename); | 1046 | "Curl resolve: %s\n", resolvename); |
1022 | ctask->resolver = curl_slist_append ( ctask->resolver, resolvename); | 1047 | ctask->resolver = curl_slist_append ( ctask->resolver, resolvename); |
1023 | curl_easy_setopt (ctask->curl, CURLOPT_RESOLVE, ctask->resolver); | 1048 | curl_easy_setopt (ctask->curl, CURLOPT_RESOLVE, ctask->resolver); |
@@ -1123,7 +1148,7 @@ create_response (void *cls, | |||
1123 | struct MhdHttpList* hd = cls; | 1148 | struct MhdHttpList* hd = cls; |
1124 | const char* page = "<html><head><title>gnoxy</title>"\ | 1149 | const char* page = "<html><head><title>gnoxy</title>"\ |
1125 | "</head><body>cURL fail</body></html>"; | 1150 | "</head><body>cURL fail</body></html>"; |
1126 | struct MHD_Response *response = NULL; | 1151 | |
1127 | char host[265]; | 1152 | char host[265]; |
1128 | char curlurl[512]; | 1153 | char curlurl[512]; |
1129 | int ret = MHD_YES; | 1154 | int ret = MHD_YES; |
@@ -1162,13 +1187,13 @@ create_response (void *cls, | |||
1162 | 1187 | ||
1163 | if ((ctask->curl == NULL) || (curl_multi == NULL)) | 1188 | if ((ctask->curl == NULL) || (curl_multi == NULL)) |
1164 | { | 1189 | { |
1165 | response = MHD_create_response_from_buffer (strlen (page), | 1190 | ctask->response = MHD_create_response_from_buffer (strlen (page), |
1166 | (void*)page, | 1191 | (void*)page, |
1167 | MHD_RESPMEM_PERSISTENT); | 1192 | MHD_RESPMEM_PERSISTENT); |
1168 | ret = MHD_queue_response (con, | 1193 | ret = MHD_queue_response (con, |
1169 | MHD_HTTP_OK, | 1194 | MHD_HTTP_OK, |
1170 | response); | 1195 | ctask->response); |
1171 | MHD_destroy_response (response); | 1196 | MHD_destroy_response (ctask->response); |
1172 | GNUNET_free (ctask); | 1197 | GNUNET_free (ctask); |
1173 | return ret; | 1198 | return ret; |
1174 | } | 1199 | } |
@@ -1213,13 +1238,13 @@ create_response (void *cls, | |||
1213 | //download_prepare (ctask); | 1238 | //download_prepare (ctask); |
1214 | //curl_download_prepare (); | 1239 | //curl_download_prepare (); |
1215 | 1240 | ||
1216 | response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, | 1241 | ctask->response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, |
1217 | MHD_SIZE_UNKNOWN, | 1242 | 20, |
1218 | &mhd_content_cb, | 1243 | &mhd_content_cb, |
1219 | ctask, | 1244 | ctask, |
1220 | &mhd_content_free); | 1245 | NULL); |
1221 | 1246 | ||
1222 | ret = MHD_queue_response (con, MHD_HTTP_OK, response); | 1247 | ret = MHD_queue_response (con, MHD_HTTP_OK, ctask->response); |
1223 | 1248 | ||
1224 | //MHD_destroy_response (response); | 1249 | //MHD_destroy_response (response); |
1225 | 1250 | ||
@@ -1518,7 +1543,7 @@ add_handle_to_mhd (struct GNUNET_NETWORK_Handle *h, struct MHD_Daemon *daemon) | |||
1518 | struct sockaddr *addr; | 1543 | struct sockaddr *addr; |
1519 | socklen_t len; | 1544 | socklen_t len; |
1520 | 1545 | ||
1521 | fd = GNUNET_NETWORK_get_fd (h); | 1546 | fd = dup (GNUNET_NETWORK_get_fd (h)); |
1522 | addr = GNUNET_NETWORK_get_addr (h); | 1547 | addr = GNUNET_NETWORK_get_addr (h); |
1523 | len = GNUNET_NETWORK_get_addrlen (h); | 1548 | len = GNUNET_NETWORK_get_addrlen (h); |
1524 | 1549 | ||
@@ -1782,6 +1807,7 @@ add_handle_to_ssl_mhd (struct GNUNET_NETWORK_Handle *h, char* domain) | |||
1782 | { | 1807 | { |
1783 | struct MhdHttpList *hd = NULL; | 1808 | struct MhdHttpList *hd = NULL; |
1784 | struct ProxyGNSCertificate *pgc; | 1809 | struct ProxyGNSCertificate *pgc; |
1810 | struct NetworkHandleList *nh; | ||
1785 | 1811 | ||
1786 | for (hd = mhd_httpd_head; hd != NULL; hd = hd->next) | 1812 | for (hd = mhd_httpd_head; hd != NULL; hd = hd->next) |
1787 | { | 1813 | { |
@@ -1821,6 +1847,13 @@ add_handle_to_ssl_mhd (struct GNUNET_NETWORK_Handle *h, char* domain) | |||
1821 | 1847 | ||
1822 | GNUNET_CONTAINER_DLL_insert (mhd_httpd_head, mhd_httpd_tail, hd); | 1848 | GNUNET_CONTAINER_DLL_insert (mhd_httpd_head, mhd_httpd_tail, hd); |
1823 | } | 1849 | } |
1850 | |||
1851 | nh = GNUNET_malloc (sizeof (struct NetworkHandleList)); | ||
1852 | nh->h = h; | ||
1853 | |||
1854 | GNUNET_CONTAINER_DLL_insert (hd->socket_handles_head, | ||
1855 | hd->socket_handles_tail, | ||
1856 | nh); | ||
1824 | 1857 | ||
1825 | return add_handle_to_mhd (h, hd->daemon); | 1858 | return add_handle_to_mhd (h, hd->daemon); |
1826 | } | 1859 | } |
@@ -1851,6 +1884,8 @@ do_read (void* cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1851 | struct sockaddr_in remote_addr; | 1884 | struct sockaddr_in remote_addr; |
1852 | struct in_addr *r_sin_addr; | 1885 | struct in_addr *r_sin_addr; |
1853 | 1886 | ||
1887 | struct NetworkHandleList *nh; | ||
1888 | |||
1854 | s5r->rtask = GNUNET_SCHEDULER_NO_TASK; | 1889 | s5r->rtask = GNUNET_SCHEDULER_NO_TASK; |
1855 | 1890 | ||
1856 | if ((NULL != tc->write_ready) && | 1891 | if ((NULL != tc->write_ready) && |
@@ -1947,6 +1982,13 @@ do_read (void* cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1947 | { | 1982 | { |
1948 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1983 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1949 | "Requested connection is HTTP\n"); | 1984 | "Requested connection is HTTP\n"); |
1985 | nh = GNUNET_malloc (sizeof (struct NetworkHandleList)); | ||
1986 | nh->h = s5r->sock; | ||
1987 | |||
1988 | GNUNET_CONTAINER_DLL_insert (mhd_httpd_head->socket_handles_head, | ||
1989 | mhd_httpd_head->socket_handles_tail, | ||
1990 | nh); | ||
1991 | |||
1950 | ret = add_handle_to_mhd ( s5r->sock, httpd ); | 1992 | ret = add_handle_to_mhd ( s5r->sock, httpd ); |
1951 | } | 1993 | } |
1952 | 1994 | ||
@@ -2160,9 +2202,15 @@ do_shutdown (void *cls, | |||
2160 | 2202 | ||
2161 | struct MhdHttpList *hd; | 2203 | struct MhdHttpList *hd; |
2162 | struct MhdHttpList *tmp_hd; | 2204 | struct MhdHttpList *tmp_hd; |
2205 | struct NetworkHandleList *nh; | ||
2206 | struct NetworkHandleList *tmp_nh; | ||
2163 | struct ProxyCurlTask *ctask; | 2207 | struct ProxyCurlTask *ctask; |
2164 | struct ProxyCurlTask *ctask_tmp; | 2208 | struct ProxyCurlTask *ctask_tmp; |
2209 | |||
2210 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
2211 | "Shutting down...\n"); | ||
2165 | 2212 | ||
2213 | MHD_fini (); | ||
2166 | gnutls_global_deinit (); | 2214 | gnutls_global_deinit (); |
2167 | 2215 | ||
2168 | if (GNUNET_SCHEDULER_NO_TASK != curl_download_task) | 2216 | if (GNUNET_SCHEDULER_NO_TASK != curl_download_task) |
@@ -2193,6 +2241,15 @@ do_shutdown (void *cls, | |||
2193 | hd->daemon = NULL; | 2241 | hd->daemon = NULL; |
2194 | } | 2242 | } |
2195 | 2243 | ||
2244 | for (nh = hd->socket_handles_head; nh != NULL; nh = tmp_nh) | ||
2245 | { | ||
2246 | tmp_nh = nh->next; | ||
2247 | |||
2248 | GNUNET_NETWORK_socket_close (nh->h); | ||
2249 | |||
2250 | GNUNET_free (nh); | ||
2251 | } | ||
2252 | |||
2196 | if (NULL != hd->proxy_cert) | 2253 | if (NULL != hd->proxy_cert) |
2197 | { | 2254 | { |
2198 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2255 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2215,6 +2272,12 @@ do_shutdown (void *cls, | |||
2215 | ctask->curl = NULL; | 2272 | ctask->curl = NULL; |
2216 | if (NULL != ctask->headers) | 2273 | if (NULL != ctask->headers) |
2217 | curl_slist_free_all (ctask->headers); | 2274 | curl_slist_free_all (ctask->headers); |
2275 | if (NULL != ctask->resolver) | ||
2276 | curl_slist_free_all (ctask->resolver); | ||
2277 | |||
2278 | if (NULL != ctask->response) | ||
2279 | MHD_destroy_response (ctask->response); | ||
2280 | |||
2218 | 2281 | ||
2219 | GNUNET_free (ctask); | 2282 | GNUNET_free (ctask); |
2220 | } | 2283 | } |
@@ -2569,6 +2632,7 @@ main (int argc, char *const *argv) | |||
2569 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 2632 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
2570 | return 2; | 2633 | return 2; |
2571 | 2634 | ||
2635 | |||
2572 | GNUNET_log_setup ("gnunet-gns-proxy", "WARNING", NULL); | 2636 | GNUNET_log_setup ("gnunet-gns-proxy", "WARNING", NULL); |
2573 | ret = | 2637 | ret = |
2574 | (GNUNET_OK == | 2638 | (GNUNET_OK == |
@@ -2576,5 +2640,7 @@ main (int argc, char *const *argv) | |||
2576 | _("GNUnet GNS proxy"), | 2640 | _("GNUnet GNS proxy"), |
2577 | options, | 2641 | options, |
2578 | &run, NULL)) ? 0 : 1; | 2642 | &run, NULL)) ? 0 : 1; |
2643 | GNUNET_free_non_null ((char*)argv); | ||
2644 | |||
2579 | return ret; | 2645 | return ret; |
2580 | } | 2646 | } |