Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed May 12, 2020
1 parent e25f262 commit 9996328
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion swoole_coroutine.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ enum sw_coro_hook_type
SW_HOOK_CURL = 1u << 28,
SW_HOOK_BLOCKING_FUNCTION = 1u << 30,

SW_HOOK_ALL = 0x7fffffff ^ SW_HOOK_CURL /* TODO: remove it */
SW_HOOK_ALL = 0x7fffffff ^ SW_HOOK_CURL /* TODO: remove it [v4.6] */
};

struct php_coro_task
Expand Down
33 changes: 18 additions & 15 deletions swoole_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1176,9 +1176,12 @@ bool PHPCoroutine::enable_hook(int flags)
{
if (hook_flags & SW_HOOK_TLS)
{
if (ori_factory.tls != nullptr) {
if (ori_factory.tls != nullptr)
{
php_stream_xport_register("tls", ori_factory.tls);
} else {
}
else
{
php_stream_xport_unregister("tls");
}
}
Expand Down Expand Up @@ -1271,8 +1274,8 @@ bool PHPCoroutine::enable_hook(int flags)
if (hook_flags & SW_HOOK_BLOCKING_FUNCTION)
{
SW_UNHOOK_FUNC(gethostbyname);
unhook_func(ZEND_STRL("exec"));
unhook_func(ZEND_STRL("shell_exec"));
SW_UNHOOK_FUNC(exec);
SW_UNHOOK_FUNC(shell_exec);
}
}

Expand All @@ -1296,16 +1299,16 @@ bool PHPCoroutine::enable_hook(int flags)
{
if (hook_flags & SW_HOOK_CURL)
{
unhook_func(ZEND_STRL("curl_init"));
unhook_func(ZEND_STRL("curl_setopt"));
unhook_func(ZEND_STRL("curl_setopt_array"));
unhook_func(ZEND_STRL("curl_exec"));
unhook_func(ZEND_STRL("curl_getinfo"));
unhook_func(ZEND_STRL("curl_errno"));
unhook_func(ZEND_STRL("curl_error"));
unhook_func(ZEND_STRL("curl_reset"));
unhook_func(ZEND_STRL("curl_close"));
unhook_func(ZEND_STRL("curl_multi_getcontent"));
SW_UNHOOK_FUNC(curl_init);
SW_UNHOOK_FUNC(curl_setopt);
SW_UNHOOK_FUNC(curl_setopt_array);
SW_UNHOOK_FUNC(curl_exec);
SW_UNHOOK_FUNC(curl_getinfo);
SW_UNHOOK_FUNC(curl_errno);
SW_UNHOOK_FUNC(curl_error);
SW_UNHOOK_FUNC(curl_reset);
SW_UNHOOK_FUNC(curl_close);
SW_UNHOOK_FUNC(curl_multi_getcontent);
}
}

Expand All @@ -1321,7 +1324,7 @@ bool PHPCoroutine::disable_hook()
static PHP_METHOD(swoole_runtime, enableCoroutine)
{
zval *zflags = nullptr;
/*TODO: enable SW_HOOK_CURL by default after curl handler completed */
/*TODO:[v4.6] enable SW_HOOK_CURL by default after curl handler completed */
zend_long flags = SW_HOOK_ALL;

ZEND_PARSE_PARAMETERS_START(0, 2)
Expand Down

0 comments on commit 9996328

Please sign in to comment.