How many times does curl_multi_exec have to be called?

KaraS

New Member
I'm using curl_multi with multi to upload files to different servers. Each server has multiple files that need uploading, so I have a curl_multi request for each server. When I execute the curl_multi handles, I just execute all the curl_multi handles in the same loop, like so:\[code\]<?phpdo { $continue_running=false; foreach($handles as $host => $handle) { if(!is_resource($handle[0])) { die("\nHandle is not a resource!\n"); } if($running_{$host}) { if(curl_multi_exec($handles[$host][0], $running_{$host}) != CURLM_OK) { die("\ncurl_multi_exec failed!\n"); } $continue_running=true; } if(!$running_{$host} && !$done_{$host}) { echo "$host finished in ".(microtime(1)-$start)." seconds\n"; $done_{$host}=true; } }} while ($continue_running);?>\[/code\]What I'm wondering is, how many times does curl_multi_exec actually have to be called in a curl request? Does it need to be called for each little bit of data transfered? Its using a lot of cpu and I'm thinking that its because its "busy looping" too much. So can I add sleep(5); at the end of each loop to make it use less cpu cycles, or will this slow down the requests majorly?I would use curl_multi_select, but I cant because theres multiple curl_multi_execs being processed.
 
Back
Top