php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51314 curl_multi_init example uses to many cpu cycles
Submitted: 2010-03-17 16:06 UTC Modified: 2010-03-18 16:30 UTC
From: casper at procurios dot nl Assigned: kalle (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2010-03-17 16:06 UTC] casper at procurios dot nl
Description:
------------
At the curl_multi_init there is an example that says:

$running=null;
//execute the handles
do {
    curl_multi_exec($mh,$running);
} while ($running > 0);

This causes a *very* tight loop while curl requests the files, as a result an 
almost 100% cpu usage.

My suggestion is to put a usleep() with a 10ms delay inside the loop:

$running=null;
//execute the handles
do {
    usleep(10000);
    curl_multi_exec($mh,$running);
} while ($running > 0);



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-18 16:30 UTC] kalle@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=296344
Log: Fixed bug #51314 (curl_multi_init example uses to many cpu cycles)
 [2010-03-18 16:30 UTC] kalle@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: kalle
 [2010-03-18 16:30 UTC] kalle@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2020-02-07 06:09 UTC] phpdocbot@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=280694b9fb72a5ab3ae55489e6ae672cef43cf3f
Log: Fixed bug #51314 (curl_multi_init example uses to many cpu cycles)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 05:01:33 2024 UTC