From 73ee47d72f89dc56427d0acc79181f60162d19b5 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Wed, 12 Jun 2024 14:56:46 +0300 Subject: [PATCH] [Core] switch_core_dump_variables: Coverity 1546314 Data race condition --- src/switch_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/switch_core.c b/src/switch_core.c index 7ec10d8885..ed9b163b28 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -345,11 +345,13 @@ SWITCH_DECLARE(void) switch_core_dump_variables(switch_stream_handle_t *stream) { switch_event_header_t *hi; - switch_mutex_lock(runtime.global_mutex); + switch_thread_rwlock_rdlock(runtime.global_var_rwlock); + for (hi = runtime.global_vars->headers; hi; hi = hi->next) { stream->write_function(stream, "%s=%s\n", hi->name, hi->value); } - switch_mutex_unlock(runtime.global_mutex); + + switch_thread_rwlock_unlock(runtime.global_var_rwlock); } SWITCH_DECLARE(const char *) switch_core_get_hostname(void)