-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
frankenphp: fix loop increment and break behavior #173
Conversation
@dunglas can you have a look at this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
|
After a night I reread my points and found point 1 to be ridiculous - the interpreter should evaluate the second condition because it's an AND! Here's the story: yesterday, I spent more than an hour trying to figure out why the runtime won't reset itself even when FRANKENPHP_LOOP_MAX is set to 1 when worker number is 1. I found that the (The following codes work as expected.) <?php
class Foo
{
private $loopMax = 10;
public function run()
{
$loops = 0;
do {
echo "loop $loops\n";
$ret = true;
gc_collect_cycles();
} while ($ret && (-1 === $this->loopMax || ++$loops < $this->loopMax));
}
}
$foo = new Foo();
$foo->run(); I request to put this PR on hold. The second fix is still correct; I'd like to fix my commit message first. Sorry for the inconvenience caused. |
The loop increment is indeed working fine. I've submitted #174 as a replacement. Sorry for the false alarm! |
Fixes the issue that the loop doesn't exist when `$loopMax` is reached, but `$loopMax+1`. Please refer to #173 for details.
Fixes the issue that the loop doesn't exist when `$loopMax` is reached, but `$loopMax+1`. Please refer to php-runtime/runtime#173 for details.
The current Runtime doesn't behavior as documented.
Found two issues in my testing, hence this PR:
$ret
is true (which seems to be always the case?), the remaining conditions won't be evaluated, so$loops
will never increment.$loopMax
to 1 will result in 2 requests be handled before resetting.I'm not very sure of what
$ret
does (I thought this will returnfalse
when an unrecoverable error occurs, turns out it won't), but in anyway it dosen't sound right for the number of request not incrementing when the response is a successful one.