Skip to content

Commit

Permalink
fix(agent): adjust how before_after_clean wraps a previously wrapped …
Browse files Browse the repository at this point in the history
…function
  • Loading branch information
ZNeumann committed Jul 25, 2023
1 parent 712396c commit 716f5f4
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions agent/php_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ nruserfn_t* nr_php_wrap_user_function_before_after_clean_with_transience(
return wraprec;
}

/* If any of the callbacks we are attempting to set are already set to
* something else, we want to exit without setting new callbacks */
if (after_callback) {
if (is_instrumentation_set(wraprec->special_instrumentation,
after_callback)) {
Expand All @@ -31,8 +33,7 @@ nruserfn_t* nr_php_wrap_user_function_before_after_clean_with_transience(
"%s: attempting to set special_instrumentation for %.*s, but "
"it is already set",
__func__, NRSAFELEN(namelen), NRBLANKSTR(name));
} else {
wraprec->special_instrumentation = after_callback;
return wraprec;
}
}

Expand All @@ -44,8 +45,7 @@ nruserfn_t* nr_php_wrap_user_function_before_after_clean_with_transience(
"for %.*s, but "
"it is already set",
__func__, NRSAFELEN(namelen), NRBLANKSTR(name));
} else {
wraprec->special_instrumentation_before = before_callback;
return wraprec;
}
}

Expand All @@ -57,11 +57,20 @@ nruserfn_t* nr_php_wrap_user_function_before_after_clean_with_transience(
"for %.*s, but "
"it is already set",
__func__, NRSAFELEN(namelen), NRBLANKSTR(name));
} else {
wraprec->special_instrumentation_clean = clean_callback;
return wraprec;
}
}

if (after_callback) {
wraprec->special_instrumentation = after_callback;
}
if (before_callback) {
wraprec->special_instrumentation_before = before_callback;
}
if (clean_callback) {
wraprec->special_instrumentation_clean = clean_callback;
}

return wraprec;
}
#endif
Expand Down

0 comments on commit 716f5f4

Please sign in to comment.