Skip to content

Commit

Permalink
[5.1]Fix missing struct members (#5528)
Browse files Browse the repository at this point in the history
* Fix missing struct members

* remove code
  • Loading branch information
NathanFreeman authored Oct 22, 2024
1 parent 9831457 commit 6660946
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion scripts/route.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export DOCKER_COMPOSE_VERSION="1.21.0"
[ -z "${SWOOLE_BRANCH}" ] && export SWOOLE_BRANCH="master"
[ -z "${SWOOLE_BUILD_DIR}" ] && export SWOOLE_BUILD_DIR=$(cd "$(dirname "$0")";cd ../;pwd)
[ -z "${PHP_VERSION_ID}" ] && export PHP_VERSION_ID=`php -r "echo PHP_VERSION_ID;"`
if [ ${PHP_VERSION_ID} -lt 80300 ]; then
if [ ${PHP_VERSION_ID} -lt 80400 ]; then
export PHP_VERSION="`php -r "echo PHP_MAJOR_VERSION;"`.`php -r "echo PHP_MINOR_VERSION;"`"
else
export PHP_VERSION="rc"
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/php/curl/curl_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ static inline php_curlsh *curl_share_from_obj(zend_object *obj) {
}

#define Z_CURL_SHARE_P(zv) curl_share_from_obj(Z_OBJ_P(zv))
void curl_multi_register_class(const zend_function_entry *method_entries);
void swoole_curl_multi_register_handlers(void);
curl_result_t swoole_curl_cast_object(zend_object *obj, zval *result, int type);

php_curl *swoole_curl_get_handle(zval *zid, bool exclusive = true, bool required = true);
Expand Down
15 changes: 6 additions & 9 deletions thirdparty/php/curl/interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ void swoole_native_curl_minit(int module_number) {
}
swoole_coroutine_curl_handle_ce = curl_ce;
swoole_coroutine_curl_handle_ce->create_object = swoole_curl_create_object;
#if PHP_VERSION_ID >= 80300
swoole_coroutine_curl_handle_ce->default_object_handlers = &swoole_coroutine_curl_handle_handlers;
#endif
memcpy(&swoole_coroutine_curl_handle_handlers, &std_object_handlers, sizeof(zend_object_handlers));
swoole_coroutine_curl_handle_handlers.offset = XtOffsetOf(php_curl, std);
swoole_coroutine_curl_handle_handlers.free_obj = swoole_curl_free_obj;
Expand All @@ -274,7 +277,7 @@ void swoole_native_curl_minit(int module_number) {

zend_declare_property_null(swoole_coroutine_curl_handle_ce, ZEND_STRL("private_data"), ZEND_ACC_PUBLIC);

curl_multi_register_class(nullptr);
swoole_curl_multi_register_handlers();

zend_unregister_functions(swoole_native_curl_functions, -1, CG(function_table));
zend_register_functions(NULL, swoole_native_curl_functions, NULL, MODULE_PERSISTENT);
Expand All @@ -293,7 +296,9 @@ static zend_object *swoole_curl_create_object(zend_class_entry *class_type) {

zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID < 80300
intern->std.handlers = &swoole_coroutine_curl_handle_handlers;
#endif

return &intern->std;
}
Expand Down Expand Up @@ -907,10 +912,6 @@ void swoole_curl_init_handle(php_curl *ch) {
zend_llist_init(&ch->to_free->post, sizeof(struct HttpPost *), (llist_dtor_func_t) curl_free_post, 0);
zend_llist_init(&ch->to_free->stream, sizeof(struct mime_data_cb_arg *), (llist_dtor_func_t) curl_free_cb_arg, 0);

#if LIBCURL_VERSION_NUM < 0x073800 && PHP_VERSION_ID >= 80100
zend_llist_init(&ch->to_free->buffers, sizeof(zend_string *), (llist_dtor_func_t)curl_free_buffers, 0);
#endif

ch->to_free->slist = (HashTable *) emalloc(sizeof(HashTable));
zend_hash_init(ch->to_free->slist, 4, NULL, curl_free_slist, 0);
ZVAL_UNDEF(&ch->postfields);
Expand Down Expand Up @@ -2444,10 +2445,6 @@ static void _php_curl_free(php_curl *ch) {
if (--(*ch->clone) == 0) {
#if PHP_VERSION_ID < 80100
zend_llist_clean(&ch->to_free->str);
#else
#if LIBCURL_VERSION_NUM < 0x073800 /* 7.56.0 */
zend_llist_clean(&ch->to_free->buffers);
#endif
#endif
zend_llist_clean(&ch->to_free->post);
zend_llist_clean(&ch->to_free->stream);
Expand Down
7 changes: 6 additions & 1 deletion thirdparty/php/curl/multi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,9 @@ static zend_object *swoole_curl_multi_create_object(zend_class_entry *class_type

zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID < 80300
intern->std.handlers = &swoole_coroutine_curl_multi_handle_handlers;
#endif

return &intern->std;
}
Expand Down Expand Up @@ -600,9 +602,12 @@ static HashTable *swoole_curl_multi_get_gc(zend_object *object, zval **table, in
return zend_std_get_properties(object);
}

void curl_multi_register_class(const zend_function_entry *method_entries) {
void swoole_curl_multi_register_handlers(void) {
swoole_coroutine_curl_multi_handle_ce = curl_multi_ce;
swoole_coroutine_curl_multi_handle_ce->create_object = swoole_curl_multi_create_object;
#if PHP_VERSION_ID >= 80300
swoole_coroutine_curl_multi_handle_ce->default_object_handlers = &swoole_coroutine_curl_multi_handle_handlers;
#endif

memcpy(&swoole_coroutine_curl_multi_handle_handlers, &std_object_handlers, sizeof(zend_object_handlers));
swoole_coroutine_curl_multi_handle_handlers.offset = XtOffsetOf(php_curlm, std);
Expand Down

0 comments on commit 6660946

Please sign in to comment.