Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support native-curl hook #3863

Merged
merged 57 commits into from
Nov 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
32874c5
Support cookie priority
matyhtf Nov 19, 2020
3b2b065
init
matyhtf Nov 19, 2020
b7e751f
save
matyhtf Nov 19, 2020
933d2bb
curl multi
matyhtf Nov 19, 2020
c935b65
curl multi [fix bug]
matyhtf Nov 20, 2020
e8c53c3
add option
matyhtf Nov 20, 2020
fe571d3
refactor
matyhtf Nov 20, 2020
1593f28
add tests
matyhtf Nov 20, 2020
b4aaae5
Revert "Support cookie priority"
matyhtf Nov 20, 2020
220d40a
revert
matyhtf Nov 20, 2020
cd68da5
fix tests
matyhtf Nov 20, 2020
0f0b001
Merge branch 'master' into curl-native
matyhtf Nov 20, 2020
37be603
fix tests [2]
matyhtf Nov 20, 2020
ef05fa8
sync latest version
matyhtf Nov 20, 2020
96d9b7b
fix
matyhtf Nov 20, 2020
0fd51c4
fix 2
matyhtf Nov 20, 2020
62ba90d
fix 3
matyhtf Nov 20, 2020
11517c4
fix 5
matyhtf Nov 20, 2020
e886d50
fix 6
matyhtf Nov 20, 2020
386b719
Merge branch 'master' into curl-native
matyhtf Nov 21, 2020
23e386e
fix 7
matyhtf Nov 21, 2020
90ec253
warning
matyhtf Nov 21, 2020
8e35c69
fix 9
matyhtf Nov 21, 2020
9638460
fix tests
matyhtf Nov 21, 2020
ded8688
Merge branch 'master' into curl-native
matyhtf Nov 21, 2020
a68d467
fix 10
matyhtf Nov 21, 2020
feedf3c
Modify some member functions to be private
matyhtf Nov 22, 2020
e54bb57
Merge branch 'master' into curl-native
matyhtf Nov 22, 2020
5da7b46
fix 11
matyhtf Nov 23, 2020
91f985f
fix 12
matyhtf Nov 23, 2020
4fb19bd
debug info
matyhtf Nov 23, 2020
0f98e5b
fix 12
matyhtf Nov 23, 2020
5ffbddc
Merge branch 'master' into curl-native
matyhtf Nov 23, 2020
63470a3
fix 13
matyhtf Nov 23, 2020
5ce4133
Delete -Werror
huanghantao Nov 23, 2020
7808ac3
fix 14, silent remove
matyhtf Nov 23, 2020
a404f8c
Merge branch 'curl-native' of github.com:swoole/swoole-src into curl-…
matyhtf Nov 23, 2020
aa86975
Remove read_info on timeout callback
huanghantao Nov 23, 2020
117a2bb
Fix timer leak
huanghantao Nov 24, 2020
94e7f76
Optimize the timer update logic
huanghantao Nov 24, 2020
79b3363
Add curl_multi.h
huanghantao Nov 24, 2020
677b2db
fix
matyhtf Nov 24, 2020
f2a5372
Compatible PHP8
huanghantao Nov 25, 2020
f5c3472
end
huanghantao Nov 25, 2020
61be96e
Fix build error
huanghantao Nov 25, 2020
2763f87
Defense
matyhtf Nov 26, 2020
c74b3a3
Merge branch 'curl-native' of github.com:swoole/swoole-src into curl-…
matyhtf Nov 26, 2020
6214cea
merge
matyhtf Nov 26, 2020
960cc27
Fix build error
huanghantao Nov 26, 2020
dedfff2
Fix segmentfault
huanghantao Nov 26, 2020
08a209b
Merge branch 'master' of github.com:swoole/swoole-src into curl-native
huanghantao Nov 26, 2020
dfb7c4c
Merge branch 'master' into curl-native
matyhtf Nov 28, 2020
4ecc5ba
Optimize code
matyhtf Nov 28, 2020
ce4e876
Try to fix compilation problem of php8
matyhtf Nov 28, 2020
e36bd7a
Try to fix compilation problem of php8 [2]
matyhtf Nov 28, 2020
927a3fd
Try to fix compilation problem of php8 [3]
matyhtf Nov 28, 2020
c3ca0b0
Try to fix compilation problem of php8 [4]
matyhtf Nov 28, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions .github/workflows/ext.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: install-deps
run: sudo apt install -y libcurl4-openssl-dev php-curl
- name: phpize
run: phpize
- name: build1
Expand All @@ -26,11 +28,17 @@ jobs:
- name: build6
run: ./configure --enable-sockets --enable-mysqlnd --enable-http2 --enable-openssl --enable-debug-log &&
make clean && make -j$(sysctl -n hw.ncpu)
- name: build7
run: ./configure --enable-sockets --enable-mysqlnd --enable-http2 --enable-swoole-curl --enable-swoole-json
--enable-openssl --enable-debug-log &&
make clean && make -j$(sysctl -n hw.ncpu)

build-ubuntu-old:
runs-on: ubuntu-16.04
steps:
- uses: actions/checkout@v1
- name: install-deps
run: sudo apt install -y libcurl4-openssl-dev php-curl
- name: phpize
run: phpize
- name: build1
Expand All @@ -48,14 +56,15 @@ jobs:
run: ./configure --enable-sockets --enable-mysqlnd --enable-http2 --enable-openssl &&
make clean && make -j$(sysctl -n hw.ncpu)
- name: build6
run: ./configure --enable-sockets --enable-mysqlnd --enable-http2 --enable-openssl --enable-debug-log &&
run: ./configure --enable-sockets --enable-mysqlnd --enable-http2 --enable-swoole-curl --enable-swoole-json
--enable-openssl --enable-debug-log &&
make clean && make -j$(sysctl -n hw.ncpu)

build-macos-latest:
runs-on: macos-latest
steps:
- name: install dependencies
run: brew install openssl && brew link openssl
run: brew install openssl && brew link openssl && brew install curl && brew link curl
- uses: actions/checkout@v1
- name: phpize
run: phpize
Expand All @@ -71,10 +80,12 @@ jobs:
run: ./configure --enable-sockets --enable-mysqlnd --enable-http2 &&
make clean && make -j$(sysctl -n hw.ncpu)
- name: build5
run: ./configure --enable-sockets --enable-mysqlnd --enable-http2 --enable-openssl --with-openssl-dir=/usr/local/opt/openssl@1.1 &&
run: ./configure --enable-sockets --enable-mysqlnd --enable-http2 --enable-openssl
--with-openssl-dir=/usr/local/opt/openssl@1.1 &&
make clean && make -j$(sysctl -n hw.ncpu)
- name: build6
run: ./configure --enable-sockets --enable-mysqlnd --enable-http2 --enable-openssl --with-openssl-dir=/usr/local/opt/openssl@1.1 --enable-debug-log &&
run: ./configure --enable-sockets --enable-mysqlnd --enable-http2 --enable-swoole-curl --enable-swoole-json
--enable-openssl --with-openssl-dir=/usr/local/opt/openssl@1.1 --enable-debug-log &&
make clean && make -j$(sysctl -n hw.ncpu)

build-alpine-latest:
Expand Down
10 changes: 9 additions & 1 deletion config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ PHP_ARG_ENABLE(swoole-dev, whether to enable Swoole developer build flags,
PHP_ARG_ENABLE(swoole-json, whether to enable Swoole JSON build flags,
[ --enable-swoole-json Enable JSON support], no, no)

PHP_ARG_ENABLE(swoole-curl, whether to enable Swoole CURL build flags,
[ --enable-swoole-curl Enable cURL support], no, no)

AC_DEFUN([SWOOLE_HAVE_PHP_EXT], [
extname=$1
haveext=$[PHP_]translit($1,a-z_-,A-Z__)
Expand Down Expand Up @@ -310,7 +313,6 @@ if test "$PHP_SWOOLE" != "no"; then
AX_CHECK_COMPILE_FLAG(-Wduplicate-enum, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wduplicate-enum")
AX_CHECK_COMPILE_FLAG(-Wempty-body, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wempty-body")
AX_CHECK_COMPILE_FLAG(-Wenum-compare, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wenum-compare")
AX_CHECK_COMPILE_FLAG(-Werror, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Werror")
AX_CHECK_COMPILE_FLAG(-Wextra, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wextra")
AX_CHECK_COMPILE_FLAG(-Wformat-security, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wformat-security")
AX_CHECK_COMPILE_FLAG(-Wheader-guard, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wheader-guard")
Expand Down Expand Up @@ -344,6 +346,10 @@ if test "$PHP_SWOOLE" != "no"; then
AC_DEFINE(SW_USE_JSON, 1, [do we enable json decoder])
fi

if test "$PHP_SWOOLE_CURL" = "yes"; then
AC_DEFINE(SW_USE_CURL, 1, [do we enable cURL native client])
fi

AC_CHECK_LIB(z, gzgets, [
AC_DEFINE(SW_HAVE_COMPRESSION, 1, [have compression])
AC_DEFINE(SW_HAVE_ZLIB, 1, [have zlib])
Expand Down Expand Up @@ -569,6 +575,7 @@ if test "$PHP_SWOOLE" != "no"; then
src/wrapper/timer.cc"

swoole_source_file="$swoole_source_file \
thirdparty/php/curl/interface.cc \
thirdparty/php/sockets/multicast.cc \
thirdparty/php/sockets/sendrecvmsg.cc \
thirdparty/php/sockets/conversions.cc \
Expand Down Expand Up @@ -717,4 +724,5 @@ if test "$PHP_SWOOLE" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/nghttp2)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php/sockets)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php/standard)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php/curl)
fi
34 changes: 34 additions & 0 deletions examples/curl/hook.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
Co::set(['hook_flags' => SWOOLE_HOOK_ALL | SWOOLE_HOOK_NATIVE_CURL, ]);
//Co::set(['hook_flags' => SWOOLE_HOOK_ALL, ]);

Co\run(function () {
$n = 3;
while($n--) {
go('test');
}
});

function test() {
echo "curl init\n";
$ch = curl_init();
// $url = 'https://www.baidu.com/';
$url = "http://127.0.0.1:9801/";

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($ch, $strHeader) {
//var_dump($ch, $strHeader);
return strlen($strHeader);
});

$output = curl_exec($ch);
var_dump($output);
var_dump(strlen($output));
if ($output === false) {
echo "CURL Error:" . curl_error($ch);
}
// var_dump($output);
curl_close($ch);
}
15 changes: 15 additions & 0 deletions examples/curl/server.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
$http = new Swoole\Http\Server("127.0.0.1", 9801);

$http->set(['worker_num' => 8, ]);

$http->on("start", function ($server) {
echo "Swoole http server is started at http://127.0.0.1:9501\n";
});

$http->on("request", function ($request, $response) {
sleep(1);
$response->end("Hello World\n");
});

$http->start();
10 changes: 8 additions & 2 deletions ext-src/php_swoole.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ static const zend_module_dep swoole_deps[] = {
#endif
#ifdef SW_SOCKETS
ZEND_MOD_REQUIRED("sockets")
#endif
#ifdef SW_USE_CURL
ZEND_MOD_REQUIRED("curl")
#endif
ZEND_MOD_END
};
Expand Down Expand Up @@ -380,8 +383,7 @@ static void fatal_error(int code, const char *format, ...) {
exception = zend_throw_exception(swoole_error_ce, swoole::std_string::vformat(format, args).c_str(), code);
va_end(args);
zend_exception_error(exception, E_ERROR);
// should never here
abort();
exit(255);
}

/* {{{ PHP_MINIT_FUNCTION
Expand Down Expand Up @@ -775,6 +777,7 @@ PHP_MINIT_FUNCTION(swoole) {
PHP_MSHUTDOWN_FUNCTION(swoole) {
swoole_clean();
zend::known_strings_dtor();
php_swoole_runtime_mshutdown();

return SUCCESS;
}
Expand Down Expand Up @@ -840,6 +843,9 @@ PHP_MINFO_FUNCTION(swoole) {
#ifdef SW_USE_JSON
php_info_print_table_row(2, "json", "enabled");
#endif
#ifdef SW_USE_CURL
php_info_print_table_row(2, "curl-native", "enabled");
#endif
#ifdef HAVE_PCRE
php_info_print_table_row(2, "pcre", "enabled");
#endif
Expand Down
21 changes: 21 additions & 0 deletions ext-src/php_swoole.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ enum php_swoole_fd_type
* for Co::fread/Co::fwrite
*/
PHP_SWOOLE_FD_CO_UTIL,
PHP_SWOOLE_FD_CO_CURL,
};
//---------------------------------------------------------
typedef enum
Expand Down Expand Up @@ -263,6 +264,12 @@ void php_swoole_event_init();
void php_swoole_event_wait();
void php_swoole_event_exit();

/**
* MSHUTDOWN
* ==============================================================
*/
void php_swoole_runtime_mshutdown() ;

static sw_inline zend_bool php_swoole_websocket_frame_is_object(zval *zdata)
{
return Z_TYPE_P(zdata) == IS_OBJECT && instanceof_function(Z_OBJCE_P(zdata), swoole_websocket_frame_ce);
Expand Down Expand Up @@ -436,6 +443,20 @@ static sw_inline zend_bool ZVAL_IS_BOOL(zval *v)
}
#endif

#ifndef ZVAL_IS_TRUE
static sw_inline zend_bool ZVAL_IS_TRUE(zval *v)
matyhtf marked this conversation as resolved.
Show resolved Hide resolved
{
return Z_TYPE_P(v) == IS_TRUE;
}
#endif

#ifndef ZVAL_IS_FALSE
static sw_inline zend_bool ZVAL_IS_FALSE(zval *v)
{
return Z_TYPE_P(v) == IS_FALSE;
}
#endif

#ifndef ZVAL_IS_LONG
static sw_inline zend_bool ZVAL_IS_LONG(zval *v)
{
Expand Down
7 changes: 4 additions & 3 deletions ext-src/php_swoole_coroutine.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ class PHPCoroutine {
HOOK_FILE = 1u << 8,
HOOK_SLEEP = 1u << 9,
HOOK_PROC = 1u << 10,
HOOK_CURL = 1u << 28,
HOOK_BLOCKING_FUNCTION = 1u << 30,
HOOK_ALL = 0x7fffffff,
HOOK_CURL = 1u << 11,
HOOK_NATIVE_CURL = 1u << 12,
HOOK_BLOCKING_FUNCTION = 1u << 13,
HOOK_ALL = 0x7fffffff ^ HOOK_NATIVE_CURL,
matyhtf marked this conversation as resolved.
Show resolved Hide resolved
};

static const uint8_t MAX_EXEC_MSEC = 10;
Expand Down
4 changes: 2 additions & 2 deletions ext-src/swoole_http_response.cc
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ static PHP_METHOD(swoole_http_response, sendfile) {
}

static void php_swoole_http_response_cookie(INTERNAL_FUNCTION_PARAMETERS, const bool url_encode) {
char *name, *value = nullptr, *path = nullptr, *domain = nullptr, *samesite = nullptr, *priority = nullptr;
char *name = nullptr, *value = nullptr, *path = nullptr, *domain = nullptr, *samesite = nullptr, *priority = nullptr;
zend_long expires = 0;
size_t name_len, value_len = 0, path_len = 0, domain_len = 0, samesite_len = 0, priority_len = 0;
zend_bool secure = 0, httponly = 0;
Expand All @@ -970,7 +970,7 @@ static void php_swoole_http_response_cookie(INTERNAL_FUNCTION_PARAMETERS, const
RETURN_FALSE;
}

int cookie_size = name_len /* + value_len */ + path_len + domain_len + 100;
size_t cookie_size = name_len /* + value_len */ + path_len + domain_len + 100;
char *cookie = nullptr, *date = nullptr;

if (name_len > 0 && strpbrk(name, "=,; \t\r\n\013\014") != nullptr) {
Expand Down
73 changes: 70 additions & 3 deletions ext-src/swoole_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "swoole_util.h"

#include "thirdparty/php/standard/proc_open.h"
#include "thirdparty/php/curl/curl_arginfo.h"

#include <unordered_map>
#include <initializer_list>

Expand Down Expand Up @@ -69,6 +71,12 @@ static PHP_FUNCTION(swoole_time_sleep_until);
static PHP_FUNCTION(swoole_stream_select);
static PHP_FUNCTION(swoole_stream_socket_pair);
static PHP_FUNCTION(swoole_user_func_handler);

#ifdef SW_USE_CURL
void swoole_native_curl_init(int module_number);
void swoole_native_curl_shutdown();
#endif

SW_EXTERN_C_END

static int socket_set_option(php_stream *stream, int option, int value, void *ptrparam);
Expand Down Expand Up @@ -158,8 +166,9 @@ static php_stream_wrapper ori_php_plain_files_wrapper;
#define SW_HOOK_FUNC(f) hook_func(ZEND_STRL(#f), PHP_FN(swoole_##f))
#define SW_UNHOOK_FUNC(f) unhook_func(ZEND_STRL(#f))

static void hook_func(const char *name, size_t l_name, zif_handler handler = nullptr);
static void hook_func(const char *name, size_t l_name, zif_handler handler = nullptr, zend_internal_arg_info *arg_info = nullptr);
static void unhook_func(const char *name, size_t l_name);
static bool hook_internal_functions(const zend_function_entry *fes);

static zend_array *tmp_function_table = nullptr;

Expand All @@ -185,9 +194,12 @@ void php_swoole_runtime_minit(int module_number) {
SW_REGISTER_LONG_CONSTANT("SWOOLE_HOOK_SLEEP", PHPCoroutine::HOOK_SLEEP);
SW_REGISTER_LONG_CONSTANT("SWOOLE_HOOK_PROC", PHPCoroutine::HOOK_PROC);
SW_REGISTER_LONG_CONSTANT("SWOOLE_HOOK_CURL", PHPCoroutine::HOOK_CURL);
SW_REGISTER_LONG_CONSTANT("SWOOLE_HOOK_NATIVE_CURL", PHPCoroutine::HOOK_NATIVE_CURL);
SW_REGISTER_LONG_CONSTANT("SWOOLE_HOOK_BLOCKING_FUNCTION", PHPCoroutine::HOOK_BLOCKING_FUNCTION);
SW_REGISTER_LONG_CONSTANT("SWOOLE_HOOK_ALL", PHPCoroutine::HOOK_ALL);

#ifdef SW_USE_CURL
swoole_native_curl_init(module_number);
#endif
swoole_proc_open_init(module_number);
}

Expand Down Expand Up @@ -224,6 +236,12 @@ void php_swoole_runtime_rshutdown() {
tmp_function_table = nullptr;
}

void php_swoole_runtime_mshutdown() {
#ifdef SW_USE_CURL
swoole_native_curl_shutdown();
#endif
}

static inline char *parse_ip_address_ex(const char *str, size_t str_len, int *portno, int get_err, zend_string **err) {
char *colon;
char *host = nullptr;
Expand Down Expand Up @@ -1139,6 +1157,50 @@ bool PHPCoroutine::enable_hook(uint32_t flags) {
}
}

#ifdef SW_USE_CURL
if (flags & PHPCoroutine::HOOK_NATIVE_CURL) {
if (flags & PHPCoroutine::HOOK_CURL) {
php_swoole_fatal_error(E_WARNING, "cannot enable both hooks HOOK_NATIVE_CURL and HOOK_CURL at same time");
flags ^= PHPCoroutine::HOOK_CURL;
}
if (!(hook_flags & PHPCoroutine::HOOK_NATIVE_CURL)) {
#if PHP_VERSION_ID >= 80000
hook_internal_functions(swoole_native_curl_functions);
#else
hook_func(ZEND_STRL("curl_close"), PHP_FN(swoole_native_curl_close));
hook_func(ZEND_STRL("curl_copy_handle"), PHP_FN(swoole_native_curl_copy_handle));
hook_func(ZEND_STRL("curl_errno"), PHP_FN(swoole_native_curl_errno));
hook_func(ZEND_STRL("curl_error"), PHP_FN(swoole_native_curl_error));
hook_func(ZEND_STRL("curl_exec"), PHP_FN(swoole_native_curl_exec));
hook_func(ZEND_STRL("curl_getinfo"), PHP_FN(swoole_native_curl_getinfo));
hook_func(ZEND_STRL("curl_init"), PHP_FN(swoole_native_curl_init));
hook_func(ZEND_STRL("curl_setopt"), PHP_FN(swoole_native_curl_setopt));
hook_func(ZEND_STRL("curl_setopt_array"), PHP_FN(swoole_native_curl_setopt_array));
hook_func(ZEND_STRL("curl_reset"), PHP_FN(swoole_native_curl_reset));
hook_func(ZEND_STRL("curl_pause"), PHP_FN(swoole_native_curl_pause));
hook_func(ZEND_STRL("curl_escape"), PHP_FN(swoole_native_curl_escape));
hook_func(ZEND_STRL("curl_unescape"), PHP_FN(swoole_native_curl_unescape));
#endif
}
} else {
if (hook_flags & PHPCoroutine::HOOK_NATIVE_CURL) {
SW_UNHOOK_FUNC(curl_close);
SW_UNHOOK_FUNC(curl_copy_handle);
SW_UNHOOK_FUNC(curl_errno);
SW_UNHOOK_FUNC(curl_error);
SW_UNHOOK_FUNC(curl_exec);
SW_UNHOOK_FUNC(curl_getinfo);
SW_UNHOOK_FUNC(curl_init);
SW_UNHOOK_FUNC(curl_setopt);
SW_UNHOOK_FUNC(curl_setopt_array);
SW_UNHOOK_FUNC(curl_reset);
SW_UNHOOK_FUNC(curl_pause);
SW_UNHOOK_FUNC(curl_escape);
SW_UNHOOK_FUNC(curl_unescape);
}
}
#endif

if (flags & PHPCoroutine::HOOK_CURL) {
if (!(hook_flags & PHPCoroutine::HOOK_CURL)) {
hook_func(ZEND_STRL("curl_init"));
Expand Down Expand Up @@ -1518,7 +1580,12 @@ static PHP_FUNCTION(swoole_stream_select) {
RETURN_LONG(retval);
}

static void hook_func(const char *name, size_t l_name, zif_handler handler) {
bool hook_internal_functions(const zend_function_entry *fes) {
zend_unregister_functions(fes, -1, CG(function_table));
return zend_register_functions(NULL, fes, NULL, MODULE_PERSISTENT) == SUCCESS;
}

static void hook_func(const char *name, size_t l_name, zif_handler handler, zend_internal_arg_info *arg_info) {
real_func *rf = (real_func *) zend_hash_str_find_ptr(tmp_function_table, name, l_name);
bool use_php_func = false;
/**
Expand Down
3 changes: 3 additions & 0 deletions include/swoole.h
Original file line number Diff line number Diff line change
Expand Up @@ -717,3 +717,6 @@ static sw_inline swoole::MemoryPool *sw_mem_pool() {
return SwooleG.memory_pool;
}

static sw_inline const swoole::Allocator *sw_std_allocator() {
return &SwooleG.std_allocator;
}
Loading