Skip to content

Commit b3de2bd

Browse files
committed
fix return value stuff
1 parent 8537742 commit b3de2bd

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

agent/fw_wordpress.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ NR_PHP_WRAPPER(nr_wordpress_wrap_hook_core) {
345345
NR_PHP_WRAPPER_LEAVE;
346346
}
347347

348-
NR_PHP_WRAPPER_CALL;
349348
if (NRPRG(wordpress_core)) {
350349
nr_wordpress_create_metric(auto_segment, NR_WORDPRESS_HOOK_PREFIX, tag);
351350
}
@@ -373,7 +372,6 @@ NR_PHP_WRAPPER(nr_wordpress_wrap_hook_plugin) {
373372
plugin = wraprec->wordpress_plugin_theme;
374373
//plugin = nr_wordpress_plugin_from_function(execute_data->func);
375374

376-
NR_PHP_WRAPPER_CALL;
377375
if (NULL != plugin) {
378376
nr_wordpress_create_metric(auto_segment, NR_WORDPRESS_HOOK_PREFIX, tag);
379377
nr_wordpress_create_metric(auto_segment, NR_WORDPRESS_PLUGIN_PREFIX,

agent/php_execute.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,7 +2126,7 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO, bool create_metric, boo
21262126
"Uncaught exception ", &NRPRG(exception_filters) TSRMLS_CC);
21272127
} else if (NULL == nr_php_get_return_value(NR_EXECUTE_ORIG_ARGS)) {
21282128
#else
2129-
if (NULL == nr_php_get_return_value(NR_EXECUTE_ORIG_ARGS)) {
2129+
if (NULL == func_return_value) {
21302130
#endif
21312131
/*
21322132
* Having no return value (and not being an exception handler) indicates
@@ -2138,6 +2138,9 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO, bool create_metric, boo
21382138
nr_status_t status = nr_php_error_record_exception_segment(
21392139
NRPRG(txn), &exception,
21402140
&NRPRG(exception_filters));
2141+
if (execute_data->func && execute_data->func->common.function_name) {
2142+
nrl_verbosedebug(NRL_AGENT, "END %s", ZSTR_VAL(execute_data->func->common.function_name));
2143+
}
21412144

21422145
if (NR_FAILURE == status) {
21432146
nrl_verbosedebug(NRL_AGENT, "%s: unable to record exception on segment",
@@ -2222,6 +2225,9 @@ void nr_php_observer_fcall_begin(zend_execute_data* execute_data) {
22222225
//if (execute_data->func && execute_data->func->common.function_name) {
22232226
// printf("BEGIN %s\n", ZSTR_VAL(execute_data->func->common.function_name));
22242227
//}
2228+
if (execute_data->func && execute_data->func->common.function_name) {
2229+
nrl_verbosedebug(NRL_AGENT, "BEGIN %s", ZSTR_VAL(execute_data->func->common.function_name));
2230+
}
22252231
if (nrunlikely(NULL == execute_data)) {
22262232
return;
22272233
}
@@ -2264,7 +2270,7 @@ void nr_php_observer_fcall_begin_instrumented(zend_execute_data* execute_data) {
22642270
*/
22652271
zval* func_return_value = NULL;
22662272
//if (execute_data->func && execute_data->func->common.function_name) {
2267-
// printf("BEGIN %s\n", ZSTR_VAL(execute_data->func->common.function_name));
2273+
// nrl_verbosedebug(NRL_AGENT, "BEGIN %s", ZSTR_VAL(execute_data->func->common.function_name));
22682274
//}
22692275
if (nrunlikely(NULL == execute_data)) {
22702276
return;

agent/php_wrapper.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D);
273273
bool is_begin = false; \
274274
nruserfn_t* wraprec = NULL; \
275275
zval* func_return_value = NULL; \
276-
zval** func_return_value_ptr = NULL; \
277276
const nrtxn_t* txn = NRPRG(txn); \
278277
const nrtime_t txn_start_time = nr_txn_start_time(txn); \
279278
if (NRPRG(in_wrapper)) { \
@@ -288,10 +287,11 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D);
288287
auto_segment = nr_txn_get_current_segment(NRPRG(txn), NULL); \
289288
is_begin = true; \
290289
} else { \
291-
func_return_value_ptr = nr_php_get_return_value_ptr(); \
292-
func_return_value = func_return_value_ptr ? *func_return_value_ptr : NULL;\
290+
va_list ptr; \
291+
va_start(ptr, execute_data); \
292+
func_return_value = va_arg(ptr, zval*); \
293293
nr_php_observer_fcall_end_keep_segment(execute_data, \
294-
func_return_value_ptr ? *func_return_value_ptr : NULL); \
294+
func_return_value); \
295295
}
296296
#endif
297297

0 commit comments

Comments
 (0)