Search code examples
phpcurl-multi

PHP curl_multi removing and closing lingering handles


I have a loop that goes through approximately 3k urls using curl_multi and I need to know of away to remove any remaining handles from curl_multi to make sure I'm not wasting resources... is there any way to do it, or do I have to go though each of the 3k handles and remove them and then close them? What if they are already removed and closed?

I use a manual timeout at the end which accounts for cURL_multi's inability to timeout on the CURLOPT_CONNECTTIMEOUT / CURLOPT_TIMEOUT options and there may be lingering URL handles that are still 'trying' to get data.

I don't mind doing a foreach() loop, but how do I check to see if a handle has already been removed, if I try to remove it won't it cause a 'this is not set' type of error? Does removing a curl handle actually unset() that variable, i.e. I can run a isset() test on it?


Solution

  • Here is a pastebin of sorts that shows how to do what your asking.

    http://codepad.viper-7.com/eZeWLj