curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: Adding/removing handles to the multi_handle produces unexpected result of curl_multi_perform

From: Daniel Stenberg via curl-library <curl-library_at_cool.haxx.se>
Date: Fri, 27 Sep 2019 17:26:33 +0200 (CEST)

On Fri, 27 Sep 2019, Denis Chapligin via curl-library wrote:

> //Here goes the main loop
> curl_multi_perform(multi_handle, &running_handles);
> while(running_handles>0){
> curl_multi_wait(multi_handle)
> while(curl_multi_info_read(multi_handle) {
> if(CURLMSG_DONE) {
> //success
> curl_multi_remove_handle(multi_handle, easy_handle);
> curl_easy_cleanup(easy_handle);
> } else {
> //Failure, need to retry
> curl_multi_remove_handle(multi_handle, easy_handle);
> curl_easy_cleanup(easy_handle);
> auto easy_handle = curl_easy_init();
> curl_multi_add_handle(multi_handle, easy_handle);
> curl_easy_setopt(m_handle, CURLOPT_URL, "http://www.example.org");
> }
> curl_multi_perform(multi_handle, &running_handles);
> }

Not sure if this is what happens for you, but if in this case the newly added
transfers fails really early, the first curl_multi_perform() call with the new
transfer will get a zero back in running_handles and this loop will stop.

-- 
  / daniel.haxx.se | Get the best commercial curl support there is - from me
                   | Private help, bug fixes, support, ports, new features
                   | https://www.wolfssl.com/contact/
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2019-09-27