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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: casper at procurios dot nl
New email:
PHP Version: OS:

 

 [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: Fri May 24 12:01:32 2024 UTC