I use curl_multi functions to request multiple URLs and process them as they complete. Since one connection completes all that I really have, it is a cURL descriptor (and related data) from curl_multi_info_read() .
The urls come from the job queue, and after processing I need to remove the job from the queue. I don't want to rely on the url to define the job (there shouldn't be duplicate urls, but what if there is one).
The solution I have developed so far is to use the cURL descriptor as the key of an array pointing to jobid. The form I can say when processed as a string, the handle looks something like this:
"Resource id #1"
These seams are reasonably unique to me. Main code:
$ch = curl_init($job->getUrl()); $handles[$ch] = $job; //then later $done = curl_multi_info_read($master); $handles[$done['handle']]->delete(); curl_multi_remove_handle($master, $done['handle']);
Is the cURL handle safe to use this way?
Or is there a better way to map cURL descriptors to the job he created?
source share