Skip to content

ext/soap: Refactor userland function calling code #19055

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Jul 6, 2025

Commits should be reviewed in order.

This gets rid of some more call_user_function API calls and reduces the amount of string copying.

@Girgias Girgias marked this pull request as ready for review July 6, 2025 17:48
@Girgias Girgias requested a review from nielsdos as a code owner July 6, 2025 17:48
ext/soap/soap.c Outdated
} else {
call_status = call_user_function(EG(function_table), NULL, &h->function_name, &h->retval, h->num_params, h->parameters);
}
call_status = call_user_function(NULL, soap_obj, &h->function_name, &h->retval, h->num_params, h->parameters);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now you're passing soap_obj not only for service->type == SOAP_CLASS || service->type == SOAP_OBJECT but now also for zend_hash_find_ptr_lc(function_table, Z_STR(h->function_name)) != NULL. So this is changed behaviour, or what am I missing?

ext/soap/soap.c Outdated
zval_ptr_dtor(soap_obj);
soap_obj = NULL;
}
call_status = call_user_function(NULL, soap_obj, &function_name, &retval, num_params, params);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

if (UNEXPECTED(header_fn == NULL)) {
if (soap_obj_ce && soap_obj_ce->__call) {
header_fn = zend_get_call_trampoline_func(soap_obj_ce, Z_STR(function_name), false);
goto soap_header_func_call;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you structure the code in such a way to avoid this goto?

zend_function *header_fn = zend_hash_find_ptr_lc(function_table, Z_STR(h->function_name));
if (UNEXPECTED(header_fn == NULL)) {
if (soap_obj_ce && soap_obj_ce->__call) {
header_fn = zend_get_call_trampoline_func(soap_obj_ce, Z_STR(function_name), false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using zend_get_call_trampoline_func you should also release the trampoline function when you're done with it. This usually doesn't cause problems because as long as you're outside of a trampoline call, this function will store the trampoline in EG(trampoline). It should be possible to test this by making a soap call from within a trampoline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants