Skip to content

Commit 829e7dc

Browse files
committed
Fix dynamic instrumentation installation when enabling via dynamic config
1 parent e31741f commit 829e7dc

4 files changed

Lines changed: 7 additions & 5 deletions

File tree

ext/configuration.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ static bool dd_parse_tags(zai_str value, zval *decoded_value, bool persistent) {
176176
#define INI_CHANGE_DYNAMIC_CONFIG(name, config) \
177177
static bool ddtrace_alter_##name(zval *old_value, zval *new_value, zend_string *new_str) { \
178178
UNUSED(old_value, new_value); \
179-
if (!DDTRACE_G(remote_config_state)) { \
179+
/* When RC writes, bypass the check for ddog_remote_config_alter_dynamic_config */ \
180+
if (!DDTRACE_G(remote_config_state) || DDTRACE_G(remote_config_writing)) { \
180181
return true; \
181182
} \
182183
return ddog_remote_config_alter_dynamic_config(DDTRACE_G(remote_config_state), DDOG_CHARSLICE_C(config), zend_string_copy(new_str)); \

ext/ddtrace.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ ZEND_BEGIN_MODULE_GLOBALS(ddtrace)
154154
MUTEX_T sidecar_universal_service_tags_mutex;
155155
ddog_AgentRemoteConfigReader *agent_config_reader;
156156
ddog_RemoteConfigState *remote_config_state;
157+
bool remote_config_writing; // true while RC WRITE mode INI update is in progress
157158
ddog_AgentInfoReader *agent_info_reader;
158159
dd_capture_arena debugger_capture_arena;
159160
ddog_Vec_DebuggerPayload exception_debugger_buffer;

ext/live_debugger.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1668,7 +1668,8 @@ void ddtrace_live_debugger_minit(void) {
16681668
bool ddtrace_alter_dynamic_instrumentation_config(zval *old_value, zval *new_value, zend_string *new_str) {
16691669
UNUSED(old_value, new_str);
16701670
bool enabled = Z_TYPE_P(new_value) == IS_TRUE;
1671-
if (DDTRACE_G(remote_config_state) && !ddog_remote_config_alter_dynamic_config(DDTRACE_G(remote_config_state), DDOG_CHARSLICE_C("datadog.dynamic_instrumentation.enabled"), zend_string_copy(new_str))) {
1671+
// When RC writes, bypass the check for ddog_remote_config_alter_dynamic_config
1672+
if (DDTRACE_G(remote_config_state) && !DDTRACE_G(remote_config_writing) && !ddog_remote_config_alter_dynamic_config(DDTRACE_G(remote_config_state), DDOG_CHARSLICE_C("datadog.dynamic_instrumentation.enabled"), zend_string_copy(new_str))) {
16721673
return false;
16731674
}
16741675

ext/remote_config.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,9 @@ static zend_string *dd_dynamic_configuration_update(ddog_CharSlice config, zend_
9999
}
100100
} else {
101101
ZEND_ASSERT(mode == DDOG_DYNAMIC_CONFIG_UPDATE_MODE_WRITE);
102-
ddog_RemoteConfigState *saved = DDTRACE_G(remote_config_state);
103-
DDTRACE_G(remote_config_state) = NULL;
102+
DDTRACE_G(remote_config_writing) = true;
104103
zend_alter_ini_entry(name, value, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
105-
DDTRACE_G(remote_config_state) = saved;
104+
DDTRACE_G(remote_config_writing) = false;
106105
zend_string_release(value);
107106
}
108107
zend_string_release(name);

0 commit comments

Comments
 (0)