Edit report at https://bugs.php.net/bug.php?id=61240&edit=1

 ID:                 61240
 Comment by:         niniwzw at qq dot com
 Reported by:        niniwzw at qq dot com
 Summary:            curl_multi_select cause cpu load 100%
 Status:             Open
 Type:               Bug
 Package:            cURL related
 Operating System:   window xp
 PHP Version:        5.3.10
 Block user comment: N
 Private report:     N

 New Comment:

the best solution work without the curl_multi_select may be this:
<?php
// create both cURL resources
$ch1 = curl_init();
$ch2 = curl_init();

// set URL and other appropriate options
curl_setopt($ch1, CURLOPT_URL, "http://lxr.php.net/";);
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/";);
curl_setopt($ch2, CURLOPT_HEADER, 0);

//create the multiple cURL handle
$mh = curl_multi_init();

//add the two handles
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);

$active = null;
$exec_count = 0;
do {
        $mrc = curl_multi_exec($mh, $active);
        usleep(1);
        $exec_count++;
} while ($mrc == CURLM_CALL_MULTI_PERFORM || ($active && $mrc == CURLM_OK));

//close the handles
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
curl_multi_close($mh);

var_dump($exec_count);
?>
I scan the source code of curl_multi_select, there was no change from php 
5.2.17 to 5.3.10, may be it's the problem of libcurl(curl_multi_fdset, fuction)


Previous Comments:
------------------------------------------------------------------------
[2012-04-03 16:27:47] bompus at gmail dot com

Related to 60790 and 61141

------------------------------------------------------------------------
[2012-03-02 08:51:47] niniwzw at qq dot com

Description:
------------
---
>From manual page: http://www.php.net/function.curl-multi-exec
---
In the document of curl_multi_exec, has a example in the document.
it can run in php 5.2, but php 5.3 and php 5.4 cause cpu load 100%.

the example is:
<?php
// create both cURL resources
$ch1 = curl_init();
$ch2 = curl_init();

// set URL and other appropriate options
curl_setopt($ch1, CURLOPT_URL, "http://lxr.php.net/";);
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/";);
curl_setopt($ch2, CURLOPT_HEADER, 0);

//create the multiple cURL handle
$mh = curl_multi_init();

//add the two handles
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);

$active = null;
//execute the handles
do {
    $mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);

while ($active && $mrc == CURLM_OK) {
    if (curl_multi_select($mh) != -1) {
        do {
            $mrc = curl_multi_exec($mh, $active);
        } while ($mrc == CURLM_CALL_MULTI_PERFORM);
    }
}

//close the handles
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
curl_multi_close($mh);

?>



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61240&edit=1

Reply via email to