Skip to content

Commit

Permalink
Add enable hook can only be run in CLI mode (#3823)
Browse files Browse the repository at this point in the history
* Add enable hook can only be run in CLI mode

* fix

* fix
  • Loading branch information
sy-records authored Nov 9, 2020
1 parent 46aee5a commit fd689d0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ext-src/swoole_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,10 @@ bool PHPCoroutine::disable_hook() {
}

static PHP_METHOD(swoole_runtime, enableCoroutine) {
if (!SWOOLE_G(cli)) {
php_swoole_fatal_error(E_ERROR, "must be used in PHP CLI mode");
RETURN_FALSE;
}
zval *zflags = nullptr;
zend_long flags = PHPCoroutine::HOOK_ALL;

Expand Down Expand Up @@ -1200,6 +1204,10 @@ static PHP_METHOD(swoole_runtime, getHookFlags) {
}

static PHP_METHOD(swoole_runtime, setHookFlags) {
if (!SWOOLE_G(cli)) {
php_swoole_fatal_error(E_ERROR, "must be used in PHP CLI mode");
RETURN_FALSE;
}
zend_long flags = PHPCoroutine::HOOK_ALL;

ZEND_PARSE_PARAMETERS_START(1, 1)
Expand Down

0 comments on commit fd689d0

Please sign in to comment.