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: Getting a list of easy handles in a multi handle - possible?

From: Dmitry Karpov via curl-library <curl-library_at_lists.haxx.se>
Date: Tue, 29 Aug 2023 19:08:28 +0000

Yes, you are right that for ABI integrity we can’t add a new parameter to curl_multi_cleanup().
The solution is either to add a new function like curl_multi_cleanup2() with a new parameter, or as you suggested - to add a the new multi option like CURLMOPT_FREE_EASY_ON_CLEANUP.

I like the new CURLMOPT_FREE_EASY_ON_CLEANUP multi-option approach.
If we can change this option any time after multi-handle creation then it is pretty easy and convenient to use.

Thanks,
Dmitry Karpov

From: Henrik Holst <henrik.holst_at_millistream.com>
Sent: Tuesday, August 29, 2023 11:54 AM
To: libcurl development <curl-library_at_lists.haxx.se>
Cc: Dmitry Karpov <dkarpov_at_roku.com>
Subject: Re: [EXTERNAL] Re: Getting a list of easy handles in a multi handle - possible?

curl_multi_cleanup() have no available parameter to add this so it would require a new function or changing the ABI of libcurl. However curl_multi_setopt() could perhaps have a new option added instead, say CURLMOPT_FREE_EASY_ON_CLEANUP or similar?

/HH

Den tis 29 aug. 2023 kl 20:49 skrev Dmitry Karpov via curl-library <curl-library_at_lists.haxx.se<mailto:curl-library_at_lists.haxx.se>>:
I think this discussion started from a pretty simple request to close and free easy handles that were previously added to a multi-handle
because the curl_multi_cleanup() removes easy handles from the multi-handle but doesn't close them.

This is snippet of the original message:
"Basically we have to maintain our own shadow list of the easy handles that we have added to the multi.
The only reason we need to do this is so that in case we close the plugin early, we can iterate over the easy handles which are still open and free them."
...
Alternatively, could there be an operation which frees up the multi handle and any also frees the easy handles that it contains?
(curl_multi_cleanup removes the easy handles from the multi, but doesn't free them.)"

I should tell that I had to keep such lists of easy handles myself exactly for the same purpose.

To help freeing easy handles when the multi-handle is cleaned up, I think it will be just enough to add a "clean_easy"
parameter to the curl_multi_cleanup(), which will allow to clean up the easy handles along with the multi-handle in just one call.

This will be an easy solution without any potential issues of changing multi-handle state from easy handle iterating callbacks or between easy handle iterator calls.

Thanks,
Dmitry Karpov



-----Original Message-----
From: curl-library <curl-library-bounces_at_lists.haxx.se<mailto:curl-library-bounces_at_lists.haxx.se>> On Behalf Of Daniel Stenberg via curl-library
Sent: Monday, August 28, 2023 3:27 PM
To: Paul Fotheringham <fotheringham.paul_at_gmail.com<mailto:fotheringham.paul_at_gmail.com>>
Cc: Daniel Stenberg <daniel_at_haxx.se<mailto:daniel_at_haxx.se>>; libcurl development <curl-library_at_lists.haxx.se<mailto:curl-library_at_lists.haxx.se>>
Subject: [EXTERNAL] Re: Getting a list of easy handles in a multi handle - possible?

On Mon, 28 Aug 2023, Paul Fotheringham wrote:

> To my mind you only need to consider two things to make it safe:
>
> 1. Make a copy of the handle list initially to ensure handles added by
> the callbacks don't get a callback invoked on them.
> 2. After each callback finishes check that the next handle is still in
> the multi's list to ensure we skip any handle removed by the
> callbacks.

Sure. Or we avoid the recursive callback and we don't complicate our lives more than we have to.

In this case, all non-callbacks version we have discussed seem much easier to me. Both to provide as an API and to use as an application.

--

  / daniel.haxx.se<http://daniel.haxx.se>
  | Commercial curl support up to 24x7 is available!
  | Private help, bug fixes, support, ports, new features
  | https://curl.se/support.html
--
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette: https://curl.se/mail/etiquette.html
--
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette: https://curl.se/mail/etiquette.html

-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2023-08-29