Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ZNeumann authored and lavarou committed Jul 31, 2024
1 parent 440684e commit dc7f429
Showing 1 changed file with 9 additions and 24 deletions.
33 changes: 9 additions & 24 deletions agent/php_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
#include "util_logging.h"

#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO
static bool nr_php_wraprec_can_add_before_after_callbacks(
static void nr_php_wraprec_add_before_after_callbacks(
const char* name, size_t namelen,
nruserfn_t* wraprec,
nrspecialfn_t before_callback,
nrspecialfn_t after_callback) {
if (NULL == wraprec) {
return false;
return;
}

/* If any of the callbacks we are attempting to set are already set to
Expand All @@ -27,7 +27,7 @@ static bool nr_php_wraprec_can_add_before_after_callbacks(
"%s: attempting to set special_instrumentation for %.*s, but "
"it is already set",
__func__, NRSAFELEN(namelen), NRBLANKSTR(name));
return false;
return;
}

if (is_instrumentation_set_and_not_equal(wraprec->special_instrumentation_before,
Expand All @@ -37,19 +37,12 @@ static bool nr_php_wraprec_can_add_before_after_callbacks(
"for %.*s, but "
"it is already set",
__func__, NRSAFELEN(namelen), NRBLANKSTR(name));
return false;
return;
}
if (wraprec->special_instrumentation_before == before_callback &&
wraprec->special_instrumentation == after_callback) {
return false;
return;
}
return true;
}

static void nr_php_wraprec_add_before_after_callbacks(
nruserfn_t* wraprec,
nrspecialfn_t before_callback,
nrspecialfn_t after_callback) {

wraprec->special_instrumentation = after_callback;
wraprec->special_instrumentation_before = before_callback;
Expand All @@ -62,13 +55,9 @@ nruserfn_t* nr_php_wrap_user_function_before_after(
nrspecialfn_t after_callback) {

nruserfn_t* wraprec = nr_php_add_custom_tracer_named(name, namelen);
if (nr_php_wraprec_can_add_before_after_callbacks(name, namelen, wraprec,
nr_php_wraprec_add_before_after_callbacks(name, namelen, wraprec,
before_callback,
after_callback)) {
nr_php_wraprec_add_before_after_callbacks(wraprec,
before_callback,
after_callback);
}
after_callback);
#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
nr_php_observer_add_begin_handler(wraprec->func, wraprec);
nr_php_observer_add_end_handler(wraprec->func, wraprec);
Expand Down Expand Up @@ -112,13 +101,9 @@ nruserfn_t* nr_php_wrap_callable_before_after(
if (nrl_should_print(NRL_VERBOSEDEBUG, NRL_INSTRUMENT)) {
name = nr_php_function_debug_name(callable);
}
if (nr_php_wraprec_can_add_before_after_callbacks(name, nr_strlen(name), wraprec,
nr_php_wraprec_add_before_after_callbacks(name, nr_strlen(name), wraprec,
before_callback,
after_callback)) {
nr_php_wraprec_add_before_after_callbacks(wraprec,
before_callback,
after_callback);
}
after_callback);
#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
nr_php_observer_add_begin_handler(callable, wraprec);
nr_php_observer_add_end_handler(callable, wraprec);
Expand Down

0 comments on commit dc7f429

Please sign in to comment.