From 175404f72ccd213c860db4e09a10ba1f13d7e1c7 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 2 Jan 2025 10:11:37 -0400 Subject: [PATCH] MT#61822 use MUTEX_STATIC_INIT in a few places where it makes sense Change-Id: Ie2b6308f5f33af9afe71584d710fd0116b17e865 --- daemon/iptables.c | 3 +-- daemon/janus.c | 4 +--- daemon/media_player.c | 7 ++----- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/daemon/iptables.c b/daemon/iptables.c index 753e2629c..1fcefd0de 100644 --- a/daemon/iptables.c +++ b/daemon/iptables.c @@ -52,7 +52,7 @@ struct ipv6_ipt_entry { }; -static mutex_t __xt_lock; +static mutex_t __xt_lock = MUTEX_STATIC_INIT; static int __xt_lock_fd = -1; @@ -327,7 +327,6 @@ void iptables_init(void) { #ifdef WITH_IPTABLES_OPTION - mutex_init(&__xt_lock); iptables_add_rule = __iptables_add_rule; iptables_del_rule = __iptables_del_rule; diff --git a/daemon/janus.c b/daemon/janus.c index b80725167..cbe3188cc 100644 --- a/daemon/janus.c +++ b/daemon/janus.c @@ -58,7 +58,7 @@ TYPED_GHASHTABLE(janus_rooms_ht, uint64_t, struct janus_room, int64_hash, int64_ TYPED_GHASHTABLE(janus_tokens_ht, char, time_t, c_str_hash, c_str_equal, g_free, g_free) -static mutex_t janus_lock; +static mutex_t janus_lock = MUTEX_STATIC_INIT; static janus_tokens_ht janus_tokens; // auth tokens, currently mostly unused static janus_sessions_ht janus_sessions; // session ID -> session. holds a session reference static janus_handles_ht janus_handles; // handle ID -> handle @@ -1974,7 +1974,6 @@ done: void janus_init(void) { - mutex_init(&janus_lock); janus_tokens = janus_tokens_ht_new(); janus_sessions = janus_sessions_ht_new(); janus_handles = janus_handles_ht_new(); @@ -1982,7 +1981,6 @@ void janus_init(void) { // XXX timer thread to clean up orphaned sessions } void janus_free(void) { - mutex_destroy(&janus_lock); t_hash_table_destroy(janus_tokens); t_hash_table_destroy(janus_sessions); t_hash_table_destroy(janus_handles); diff --git a/daemon/media_player.c b/daemon/media_player.c index f9a4ee4b1..1acbce797 100644 --- a/daemon/media_player.c +++ b/daemon/media_player.c @@ -82,7 +82,7 @@ struct media_player_cache_packet { long long duration_ts; }; -static mutex_t media_player_cache_lock; +static mutex_t media_player_cache_lock = MUTEX_STATIC_INIT; static GHashTable *media_player_cache; // keys and values only ever freed at shutdown static bool media_player_read_packet(struct media_player *mp); @@ -1744,7 +1744,6 @@ void media_player_init(void) { media_player_cache = g_hash_table_new_full(media_player_cache_entry_hash, media_player_cache_entry_eq, media_player_cache_index_free, media_player_cache_entry_free); - mutex_init(&media_player_cache_lock); } timerthread_init(&media_player_thread, rtpe_config.media_num_threads, media_player_run); @@ -1756,10 +1755,8 @@ void media_player_free(void) { #ifdef WITH_TRANSCODING timerthread_free(&media_player_thread); - if (media_player_cache) { - mutex_destroy(&media_player_cache_lock); + if (media_player_cache) g_hash_table_destroy(media_player_cache); - } #endif timerthread_free(&send_timer_thread); }