cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Re[2]: exception in libcurl

From: m brandenberg <mcbinc_at_panix.com>
Date: Sun, 22 Mar 2015 00:12:58 -0400 (EDT)

On Sun, 22 Mar 2015, ~Vен~O wrote:

> And one more:

What OS?
What version of libcurl?
Libcurl with c-ares or threaded resolver?
What compiler chain?
What *actual* error message?

libcurl is C, not C++. It does not throw exceptions. An
actual C++ exception would likely be a problem in your code.

>
> curl_global_init(CURL_GLOBAL_ALL);
> CURLM* curl_m = curl_multi_init();
> curl_multi_setopt(curl_m, CURLMOPT_MAX_TOTAL_CONNECTIONS , long(100));
> curl_multi_setopt(curl_m, CURLMOPT_MAXCONNECTS, long(100));
>
> CURLSH* curl_sh = curl_share_init();
> std::vector<CURL*> h;
> h.resize(600);
> while(1)
> {
> for(int i=0; i<600; i++)
> {
>    h[i] = curl_easy_init();

Check the pointer return for validity.

>   curl_easy_setopt(h[i], CURLOPT_URL, "primorye.ru");

That is not a URL.
Check the return status code.

>    curl_easy_setopt(h[i], CURLOPT_SHARE, curl_sh);

Check the return status code.
Binding a share object to the easy handle will disable the
   use of the multi objects shared data (dns, cookie, etc.)

>    CURLMcode c = curl_multi_add_handle(curl_m, h[i]);

Check the status code.

> }
> int running_handles;
> curl_multi_perform(curl_m, &running_handles);
> curl_multi_perform(curl_m, &running_handles);
> curl_multi_perform(curl_m, &running_handles);

Check the status codes. Assuming libcurl launched
GET against 'http://primorye.ru/', the above will
have handles in various states of incompleteness.
Should be handled cleanly below, perhaps not.

> for(int i=0; i<600; i++)
> {
>    CURLMcode c = curl_multi_remove_handle(curl_m, h[i]);

Check the status code.

>    curl_easy_cleanup(h[i]);
> }
> printf("+");
> }

m

--
Monty Brandenberg

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-03-22