Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions ext-src/php_swoole.cc
Original file line number Diff line number Diff line change
Expand Up @@ -395,17 +395,17 @@ void php_swoole_set_global_option(HashTable *vht) {
zval *ztmp;

#ifdef SW_DEBUG
if (php_swoole_array_get_value(vht, "debug_mode", ztmp) && zval_is_true(ztmp)) {
if (php_swoole_array_get_value(vht, "debug_mode", ztmp) && zend_is_true(ztmp)) {
swoole_set_log_level(0);
}
#endif
// [EventLoop]
// ======================================================================
if (php_swoole_array_get_value(vht, "enable_signalfd", ztmp)) {
SwooleG.enable_signalfd = zval_is_true(ztmp);
SwooleG.enable_signalfd = zend_is_true(ztmp);
}
if (php_swoole_array_get_value(vht, "enable_kqueue", ztmp)) {
SwooleG.enable_kqueue = zval_is_true(ztmp);
SwooleG.enable_kqueue = zend_is_true(ztmp);
}
// [Logger]
// ======================================================================
Expand All @@ -422,13 +422,13 @@ void php_swoole_set_global_option(HashTable *vht) {
sw_logger()->set_date_format(zend::String(ztmp).val());
}
if (php_swoole_array_get_value(vht, "log_date_with_microseconds", ztmp)) {
sw_logger()->set_date_with_microseconds(zval_is_true(ztmp));
sw_logger()->set_date_with_microseconds(zend_is_true(ztmp));
}
if (php_swoole_array_get_value(vht, "log_rotation", ztmp)) {
sw_logger()->set_rotation(zval_get_long(ztmp));
}
if (php_swoole_array_get_value(vht, "display_errors", ztmp)) {
SWOOLE_G(display_errors) = zval_is_true(ztmp);
SWOOLE_G(display_errors) = zend_is_true(ztmp);
}
if (php_swoole_array_get_value(vht, "print_backtrace_on_error", ztmp)) {
#if !defined(HAVE_BOOST_STACKTRACE) && !defined(HAVE_EXECINFO)
Expand All @@ -437,7 +437,7 @@ void php_swoole_set_global_option(HashTable *vht) {
"The `print_backtrace_on_error` option requires `boost stacktrace` or `execinfo.h` to be installed",
SW_ERROR_OPERATION_NOT_SUPPORT);
#else
SwooleG.print_backtrace_on_error = zval_is_true(ztmp);
SwooleG.print_backtrace_on_error = zend_is_true(ztmp);
#endif
}
// [DNS]
Expand Down
4 changes: 2 additions & 2 deletions ext-src/php_swoole_cxx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Variable call(const std::string &func_name, int argc, zval *argv) {
if (call_user_function(EG(function_table), nullptr, &function_name, &retval.value, argc, argv) != SUCCESS) {
ZVAL_NULL(&retval.value);
}
zval_dtor(&function_name);
zval_ptr_dtor_nogc(&function_name);
/* we have no chance to return to ZendVM to check the exception */
if (UNEXPECTED(EG(exception))) {
zend_exception_error(EG(exception), E_ERROR);
Expand All @@ -136,7 +136,7 @@ Variable call(const std::string &func_name, int argc, zval *argv) {

Callable::Callable(zval *_zfn) {
ZVAL_UNDEF(&zfn);
if (!zval_is_true(_zfn)) {
if (!zend_is_true(_zfn)) {
php_swoole_fatal_error(E_WARNING, "illegal callback function");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion ext-src/php_swoole_cxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ static inline zend::Callable *sw_callable_create(zval *zfn) {
}

static inline zend::Callable *sw_callable_create_ex(zval *zfn, const char *fname, bool allow_null = true) {
if (zfn == nullptr || ZVAL_IS_NULL(zfn)) {
if (zfn == nullptr || Z_ISNULL_P(zfn)) {
if (!allow_null) {
zend_throw_exception_ex(
swoole_exception_ce, SW_ERROR_INVALID_PARAMS, "%s must be of type callable, null given", fname);
Expand Down
2 changes: 1 addition & 1 deletion ext-src/php_swoole_http.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ struct Context {
}

bool is_co_socket() const {
return !ZVAL_IS_NULL(&zsocket);
return !Z_ISNULL_P(&zsocket);
}

Server *get_async_server() const {
Expand Down
8 changes: 4 additions & 4 deletions ext-src/php_swoole_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ BEGIN_EXTERN_C()

#if PHP_VERSION_ID < 80200
#error "require PHP version 8.2 or later"
#elif PHP_VERSION_ID >= 80600
#error "require PHP version 8.5 or earlier"
#elif PHP_VERSION_ID > 80600
#error "require PHP version 8.6 or earlier"
#endif

#if defined(ZTS) && defined(SW_USE_THREAD_CONTEXT)
Expand Down Expand Up @@ -547,8 +547,8 @@ static sw_inline zend_string *sw_zend_string_recycle(zend_string *s, size_t allo
//----------------------------------Array API------------------------------------

#define php_swoole_array_length(zarray) zend_hash_num_elements(Z_ARRVAL_P(zarray))
#define php_swoole_array_get_value(ht, str, v) ((v = zend_hash_str_find(ht, str, sizeof(str) - 1)) && !ZVAL_IS_NULL(v))
#define php_swoole_array_get_value_ex(ht, str, v) ((v = zend_hash_str_find(ht, str, strlen(str))) && !ZVAL_IS_NULL(v))
#define php_swoole_array_get_value(ht, str, v) ((v = zend_hash_str_find(ht, str, sizeof(str) - 1)) && !Z_ISNULL_P(v))
#define php_swoole_array_get_value_ex(ht, str, v) ((v = zend_hash_str_find(ht, str, strlen(str))) && !Z_ISNULL_P(v))

static sw_inline int php_swoole_array_length_safe(zval *zarray) {
if (zarray && ZVAL_IS_ARRAY(zarray)) {
Expand Down
8 changes: 4 additions & 4 deletions ext-src/swoole_async_coro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ PHP_FUNCTION(swoole_async_set) {
php_swoole_set_aio_option(vht);

if (php_swoole_array_get_value(vht, "wait_signal", ztmp)) {
SwooleG.wait_signal = zval_is_true(ztmp);
SwooleG.wait_signal = zend_is_true(ztmp);
}
if (php_swoole_array_get_value(vht, "dns_cache_refresh_time", ztmp)) {
SwooleG.dns_cache_refresh_time = zval_get_double(ztmp);
Expand All @@ -112,13 +112,13 @@ PHP_FUNCTION(swoole_async_set) {
SwooleG.aio_worker_num = v;
}
if (php_swoole_array_get_value(vht, "dns_lookup_random", ztmp)) {
SwooleG.dns_lookup_random = zval_is_true(ztmp);
SwooleG.dns_lookup_random = zend_is_true(ztmp);
}
if (php_swoole_array_get_value(vht, "use_async_resolver", ztmp)) {
SwooleG.use_async_resolver = zval_is_true(ztmp);
SwooleG.use_async_resolver = zend_is_true(ztmp);
}
if (php_swoole_array_get_value(vht, "enable_coroutine", ztmp)) {
SwooleG.enable_coroutine = zval_is_true(ztmp);
SwooleG.enable_coroutine = zend_is_true(ztmp);
}
RETURN_TRUE;
}
Expand Down
20 changes: 10 additions & 10 deletions ext-src/swoole_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void php_swoole_client_check_ssl_setting(const Client *cli, const zval *zset) {
cli->set_ssl_protocols(zval_get_long(ztmp));
}
if (php_swoole_array_get_value(vht, "ssl_compress", ztmp)) {
cli->set_ssl_disable_compress(!zval_is_true(ztmp));
cli->set_ssl_disable_compress(!zend_is_true(ztmp));
}
if (php_swoole_array_get_value(vht, "ssl_cert_file", ztmp)) {
zend::String str_v(ztmp);
Expand All @@ -219,10 +219,10 @@ void php_swoole_client_check_ssl_setting(const Client *cli, const zval *zset) {
}
#endif
if (php_swoole_array_get_value(vht, "ssl_verify_peer", ztmp)) {
cli->set_ssl_verify_peer(zval_is_true(ztmp));
cli->set_ssl_verify_peer(zend_is_true(ztmp));
}
if (php_swoole_array_get_value(vht, "ssl_allow_self_signed", ztmp)) {
cli->set_ssl_allow_self_signed(zval_is_true(ztmp));
cli->set_ssl_allow_self_signed(zend_is_true(ztmp));
}
if (php_swoole_array_get_value(vht, "ssl_cafile", ztmp)) {
zend::String str_v(ztmp);
Expand Down Expand Up @@ -257,11 +257,11 @@ bool php_swoole_client_check_setting(Client *cli, const zval *zset) {

// buffer: eof check
if (php_swoole_array_get_value(vht, "open_eof_check", ztmp)) {
cli->open_eof_check = zval_is_true(ztmp);
cli->open_eof_check = zend_is_true(ztmp);
}
// buffer: split package with eof
if (php_swoole_array_get_value(vht, "open_eof_split", ztmp)) {
cli->protocol.split_by_eof = zval_is_true(ztmp);
cli->protocol.split_by_eof = zend_is_true(ztmp);
if (cli->protocol.split_by_eof) {
cli->open_eof_check = true;
}
Expand All @@ -281,14 +281,14 @@ bool php_swoole_client_check_setting(Client *cli, const zval *zset) {
}
// open mqtt protocol
if (php_swoole_array_get_value(vht, "open_mqtt_protocol", ztmp)) {
cli->open_length_check = zval_is_true(ztmp);
if (zval_is_true(ztmp)) {
cli->open_length_check = zend_is_true(ztmp);
if (zend_is_true(ztmp)) {
swoole::mqtt::set_protocol(&cli->protocol);
}
}
// open length check
if (php_swoole_array_get_value(vht, "open_length_check", ztmp)) {
cli->open_length_check = zval_is_true(ztmp);
cli->open_length_check = zend_is_true(ztmp);
cli->protocol.get_package_length = Protocol::default_length_func;
}
// package length size
Expand Down Expand Up @@ -379,7 +379,7 @@ bool php_swoole_client_check_setting(Client *cli, const zval *zset) {
* client: tcp_nodelay
*/
if (php_swoole_array_get_value(vht, "open_tcp_nodelay", ztmp)) {
if (zval_is_true(ztmp)) {
if (zend_is_true(ztmp)) {
goto _open_tcp_nodelay;
}
} else {
Expand Down Expand Up @@ -499,7 +499,7 @@ ssize_t php_swoole_length_func(const Protocol *protocol, Socket *_socket, Packet

static Client *php_swoole_client_new(zval *zobject, char *host, int host_len, int port) {
zval *ztype = sw_zend_read_property_ex(Z_OBJCE_P(zobject), zobject, SW_ZSTR_KNOWN(SW_ZEND_STR_TYPE), 0);
if (ztype == nullptr || ZVAL_IS_NULL(ztype)) {
if (ztype == nullptr || Z_ISNULL_P(ztype)) {
php_swoole_fatal_error(E_ERROR, "failed to get swoole_client->type");
return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion ext-src/swoole_client_async.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ static PHP_METHOD(swoole_client_async, __destruct) {

static Client *php_swoole_client_async_new(zval *zobject, char *host, int host_len, int port) {
zval *ztype = sw_zend_read_property_ex(Z_OBJCE_P(zobject), zobject, SW_ZSTR_KNOWN(SW_ZEND_STR_TYPE), 0);
if (ztype == nullptr || ZVAL_IS_NULL(ztype)) {
if (ztype == nullptr || Z_ISNULL_P(ztype)) {
php_swoole_fatal_error(E_ERROR, "failed to get client type");
return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion ext-src/swoole_coroutine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ void PHPCoroutine::activate() {
}

zval *enable_library = zend_get_constant_str(ZEND_STRL("SWOOLE_LIBRARY"));
if (enable_library == nullptr || !zval_is_true(enable_library)) {
if (enable_library == nullptr || !zend_is_true(enable_library)) {
php_swoole_load_library();
}

Expand Down
6 changes: 3 additions & 3 deletions ext-src/swoole_coroutine_scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static bool php_swoole_coroutine_reactor_can_exit(Reactor *reactor, size_t &even
void php_swoole_coroutine_scheduler_rshutdown() {
swoole_name_resolver_each([](const std::list<NameResolver>::iterator &iter) -> swTraverseOperation {
if (iter->type == NameResolver::TYPE_PHP) {
zval_dtor((zval *) iter->private_data);
zval_ptr_dtor_nogc((zval *) iter->private_data);
efree(iter->private_data);
return SW_TRAVERSE_REMOVE;
} else {
Expand All @@ -148,13 +148,13 @@ void php_swoole_set_coroutine_option(zend_array *vht) {
PHPCoroutine::set_max_num(max_num <= 0 ? SW_DEFAULT_MAX_CORO_NUM : max_num);
}
if (php_swoole_array_get_value(vht, "enable_deadlock_check", ztmp)) {
PHPCoroutine::set_deadlock_check(zval_is_true(ztmp));
PHPCoroutine::set_deadlock_check(zend_is_true(ztmp));
}
if (php_swoole_array_get_value(vht, "hook_flags", ztmp)) {
PHPCoroutine::set_hook_flags(zval_get_long(ztmp));
}
if (php_swoole_array_get_value(vht, "enable_preemptive_scheduler", ztmp)) {
PHPCoroutine::enable_preemptive_scheduler(zval_is_true(ztmp));
PHPCoroutine::enable_preemptive_scheduler(zend_is_true(ztmp));
}
if (php_swoole_array_get_value(vht, "c_stack_size", ztmp) || php_swoole_array_get_value(vht, "stack_size", ztmp)) {
Coroutine::set_stack_size(php_swoole_parse_to_size(ztmp));
Expand Down
2 changes: 1 addition & 1 deletion ext-src/swoole_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ static PHP_FUNCTION(swoole_event_cycle) {
auto reactor = sw_reactor();
auto defer_task = before ? &reactor->future_task : &reactor->idle_task;

if (ZVAL_IS_NULL(zcallback)) {
if (Z_ISNULL_P(zcallback)) {
if (defer_task->callback == nullptr) {
RETURN_FALSE;
} else {
Expand Down
10 changes: 5 additions & 5 deletions ext-src/swoole_http2_client_coro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ ssize_t Client::build_header(const zval *zobj, zval *zrequest, char *buffer) {
zval *zvalue;

ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(zheaders), key, zvalue) {
if (UNEXPECTED(!key || *ZSTR_VAL(key) == ':' || ZVAL_IS_NULL(zvalue))) {
if (UNEXPECTED(!key || *ZSTR_VAL(key) == ':' || Z_ISNULL_P(zvalue))) {
continue;
}
zend::String str_value(zvalue);
Expand Down Expand Up @@ -1012,7 +1012,7 @@ ssize_t Client::build_header(const zval *zobj, zval *zrequest, char *buffer) {
String *header_buffer = sw_tg_buffer();

ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(zcookies), key, zvalue) {
if (UNEXPECTED(!key || ZVAL_IS_NULL(zvalue))) {
if (UNEXPECTED(!key || Z_ISNULL_P(zvalue))) {
continue;
}
zend::String str_value(zvalue);
Expand Down Expand Up @@ -1122,7 +1122,7 @@ uint32_t Client::send_request(zval *zrequest) {
zval ztmp,
*zuse_pipeline_read = zend_read_property_ex(
Z_OBJCE_P(zrequest), SW_Z8_OBJ_P(zrequest), SW_ZSTR_KNOWN(SW_ZEND_STR_USE_PIPELINE_READ), true, &ztmp);
bool is_data_empty = Z_TYPE_P(zdata) == IS_STRING ? Z_STRLEN_P(zdata) == 0 : !zval_is_true(zdata);
bool is_data_empty = Z_TYPE_P(zdata) == IS_STRING ? Z_STRLEN_P(zdata) == 0 : !zend_is_true(zdata);

if (ZVAL_IS_ARRAY(zdata)) {
add_assoc_stringl_ex(
Expand All @@ -1140,10 +1140,10 @@ uint32_t Client::send_request(zval *zrequest) {
}

uint8_t flags = 0;
if (zval_is_true(zpipeline)) {
if (zend_is_true(zpipeline)) {
flags |= SW_HTTP2_STREAM_PIPELINE_REQUEST;
}
if (zval_is_true(zuse_pipeline_read)) {
if (zend_is_true(zuse_pipeline_read)) {
flags |= SW_HTTP2_STREAM_USE_PIPELINE_READ;
}

Expand Down
6 changes: 3 additions & 3 deletions ext-src/swoole_http2_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static ssize_t http2_server_build_trailer(const HttpContext *ctx, uchar *buffer)
zval *zvalue;

ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(ztrailer), key, zvalue) {
if (UNEXPECTED(!key || ZVAL_IS_NULL(zvalue))) {
if (UNEXPECTED(!key || Z_ISNULL_P(zvalue))) {
continue;
}
zend::String str_value(zvalue);
Expand Down Expand Up @@ -346,7 +346,7 @@ static ssize_t http2_server_build_header(HttpContext *ctx, uchar *buffer, const
auto add_header =
[ctx, &content_type](
Http2::HeaderSet &headers, const char *key, size_t l_key, zval *value, uint32_t &header_flags) {
if (ZVAL_IS_NULL(value)) {
if (Z_ISNULL_P(value)) {
return;
}
zend::String str_value(value);
Expand All @@ -372,7 +372,7 @@ static ssize_t http2_server_build_header(HttpContext *ctx, uchar *buffer, const
};

SW_HASHTABLE_FOREACH_START2(Z_ARRVAL_P(zheader), key, keylen, type, zvalue) {
if (UNEXPECTED(!key || ZVAL_IS_NULL(zvalue))) {
if (UNEXPECTED(!key || Z_ISNULL_P(zvalue))) {
continue;
}
if (ZVAL_IS_ARRAY(zvalue)) {
Expand Down
18 changes: 9 additions & 9 deletions ext-src/swoole_http_client_coro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -743,19 +743,19 @@ void Client::apply_setting(zval *zset, const bool check_all) {
max_retries = (uint8_t) SW_MIN(zval_get_long(ztmp), UINT8_MAX);
}
if (php_swoole_array_get_value(vht, "defer", ztmp)) {
defer = zval_is_true(ztmp);
defer = zend_is_true(ztmp);
}
if (php_swoole_array_get_value(vht, "lowercase_header", ztmp)) {
lowercase_header = zval_is_true(ztmp);
lowercase_header = zend_is_true(ztmp);
}
if (php_swoole_array_get_value(vht, "keep_alive", ztmp)) {
keep_alive = zval_is_true(ztmp);
keep_alive = zend_is_true(ztmp);
}
if (php_swoole_array_get_value(vht, "http_compression", ztmp)) {
http_compression = zval_is_true(ztmp);
http_compression = zend_is_true(ztmp);
}
if (php_swoole_array_get_value(vht, "body_decompression", ztmp)) {
body_decompression = zval_is_true(ztmp);
body_decompression = zend_is_true(ztmp);
}
if (php_swoole_array_get_value(vht, "write_func", ztmp)) {
delete write_func;
Expand Down Expand Up @@ -1004,7 +1004,7 @@ bool Client::send_request() {

if (ZVAL_IS_ARRAY(zheaders)) {
SW_HASHTABLE_FOREACH_START2(Z_ARRVAL_P(zheaders), key, keylen, keytype, zvalue) {
if (UNEXPECTED(HASH_KEY_IS_STRING != keytype || ZVAL_IS_NULL(zvalue))) {
if (UNEXPECTED(HASH_KEY_IS_STRING != keytype || Z_ISNULL_P(zvalue))) {
continue;
}
if (SW_STRCASEEQ(key, keylen, "Host")) {
Expand Down Expand Up @@ -1131,7 +1131,7 @@ bool Client::send_request() {
// calculate length before encode array
if (zbody && ZVAL_IS_ARRAY(zbody)) {
SW_HASHTABLE_FOREACH_START2(Z_ARRVAL_P(zbody), key, keylen, keytype, zvalue)
if (UNEXPECTED(HASH_KEY_IS_STRING != keytype || ZVAL_IS_NULL(zvalue))) {
if (UNEXPECTED(HASH_KEY_IS_STRING != keytype || Z_ISNULL_P(zvalue))) {
continue;
}
zend::String str_value(zvalue);
Expand Down Expand Up @@ -1181,7 +1181,7 @@ bool Client::send_request() {
// ============ form-data body ============
if (zbody && ZVAL_IS_ARRAY(zbody)) {
SW_HASHTABLE_FOREACH_START2(Z_ARRVAL_P(zbody), key, keylen, keytype, zvalue) {
if (UNEXPECTED(HASH_KEY_IS_STRING != keytype || ZVAL_IS_NULL(zvalue))) {
if (UNEXPECTED(HASH_KEY_IS_STRING != keytype || Z_ISNULL_P(zvalue))) {
continue;
}
zend::String str_value(zvalue);
Expand Down Expand Up @@ -1499,7 +1499,7 @@ void Client::recv_websocket_frame(zval *return_value, double timeout) {
}
return;
}
if (sw_unlikely(ZVAL_IS_NULL(return_value))) {
if (sw_unlikely(Z_ISNULL_P(return_value))) {
ZVAL_FALSE(return_value);
}
}
Expand Down
Loading
Loading