--- parser3/src/classes/curl.C 2020/10/14 21:20:15 1.63 +++ parser3/src/classes/curl.C 2020/12/15 17:10:27 1.67 @@ -1,7 +1,7 @@ /** @file Parser: @b curl parser class. - Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com) */ #include "pa_config_includes.h" @@ -17,7 +17,7 @@ #include "pa_http.h" #include "ltdl.h" -volatile const char * IDENT_CURL_C="$Id: curl.C,v 1.63 2020/10/14 21:20:15 moko Exp $"; +volatile const char * IDENT_CURL_C="$Id: curl.C,v 1.67 2020/12/15 17:10:27 moko Exp $"; class MCurl: public Methoded { public: @@ -116,10 +116,14 @@ static ParserOptions &options(){ class Temp_curl { CURL *saved_curl; ParserOptions *saved_options; + + // every TLS should be referenced elsewhere, or GC will collect it + CURL *thread_curl; + ParserOptions *thread_options; public: Temp_curl() : saved_curl(fcurl), saved_options(foptions){ - fcurl = f_curl_easy_init(); - foptions = new ParserOptions(); + thread_curl = fcurl = f_curl_easy_init(); + thread_options = foptions = new ParserOptions(); f_curl_easy_setopt(fcurl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); // avoid ipv6 by default } @@ -523,13 +527,13 @@ static void curl_setopt(HashStringValue: } case CurlOption::CURL_FILE:{ // file-spec curl option - const char *file_spec_cstr=curl_check_file(r.absolute(v.as_string())); + const char *file_spec_cstr=curl_check_file(r.full_disk_path(v.as_string())); res=f_curl_easy_setopt(curl(), opt->id, file_spec_cstr); break; } case CurlOption::CURL_STDERR:{ // verbose output redirection from stderr to file curl option - const char *file_spec_cstr=curl_check_file(r.absolute(v.as_string())); + const char *file_spec_cstr=curl_check_file(r.full_disk_path(v.as_string())); FILE *f_stderr=options().f_stderr=pa_fopen(file_spec_cstr, "wt"); if (f_stderr){ res=f_curl_easy_setopt(curl(), opt->id, f_stderr); @@ -744,7 +748,7 @@ static void _curl_load_action(Request& r case CURLE_SSL_ENGINE_INITFAILED: ex_type = "curl.ssl"; break; case CURLE_WRITE_ERROR: - check_file_size(response.content_length, *new String(options().url)); break; + check_file_size(response.content_length, new String(options().url)); break; default: break; } throw Exception( PA_DEFAULT(ex_type, "curl.fail"), new String(options().url), "%s", f_curl_easy_strerror(res));