Skip to content

Commit 05935f2

Browse files
committed
fix wrapper tracking
1 parent 9c9d966 commit 05935f2

File tree

5 files changed

+13
-30
lines changed

5 files changed

+13
-30
lines changed

agent/php_execute.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2146,9 +2146,6 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO, bool create_metric, boo
21462146
nr_status_t status = nr_php_error_record_exception_segment(
21472147
NRPRG(txn), &exception,
21482148
&NRPRG(exception_filters));
2149-
if (execute_data->func && execute_data->func->common.function_name) {
2150-
nrl_verbosedebug(NRL_AGENT, "END %s", ZSTR_VAL(execute_data->func->common.function_name));
2151-
}
21522149

21532150
if (NR_FAILURE == status) {
21542151
nrl_verbosedebug(NRL_AGENT, "%s: unable to record exception on segment",
@@ -2233,9 +2230,6 @@ void nr_php_observer_fcall_begin(zend_execute_data* execute_data) {
22332230
//if (execute_data->func && execute_data->func->common.function_name) {
22342231
// printf("BEGIN %s\n", ZSTR_VAL(execute_data->func->common.function_name));
22352232
//}
2236-
if (execute_data->func && execute_data->func->common.function_name) {
2237-
nrl_verbosedebug(NRL_AGENT, "BEGIN %s", ZSTR_VAL(execute_data->func->common.function_name));
2238-
}
22392233
if (nrunlikely(NULL == execute_data)) {
22402234
return;
22412235
}
@@ -2278,7 +2272,7 @@ void nr_php_observer_fcall_begin_instrumented(zend_execute_data* execute_data) {
22782272
*/
22792273
zval* func_return_value = NULL;
22802274
//if (execute_data->func && execute_data->func->common.function_name) {
2281-
// nrl_verbosedebug(NRL_AGENT, "BEGIN %s", ZSTR_VAL(execute_data->func->common.function_name));
2275+
// printf("BEGIN %s", ZSTR_VAL(execute_data->func->common.function_name));
22822276
//}
22832277
if (nrunlikely(NULL == execute_data)) {
22842278
return;

agent/php_newrelic.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,6 @@ int symfony1_in_dispatch; /* Whether we are currently within a
450450
int symfony1_in_error404; /* Whether we are currently within a
451451
sfError404Exception::printStackTrace() frame */
452452

453-
#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO \
454-
&& !defined OVERWRITE_ZEND_EXECUTE_DATA
455-
bool in_wrapper;
456-
#endif
457-
458453
#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \
459454
&& !defined OVERWRITE_ZEND_EXECUTE_DATA
460455
bool check_cufa;

agent/php_rinit.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,9 @@ PHP_RINIT_FUNCTION(newrelic) {
124124
nr_stack_init(&NRPRG(drupal_invoke_all_hooks), NR_STACK_DEFAULT_CAPACITY);
125125
nr_stack_init(&NRPRG(drupal_invoke_all_states), NR_STACK_DEFAULT_CAPACITY);
126126
NRPRG(predis_ctxs).dtor = str_stack_dtor;
127+
NRPRG(wordpress_tags).dtor = str_stack_dtor;
127128
NRPRG(drupal_invoke_all_hooks).dtor = zval_stack_dtor;
128129
#endif
129-
#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO \
130-
&& !defined OVERWRITE_ZEND_EXECUTE_DATA
131-
NRPRG(in_wrapper) = false;
132-
#endif
133130

134131
NRPRG(mysql_last_conn) = NULL;
135132
NRPRG(pgsql_last_conn) = NULL;

agent/php_wrapper.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ nruserfn_t* nr_php_wrap_callable_before_after(
9090
// begin_handler will be NULL if the observer hasn't been installed yet.
9191
// *begin_Handler will be NULL if the function has not yet been called.
9292
if (begin_handler && *begin_handler) {
93+
name = nr_php_function_debug_name(callable);
94+
php_printf("AHHHHHHH %s\n", name);
95+
nr_free(name);
9396
// It is okay to attempt to remove a handler that doesn't exist
9497
// TODO this could remove nr_php_observer_fcall_begin/end and then re-add it :)
9598
if (zend_observer_remove_begin_handler(callable, NRINI(tt_detail) ?

agent/php_wrapper.h

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -269,27 +269,22 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D);
269269
#define NR_PHP_WRAPPER_START(name) \
270270
NR_PHP_WRAPPER_PROTOTYPE(name) { \
271271
int was_executed = 0; \
272+
bool in_begin = true;\
272273
int zcaught = 0; \
273-
bool is_begin = false; \
274274
nruserfn_t* wraprec = NULL; \
275275
zval* func_return_value = NULL; \
276276
const nrtxn_t* txn = NRPRG(txn); \
277277
const nrtime_t txn_start_time = nr_txn_start_time(txn); \
278-
if (NRPRG(in_wrapper)) { \
279-
printf("AAHHHHHHHHHHH %s\n", #name); \
280-
} \
281-
NRPRG(in_wrapper) = true; \
282278
\
283279
nr_segment_t* auto_segment = nr_txn_get_current_segment(NRPRG(txn), NULL); \
284-
if (!auto_segment || auto_segment->execute_data != execute_data || \
285-
auto_segment == NRPRG(txn)->segment_root) { \
280+
if (!auto_segment || auto_segment->execute_data != execute_data) { \
286281
nr_php_observer_fcall_begin(execute_data); \
287-
auto_segment = nr_txn_get_current_segment(NRPRG(txn), NULL); \
288-
is_begin = true; \
289282
} else { \
290-
va_list ptr; \
291-
va_start(ptr, execute_data); \
292-
func_return_value = va_arg(ptr, zval*); \
283+
va_list args; \
284+
va_start(args, execute_data); \
285+
func_return_value = va_arg(args, zval*); \
286+
va_end(args); \
287+
in_begin = false; \
293288
nr_php_observer_fcall_end_keep_segment(execute_data, \
294289
func_return_value); \
295290
}
@@ -320,12 +315,11 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D);
320315
if (!was_executed) { \
321316
NR_PHP_WRAPPER_CALL \
322317
} \
323-
if (is_begin) { \
318+
if (in_begin) { \
324319
nr_php_observer_fcall_begin_late(execute_data, txn_start_time);\
325320
} else { \
326321
nr_php_observer_fcall_end_late(execute_data, false, txn_start_time); \
327322
} \
328-
NRPRG(in_wrapper) = false; \
329323
if (zcaught) { \
330324
zend_bailout(); \
331325
} \

0 commit comments

Comments
 (0)