Skip to content

Commit

Permalink
bug fix by reverting some of last commit, insure progressTask only …
Browse files Browse the repository at this point in the history
…execute if actual data is returned
  • Loading branch information
TheTechsTech committed Feb 28, 2021
1 parent 1a73de2 commit 9770a70
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Coroutine/FileSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ protected static function writeFile($fd, string $buffer, $immediately = false)
yield;
$fwrite = 0;
for ($written = 0; $written < \strlen($buffer); $written += $fwrite) {
yield Kernel::writeWait($fd, $immediately);
yield Kernel::writeWait($fd, (\is_bool($immediately) ? $immediately : false));
$fwrite = \fwrite($fd, \substr($buffer, $written));
// see https://www.php.net/manual/en/function.fwrite.php#96951
if (($fwrite === false) || ($fwrite == 0)) {
Expand Down Expand Up @@ -1187,7 +1187,7 @@ public static function meta($fd, ?string $info = null)
if ($info == 'status' && isset($meta['wrapper_data'])) {
$http_statusCode = 400;
foreach ($meta['wrapper_data'] as $headerLine) {
if (preg_match('/^HTTP\/(\d+\.\d+)\s+(\d+)\s*(.+)?$/', $headerLine, $result)) {
if (\preg_match('/^HTTP\/(\d+\.\d+)\s+(\d+)\s*(.+)?$/', $headerLine, $result)) {
$http_statusCode = (int) $result[2];
}
}
Expand Down
4 changes: 2 additions & 2 deletions Coroutine/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,8 @@ public static function progressTask(callable $handler)
if (\is_array($received) && (\count($received) == 2)) {
[$type, $data] = $received;
$received = null;
yield $handler($type, $data);
if (!\is_null($data))
yield $handler($type, $data);
}
}
});
Expand Down Expand Up @@ -818,7 +819,6 @@ function (TaskInterface $task, CoroutineInterface $coroutine) use ($taskId) {
continue;
}


if ($tasks->isPending()) {
$coroutine->execute();
} elseif ($tasks->isRescheduled()) {
Expand Down
2 changes: 1 addition & 1 deletion tests/FileSystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public function taskFileSendfile()
$this->assertEquals($size, $written);
$data = yield \file_contents($outFd);
$this->assertEquals('Hello', \trim($data));
$this->assertGreaterThanOrEqual(8, $this->counterResult);
$this->assertGreaterThanOrEqual(7, $this->counterResult);
yield \file_close($fd);
yield \file_close($outFd);

Expand Down
2 changes: 1 addition & 1 deletion tests/libuv/010-uv_ip4_addr.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Check for uv_ip4_addr
<?php
var_dump(uv_ip4_addr("0.0.0.0",0));
--EXPECTF--
object(UVSockAddrIPv4)#7 (0) {
object(UVSockAddrIPv4)#1 (0) {
}
2 changes: 1 addition & 1 deletion tests/libuv/010-uv_ip6_addr.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Check for uv_ip6_addr
<?php
var_dump(uv_ip6_addr("::0",0));
--EXPECTF--
object(UVSockAddrIPv6)#7 (0) {
object(UVSockAddrIPv6)#1 (0) {
}

0 comments on commit 9770a70

Please sign in to comment.