Is curl_multi_exec() a blocking call?
curl, curl-multi, libcurl, php
Solution
Shot answer : `curl_multi_exec()` is non-blocking
Longer answer : `curl_multi_exec()` is non-blocking, but blocking can be made with the combination of `curl_multi_select`, which blocks until there is activity on any of the curl_multi connections.
Edit: Currently I am working on a crawler, this is outline of a piece of code I used.
do {
$mrc = curl_multi_exec($mh, $active);
if($to_db_queue->count()>0){
while($to_db_queue->count()>0)
//dequeue from queue and insert into database
}
else
curl_multi_select($mh); //block till state change
} while ($active > 0);
This code will make a `curl_multi_exec` and then will continue its database work queued in `$to_db_queue`, else if nothing in queue `curl_multi_select` will be called to block the loop until a state change occur in curl_multi connections.
Hope this will help you understand the concept.
Problem
Was just curious if the `curl_multi_exec()` call in PHP is blocking or non-blocking call.