@@ -23,45 +23,42 @@ nruserfn_t* nr_php_wrap_user_function_before_after_clean_with_transience(
23
23
return wraprec ;
24
24
}
25
25
26
- if (after_callback ) {
27
- if (is_instrumentation_set (wraprec -> special_instrumentation ,
28
- after_callback )) {
29
- nrl_verbosedebug (
30
- NRL_INSTRUMENT ,
31
- "%s: attempting to set special_instrumentation for %.*s, but "
32
- "it is already set" ,
33
- __func__ , NRSAFELEN (namelen ), NRBLANKSTR (name ));
34
- } else {
35
- wraprec -> special_instrumentation = after_callback ;
36
- }
26
+ /* If any of the callbacks we are attempting to set are already set to
27
+ * something else, we want to exit without setting new callbacks */
28
+ if (is_instrumentation_set_and_not_equal (wraprec -> special_instrumentation ,
29
+ after_callback )) {
30
+ nrl_verbosedebug (
31
+ NRL_INSTRUMENT ,
32
+ "%s: attempting to set special_instrumentation for %.*s, but "
33
+ "it is already set" ,
34
+ __func__ , NRSAFELEN (namelen ), NRBLANKSTR (name ));
35
+ return wraprec ;
37
36
}
38
37
39
- if (before_callback ) {
40
- if (is_instrumentation_set (wraprec -> special_instrumentation_before ,
41
- before_callback )) {
42
- nrl_verbosedebug (NRL_INSTRUMENT ,
43
- "%s: attempting to set special_instrumentation_before "
44
- "for %.*s, but "
45
- "it is already set" ,
46
- __func__ , NRSAFELEN (namelen ), NRBLANKSTR (name ));
47
- } else {
48
- wraprec -> special_instrumentation_before = before_callback ;
49
- }
38
+ if (is_instrumentation_set_and_not_equal (wraprec -> special_instrumentation_before ,
39
+ before_callback )) {
40
+ nrl_verbosedebug (NRL_INSTRUMENT ,
41
+ "%s: attempting to set special_instrumentation_before "
42
+ "for %.*s, but "
43
+ "it is already set" ,
44
+ __func__ , NRSAFELEN (namelen ), NRBLANKSTR (name ));
45
+ return wraprec ;
50
46
}
51
47
52
- if (clean_callback ) {
53
- if (is_instrumentation_set (wraprec -> special_instrumentation_clean ,
54
- clean_callback )) {
55
- nrl_verbosedebug (NRL_INSTRUMENT ,
56
- "%s: attempting to set special_instrumentation_clean "
57
- "for %.*s, but "
58
- "it is already set" ,
59
- __func__ , NRSAFELEN (namelen ), NRBLANKSTR (name ));
60
- } else {
61
- wraprec -> special_instrumentation_clean = clean_callback ;
62
- }
48
+ if (is_instrumentation_set_and_not_equal (wraprec -> special_instrumentation_clean ,
49
+ clean_callback )) {
50
+ nrl_verbosedebug (NRL_INSTRUMENT ,
51
+ "%s: attempting to set special_instrumentation_clean "
52
+ "for %.*s, but "
53
+ "it is already set" ,
54
+ __func__ , NRSAFELEN (namelen ), NRBLANKSTR (name ));
55
+ return wraprec ;
63
56
}
64
57
58
+ wraprec -> special_instrumentation = after_callback ;
59
+ wraprec -> special_instrumentation_before = before_callback ;
60
+ wraprec -> special_instrumentation_clean = clean_callback ;
61
+
65
62
return wraprec ;
66
63
}
67
64
#endif
0 commit comments