Skip to content

Commit 26ed257

Browse files
committed
simplify user instrumentation initialization handling
The only way nr_php_user_instrument_wraprec_hashmap_init can fail is when memory cannot be allocated, which is already considered a fatal error and causes php process to exit so there's no point in returning failure status in such case. Additionally, nrl_* (logging) does not work until INI has been processed so the error message wouldn't get logged anyway.
1 parent 5383c94 commit 26ed257

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed

agent/php_minit.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,7 @@ PHP_MINIT_FUNCTION(newrelic) {
499499
* - newrelic.webtransaction.name.functions
500500
* - newrelic.transaction_tracer.custom
501501
*/
502-
if (NR_SUCCESS != nr_php_user_instrument_wraprec_hashmap_init()) {
503-
nrl_error(NRL_AGENT,
504-
"%s: Failed to initialize user function instrumentation and user "
505-
"functions will not be instrumented.",
506-
__func__);
507-
}
502+
nr_php_user_instrument_wraprec_hashmap_init();
508503
#endif
509504

510505
nr_php_register_ini_entries(module_number TSRMLS_CC);

agent/php_user_instrument_wraprec_hashmap.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,17 +380,13 @@ static void nr_php_user_instrument_wraprec_hashmap_name2keys(
380380
func->name_hash = zend_hash_func(func->name, func->name_len);
381381
}
382382

383-
nr_status_t nr_php_user_instrument_wraprec_hashmap_init(void) {
383+
void nr_php_user_instrument_wraprec_hashmap_init(void) {
384384
if (NULL == scope_ht) {
385385
scope_ht = nr_scope_hashmap_create_internal(0);
386386
}
387387
if (NULL == global_funcs_ht) {
388388
global_funcs_ht = nr_func_hashmap_create_internal(0);
389389
}
390-
if (NULL == scope_ht || NULL == global_funcs_ht) {
391-
return NR_FAILURE;
392-
}
393-
return NR_SUCCESS;
394390
}
395391

396392
/* This function expects namestr and namestrlen to be validated with

agent/php_user_instrument_wraprec_hashmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// clang-format off
1212

13-
extern nr_status_t nr_php_user_instrument_wraprec_hashmap_init(void);
13+
extern void nr_php_user_instrument_wraprec_hashmap_init(void);
1414
extern nruserfn_t* nr_php_user_instrument_wraprec_hashmap_add(const char* namestr, size_t namestrlen);
1515
extern nruserfn_t* nr_php_user_instrument_wraprec_hashmap_get(zend_string *func_name, zend_string *scope_name);
1616
extern void nr_php_user_instrument_wraprec_hashmap_destroy(void);

0 commit comments

Comments
 (0)