Skip to content

Commit 3476893

Browse files
authored
Add support to disable default diagnostic server listener. (#52184)
1 parent 69ac4c5 commit 3476893

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

src/mono/mono.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@
413413

414414
<ItemGroup Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsAndroid)' == 'true'">
415415
<_MonoCMakeArgs Include="-DFEATURE_PERFTRACING_PAL_TCP=1"/>
416-
<_MonoCMakeArgs Include="-DFEATURE_PERFTRACING_DISABLE_LISTEN_PORTS=1"/>
416+
<_MonoCMakeArgs Include="-DFEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT=1"/>
417417
<_MonoCMakeArgs Include="-DDISABLE_LINK_STATIC_COMPONENTS=1" />
418418
</ItemGroup>
419419

src/mono/mono/eventpipe/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ if(ENABLE_PERFTRACING)
55
endif (FEATURE_PERFTRACING_PAL_TCP)
66

77
if (FEATURE_PERFTRACING_DISABLE_LISTEN_PORTS)
8-
add_definitions(-DENABLE_PERFTRACING_DISABLE_LISTEN_PORTS)
8+
add_definitions(-DDISABLE_PERFTRACING_LISTEN_PORTS)
99
endif (FEATURE_PERFTRACING_DISABLE_LISTEN_PORTS)
1010

11+
if (FEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT)
12+
add_definitions(-DDISABLE_PERFTRACING_DEFAULT_LISTEN_PORT)
13+
endif (FEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT)
14+
1115
if (FEATURE_PERFTRACING_DISABLE_CONNECT_PORTS)
12-
add_definitions(-DENABLE_PERFTRACING_DISABLE_CONNECT_PORTS)
16+
add_definitions(-DDISABLE_PERFTRACING_CONNECT_PORTS)
1317
endif (FEATURE_PERFTRACING_DISABLE_CONNECT_PORTS)
1418

1519
include (${SHARED_EVENTPIPE_SOURCE_PATH}CMakeLists.txt)

src/native/eventpipe/ds-ipc.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,12 @@ ipc_stream_factory_build_and_add_port (
165165
bool result = false;
166166
DiagnosticsIpc *ipc = NULL;
167167

168-
#ifndef DS_IPC_DISABLE_LISTEN_PORTS
168+
#ifndef DS_IPC_DISABLE_DEFAULT_LISTEN_PORT
169169
if (!default_port && builder->type == DS_PORT_TYPE_LISTEN) {
170170
// Ignore listen type (see conversation in https://github.com/dotnet/runtime/pull/40499 for details)
171171
DS_LOG_INFO_0 ("ipc_stream_factory_build_and_add_port - Ignoring LISTEN port configuration");
172172
return true;
173173
}
174-
#else
175-
if (default_port && builder->type == DS_PORT_TYPE_LISTEN) {
176-
DS_LOG_DEBUG_0 ("ipc_stream_factory_build_and_add_port - Ignoring default LISTEN port");
177-
return true;
178-
}
179174
#endif
180175

181176
if (builder->type == DS_PORT_TYPE_LISTEN) {
@@ -324,6 +319,7 @@ ds_ipc_stream_factory_configure (ds_ipc_error_callback_func callback)
324319
ep_rt_utf8_string_free (ports);
325320
}
326321

322+
#ifndef DS_IPC_DISABLE_DEFAULT_LISTEN_PORT
327323
// create the default listen port
328324
uint32_t port_suspend = ds_rt_config_value_get_default_port_suspend ();
329325

@@ -339,6 +335,9 @@ ds_ipc_stream_factory_configure (ds_ipc_error_callback_func callback)
339335
} else {
340336
result &= false;
341337
}
338+
#else
339+
DS_LOG_DEBUG_0 ("ds_ipc_stream_factory_configure - Ignoring default LISTEN port");
340+
#endif
342341

343342
return result;
344343
}

src/native/eventpipe/ds-rt-config.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@
2121
#endif
2222
#endif
2323

24-
#ifdef ENABLE_PERFTRACING_DISABLE_CONNECT_PORTS
24+
#ifdef DISABLE_PERFTRACING_CONNECT_PORTS
2525
#define DS_IPC_DISABLE_CONNECT_PORTS
2626
#endif
2727

28-
#ifdef ENABLE_PERFTRACING_DISABLE_LISTEN_PORTS
28+
#ifdef DISABLE_PERFTRACING_LISTEN_PORTS
2929
#define DS_IPC_DISABLE_LISTEN_PORTS
30+
#define DS_IPC_DISABLE_DEFAULT_LISTEN_PORT
31+
#endif
32+
33+
#ifdef DISABLE_PERFTRACING_DEFAULT_LISTEN_PORT
34+
#define DS_IPC_DISABLE_DEFAULT_LISTEN_PORT
3035
#endif
3136

3237
#endif /* __DIAGNOSTICS_RT_CONFIG_H__ */

0 commit comments

Comments
 (0)