Skip to content

Commit

Permalink
fix(async): MutliRunner burn CPU
Browse files Browse the repository at this point in the history
Fixes #55.
  • Loading branch information
mekras committed Apr 10, 2019
1 parent d023430 commit 3b201af
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/MultiRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,18 @@ public function wait(PromiseCore $targetCore = null): void
{
do {
$status = curl_multi_exec($this->multiHandle, $active);
curl_multi_select($this->multiHandle, 0.1);

This comment has been minimized.

Copy link
@jderusse

jderusse Apr 10, 2019

You should take https://bugs.php.net/bug.php?id=61141 into account.

https://github.com/guzzle/guzzle/blob/fa745406c2f48210693ba05f11280a1473037b2f/src/Handler/CurlMultiHandler.php#L106-L112

IMHO should be performed BEFORE the call to curl_multi_exec in order to wait for activity on the stream BEFORE reading it.

This comment has been minimized.

Copy link
@mekras

mekras Apr 10, 2019

Author Collaborator

OK!

$info = curl_multi_info_read($this->multiHandle);
if (false !== $info) {
if ($info !== false) {

This comment has been minimized.

Copy link
@thePanz

thePanz Jan 22, 2020

Please keep the YODA stile

$core = $this->findCoreByHandle($info['handle']);

if (null === $core) {
if ($core === null) {

This comment has been minimized.

Copy link
@thePanz

thePanz Jan 22, 2020

Please keep the YODA stile

// We have no promise for this handle. Drop it.
curl_multi_remove_handle($this->multiHandle, $info['handle']);
continue;
}

if (CURLE_OK === $info['result']) {
if ($info['result'] === CURLE_OK) {

This comment has been minimized.

Copy link
@thePanz

thePanz Jan 22, 2020

Please keep the YODA stile

$core->fulfill();
} else {
$error = curl_error($core->getHandle());
Expand Down

0 comments on commit 3b201af

Please sign in to comment.