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-boun...@lists.haxx.se> On Behalf Of Daniel Stenberg via curl-library Sent: Monday, August 28, 2023 3:27 PM To: Paul Fotheringham <fotheringham.p...@gmail.com> Cc: Daniel Stenberg <dan...@haxx.se>; libcurl development <curl-library@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 | 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