Skip to content

Commit 3080a84

Browse files
fix(profiling): normalize ini modified flag
1 parent 70462ac commit 3080a84

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

profiling/src/config.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -916,18 +916,18 @@ unsafe extern "C" fn parse_profiling_enabled(
916916

917917
/// Display the profiling enabled config value
918918
unsafe extern "C" fn display_profiling_enabled(ini_entry: *mut zend_ini_entry, type_: c_int) {
919-
let tmp_value: *mut zend_string =
920-
if type_ as u32 == ZEND_INI_DISPLAY_ORIG && (*ini_entry).modified as u8 != 0 {
921-
if !(*ini_entry).orig_value.is_null() {
922-
(*ini_entry).orig_value
923-
} else {
924-
ptr::null_mut()
925-
}
926-
} else if !(*ini_entry).value.is_null() {
927-
(*ini_entry).value
919+
let modified = bindings::ddog_php_prof_ini_entry_modified(ini_entry);
920+
let tmp_value: *mut zend_string = if type_ as u32 == ZEND_INI_DISPLAY_ORIG && modified {
921+
if !(*ini_entry).orig_value.is_null() {
922+
(*ini_entry).orig_value
928923
} else {
929924
ptr::null_mut()
930-
};
925+
}
926+
} else if !(*ini_entry).value.is_null() {
927+
(*ini_entry).value
928+
} else {
929+
ptr::null_mut()
930+
};
931931

932932
let mut value: bool = false;
933933
if !tmp_value.is_null() {

profiling/src/php_ffi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ void ddog_php_prof_copy_long_into_zval(zval *dest, long num) {
232232
return;
233233
}
234234

235+
bool ddog_php_prof_ini_entry_modified(zend_ini_entry *ini_entry) {
236+
return ini_entry->modified;
237+
}
238+
235239
void ddog_php_prof_zend_mm_set_custom_handlers(zend_mm_heap *heap,
236240
ddog_php_prof_zend_mm_malloc _malloc,
237241
ddog_php_prof_zend_mm_free _free,

profiling/src/php_ffi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ void datadog_php_profiling_copy_string_view_into_zval(zval *dest, zai_str view,
137137
*/
138138
void ddog_php_prof_copy_long_into_zval(zval *dest, long num);
139139

140+
bool ddog_php_prof_ini_entry_modified(zend_ini_entry *ini_entry);
141+
140142
/**
141143
* Wrapper to PHP's `zend_mm_set_custom_handlers()`. Starting from PHP 7.3
142144
* onwards the upstream `zend_mm_set_custom_handlers()` function will restore

0 commit comments

Comments
 (0)