Fixed is_resource does not works when use Runtime::enableCoroutine() privately in filesystem. (#1854)

This commit is contained in:
李铭昕 2020-06-02 18:59:21 +08:00 committed by GitHub
parent dc4cf6dfe3
commit 7b363af5a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 10 deletions

View File

@ -44,6 +44,7 @@
## Fixed
- [#1825](https://github.com/hyperf/hyperf/pull/1825) Fixed `TypeError` for `StartServer::execute`.
- [#1854](https://github.com/hyperf/hyperf/pull/1854) Fixed `is_resource` does not works when use `Runtime::enableCoroutine()` privately in filesystem.
## Optimized

View File

@ -10,12 +10,11 @@ declare(strict_types=1);
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace Oss\OssClient {
use Swoole\Runtime;
function is_resource($resource)
{
if (! function_exists('swoole_hook_flags')) {
return \is_resource($resource) || $resource instanceof \Swoole\Curl\Handler;
}
if (swoole_hook_flags() & SWOOLE_HOOK_CURL) {
if (Runtime::getHookFlags() & SWOOLE_HOOK_CURL) {
return \is_resource($resource) || $resource instanceof \Swoole\Curl\Handler;
}
return \is_resource($resource);
@ -23,12 +22,11 @@ namespace Oss\OssClient {
}
namespace Oss\Http {
use Swoole\Runtime;
function is_resource($resource)
{
if (! function_exists('swoole_hook_flags')) {
return \is_resource($resource) || $resource instanceof \Swoole\Curl\Handler;
}
if (swoole_hook_flags() & SWOOLE_HOOK_CURL) {
if (Runtime::getHookFlags() & SWOOLE_HOOK_CURL) {
return \is_resource($resource) || $resource instanceof \Swoole\Curl\Handler;
}
return \is_resource($resource);

View File

@ -439,11 +439,11 @@ if (! function_exists('run')) {
if (! function_exists('swoole_hook_flags')) {
/**
* Return the currently enabled swoole hook flags.
* Return the default swoole hook flags, you can rewrite it by defining `SWOOLE_HOOK_FLAGS`.
*/
function swoole_hook_flags(): int
{
return \Swoole\Runtime::getHookFlags();
return defined('SWOOLE_HOOK_FLAGS') ? SWOOLE_HOOK_FLAGS : SWOOLE_HOOK_ALL;
}
}